summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ejs/ejsParser.c1
-rw-r--r--source4/lib/ejs/ejsProcs.c1
-rw-r--r--source4/lib/ejs/var.c29
-rw-r--r--source4/lib/ejs/var.h3
4 files changed, 34 insertions, 0 deletions
diff --git a/source4/lib/ejs/ejsParser.c b/source4/lib/ejs/ejsParser.c
index 17fe0ce98a..8d0aa7ba2c 100644
--- a/source4/lib/ejs/ejsParser.c
+++ b/source4/lib/ejs/ejsParser.c
@@ -1659,6 +1659,7 @@ static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs)
case MPR_TYPE_CFUNCTION:
case MPR_TYPE_FUNCTION:
case MPR_TYPE_OBJECT:
+ case MPR_TYPE_PTR:
mprCopyVarValue(&ep->result, mprCreateBoolVar(0), 0);
return 0;
diff --git a/source4/lib/ejs/ejsProcs.c b/source4/lib/ejs/ejsProcs.c
index b15985c8cf..e9932406ad 100644
--- a/source4/lib/ejs/ejsProcs.c
+++ b/source4/lib/ejs/ejsProcs.c
@@ -310,6 +310,7 @@ static int valueOfProc(EjsHandle eid, int argc, MprVar **argv)
case MPR_TYPE_OBJECT:
case MPR_TYPE_FUNCTION:
case MPR_TYPE_STRING_CFUNCTION:
+ case MPR_TYPE_PTR:
mprCopyVar(&ep->result, obj, MPR_SHALLOW_COPY);
break;
diff --git a/source4/lib/ejs/var.c b/source4/lib/ejs/var.c
index ce771caa04..6ef1c4d3a3 100644
--- a/source4/lib/ejs/var.c
+++ b/source4/lib/ejs/var.c
@@ -1182,6 +1182,21 @@ MprVar mprCreateStringCFunctionVar(MprStringCFunction fn, void *thisPtr, int fla
return v;
}
+/*
+ * Initialize an opaque pointer.
+ */
+
+MprVar mprCreatePtrVar(void *ptr, const char *name)
+{
+ MprVar v;
+
+ memset(&v, 0x0, sizeof(v));
+ v.type = MPR_TYPE_PTR;
+ v.ptr = ptr;
+
+ return v;
+}
+
/******************************************************************************/
#if BLD_FEATURE_FLOATING_POINT
/*
@@ -1398,6 +1413,10 @@ static void copyVarCore(MprVar *dest, MprVar *src, int copyDepth)
dest->cFunctionWithStrings = src->cFunctionWithStrings;
break;
+ case MPR_TYPE_PTR:
+ dest->ptr = src->ptr;
+ break;
+
case MPR_TYPE_CFUNCTION:
dest->cFunction = src->cFunction;
break;
@@ -1645,6 +1664,10 @@ void mprVarToString(char** out, int size, char *fmt, MprVar *obj)
mprAllocSprintf(out, size, "[C StringFunction]");
break;
+ case MPR_TYPE_PTR:
+ mprAllocSprintf(out, size, "[C Pointer: %p]", obj->ptr);
+ break;
+
case MPR_TYPE_FUNCTION:
mprAllocSprintf(out, size, "[JavaScript Function]");
break;
@@ -1779,6 +1802,9 @@ bool mprVarToBool(MprVar *vp)
case MPR_TYPE_OBJECT:
return 0;
+ case MPR_TYPE_PTR:
+ return (vp->ptr != NULL);
+
case MPR_TYPE_BOOL:
return vp->boolean;
@@ -1821,6 +1847,7 @@ double mprVarToFloat(MprVar *vp)
case MPR_TYPE_CFUNCTION:
case MPR_TYPE_FUNCTION:
case MPR_TYPE_OBJECT:
+ case MPR_TYPE_PTR:
return 0;
case MPR_TYPE_BOOL:
@@ -1896,6 +1923,7 @@ int64 mprVarToInteger64(MprVar *vp)
case MPR_TYPE_CFUNCTION:
case MPR_TYPE_FUNCTION:
case MPR_TYPE_OBJECT:
+ case MPR_TYPE_PTR:
return 0;
case MPR_TYPE_BOOL:
@@ -2010,6 +2038,7 @@ int mprVarToInteger(MprVar *vp)
case MPR_TYPE_CFUNCTION:
case MPR_TYPE_FUNCTION:
case MPR_TYPE_OBJECT:
+ case MPR_TYPE_PTR:
return 0;
case MPR_TYPE_BOOL:
diff --git a/source4/lib/ejs/var.h b/source4/lib/ejs/var.h
index 3cb23cf461..c313e29544 100644
--- a/source4/lib/ejs/var.h
+++ b/source4/lib/ejs/var.h
@@ -92,6 +92,7 @@ typedef int MprType;
#define MPR_TYPE_FUNCTION 8 /* JavaScript function */
#define MPR_TYPE_STRING 9 /* String (immutable) */
#define MPR_TYPE_STRING_CFUNCTION 10 /* C/C++ function with string args */
+#define MPR_TYPE_PTR 11 /* C pointer */
/*
* Create a type for the default number type
@@ -315,6 +316,7 @@ typedef struct MprVar {
void *thisPtr;
} cFunctionWithStrings;
MprStr string; /* Allocated string */
+ void *ptr; /* C pointer */
#if !BLD_DEBUG && !LINUX && !VXWORKS
};
#endif
@@ -351,6 +353,7 @@ extern MprVar mprCreateObjVar(const char *name, int hashSize);
extern MprVar mprCreateBoolVar(bool value);
extern MprVar mprCreateCFunctionVar(MprCFunction fn, void *thisPtr,
int flags);
+extern MprVar mprCreatePtrVar(void *ptr, const char *name);
#if BLD_FEATURE_FLOATING_POINT
extern MprVar mprCreateFloatVar(double value);
#endif