Subj : [SpiderMonkey] JS_Get/SetPrivate truncates 0x1 bit To : netscape.public.mozilla.jseng From : Brian Barnes Date : Sat May 22 2004 02:54 am Does JS_GetPrivate and JS_SetPrivate do something funny (other than convert to jsval) to the data you pass it? I wanted to pass it just an integer (not an actual pointer to data, but mangle to a pointer), and it seems to strip off the 0x1 bit. For instance: int i=5,k; void *v; // make sure cast works v=(void*)i; k=(int)v; fprintf(stdout,"%d\n",k); // call set/get JS_SetPrivate(cx,obj,(void*)i); k=(int)JS_GetPrivate(cx,obj); fprintf(stdout,"%d\n",k); You'd get: 5 4 I don't know how the heck it knows the difference between my pointer and regular integers, unless I'm getting lucky and my pointers always have the 0x1 bit at 0 (could potentially be true.) The workaround is to make a static array (like int intarray[]={0,1,2,3,4,5,6,7} but that's a little silly :) ) I know I'm missing something obvious here. [>] Brian .