Subj : Re: Creating classes/namespaces on the fly from existing functions? To : bubbfree From : Brendan Eich Date : Wed Jan 05 2005 04:59 pm bubbfree@gmail.com wrote: > The object or namespace 'externalFile1' would be dynamically created by > the useLibrary() implementation, and all functions found in that file > would be added as member functions of the newly created > object/namespace. > > Is this possible? Thanks! Sure, it's possible. useLibrary would parse its argument, JS_DefineObject using the name up to the ".js" and defining the new object in the global object, and so on. Beware JSOPTION_VAROBJFIX, however -- you don't want this option for this application. (One way to use JSOPTION_VAROBJFIX would be to temporarily JS_SetParent(cx, libobj, NULL) and JS_SetParent(cx, libobj, global) around all JS_Evaluate*Script* and JS_Compile* API calls.) /be .