Inconsistency In Online Documentation: JSScript Vs JSObject

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Inconsistency In Online Documentation: JSScript Vs JSObject

Masquerade-2
In the the official documentation for Spidermonkey:

https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_CompileScriptForPrincipals
https://developer.mozilla.org/en/JSAPI_User_Guide#Compiled_scripts

the return types of  JS_CompileScriptForPrincipals, JS_CompileScript,
JS_CompileFile, and JS_CompileFileHandle are all JSScript*.  But in
the jsapi.h (the current version is 1.8.5) , they're all JSObject*.
Which one should we use?

Also, what is the difference between JSScript and JSObject?  If my old
routine is expecting a JSScript*, how do I obtain one from a
JSObject* ?
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Inconsistency In Online Documentation: JSScript Vs JSObject

Masquerade-2
In particular, I'm wondering if the XDR API still application in
1.8.5.  Because according to the informal sample found in this group,
we would call these XDR functions in the previous versions (pre-1.8.5)
to serialize a script to a disk file:

JSScript *s script;
script = JS_CompileFile(....);

JSXDRState*    xdr = JS_XDRNewMem( ...);
if (JS_XDRScript( xdr, &script)) {
  uint32        len = 0;
   char*    bytes = (char*) JS_XDRMemGetData( xdr, &len);
  ...
}

But now, how do we obtain the JSScript* required by the
JS_XDRScript()?  JS_CompileFIle()/JS_CompileScript() now return
JSObject.

Is the "JS_PUBLIC_API(JSScript *) JS_GetScriptFromObject(JSObject
*scriptObj)" declared in jsdbgapi.h applicable?
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Inconsistency In Online Documentation: JSScript Vs JSObject

Andrew  McCreight
In reply to this post by Masquerade-2
----- Original Message -----
> In the the official documentation for Spidermonkey:
>
> https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_CompileScriptForPrincipals
> https://developer.mozilla.org/en/JSAPI_User_Guide#Compiled_scripts
>
> the return types of JS_CompileScriptForPrincipals, JS_CompileScript,
> JS_CompileFile, and JS_CompileFileHandle are all JSScript*. But in
> the jsapi.h (the current version is 1.8.5) , they're all JSObject*.
> Which one should we use?

It used to be that scripts were wrapped in objects, but a patch landed in the last few months that changed it so you just handle the bare script now.

> Also, what is the difference between JSScript and JSObject? If my old
> routine is expecting a JSScript*, how do I obtain one from a
> JSObject* ?

I'm not really sure, sorry.  I don't think the corresponding JSObject will exist any more, but I could be wrong.

> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine