0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 14:01:53 +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 */
// 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);
tpl->SetClassName(V8JS_SYM("V8Js"));
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(c->isolate);
c->global_template.Reset(isolate, tpl);
/* Register builtin methods */
v8js_register_methods(tpl->InstanceTemplate(), c);
v8js_register_methods(tpl, c);
/* 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) {
v8js_free_ext_strarr(exts, exts_count);

View File

@ -18,6 +18,7 @@
/* Abbreviate long type names */
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;
/* Forward declarations */
@ -48,7 +49,7 @@ struct v8js_ctx {
bool memory_limit_hit;
long average_object_size;
v8js_function_tmpl_t global_template;
v8js_object_tmpl_t global_template;
v8js_function_tmpl_t array_tmpl;
zval module_normaliser;