| Index: gin/wrappable.cc
|
| diff --git a/gin/wrappable.cc b/gin/wrappable.cc
|
| index 4a9ef0e1935d32e0b7a5213ab6ec47a230d093db..68b84eca4875d57a513c3f50014f2cf30cbdbb29 100644
|
| --- a/gin/wrappable.cc
|
| +++ b/gin/wrappable.cc
|
| @@ -17,9 +17,9 @@ WrappableBase::~WrappableBase() {
|
| }
|
|
|
| v8::Handle<v8::Object> WrappableBase::GetWrapperImpl(
|
| - v8::Isolate* isolate, WrapperInfo* wrapper_info) {
|
| + v8::Isolate* isolate, WrapperInfo* wrapper_info, TemplateBuilder builder) {
|
| if (wrapper_.IsEmpty())
|
| - CreateWrapper(isolate, wrapper_info);
|
| + CreateWrapper(isolate, wrapper_info, builder);
|
| return v8::Local<v8::Object>::New(isolate, wrapper_);
|
| }
|
|
|
| @@ -31,10 +31,15 @@ void WrappableBase::WeakCallback(
|
| }
|
|
|
| v8::Handle<v8::Object> WrappableBase::CreateWrapper(v8::Isolate* isolate,
|
| - WrapperInfo* info) {
|
| + WrapperInfo* info,
|
| + TemplateBuilder builder) {
|
| PerIsolateData* data = PerIsolateData::From(isolate);
|
| v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(info);
|
| - CHECK(!templ.IsEmpty()); // Don't forget to register an object template.
|
| + if (templ.IsEmpty()) {
|
| + templ = builder(isolate);
|
| + CHECK(!templ.IsEmpty());
|
| + data->SetObjectTemplate(info, templ);
|
| + }
|
| CHECK_EQ(kNumberOfInternalFields, templ->InternalFieldCount());
|
| v8::Handle<v8::Object> wrapper = templ->NewInstance();
|
| wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info);
|
|
|