Pass FunctionTemplate in BuildPrototype
This commit is contained in:
parent
3a7a6efffb
commit
4dbe051494
1 changed files with 8 additions and 8 deletions
|
@ -27,13 +27,13 @@ class Wrappable : public WrappableBase {
|
||||||
template<typename Sig>
|
template<typename Sig>
|
||||||
static void SetConstructor(v8::Isolate* isolate,
|
static void SetConstructor(v8::Isolate* isolate,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const base::Callback<Sig>& factory) {
|
const base::Callback<Sig>& constructor) {
|
||||||
v8::Local<v8::FunctionTemplate> constructor = CreateFunctionTemplate(
|
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
|
||||||
isolate, base::Bind(&internal::InvokeNew<Sig>, factory));
|
isolate, base::Bind(&internal::InvokeNew<Sig>, constructor));
|
||||||
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
constructor->SetClassName(StringToV8(isolate, name));
|
templ->SetClassName(StringToV8(isolate, name));
|
||||||
T::BuildPrototype(isolate, constructor->PrototypeTemplate());
|
T::BuildPrototype(isolate, templ);
|
||||||
templ_ = new v8::Global<v8::FunctionTemplate>(isolate, constructor);
|
templ_ = new v8::Global<v8::FunctionTemplate>(isolate, templ);
|
||||||
}
|
}
|
||||||
|
|
||||||
static v8::Local<v8::FunctionTemplate> GetConstructor(v8::Isolate* isolate) {
|
static v8::Local<v8::FunctionTemplate> GetConstructor(v8::Isolate* isolate) {
|
||||||
|
@ -41,7 +41,7 @@ class Wrappable : public WrappableBase {
|
||||||
if (!templ_) {
|
if (!templ_) {
|
||||||
v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
|
v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
|
||||||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
T::BuildPrototype(isolate, templ->PrototypeTemplate());
|
T::BuildPrototype(isolate, templ);
|
||||||
templ_ = new v8::Global<v8::FunctionTemplate>(isolate, templ);
|
templ_ = new v8::Global<v8::FunctionTemplate>(isolate, templ);
|
||||||
}
|
}
|
||||||
return v8::Local<v8::FunctionTemplate>::New(isolate, *templ_);
|
return v8::Local<v8::FunctionTemplate>::New(isolate, *templ_);
|
||||||
|
|
Loading…
Reference in a new issue