summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs/mprutil.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-20 06:20:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:47 -0500
commit240ca36cf2a3ceb89e46b73486865a4a57339c89 (patch)
tree7b6bd88d310719d197103a6fb2eae7f8980243ff /source4/scripting/ejs/mprutil.c
parenta4428c814ad90884ac0b442233d318f061f221bc (diff)
downloadsamba-240ca36cf2a3ceb89e46b73486865a4a57339c89.tar.gz
samba-240ca36cf2a3ceb89e46b73486865a4a57339c89.tar.bz2
samba-240ca36cf2a3ceb89e46b73486865a4a57339c89.zip
r8635: make object inheritance with the builtin objects easy by allowing
callers to optionally supply an existing object to add the properties to. So you can do: var rpc = samr_init(); lsa_init(rpc); and you end up with 'rpc' having both the samr and lsa functions and constants available. (This used to be commit 6a1ed328e27769bd52899fc2437a43fc17104eff)
Diffstat (limited to 'source4/scripting/ejs/mprutil.c')
-rw-r--r--source4/scripting/ejs/mprutil.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c
index f9813f2597..14d120c45a 100644
--- a/source4/scripting/ejs/mprutil.c
+++ b/source4/scripting/ejs/mprutil.c
@@ -403,3 +403,17 @@ void mprSetThisPtr(int eid, const char *name, void *ptr)
struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0);
mprSetPtrChild(this, name, ptr);
}
+
+/*
+ used by object xxx_init() routines to allow for the caller
+ to supply a pre-existing object to add properties to,
+ or create a new object. This makes inheritance easy
+*/
+struct MprVar *mprInitObject(int eid, const char *name, int argc, struct MprVar **argv)
+{
+ if (argc > 0 && mprVarIsObject(argv[0]->type)) {
+ return argv[0];
+ }
+ mpr_Return(eid, mprObject(name));
+ return ejsGetReturnValue(eid);
+}