How to add named variables to a SpiderMonkey context?

Kent Williams <[email protected]> Wed, 15 Jul 2020 11:20:32 -0500
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
This seems super-obvious to me but it's a part of using the SpiderMonkey 
C++ API I haven't had to use before.

1. How do you add named objects to an interpreter context? Like there 
should be functions like

JS_AddNamedObject(JSContext *cx, char *name, JS::HandleObject obj);
JS_AddNamedValue(JSContext *cx, char *name, JS::HandleValue obj);

2. Similarly there should be functions to look up values in the 
Interpreter context by name.
JS_GetNamedValue(JSContext *cx, char *name, JS::HandleValue &value);

Am I just missing where this stuff is in the API?


USE CASE: I want replace making assignments by building up a script and 
then evaluating it, to doing the assignment directly with C++ api.

It should faster to not parse and execute a script, and it would also 
get rid of a bunch of escaping you need to do for JS code to interpret 
the value literals properly.