diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-04-08 18:14:00 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-06-14 15:53:38 +0300 |
commit | 8a7201b25fa2e5342b5d737742586bcd5ea1da5e (patch) | |
tree | 57382552b4b50d471b91ab41d19df3eeab0b67d4 /src/env.cc | |
parent | c17d2f99018ae48ed82a90a9eccc570ed1ae83c6 (diff) |
src: introduce BaseObject base FunctionTemplate
PR-URL: https://github.com/nodejs/node/pull/33772
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r-- | src/env.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/env.cc b/src/env.cc index 677faf093a8..4030df9ec90 100644 --- a/src/env.cc +++ b/src/env.cc @@ -269,6 +269,7 @@ void Environment::CreateProperties() { Local<FunctionTemplate> templ = FunctionTemplate::New(isolate()); templ->InstanceTemplate()->SetInternalFieldCount( BaseObject::kInternalFieldCount); + templ->Inherit(BaseObject::GetConstructorTemplate(this)); set_binding_data_ctor_template(templ); } @@ -1112,4 +1113,14 @@ bool BaseObject::IsRootNode() const { return !persistent_handle_.IsWeak(); } +Local<FunctionTemplate> BaseObject::GetConstructorTemplate(Environment* env) { + Local<FunctionTemplate> tmpl = env->base_object_ctor_template(); + if (tmpl.IsEmpty()) { + tmpl = env->NewFunctionTemplate(nullptr); + tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "BaseObject")); + env->set_base_object_ctor_template(tmpl); + } + return tmpl; +} + } // namespace node |