Subj : Re: SM: run a script from a native function To : netscape.public.mozilla.jseng From : Marcello Bastea-Forte Date : Wed Jan 07 2004 10:53 pm >> In SpiderMonkey, what's the proper way to call JS_EvaluateScript from >> within a native function (itself invoked by a script)? Do you have to >> do anything to reset the stack frame or context state? > > Do you want to make something like eval? If not, just use > JS_EvaluateScript or one of its {UC, ForPrincipals} variants. Does that mean I shouldn't be doing the following: ------------------------------------------------------------------------ JSBool JavaScript::JS_include(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { JSString *str = JS_ValueToString(cx, argv[0]); if (!str) return JS_FALSE; JSScript *s = JS_CompileFile(cx, obj, JS_GetStringBytes(str)); jsval ret; bool b = JS_ExecuteScript(cx, obj, s, &ret); JS_DestroyScript(cx, s); return b; } ------------------------------------------------------------------------ To make an include() function? (Need to improve it to handle relative directories.) Marcello .