Subj : [spidermonkey] Questions To : netscape.public.mozilla.jseng From : Kirill Date : Wed Jul 13 2005 11:44 am This is a multi-part message in MIME format. ------=_NextPart_000_0058_01C58797.D7092780 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi guys, I have a couple questions, hoping someone could put me on the right = track. In my C++ application I'm trying to provide some "Internal" objects to = the JS. My goal is to have objects like Direct3DDevice, Mouse, Keyboard, = etc, that are already instantiated and could not be deleted or created = anew by the user. I am not using C++ classes, by the way, just static = functions.=20 Here's what I did: JSClass cDevice =3D=20 { "DEVICE", 0, JS_PropertyStub, JS_PropertyStub, device_getp, device_setp,=20 JS_EnumerateStub, JS_ResolveStub,=20 JS_ConvertStub, JS_FinalizeStub }; =20 JSPropertySpec devicePROPS[] =3D { .. } static JSFunctionSpec deviceFUNCS[] =3D { .. } static JSBool device_getp(JSContext *cx, JSObject *obj, jsval id, jsval = *vp){ .. } static JSBool device_setp(JSContext *cx, JSObject *obj, jsval id, jsval = *vp){ .. } JSObject *newObj =3D JS_InitClass(cx, globalObj, NULL, &cDevice,=20 NULL, 0, devicePROPS, deviceFUNCS, NULL, NULL); JSObject *globalDeviceObject =3D JS_DefineObject(cx, globalObj, "Device", cGenericClass, newObj, PROP_PERMANENT); newObj is not null, after this is executed. The program runs fine, = however, I get an uncaught exception in the end, when I call = JS_DestroyContext. I also get an exception if I try to execute in JS = something like blah=3Dnew DEVICE();=20 My question is: why do I get the exception (memory violation), and also = what's the best way to add a single interface object that can not be = instantiated by calling new operator or deleted. My second question is: how would I go about implementing something = similar to Flash ActionScript's anyobject.watch("anyproperty", onChange) = function. That would invoke onChange any time anyobject.anyproperty = changes. Thank you a bazillion for your time. Kirill nagual20@yahoo.com ------=_NextPart_000_0058_01C58797.D7092780 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable