Subj : Re: Creating classes/namespaces on the fly from existing functions? To : bubbfree From : Brendan Eich Date : Thu Jan 06 2005 09:58 pm bubbfree@gmail.com wrote: > Oh wait... maybe it's simpler than that... I was going to reply to your previous message saying "look only at jsapi.h" and the (lagging, but still useful) API docs. > how about: > > JSObject* pExternalObj = JS_NewObject(.... ...); > JS_EvaluateFile(cx, pExternalObj, .....); > JS_DefineObject(cx, myMainGlobalObj, "external1", , > pExternalObj, JSPROP_PERMANENT); > > would my pExternalObj just serve as the prototype object for the new > "external1" in my global scope ? And the JSClassDef that I put in can > just be a generic one w/o much defined in there ? Do you need another object that's prototyped by the first one, in which the file's contents were evaluated? If not, just use JS_DefineProperty instead of JS_DefineObject (which is like JS_NewObject followed by JS_DefineProperty). /be .