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

Side by Side Diff: gin/object_template_builder.cc

Issue 1106393002: gin: Use V8 Maybe APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maybe-gin-converter
Patch Set: Created 5 years, 6 months 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
« no previous file with comments | « gin/modules/module_registry.cc ('k') | gin/shell/gin_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "gin/object_template_builder.h" 5 #include "gin/object_template_builder.h"
6 6
7 #include "gin/interceptor.h" 7 #include "gin/interceptor.h"
8 #include "gin/per_isolate_data.h" 8 #include "gin/per_isolate_data.h"
9 #include "gin/public/wrapper_info.h" 9 #include "gin/public/wrapper_info.h"
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return; 86 return;
87 info.GetReturnValue().Set(0); 87 info.GetReturnValue().Set(0);
88 } 88 }
89 89
90 void NamedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { 90 void NamedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
91 v8::Isolate* isolate = info.GetIsolate(); 91 v8::Isolate* isolate = info.GetIsolate();
92 NamedPropertyInterceptor* interceptor = 92 NamedPropertyInterceptor* interceptor =
93 NamedInterceptorFromV8(isolate, info.Holder()); 93 NamedInterceptorFromV8(isolate, info.Holder());
94 if (!interceptor) 94 if (!interceptor)
95 return; 95 return;
96 info.GetReturnValue().Set(v8::Local<v8::Array>::Cast( 96 v8::Local<v8::Value> properties;
97 ConvertToV8(isolate, interceptor->EnumerateNamedProperties(isolate)))); 97 if (!TryConvertToV8(isolate, interceptor->EnumerateNamedProperties(isolate),
98 &properties))
99 return;
100 info.GetReturnValue().Set(v8::Local<v8::Array>::Cast(properties));
98 } 101 }
99 102
100 void IndexedPropertyGetter(uint32_t index, 103 void IndexedPropertyGetter(uint32_t index,
101 const v8::PropertyCallbackInfo<v8::Value>& info) { 104 const v8::PropertyCallbackInfo<v8::Value>& info) {
102 v8::Isolate* isolate = info.GetIsolate(); 105 v8::Isolate* isolate = info.GetIsolate();
103 IndexedPropertyInterceptor* interceptor = 106 IndexedPropertyInterceptor* interceptor =
104 IndexedInterceptorFromV8(isolate, info.Holder()); 107 IndexedInterceptorFromV8(isolate, info.Holder());
105 if (!interceptor) 108 if (!interceptor)
106 return; 109 return;
107 info.GetReturnValue().Set(interceptor->GetIndexedProperty(isolate, index)); 110 info.GetReturnValue().Set(interceptor->GetIndexedProperty(isolate, index));
(...skipping 11 matching lines...) Expand all
119 info.GetReturnValue().Set(value); 122 info.GetReturnValue().Set(value);
120 } 123 }
121 124
122 void IndexedPropertyEnumerator( 125 void IndexedPropertyEnumerator(
123 const v8::PropertyCallbackInfo<v8::Array>& info) { 126 const v8::PropertyCallbackInfo<v8::Array>& info) {
124 v8::Isolate* isolate = info.GetIsolate(); 127 v8::Isolate* isolate = info.GetIsolate();
125 IndexedPropertyInterceptor* interceptor = 128 IndexedPropertyInterceptor* interceptor =
126 IndexedInterceptorFromV8(isolate, info.Holder()); 129 IndexedInterceptorFromV8(isolate, info.Holder());
127 if (!interceptor) 130 if (!interceptor)
128 return; 131 return;
129 info.GetReturnValue().Set(v8::Local<v8::Array>::Cast( 132 v8::Local<v8::Value> properties;
130 ConvertToV8(isolate, interceptor->EnumerateIndexedProperties(isolate)))); 133 if (!TryConvertToV8(isolate, interceptor->EnumerateIndexedProperties(isolate),
134 &properties))
135 return;
136 info.GetReturnValue().Set(v8::Local<v8::Array>::Cast(properties));
131 } 137 }
132 138
133 } // namespace 139 } // namespace
134 140
135 ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate) 141 ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate)
136 : isolate_(isolate), template_(v8::ObjectTemplate::New(isolate)) { 142 : isolate_(isolate), template_(v8::ObjectTemplate::New(isolate)) {
137 template_->SetInternalFieldCount(kNumberOfInternalFields); 143 template_->SetInternalFieldCount(kNumberOfInternalFields);
138 } 144 }
139 145
140 ObjectTemplateBuilder::~ObjectTemplateBuilder() { 146 ObjectTemplateBuilder::~ObjectTemplateBuilder() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return *this; 178 return *this;
173 } 179 }
174 180
175 v8::Local<v8::ObjectTemplate> ObjectTemplateBuilder::Build() { 181 v8::Local<v8::ObjectTemplate> ObjectTemplateBuilder::Build() {
176 v8::Local<v8::ObjectTemplate> result = template_; 182 v8::Local<v8::ObjectTemplate> result = template_;
177 template_.Clear(); 183 template_.Clear();
178 return result; 184 return result;
179 } 185 }
180 186
181 } // namespace gin 187 } // namespace gin
OLDNEW
« no previous file with comments | « gin/modules/module_registry.cc ('k') | gin/shell/gin_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698