Skip to content

Commit bd73006

Browse files
committed
use ObjectTemplate as base for global object
1 parent 7a947fe commit bd73006

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

v8js_class.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,14 @@ static PHP_METHOD(V8Js, __construct)
425425
/* Create global template for global object */
426426
// Now we are using multiple isolates this needs to be created for every context
427427

428-
v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(c->isolate, 0);
429-
430-
tpl->SetClassName(V8JS_SYM("V8Js"));
428+
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(c->isolate);
431429
c->global_template.Reset(isolate, tpl);
432430

433431
/* Register builtin methods */
434-
v8js_register_methods(tpl->InstanceTemplate(), c);
432+
v8js_register_methods(tpl, c);
435433

436434
/* Create context */
437-
v8::Local<v8::Context> context = v8::Context::New(isolate, &extension_conf, tpl->InstanceTemplate());
435+
v8::Local<v8::Context> context = v8::Context::New(isolate, &extension_conf, tpl);
438436

439437
if (exts) {
440438
v8js_free_ext_strarr(exts, exts_count);

v8js_class.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
/* Abbreviate long type names */
2020
typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_function_tmpl_t;
21+
typedef v8::Persistent<v8::ObjectTemplate, v8::CopyablePersistentTraits<v8::ObjectTemplate> > v8js_object_tmpl_t;
2122
typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
2223

2324
/* Forward declarations */
@@ -48,7 +49,7 @@ struct v8js_ctx {
4849
bool memory_limit_hit;
4950
long average_object_size;
5051

51-
v8js_function_tmpl_t global_template;
52+
v8js_object_tmpl_t global_template;
5253
v8js_function_tmpl_t array_tmpl;
5354

5455
zval module_normaliser;

0 commit comments

Comments
 (0)