svn commit: samba r7456 - in branches/SAMBA_4_0/source/lib/ejs: .

tpot at samba.org tpot at samba.org
Fri Jun 10 07:58:46 GMT 2005


Author: tpot
Date: 2005-06-10 07:58:45 +0000 (Fri, 10 Jun 2005)
New Revision: 7456

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7456

Log:
Add a simple type that represents a pointer.  The ejs people may ask us
to change this later but that will be pretty easy.  

We can use this type to pass around pointers to handles in C.  Talloc
allows us to do type checking too.

Modified:
   branches/SAMBA_4_0/source/lib/ejs/ejsParser.c
   branches/SAMBA_4_0/source/lib/ejs/ejsProcs.c
   branches/SAMBA_4_0/source/lib/ejs/var.c
   branches/SAMBA_4_0/source/lib/ejs/var.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ejs/ejsParser.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ejs/ejsParser.c	2005-06-10 07:49:00 UTC (rev 7455)
+++ branches/SAMBA_4_0/source/lib/ejs/ejsParser.c	2005-06-10 07:58:45 UTC (rev 7456)
@@ -1659,6 +1659,7 @@
 	case MPR_TYPE_CFUNCTION:
 	case MPR_TYPE_FUNCTION:
 	case MPR_TYPE_OBJECT:
+	case MPR_TYPE_PTR:
 		mprCopyVarValue(&ep->result, mprCreateBoolVar(0), 0);
 		return 0;
 

Modified: branches/SAMBA_4_0/source/lib/ejs/ejsProcs.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ejs/ejsProcs.c	2005-06-10 07:49:00 UTC (rev 7455)
+++ branches/SAMBA_4_0/source/lib/ejs/ejsProcs.c	2005-06-10 07:58:45 UTC (rev 7456)
@@ -310,6 +310,7 @@
 	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;
 

Modified: branches/SAMBA_4_0/source/lib/ejs/var.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ejs/var.c	2005-06-10 07:49:00 UTC (rev 7455)
+++ branches/SAMBA_4_0/source/lib/ejs/var.c	2005-06-10 07:58:45 UTC (rev 7456)
@@ -1182,6 +1182,21 @@
 	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 @@
 		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 @@
 		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 @@
 	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 @@
 	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 @@
 	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 @@
 	case MPR_TYPE_CFUNCTION:
 	case MPR_TYPE_FUNCTION:
 	case MPR_TYPE_OBJECT:
+	case MPR_TYPE_PTR:
 		return 0;
 
 	case MPR_TYPE_BOOL:

Modified: branches/SAMBA_4_0/source/lib/ejs/var.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ejs/var.h	2005-06-10 07:49:00 UTC (rev 7455)
+++ branches/SAMBA_4_0/source/lib/ejs/var.h	2005-06-10 07:58:45 UTC (rev 7456)
@@ -92,6 +92,7 @@
 #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 @@
 			void		*thisPtr;
 		} cFunctionWithStrings;
 		MprStr			string;					/* Allocated string */
+		void *ptr;                              /* C pointer */
 #if !BLD_DEBUG && !LINUX && !VXWORKS
 	};
 #endif
@@ -351,6 +353,7 @@
 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



More information about the samba-cvs mailing list