summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/mprutil.c18
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c6
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;
}