Subj : Re: SM: run a script from a native function To : netscape.public.mozilla.jseng From : Shanti Rao Date : Fri Jan 09 2004 03:13 pm Brendan Eich wrote: > Shanti Rao wrote: > [. . .] > >> js_ReportIsNotDefined() gets called back from js_Interpret. >> InitExecptionObject() gets called as before, and makes a >> ReferenceError exception with the right file name and line number. The >> pending exception then has the messgae "asdf is not defined", just as >> before. This time, however, when control returns to >> EvaluateUCScriptFP(), cx->fp is null, > > > You mean "not null" here. Sorry, you're right. My problem is that, although there's a pending exception, the interpreter never acts on it. Here's what one needs to do to make a proper run() native function: JSBool RunScript(JSContext*cx, JSObject*obj, uintN argc, jsval *argv, jsval *rval) { *rval = OBJECT_TO_JSVAL(0); if (argc < 1) return JS_TRUE; //open the script if (JS_BufferIsCompilableUnit(cx,global,text,text.size()) { if (!JS_EvaluateScript(cx,global,text,text.size(),filename,line,&rval)) return JS_FALSE; } return JS_TRUE; } My mistake was in not returning JS_FALSE if JS_EvaluateScript didn't return false. Thanks for your help! Shanti .