Re: migration to mozjs-52
Jason Orendorff <[email protected]> Tue, 2 Jul 2019 13:51:47 -0500
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <CA+W3DWE2Q73h2Os6DU5rWCK=xG3qWg3JJZWOmj6m=_FGYM5vug@mail.gmail.com> |
I don't have mozjs-52 handy, but I can give you a few pointers. You don't need a replacement for JS_NewScriptObject, JS_DestroyScript, JS_AddNamedRoot, or JS_RemoveRoot. They are all related to GC-safety and you shouldn't need anything more complicated than JS::Rooted for that. Instead of separately calling JS_CompileScript and JS_ExecuteScript, you should call JS::Evaluate (in js/public/CompilationAndEvaluation.h) if it exists in mozjs-52. If not, I think it was called JS_EvaluateScript. If you need a CompileOptions object, use JS::OwnedCompileOptions, defined in js/public/CompileOptions.h, and make sure to call init() on it before using it. -j On Tue, Jul 2, 2019 at 8:35 AM <[email protected]> wrote: > Greetings! > > I've been working on some updates to OpenVXI and decided to update all the > libraries first. > Looks like I was able to figure out most of it, but still have some > questions (also I should mention that this is my first big c/c++ endeavor) > > I have this type of thing going on and I'm not sure what to replace it > with as all/most of these functions seem to be obsolete but JSAPI User > guide still has them in there. > > bool jsScriptRes = JS_CompileUCScript (context, > tmpscript, tmpscriptlen, > options, &jsScript); > if ( ! jsScriptRes ) > rc = VXIjsi_RESULT_SYNTAX_ERROR; > else { > JSObject *jsScriptObj = JS_NewScriptObject (context, jsScript); > if (( ! jsScriptObj ) || > ( ! JS_AddNamedRoot (context, &jsScriptObj, SCRIPT_OBJECT_NAME) )) > { > JS_DestroyScript (context, jsScript); > rc = VXIjsi_RESULT_OUT_OF_MEMORY; > } else { > > JS::Rooted <JS::Value> val(context, JS::UndefinedValue()); > JS::Rooted <JSObject*> robj(context, currentScope->GetJsobj( )); > > if ( JS_ExecuteScript (context, jsScript, > &val) ) { > if ( retval ) > rc = retval->Set (val); > } else if ( exception ) { > rc = VXIjsi_RESULT_SCRIPT_EXCEPTION; > } else if ( numBranches > maxBranches ) { > rc = VXIjsi_RESULT_SECURITY_VIOLATION; > } else { > rc = VXIjsi_RESULT_NON_FATAL_ERROR; > } > > if ( ! JS_RemoveRoot (context, &jsScriptObj) ) > rc = VXIjsi_RESULT_FATAL_ERROR; > } > } > _______________________________________________ > dev-tech-js-engine mailing list > [email protected] > https://lists.mozilla.org/listinfo/dev-tech-js-engine >