Subj : Re: Creating classes/namespaces on the fly from existing functions? To : netscape.public.mozilla.jseng From : bubbfree Date : Thu Jan 06 2005 08:27 pm Great! I've been searching through the .h's, but I think I'm not finding the appropriate functions to do this (pseudo code): JSResult handlerForAddLibrary(...) { JSObject* newExternal1Object; JSObject* pObj = compileFile("external1.js"); JS_DefineObject("external1", &newExternal1Object, .....); for all functions defined in pObj { JSFunction* pFunction = getFunction(pObj, i); JS_DefineFunction(newExternal1Object, pFunction); } } I can do the defining of 'external1' as a new object in the global object, but I'm wondering how to get the compiled functions from external1.js into that new ly created object ? (I'm hoping I wouldn't have to parse external1.js, dynamically create a JSNative hook that would JS_CallFunction(...) into that file ? ). Thanks in advance! Brendan Eich wrote: > 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. .