define JS type outside of script

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

define JS type outside of script

Hi All,

I'm embedding Spidermonkey in a C++ app, compile my script snippets with JS::CompileFunction(..), and execute them later, passing in args converted from C++.
The functions have so far been unaware of each other, but now I need to define a JavaScript contructor for a type "Foo" with a few instance-functions, so that each of our JS script function can do this:

var x = new Foo();

I'm able to do this with JS_InitClass(), but the "Foo" type need to be written in JavaScript. I do not want to string-concatenate the JavaScript code for "Foo" into each of our script functions before compiling them - if possible.

I'd appreciate some hints on how to achieve this / where to look.

dev-tech-js-engine mailing list
[hidden email]