Provide more control about the target object/namespace where a v8 module is registered to.
This commit is contained in:
parent
6754bf2b49
commit
008adca72f
2 changed files with 6 additions and 4 deletions
|
|
@ -386,12 +386,11 @@ fail:
|
||||||
%{
|
%{
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void $jsname_initialize(v8::Handle<v8::Context> context)
|
void $jsname_initialize(v8::Handle<v8::Context> context, v8::Handle<v8::Object> global_obj)
|
||||||
{
|
{
|
||||||
SWIG_InitializeModule(0);
|
SWIG_InitializeModule(0);
|
||||||
|
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Local<v8::Object> global_obj = context->Global();
|
|
||||||
|
|
||||||
// a class template for creating proxies of undefined types
|
// a class template for creating proxies of undefined types
|
||||||
SWIGV8_SWIGTYPE_Proxy_class_templ = SWIGV8_CreateClassTemplate("SwigProxy");
|
SWIGV8_SWIGTYPE_Proxy_class_templ = SWIGV8_CreateClassTemplate("SwigProxy");
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "js_shell.h"
|
#include "js_shell.h"
|
||||||
|
|
||||||
typedef int (*V8ExtensionRegistrar) (v8::Handle<v8::Context>);
|
typedef int (*V8ExtensionRegistrar) (v8::Handle<v8::Context>, v8::Handle<v8::Object>);
|
||||||
|
|
||||||
class V8Shell: public JSShell {
|
class V8Shell: public JSShell {
|
||||||
|
|
||||||
|
|
@ -153,10 +153,13 @@ bool V8Shell::InitializeEngine() {
|
||||||
|
|
||||||
void V8Shell::ExtendEngine() {
|
void V8Shell::ExtendEngine() {
|
||||||
|
|
||||||
|
v8::HandleScope scope;
|
||||||
|
v8::Local<v8::Object> global = context->Global();
|
||||||
|
|
||||||
// register extensions
|
// register extensions
|
||||||
for(std::vector<V8ExtensionRegistrar>::iterator it=module_initializers.begin();
|
for(std::vector<V8ExtensionRegistrar>::iterator it=module_initializers.begin();
|
||||||
it != module_initializers.end(); ++it) {
|
it != module_initializers.end(); ++it) {
|
||||||
(*it)(context);
|
(*it)(context, global);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue