Subj : GetProperty To : netscape.public.mozilla.jseng From : "Jochen Stier" Date : Tue Feb 10 2004 03:09 pm Hi Brendan. First of all, thx for working on the JS engine. I am integrating it into an App that uses OpenInventor. I am trying to give some scrpting access to this API. My question concerns jsdouble and especially DOUBLE_TO_JSVAL. I am trying to give javascript access to a SbVec3f object, which is straight from the OpenInventor Api. This vector object has an array of 3 floats (!) for x, y and z coordinates. I am using something like JSPropertySpec ScrSFVec3f::sJSProperties[] = { { "", 0, JSPROP_INDEX }, { 0 } }; to allow access to this array via the JSGetProperty method. Unfortunately I cannot use DOUBLE_TO_JSVAL on a float, or a pointer to a float. So I have to create temporary double, like the lValue in the following example. JSBool ScrSFVec3f::JSGetProperty(JSContext* iContext, JSObject* iObject, jsval id, jsval *vp) { if (JSVAL_IS_INT (id)) { SoSFVec3f* lVector = (SoSFVec3f*) JS_GetPrivate(iContext, iObject); static double lValue; lValue = lVector->getValue()[JSVAL_TO_INT(id)]; *vp = DOUBLE_TO_JSVAL(&lValue); } return JS_TRUE; } Now, my question is if the Javascript engine makes a copy of the double, or does it come back to the memory location of lValue whenever it needs to read the value of the double. This is important for the following javascript var l = new SbVec3f; l[0] = l[0] + l[1] + l[2]; In my example the static double lValue will be constantly overriden ! This assignment will not work unless the JS engine makes copies of the doubles. I guess I will try this out myself to see what happens.... But maybe you have something to add... Cheers Jochen .