-
Notifications
You must be signed in to change notification settings - Fork 14
JSLanguageFeaturesJSVvsV8
Here we gather ideas and knowledge how to transfer C++ to JS in general and how to implement it for v8 and JSC, respectively. The aim is to find a unified solution.
v8: a persistent V8::FunctionTemplate instance is created once providing a ctor wrapper function. The ctor function is registered as a variable in the surrounding context with the class's name.
JSC: a ctor function is created given a (static) JSClassRef and the ctor function wrapper. The ctor function is registered in the surrounding context under the class's name.
v8: Static members are created by manipulating the so called InstanceTemplate with API functions. I.e., a module initialize function needs to be created during processing of variables and functions.
JSC: during the creation of the JSClassRef
definition.static_values
and definition.static_functions
can be set which are tables defining properties and functions, respectively. I.e., tables have to be created during the processing of variables and functions.
v8: same way as with static members but manipulating the PrototypeTemplate.
JSC: Do not know. There is JSObjectSetPrototype
, though, it is called on an instance and not on the JSClassRef.
Obviously, multiple inheritance can not transferred to JS.
v8: the chain is created by calling Inherit
on the class template.
JSC: do not know. For the creation of JSClassRef
definition.parent
can be specified.
Similar to other scripting language overloaded functions must be implemented using a dispatcher function that checks the number of arguments and maybe the type. Have a look at the Python module.
v8: every method wrapper opens a Scope. One argument can be returned (without persisting) and ownership is transferred automatically. All other handles are freed automatically.
v8::HandleScope scope;
...
return scope.Close(jsresult);
JSC: do not know.
~ Classes. This sounds easy at first, though, for that a context stack (or something equivalent) is necessary. BTW, nested classes do not need to be considered as it isn't support by SWIG currently.
~ Classes.
Look at Python module.
Read-only static variables.
Do not know yet.
Do not know yet.