Subj : Create an instance of a JS object from C To : netscape.public.mozilla.jseng From : spellcaster@web.de (spellcaster) Date : Fri Dec 12 2003 08:26 am Hi! I'm pretty new to spidermonkey and I'm amazed fast I could integrate it into my app. I guess I'm just blind, but I can't find a function to create an instance of a Class within the context. -- Code -- JSClass dummyClass = { "Dummy", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub, dummyGetFunc, dummySetFunc, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, dummyDestructor }; -- /Code -- Assume all these functions exists, and that the class was registered via JS_InitClass(). Now I want to populate my context with some instances of Dummy objects. Right now what I do is something like this: -- Code -- jsval rval; char* script = "test = new Dummy();"; JS_EvaluateScript( jsContext, jsGlobalObj, script, strlen(script), "[init]", __LINE__, &rval); -- /Code -- To ensure that a variable named "test" of type "Dummy" exists in the context. Is there a pure C way of doing this? Calling JS_EvaluateScript() seems hackish... Thanks, /spellcaaster .