Subj : Class width SpiderMonkey To : netscape.public.mozilla.jseng From : "Jan Herling" Date : Wed Nov 05 2003 09:58 pm Hallo all, I have written the following C++ class for JavaSript with SpiderMonkey: class ClassA { double a; double b; }; But this class works good with the following Script-File: (ca is an extern def. var. from typ ClassA) javascript: ca.a = Math.random(); This only works because Mathe.random() proceeds a value between 0 and 1 (.4345 or .7644) When I tryed the following Script-File, the program breaked down: javascript: ca.a = 0; ("or ") ca.a = 1; Here is the important part of my Spidermonkey-Class: JSBool ClassASetValue(JSContext *cx, JSObject *obj, double value) { jsval val; JS_NewDoubleValue(cx, (jsdouble) value, &val); JS_SetProperty(cx, obj, "a", &val); .... } JSBool ClassAGetValue(JSContext *cx, JSObject *obj, float *value) { jsval val; jsdouble jsd; ....... JS_GetProperty(cx, obj, "a", &val); jsd = *JSVAL_TO_DOUBLE(val); ("or") JS_ValueToNumber(cx, val, &jsd); (makes no differents - allways breaks down here if : "ca.a = 1" ) *value = (float) jsd; ....... } I think this is a problem with the conversion from JSVAL to DOUBLE. Is this a well known problem or bug? Or did I make a big mistake? It would be nice, if someone of you could help me. Jan .