| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "gin/arguments.h" | 6 #include "gin/arguments.h" |
| 7 #include "gin/handle.h" | 7 #include "gin/handle.h" |
| 8 #include "gin/object_template_builder.h" | 8 #include "gin/object_template_builder.h" |
| 9 #include "gin/per_isolate_data.h" | 9 #include "gin/per_isolate_data.h" |
| 10 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 WrapperInfo MyObject::kWrapperInfo = { kEmbedderNativeGin }; | 36 WrapperInfo MyObject::kWrapperInfo = { kEmbedderNativeGin }; |
| 37 | 37 |
| 38 gin::Handle<MyObject> MyObject::Create(v8::Isolate* isolate) { | 38 gin::Handle<MyObject> MyObject::Create(v8::Isolate* isolate) { |
| 39 return CreateHandle(isolate, new MyObject()); | 39 return CreateHandle(isolate, new MyObject()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 WrapperInfo* MyObject::GetWrapperInfo() { | 42 WrapperInfo* MyObject::GetWrapperInfo() { |
| 43 return &kWrapperInfo; | 43 return &kWrapperInfo; |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace | |
| 47 | |
| 48 template<> | |
| 49 struct Converter<MyObject*> : public WrappableConverter<MyObject> {}; | |
| 50 | |
| 51 namespace { | |
| 52 | |
| 53 void RegisterTemplate(v8::Isolate* isolate) { | 46 void RegisterTemplate(v8::Isolate* isolate) { |
| 54 PerIsolateData* data = PerIsolateData::From(isolate); | 47 PerIsolateData* data = PerIsolateData::From(isolate); |
| 55 DCHECK(data->GetObjectTemplate(&MyObject::kWrapperInfo).IsEmpty()); | 48 DCHECK(data->GetObjectTemplate(&MyObject::kWrapperInfo).IsEmpty()); |
| 56 | 49 |
| 57 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate) | 50 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate) |
| 58 .SetProperty("value", &MyObject::value, &MyObject::set_value) | 51 .SetProperty("value", &MyObject::value, &MyObject::set_value) |
| 59 .Build(); | 52 .Build(); |
| 60 templ->SetInternalFieldCount(kNumberOfInternalFields); | 53 templ->SetInternalFieldCount(kNumberOfInternalFields); |
| 61 data->SetObjectTemplate(&MyObject::kWrapperInfo, templ); | 54 data->SetObjectTemplate(&MyObject::kWrapperInfo, templ); |
| 62 } | 55 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 }; | 99 }; |
| 107 func->Call(v8::Undefined(isolate), 1, argv); | 100 func->Call(v8::Undefined(isolate), 1, argv); |
| 108 EXPECT_FALSE(try_catch.HasCaught()); | 101 EXPECT_FALSE(try_catch.HasCaught()); |
| 109 EXPECT_EQ("", try_catch.GetStackTrace()); | 102 EXPECT_EQ("", try_catch.GetStackTrace()); |
| 110 | 103 |
| 111 EXPECT_EQ(191, obj->value()); | 104 EXPECT_EQ(191, obj->value()); |
| 112 } | 105 } |
| 113 | 106 |
| 114 } // namespace | 107 } // namespace |
| 115 } // namespace gin | 108 } // namespace gin |
| OLD | NEW |