Rearrange generation of init block to have custom init code within the initializer body.
This commit is contained in:
parent
80ce36c445
commit
1f07195812
5 changed files with 137 additions and 125 deletions
|
|
@ -464,71 +464,3 @@ fail:
|
|||
%{
|
||||
SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter);
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* js_initializer: template for the module initializer function
|
||||
* - $jsname: module name
|
||||
* - $jsv8nspaces: part with code creating namespace objects
|
||||
* - $jsv8classtemplates: part with code creating class templates
|
||||
* - $jsv8wrappers: part with code that registers wrapper functions
|
||||
* - $jsv8inheritance: part with inherit statements
|
||||
* - $jsv8classinstances: part with code creating class objects
|
||||
* - $jsv8staticwrappers: part with code adding static functions to class objects
|
||||
* - $jsv8registerclasses: part with code that registers class objects in namespaces
|
||||
* - $jsv8registernspaces: part with code that registers namespaces in parent namespaces
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%fragment("js_initializer", "templates")
|
||||
%{
|
||||
|
||||
// Note: 'extern "C"'' disables name mangling which makes it easier to load the symbol manually
|
||||
// TODO: is it ok to do that?
|
||||
extern "C"
|
||||
#if (NODE_MODULE_VERSION < 0x000C)
|
||||
void $jsname_initialize(v8::Handle<v8::Object> exports)
|
||||
#else
|
||||
void $jsname_initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*module*/)
|
||||
#endif
|
||||
{
|
||||
SWIG_InitializeModule(static_cast<void *>(&exports));
|
||||
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Object> exports_obj = exports;
|
||||
|
||||
// a class template for creating proxies of undefined types
|
||||
|
||||
#if (SWIG_V8_VERSION < 0x031900)
|
||||
SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent<v8::FunctionTemplate>::New(SWIGV8_CreateClassTemplate("SwigProxy"));
|
||||
#else
|
||||
SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy"));
|
||||
#endif
|
||||
|
||||
/* create objects for namespaces */
|
||||
$jsv8nspaces
|
||||
|
||||
/* create class templates */
|
||||
$jsv8classtemplates
|
||||
|
||||
/* register wrapper functions */
|
||||
$jsv8wrappers
|
||||
|
||||
/* setup inheritances */
|
||||
$jsv8inheritance
|
||||
|
||||
/* class instances */
|
||||
$jsv8classinstances
|
||||
|
||||
/* add static class functions and variables */
|
||||
$jsv8staticwrappers
|
||||
|
||||
/* register classes */
|
||||
$jsv8registerclasses
|
||||
|
||||
/* create and register namespace objects */
|
||||
$jsv8registernspaces
|
||||
}
|
||||
|
||||
#if defined(BUILDING_NODE_EXTENSION)
|
||||
NODE_MODULE($jsname, $jsname_initialize);
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue