{
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);
+}
*/
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");
}
{
struct ldb_context *ldb;
const char *dbfile;
- struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0);
if (argc != 1) {
ejsSetErrorMsg(eid, "ldb.connect invalid arguments");
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;
}