Re: migration to mozjs-52

Steve Fink <[email protected]> Mon, 8 Jul 2019 11:55:39 -0700
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On 7/2/19 1:00 PM, [email protected] wrote:
> the other thing is, I've been trying to figure out how to make this 
> expression work without JS_GetStringChars function to use it with 
> JS_GetUCProperty later:
> name = JS_GetStringChars(prName.toString());

That's a generally dangerous thing to be doing, since you now have a 
pointer to GC-controlled data that could be freed at any time. If 
AutoStableStringChars exists, that's probably the safe way to go about it.

But you should also be able to use the string "directly" through some 
horrendously ugly APIs. Call |interned = JS_AtomizeAndPinJSString(cx, 
prName.toString()), then |||INTERNED_STRING_TO_JSID(cx, interned) on 
that, to get a jsid you can use for JS_GetProperty (error-checking all 
the way).||

||https://searchfox.org/mozilla-central/source/js/src/gdb/tests/test-jsid.cpp#7-9||

||
||

||||