0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 15:25:19 +00:00

use ObjectTemplate as base for global object

This commit is contained in:
Stefan Siegl 2016-07-09 11:31:44 +02:00
parent 7a947fe9d1
commit bd730068a2
No known key found for this signature in database
GPG Key ID: 73942AF5642F3DDA
2 changed files with 5 additions and 6 deletions

View File

@ -425,16 +425,14 @@ static PHP_METHOD(V8Js, __construct)
/* Create global template for global object */ /* Create global template for global object */
// Now we are using multiple isolates this needs to be created for every context // Now we are using multiple isolates this needs to be created for every context
v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(c->isolate, 0); v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(c->isolate);
tpl->SetClassName(V8JS_SYM("V8Js"));
c->global_template.Reset(isolate, tpl); c->global_template.Reset(isolate, tpl);
/* Register builtin methods */ /* Register builtin methods */
v8js_register_methods(tpl->InstanceTemplate(), c); v8js_register_methods(tpl, c);
/* Create context */ /* Create context */
v8::Local<v8::Context> context = v8::Context::New(isolate, &extension_conf, tpl->InstanceTemplate()); v8::Local<v8::Context> context = v8::Context::New(isolate, &extension_conf, tpl);
if (exts) { if (exts) {
v8js_free_ext_strarr(exts, exts_count); v8js_free_ext_strarr(exts, exts_count);

View File

@ -18,6 +18,7 @@
/* Abbreviate long type names */ /* Abbreviate long type names */
typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_function_tmpl_t; typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_function_tmpl_t;
typedef v8::Persistent<v8::ObjectTemplate, v8::CopyablePersistentTraits<v8::ObjectTemplate> > v8js_object_tmpl_t;
typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t; typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
/* Forward declarations */ /* Forward declarations */
@ -48,7 +49,7 @@ struct v8js_ctx {
bool memory_limit_hit; bool memory_limit_hit;
long average_object_size; long average_object_size;
v8js_function_tmpl_t global_template; v8js_object_tmpl_t global_template;
v8js_function_tmpl_t array_tmpl; v8js_function_tmpl_t array_tmpl;
zval module_normaliser; zval module_normaliser;