Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: gin/wrappable_unittest.cc

Issue 107113005: Gin: Consolidate all the Converter<Wrappable> subclasses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded friend declaration Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698