diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-15 11:23:17 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:23:09 -0500 |
commit | 84e3efd8ea1cdb48e20f2f42c32f3ffa7b822352 (patch) | |
tree | fb0222c46d9a6db77cc8ae275045d11fc8ad4d79 /source4/scripting/ejs | |
parent | 94d99612b9093ca83da3b6b66f875915eeabb389 (diff) | |
download | samba-84e3efd8ea1cdb48e20f2f42c32f3ffa7b822352.tar.gz samba-84e3efd8ea1cdb48e20f2f42c32f3ffa7b822352.tar.bz2 samba-84e3efd8ea1cdb48e20f2f42c32f3ffa7b822352.zip |
r8489: neaten up the object handling
(This used to be commit ccf20b2b13b11ac07b59988809b6c5160388a616)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r-- | source4/scripting/ejs/mprutil.c | 18 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls_ldb.c | 6 |
2 files changed, 20 insertions, 4 deletions
diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c index f25064f245..f9813f2597 100644 --- a/source4/scripting/ejs/mprutil.c +++ b/source4/scripting/ejs/mprutil.c @@ -385,3 +385,21 @@ void mpr_ReturnString(int eid, const char *s) { mprSetVar(obj, name, mprCreateStringCFunctionVar(fn, obj, MPR_VAR_SCRIPT_HANDLE)); } + +/* + get a poiner in the current object +*/ +void *mprGetThisPtr(int eid, const char *name) +{ + struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); + return mprGetPtr(this, name); +} + +/* + set a pointer as a child of the local object +*/ +void mprSetThisPtr(int eid, const char *name, void *ptr) +{ + struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); + mprSetPtrChild(this, name, ptr); +} diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c index 924a9665b3..cdf3b3dd6c 100644 --- a/source4/scripting/ejs/smbcalls_ldb.c +++ b/source4/scripting/ejs/smbcalls_ldb.c @@ -30,8 +30,7 @@ */ static struct ldb_context *ejs_ldb_db(int eid) { - struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); - struct ldb_context *ldb = mprGetPtr(this, "db"); + struct ldb_context *ldb = mprGetThisPtr(eid, "db"); if (ldb == NULL) { ejsSetErrorMsg(eid, "invalid ldb connection"); } @@ -227,7 +226,6 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv) { struct ldb_context *ldb; const char *dbfile; - struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); if (argc != 1) { ejsSetErrorMsg(eid, "ldb.connect invalid arguments"); @@ -241,7 +239,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv) ejsSetErrorMsg(eid, "ldb.connect failed to open %s", dbfile); } - mprSetPtrChild(this, "db", ldb); + mprSetThisPtr(eid, "db", ldb); mpr_Return(eid, mprCreateBoolVar(ldb != NULL)); return 0; } |