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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: More fixes - things build fine at this point. Created 3 years, 8 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
OLDNEW
1 {% extends 'interface_base.cpp.tmpl' %} 1 {% extends 'interface_base.cpp.tmpl' %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% block indexed_property_getter %} 4 {% block indexed_property_getter %}
5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
6 {% set getter = indexed_property_getter %} 6 {% set getter = indexed_property_getter %}
7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
8 {% if getter.is_raises_exception %} 8 {% if getter.is_raises_exception %}
9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}"); 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedGette rContext, "{{interface_name}}");
10 {% endif %} 10 {% endif %}
11 11
12 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 12 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
13 13
14 // We assume that all the implementations support length() method, although 14 // We assume that all the implementations support length() method, although
15 // the spec doesn't require that length() must exist. It's okay that 15 // the spec doesn't require that length() must exist. It's okay that
16 // the interface does not have length attribute as long as the 16 // the interface does not have length attribute as long as the
17 // implementation supports length() member function. 17 // implementation supports length() member function.
18 if (index >= impl->length()) 18 if (index >= impl->length())
19 return; // Returns undefined due to out-of-range. 19 return; // Returns undefined due to out-of-range.
20 20
21 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} 21 {% set getter_name = getter.name or 'AnonymousIndexedGetter' %}
22 {% set getter_arguments = ['index'] %} 22 {% set getter_arguments = ['index'] %}
23 {% if getter.is_call_with_script_state %} 23 {% if getter.is_call_with_script_state %}
24 ScriptState* scriptState = ScriptState::forReceiverObject(info); 24 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
25 {% set getter_arguments = ['scriptState'] + getter_arguments %} 25 {% set getter_arguments = ['scriptState'] + getter_arguments %}
26 {% endif %} 26 {% endif %}
27 {% if getter.is_raises_exception %} 27 {% if getter.is_raises_exception %}
28 {% set getter_arguments = getter_arguments + ['exceptionState'] %} 28 {% set getter_arguments = getter_arguments + ['exceptionState'] %}
29 {% endif %} 29 {% endif %}
30 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join(' , ')}}); 30 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join(' , ')}});
31 {{getter.v8_set_return_value}}; 31 {{getter.v8_set_return_value}};
32 } 32 }
33 33
34 {% endif %} 34 {% endif %}
35 {% endblock %} 35 {% endblock %}
36 36
37 37
38 {##############################################################################} 38 {##############################################################################}
39 {% block indexed_property_getter_callback %} 39 {% block indexed_property_getter_callback %}
40 {% if indexed_property_getter or named_property_getter %} 40 {% if indexed_property_getter or named_property_getter %}
41 {% set getter = indexed_property_getter or named_property_getter %} 41 {% set getter = indexed_property_getter or named_property_getter %}
42 void {{v8_class_or_partial}}::indexedPropertyGetterCallback(uint32_t index, cons t v8::PropertyCallbackInfo<v8::Value>& info) { 42 void {{v8_class_or_partial}}::indexedPropertyGetterCallback(uint32_t index, cons t v8::PropertyCallbackInfo<v8::Value>& info) {
43 {% if indexed_property_getter %} 43 {% if indexed_property_getter %}
44 44
45 {% if getter.is_custom %} 45 {% if getter.is_custom %}
46 {{v8_class}}::indexedPropertyGetterCustom(index, info); 46 {{v8_class}}::indexedPropertyGetterCustom(index, info);
47 {% else %} 47 {% else %}
48 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); 48 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info);
49 {% endif %} 49 {% endif %}
50 50
51 {% else %}{# otherwise, named property #} 51 {% else %}{# otherwise, named property #}
52 52
53 const AtomicString& propertyName = AtomicString::number(index); 53 const AtomicString& propertyName = AtomicString::Number(index);
54 54
55 {% if getter.is_custom %} 55 {% if getter.is_custom %}
56 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); 56 {{v8_class}}::namedPropertyGetterCustom(propertyName, info);
57 {% else %} 57 {% else %}
58 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); 58 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info);
59 {% endif %} 59 {% endif %}
60 60
61 {% endif %}{# indexed_property_getter #} 61 {% endif %}{# indexed_property_getter #}
62 } 62 }
63 63
64 {% endif %} 64 {% endif %}
65 {% endblock %} 65 {% endblock %}
66 66
67 67
68 {##############################################################################} 68 {##############################################################################}
69 {% block indexed_property_setter %} 69 {% block indexed_property_setter %}
70 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} 70 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %}
71 {% if indexed_property_setter and not indexed_property_setter.is_custom %} 71 {% if indexed_property_setter and not indexed_property_setter.is_custom %}
72 {% set setter = indexed_property_setter %} 72 {% set setter = indexed_property_setter %}
73 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { 73 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
74 {% if setter.has_exception_state %} 74 {% if setter.has_exception_state %}
75 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedSetter Context, "{{interface_name}}"); 75 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedSette rContext, "{{interface_name}}");
76 {% endif %} 76 {% endif %}
77 77
78 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 78 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
79 {{v8_value_to_local_cpp_value(setter) | indent(2)}} 79 {{v8_value_to_local_cpp_value(setter) | indent(2)}}
80 {% if setter.has_type_checking_interface %} 80 {% if setter.has_type_checking_interface %}
81 {# Type checking for interface types (if interface not implemented, throw 81 {# Type checking for interface types (if interface not implemented, throw
82 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 82 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
83 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { 83 if (!propertyValue{% if setter.is_nullable %} && !IsUndefinedOrNull(v8Value){% endif %}) {
84 exceptionState.throwTypeError("The provided value is not of type '{{setter.i dl_type}}'."); 84 exceptionState.ThrowTypeError("The provided value is not of type '{{setter.i dl_type}}'.");
85 return; 85 return;
86 } 86 }
87 {% endif %} 87 {% endif %}
88 88
89 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} 89 {% set setter_name = setter.name or 'AnonymousIndexedSetter' %}
90 {% set setter_arguments = ['index', 'propertyValue'] %} 90 {% set setter_arguments = ['index', 'propertyValue'] %}
91 {% if setter.is_call_with_script_state %} 91 {% if setter.is_call_with_script_state %}
92 ScriptState* scriptState = ScriptState::forReceiverObject(info); 92 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
93 {% set setter_arguments = ['scriptState'] + setter_arguments %} 93 {% set setter_arguments = ['scriptState'] + setter_arguments %}
94 {% endif %} 94 {% endif %}
95 {% if setter.is_raises_exception %} 95 {% if setter.is_raises_exception %}
96 {% set setter_arguments = setter_arguments + ['exceptionState'] %} 96 {% set setter_arguments = setter_arguments + ['exceptionState'] %}
97 {% endif %} 97 {% endif %}
98 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); 98 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}});
99 {% if setter.is_raises_exception %} 99 {% if setter.is_raises_exception %}
100 if (exceptionState.hadException()) 100 if (exceptionState.HadException())
101 return; 101 return;
102 {% endif %} 102 {% endif %}
103 if (!result) 103 if (!result)
104 return; 104 return;
105 v8SetReturnValue(info, v8Value); 105 V8SetReturnValue(info, v8Value);
106 } 106 }
107 107
108 {% endif %} 108 {% endif %}
109 {% endblock %} 109 {% endblock %}
110 110
111 111
112 {##############################################################################} 112 {##############################################################################}
113 {% block indexed_property_setter_callback %} 113 {% block indexed_property_setter_callback %}
114 {% if indexed_property_setter or named_property_setter %} 114 {% if indexed_property_setter or named_property_setter %}
115 {% set setter = indexed_property_setter or named_property_setter %} 115 {% set setter = indexed_property_setter or named_property_setter %}
116 void {{v8_class_or_partial}}::indexedPropertySetterCallback(uint32_t index, v8:: Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { 116 void {{v8_class_or_partial}}::indexedPropertySetterCallback(uint32_t index, v8:: Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
117 {% if setter.is_ce_reactions %} 117 {% if setter.is_ce_reactions %}
118 CEReactionsScope ceReactionsScope; 118 CEReactionsScope ceReactionsScope;
119 {% endif %} 119 {% endif %}
120 120
121 {% if indexed_property_setter %} 121 {% if indexed_property_setter %}
122 122
123 {% if setter.is_custom %} 123 {% if setter.is_custom %}
124 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info); 124 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info);
125 {% else %} 125 {% else %}
126 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info); 126 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info);
127 {% endif %} 127 {% endif %}
128 128
129 {% else %}{# otherwise, named property #} 129 {% else %}{# otherwise, named property #}
130 130
131 const AtomicString& propertyName = AtomicString::number(index); 131 const AtomicString& propertyName = AtomicString::Number(index);
132 132
133 {% if setter.is_custom %} 133 {% if setter.is_custom %}
134 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); 134 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info);
135 {% else %} 135 {% else %}
136 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); 136 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info);
137 {% endif %} 137 {% endif %}
138 138
139 {% endif %}{# indexed_property_setter #} 139 {% endif %}{# indexed_property_setter #}
140 } 140 }
141 141
142 {% endif %} 142 {% endif %}
143 {% endblock %} 143 {% endblock %}
144 144
145 145
146 {##############################################################################} 146 {##############################################################################}
147 {% block indexed_property_deleter %} 147 {% block indexed_property_deleter %}
148 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} 148 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %}
149 {% set deleter = indexed_property_deleter %} 149 {% set deleter = indexed_property_deleter %}
150 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) { 150 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) {
151 {% if deleter.is_raises_exception %} 151 {% if deleter.is_raises_exception %}
152 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedDeleti onContext, "{{interface_name}}"); 152 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedDelet ionContext, "{{interface_name}}");
153 {% endif %} 153 {% endif %}
154 154
155 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 155 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
156 156
157 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} 157 {% set deleter_name = deleter.name or 'AnonymousIndexedDeleter' %}
158 {% set deleter_arguments = ['index'] %} 158 {% set deleter_arguments = ['index'] %}
159 {% if deleter.is_call_with_script_state %} 159 {% if deleter.is_call_with_script_state %}
160 ScriptState* scriptState = ScriptState::forReceiverObject(info); 160 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
161 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} 161 {% set deleter_arguments = ['scriptState'] + deleter_arguments %}
162 {% endif %} 162 {% endif %}
163 {% if deleter.is_raises_exception %} 163 {% if deleter.is_raises_exception %}
164 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} 164 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %}
165 {% endif %} 165 {% endif %}
166 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} }); 166 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} });
167 {% if deleter.is_raises_exception %} 167 {% if deleter.is_raises_exception %}
168 if (exceptionState.hadException()) 168 if (exceptionState.HadException())
169 return; 169 return;
170 {% endif %} 170 {% endif %}
171 if (result == DeleteUnknownProperty) 171 if (result == kDeleteUnknownProperty)
172 return; 172 return;
173 v8SetReturnValue(info, result == DeleteSuccess); 173 V8SetReturnValue(info, result == kDeleteSuccess);
174 } 174 }
175 175
176 {% endif %} 176 {% endif %}
177 {% endblock %} 177 {% endblock %}
178 178
179 179
180 {##############################################################################} 180 {##############################################################################}
181 {% block indexed_property_deleter_callback %} 181 {% block indexed_property_deleter_callback %}
182 {% if indexed_property_deleter or named_property_deleter %} 182 {% if indexed_property_deleter or named_property_deleter %}
183 {% set deleter = indexed_property_deleter or named_property_deleter %} 183 {% set deleter = indexed_property_deleter or named_property_deleter %}
184 void {{v8_class_or_partial}}::indexedPropertyDeleterCallback(uint32_t index, con st v8::PropertyCallbackInfo<v8::Boolean>& info) { 184 void {{v8_class_or_partial}}::indexedPropertyDeleterCallback(uint32_t index, con st v8::PropertyCallbackInfo<v8::Boolean>& info) {
185 {% if deleter.is_ce_reactions %} 185 {% if deleter.is_ce_reactions %}
186 CEReactionsScope ceReactionsScope; 186 CEReactionsScope ceReactionsScope;
187 {% endif %} 187 {% endif %}
188 188
189 {% if indexed_property_deleter %} 189 {% if indexed_property_deleter %}
190 190
191 {% if deleter.is_custom %} 191 {% if deleter.is_custom %}
192 {{v8_class}}::indexedPropertyDeleterCustom(index, info); 192 {{v8_class}}::indexedPropertyDeleterCustom(index, info);
193 {% else %} 193 {% else %}
194 {{cpp_class}}V8Internal::indexedPropertyDeleter(index, info); 194 {{cpp_class}}V8Internal::indexedPropertyDeleter(index, info);
195 {% endif %} 195 {% endif %}
196 196
197 {% else %}{# otherwise, named property #} 197 {% else %}{# otherwise, named property #}
198 198
199 const AtomicString& propertyName = AtomicString::number(index); 199 const AtomicString& propertyName = AtomicString::Number(index);
200 200
201 {% if deleter.is_custom %} 201 {% if deleter.is_custom %}
202 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info); 202 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info);
203 {% else %} 203 {% else %}
204 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info); 204 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info);
205 {% endif %} 205 {% endif %}
206 206
207 {% endif %}{# indexed_property_deleter #} 207 {% endif %}{# indexed_property_deleter #}
208 } 208 }
209 209
210 {% endif %} 210 {% endif %}
211 {% endblock %} 211 {% endblock %}
212 212
213 213
214 {##############################################################################} 214 {##############################################################################}
215 {% block named_property_getter %} 215 {% block named_property_getter %}
216 {% if named_property_getter and not named_property_getter.is_custom %} 216 {% if named_property_getter and not named_property_getter.is_custom %}
217 {% set getter = named_property_getter %} 217 {% set getter = named_property_getter %}
218 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall backInfo<v8::Value>& info) { 218 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall backInfo<v8::Value>& info) {
219 {% if getter.is_raises_exception %} 219 {% if getter.is_raises_exception %}
220 const CString& nameInUtf8 = name.utf8(); 220 const CString& nameInUtf8 = name.Utf8();
221 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext , "{{interface_name}}", nameInUtf8.data()); 221 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContex t, "{{interface_name}}", nameInUtf8.Data());
222 {% endif %} 222 {% endif %}
223 {% if getter.is_call_with_script_state %} 223 {% if getter.is_call_with_script_state %}
224 ScriptState* scriptState = ScriptState::forReceiverObject(info); 224 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
225 {% endif %} 225 {% endif %}
226 226
227 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 227 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
228 {% if getter.use_output_parameter_for_result %} 228 {% if getter.use_output_parameter_for_result %}
229 {{getter.cpp_type}} result; 229 {{getter.cpp_type}} result;
230 {{getter.cpp_value}}; 230 {{getter.cpp_value}};
231 {% else %} 231 {% else %}
232 {{getter.cpp_type}} result = {{getter.cpp_value}}; 232 {{getter.cpp_type}} result = {{getter.cpp_value}};
233 {% endif %} 233 {% endif %}
234 if ({{getter.is_null_expression}}) 234 if ({{getter.is_null_expression}})
235 return; 235 return;
236 {{getter.v8_set_return_value}}; 236 {{getter.v8_set_return_value}};
237 } 237 }
238 238
239 {% endif %} 239 {% endif %}
240 {% endblock %} 240 {% endblock %}
241 241
242 242
243 {##############################################################################} 243 {##############################################################################}
244 {% block named_property_getter_callback %} 244 {% block named_property_getter_callback %}
245 {% if named_property_getter %} 245 {% if named_property_getter %}
246 {% set getter = named_property_getter %} 246 {% set getter = named_property_getter %}
247 void {{v8_class_or_partial}}::namedPropertyGetterCallback(v8::Local<v8::Name> na me, const v8::PropertyCallbackInfo<v8::Value>& info) { 247 void {{v8_class_or_partial}}::namedPropertyGetterCallback(v8::Local<v8::Name> na me, const v8::PropertyCallbackInfo<v8::Value>& info) {
248 if (!name->IsString()) 248 if (!name->IsString())
249 return; 249 return;
250 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); 250 const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>());
251 251
252 {% if getter.is_custom %} 252 {% if getter.is_custom %}
253 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); 253 {{v8_class}}::namedPropertyGetterCustom(propertyName, info);
254 {% else %} 254 {% else %}
255 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); 255 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info);
256 {% endif %} 256 {% endif %}
257 } 257 }
258 258
259 {% endif %} 259 {% endif %}
260 {% endblock %} 260 {% endblock %}
261 261
262 262
263 {##############################################################################} 263 {##############################################################################}
264 {% block named_property_setter %} 264 {% block named_property_setter %}
265 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} 265 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %}
266 {% if named_property_setter and not named_property_setter.is_custom %} 266 {% if named_property_setter and not named_property_setter.is_custom %}
267 {% set setter = named_property_setter %} 267 {% set setter = named_property_setter %}
268 static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { 268 static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
269 {% if setter.has_exception_state %} 269 {% if setter.has_exception_state %}
270 const CString& nameInUtf8 = name.utf8(); 270 const CString& nameInUtf8 = name.Utf8();
271 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", nameInUtf8.data()); 271 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kSetterContex t, "{{interface_name}}", nameInUtf8.Data());
272 {% endif %} 272 {% endif %}
273 {% if setter.is_call_with_script_state %} 273 {% if setter.is_call_with_script_state %}
274 ScriptState* scriptState = ScriptState::forReceiverObject(info); 274 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
275 {% endif %} 275 {% endif %}
276 276
277 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 277 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
278 {{v8_value_to_local_cpp_value(setter) | indent(2)}} 278 {{v8_value_to_local_cpp_value(setter) | indent(2)}}
279 {% if setter.has_type_checking_interface %} 279 {% if setter.has_type_checking_interface %}
280 {# Type checking for interface types (if interface not implemented, throw 280 {# Type checking for interface types (if interface not implemented, throw
281 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 281 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
282 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { 282 if (!propertyValue{% if setter.is_nullable %} && !IsUndefinedOrNull(v8Value){% endif %}) {
283 exceptionState.throwTypeError("The provided value is not of type '{{setter.i dl_type}}'."); 283 exceptionState.ThrowTypeError("The provided value is not of type '{{setter.i dl_type}}'.");
284 return; 284 return;
285 } 285 }
286 {% endif %} 286 {% endif %}
287 287
288 {% set setter_name = setter.name or 'anonymousNamedSetter' %} 288 {% set setter_name = setter.name or 'AnonymousNamedSetter' %}
289 {% set setter_arguments = ['name', 'propertyValue'] %} 289 {% set setter_arguments = ['name', 'propertyValue'] %}
290 {% if setter.is_call_with_script_state %} 290 {% if setter.is_call_with_script_state %}
291 {% set setter_arguments = ['scriptState'] + setter_arguments %} 291 {% set setter_arguments = ['scriptState'] + setter_arguments %}
292 {% endif %} 292 {% endif %}
293 {% if setter.is_raises_exception %} 293 {% if setter.is_raises_exception %}
294 {% set setter_arguments = setter_arguments + ['exceptionState'] %} 294 {% set setter_arguments = setter_arguments + ['exceptionState'] %}
295 {% endif %} 295 {% endif %}
296 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); 296 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}});
297 {% if setter.is_raises_exception %} 297 {% if setter.is_raises_exception %}
298 if (exceptionState.hadException()) 298 if (exceptionState.HadException())
299 return; 299 return;
300 {% endif %} 300 {% endif %}
301 if (!result) 301 if (!result)
302 return; 302 return;
303 v8SetReturnValue(info, v8Value); 303 V8SetReturnValue(info, v8Value);
304 } 304 }
305 305
306 {% endif %} 306 {% endif %}
307 {% endblock %} 307 {% endblock %}
308 308
309 309
310 {##############################################################################} 310 {##############################################################################}
311 {% block named_property_setter_callback %} 311 {% block named_property_setter_callback %}
312 {% if named_property_setter %} 312 {% if named_property_setter %}
313 {% set setter = named_property_setter %} 313 {% set setter = named_property_setter %}
314 void {{v8_class_or_partial}}::namedPropertySetterCallback(v8::Local<v8::Name> na me, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& inf o) { 314 void {{v8_class_or_partial}}::namedPropertySetterCallback(v8::Local<v8::Name> na me, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& inf o) {
315 if (!name->IsString()) 315 if (!name->IsString())
316 return; 316 return;
317 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); 317 const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>());
318 318
319 {% if setter.is_ce_reactions %} 319 {% if setter.is_ce_reactions %}
320 CEReactionsScope ceReactionsScope; 320 CEReactionsScope ceReactionsScope;
321 {% endif %} 321 {% endif %}
322 322
323 {% if setter.is_custom %} 323 {% if setter.is_custom %}
324 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); 324 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info);
325 {% else %} 325 {% else %}
326 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); 326 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info);
327 {% endif %} 327 {% endif %}
328 } 328 }
329 329
330 {% endif %} 330 {% endif %}
331 {% endblock %} 331 {% endblock %}
332 332
333 333
334 {##############################################################################} 334 {##############################################################################}
335 {% block named_property_deleter %} 335 {% block named_property_deleter %}
336 {% if named_property_deleter and not named_property_deleter.is_custom %} 336 {% if named_property_deleter and not named_property_deleter.is_custom %}
337 {% set deleter = named_property_deleter %} 337 {% set deleter = named_property_deleter %}
338 static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) { 338 static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) {
339 {% if deleter.is_raises_exception %} 339 {% if deleter.is_raises_exception %}
340 const CString& nameInUtf8 = name.utf8(); 340 const CString& nameInUtf8 = name.Utf8();
341 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionConte xt, "{{interface_name}}", nameInUtf8.data()); 341 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kDeletionCont ext, "{{interface_name}}", nameInUtf8.Data());
342 {% endif %} 342 {% endif %}
343 {% if deleter.is_call_with_script_state %} 343 {% if deleter.is_call_with_script_state %}
344 ScriptState* scriptState = ScriptState::forReceiverObject(info); 344 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
345 {% endif %} 345 {% endif %}
346 346
347 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 347 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
348 348
349 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} 349 {% set deleter_name = deleter.name or 'AnonymousNamedDeleter' %}
350 {% set deleter_arguments = ['name'] %} 350 {% set deleter_arguments = ['name'] %}
351 {% if deleter.is_call_with_script_state %} 351 {% if deleter.is_call_with_script_state %}
352 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} 352 {% set deleter_arguments = ['scriptState'] + deleter_arguments %}
353 {% endif %} 353 {% endif %}
354 {% if deleter.is_raises_exception %} 354 {% if deleter.is_raises_exception %}
355 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} 355 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %}
356 {% endif %} 356 {% endif %}
357 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} }); 357 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} });
358 {% if deleter.is_raises_exception %} 358 {% if deleter.is_raises_exception %}
359 if (exceptionState.hadException()) 359 if (exceptionState.HadException())
360 return; 360 return;
361 {% endif %} 361 {% endif %}
362 if (result == DeleteUnknownProperty) 362 if (result == kDeleteUnknownProperty)
363 return; 363 return;
364 v8SetReturnValue(info, result == DeleteSuccess); 364 V8SetReturnValue(info, result == kDeleteSuccess);
365 } 365 }
366 366
367 {% endif %} 367 {% endif %}
368 {% endblock %} 368 {% endblock %}
369 369
370 370
371 {##############################################################################} 371 {##############################################################################}
372 {% block named_property_deleter_callback %} 372 {% block named_property_deleter_callback %}
373 {% if named_property_deleter %} 373 {% if named_property_deleter %}
374 {% set deleter = named_property_deleter %} 374 {% set deleter = named_property_deleter %}
375 void {{v8_class_or_partial}}::namedPropertyDeleterCallback(v8::Local<v8::Name> n ame, const v8::PropertyCallbackInfo<v8::Boolean>& info) { 375 void {{v8_class_or_partial}}::namedPropertyDeleterCallback(v8::Local<v8::Name> n ame, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
376 if (!name->IsString()) 376 if (!name->IsString())
377 return; 377 return;
378 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); 378 const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>());
379 379
380 {% if deleter.is_ce_reactions %} 380 {% if deleter.is_ce_reactions %}
381 CEReactionsScope ceReactionsScope; 381 CEReactionsScope ceReactionsScope;
382 {% endif %} 382 {% endif %}
383 383
384 {% if deleter.is_custom %} 384 {% if deleter.is_custom %}
385 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info); 385 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info);
386 {% else %} 386 {% else %}
387 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info); 387 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info);
388 {% endif %} 388 {% endif %}
389 } 389 }
390 390
391 {% endif %} 391 {% endif %}
392 {% endblock %} 392 {% endblock %}
393 393
394 394
395 {##############################################################################} 395 {##############################################################################}
396 {% block named_property_query %} 396 {% block named_property_query %}
397 {% if named_property_getter and named_property_getter.is_enumerable and 397 {% if named_property_getter and named_property_getter.is_enumerable and
398 not named_property_getter.is_custom_property_query %} 398 not named_property_getter.is_custom_property_query %}
399 {% set getter = named_property_getter %} 399 {% set getter = named_property_getter %}
400 {# If there is an enumerator, there MUST be a query method to properly 400 {# If there is an enumerator, there MUST be a query method to properly
401 communicate property attributes. #} 401 communicate property attributes. #}
402 static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb ackInfo<v8::Integer>& info) { 402 static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb ackInfo<v8::Integer>& info) {
403 const CString& nameInUtf8 = name.utf8(); 403 const CString& nameInUtf8 = name.Utf8();
404 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext , "{{interface_name}}", nameInUtf8.data()); 404 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContex t, "{{interface_name}}", nameInUtf8.Data());
405 {% if getter.is_call_with_script_state %} 405 {% if getter.is_call_with_script_state %}
406 ScriptState* scriptState = ScriptState::forReceiverObject(info); 406 ScriptState* scriptState = ScriptState::ForReceiverObject(info);
407 {% endif %} 407 {% endif %}
408 408
409 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 409 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
410 410
411 {% set getter_arguments = ['name', 'exceptionState'] %} 411 {% set getter_arguments = ['name', 'exceptionState'] %}
412 {% if getter.is_call_with_script_state %} 412 {% if getter.is_call_with_script_state %}
413 {% set getter_arguments = ['scriptState'] + getter_arguments %} 413 {% set getter_arguments = ['scriptState'] + getter_arguments %}
414 {% endif %} 414 {% endif %}
415 bool result = impl->namedPropertyQuery({{getter_arguments | join(', ')}}); 415 bool result = impl->NamedPropertyQuery({{getter_arguments | join(', ')}});
416 if (!result) 416 if (!result)
417 return; 417 return;
418 v8SetReturnValueInt(info, v8::None); 418 V8SetReturnValueInt(info, v8::None);
419 } 419 }
420 420
421 {% endif %} 421 {% endif %}
422 {% endblock %} 422 {% endblock %}
423 423
424 424
425 {##############################################################################} 425 {##############################################################################}
426 {% block named_property_query_callback %} 426 {% block named_property_query_callback %}
427 {% if named_property_getter and named_property_getter.is_enumerable %} 427 {% if named_property_getter and named_property_getter.is_enumerable %}
428 {% set getter = named_property_getter %} 428 {% set getter = named_property_getter %}
429 void {{v8_class_or_partial}}::namedPropertyQueryCallback(v8::Local<v8::Name> nam e, const v8::PropertyCallbackInfo<v8::Integer>& info) { 429 void {{v8_class_or_partial}}::namedPropertyQueryCallback(v8::Local<v8::Name> nam e, const v8::PropertyCallbackInfo<v8::Integer>& info) {
430 if (!name->IsString()) 430 if (!name->IsString())
431 return; 431 return;
432 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); 432 const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>());
433 433
434 {% if getter.is_custom_property_query %} 434 {% if getter.is_custom_property_query %}
435 {{v8_class}}::namedPropertyQueryCustom(propertyName, info); 435 {{v8_class}}::namedPropertyQueryCustom(propertyName, info);
436 {% else %} 436 {% else %}
437 {{cpp_class}}V8Internal::namedPropertyQuery(propertyName, info); 437 {{cpp_class}}V8Internal::namedPropertyQuery(propertyName, info);
438 {% endif %} 438 {% endif %}
439 } 439 }
440 440
441 {% endif %} 441 {% endif %}
442 {% endblock %} 442 {% endblock %}
443 443
444 444
445 {##############################################################################} 445 {##############################################################################}
446 {% block named_property_enumerator %} 446 {% block named_property_enumerator %}
447 {% if named_property_getter and named_property_getter.is_enumerable and 447 {% if named_property_getter and named_property_getter.is_enumerable and
448 not named_property_getter.is_custom_property_enumerator %} 448 not named_property_getter.is_custom_property_enumerator %}
449 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) { 449 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) {
450 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::EnumerationCo ntext, "{{interface_name}}"); 450 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kEnumerationC ontext, "{{interface_name}}");
451 451
452 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 452 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
453 453
454 Vector<String> names; 454 Vector<String> names;
455 impl->namedPropertyEnumerator(names, exceptionState); 455 impl->NamedPropertyEnumerator(names, exceptionState);
456 if (exceptionState.hadException()) 456 if (exceptionState.HadException())
457 return; 457 return;
458 v8SetReturnValue(info, ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Ar ray>()); 458 V8SetReturnValue(info, ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Ar ray>());
459 } 459 }
460 460
461 {% endif %} 461 {% endif %}
462 {% endblock %} 462 {% endblock %}
463 463
464 464
465 {##############################################################################} 465 {##############################################################################}
466 {% block named_property_enumerator_callback %} 466 {% block named_property_enumerator_callback %}
467 {% if named_property_getter and named_property_getter.is_enumerable %} 467 {% if named_property_getter and named_property_getter.is_enumerable %}
468 {% set getter = named_property_getter %} 468 {% set getter = named_property_getter %}
(...skipping 16 matching lines...) Expand all
485 {% block origin_safe_method_setter %} 485 {% block origin_safe_method_setter %}
486 {% if has_origin_safe_method_setter %} 486 {% if has_origin_safe_method_setter %}
487 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { 487 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) {
488 if (!name->IsString()) 488 if (!name->IsString())
489 return; 489 return;
490 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info .Holder(), info.GetIsolate()); 490 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info .Holder(), info.GetIsolate());
491 if (holder.IsEmpty()) 491 if (holder.IsEmpty())
492 return; 492 return;
493 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 493 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
494 v8::String::Utf8Value methodName(name); 494 v8::String::Utf8Value methodName(name);
495 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", *methodName); 495 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kSetterContex t, "{{interface_name}}", *methodName);
496 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { 496 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(info.GetIsolate()), impl, exceptionState)) {
497 return; 497 return;
498 } 498 }
499 499
500 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand le if info.Holder() is an Object. #} 500 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand le if info.Holder() is an Object. #}
501 {% raw %} 501 {% raw %}
502 // |methodName| must be same with {{method.name}} in 502 // |methodName| must be same with {{method.name}} in
503 // {{method.name}}OriginSafeMethodGetter{{world_suffix}} defined in 503 // {{method.name}}OriginSafeMethodGetter{{world_suffix}} defined in
504 // methods.cpp.tmpl 504 // methods.cpp.tmpl
505 {% endraw %} 505 {% endraw %}
506 V8PrivateProperty::getSymbol(info.GetIsolate(), *methodName) 506 V8PrivateProperty::GetSymbol(info.GetIsolate(), *methodName)
507 .set(v8::Local<v8::Object>::Cast(info.Holder()), v8Value); 507 .Set(v8::Local<v8::Object>::Cast(info.Holder()), v8Value);
508 } 508 }
509 {% endif %} 509 {% endif %}
510 {% endblock %} 510 {% endblock %}
511 511
512 {% block origin_safe_method_setter_callback %} 512 {% block origin_safe_method_setter_callback %}
513 {% if has_origin_safe_method_setter %} 513 {% if has_origin_safe_method_setter %}
514 void {{v8_class_or_partial}}::{{cpp_class}}OriginSafeMethodSetterCallback(v8::Lo cal<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo <void>& info) { 514 void {{v8_class_or_partial}}::{{cpp_class}}OriginSafeMethodSetterCallback(v8::Lo cal<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo <void>& info) {
515 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in fo); 515 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in fo);
516 } 516 }
517 {% endif %} 517 {% endif %}
518 {% endblock %} 518 {% endblock %}
519 519
520 520
521 {##############################################################################} 521 {##############################################################################}
522 {% block named_constructor %} 522 {% block named_constructor %}
523 {% from 'methods.cpp.tmpl' import generate_constructor with context %} 523 {% from 'methods.cpp.tmpl' import generate_constructor with context %}
524 {% if named_constructor %} 524 {% if named_constructor %}
525 {% set active_scriptwrappable_inheritance = 525 {% set active_scriptwrappable_inheritance =
526 'InheritFromActiveScriptWrappable' 526 'kInheritFromActiveScriptWrappable'
527 if active_scriptwrappable else 527 if active_scriptwrappable else
528 'NotInheritFromActiveScriptWrappable' %} 528 'kNotInheritFromActiveScriptWrappable' %}
529 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial 529 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
530 // and does not depend on another global objects. 530 // and does not depend on another global objects.
531 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 531 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
532 #pragma clang diagnostic push 532 #pragma clang diagnostic push
533 #pragma clang diagnostic ignored "-Wglobal-constructors" 533 #pragma clang diagnostic ignored "-Wglobal-constructors"
534 #endif 534 #endif
535 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::trace, {{v8_class}}: :traceWrappers, {{prepare_prototype_and_interface_object_func or 'nullptr'}}, "{ {interface_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeI nfo::{{wrapper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inheritance }}, WrapperTypeInfo::{{lifetime}} }; 535 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::Trace, {{v8_class}}: :TraceWrappers, {{prepare_prototype_and_interface_object_func or 'nullptr'}}, "{ {interface_name}}", 0, WrapperTypeInfo::kWrapperTypeObjectPrototype, WrapperType Info::{{wrapper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inheritanc e}}, WrapperTypeInfo::{{lifetime}} };
536 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 536 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
537 #pragma clang diagnostic pop 537 #pragma clang diagnostic pop
538 #endif 538 #endif
539 539
540 {{generate_constructor(named_constructor)}} 540 {{generate_constructor(named_constructor)}}
541 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate * isolate, const DOMWrapperWorld& world) { 541 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate * isolate, const DOMWrapperWorld& world) {
542 static int domTemplateKey; // This address is used for a key to look up the do m template. 542 static int domTemplateKey; // This address is used for a key to look up the do m template.
543 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 543 V8PerIsolateData* data = V8PerIsolateData::From(isolate);
544 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d omTemplateKey); 544 v8::Local<v8::FunctionTemplate> result = data->FindInterfaceTemplate(world, &d omTemplateKey);
545 if (!result.IsEmpty()) 545 if (!result.IsEmpty())
546 return result; 546 return result;
547 547
548 result = v8::FunctionTemplate::New(isolate, {{v8_class}}ConstructorCallback); 548 result = v8::FunctionTemplate::New(isolate, {{v8_class}}ConstructorCallback);
549 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); 549 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
550 instanceTemplate->SetInternalFieldCount({{v8_class}}::internalFieldCount); 550 instanceTemplate->SetInternalFieldCount({{v8_class}}::internalFieldCount);
551 result->SetClassName(v8AtomicString(isolate, "{{named_constructor.name}}")); 551 result->SetClassName(V8AtomicString(isolate, "{{named_constructor.name}}"));
552 result->Inherit({{v8_class}}::domTemplate(isolate, world)); 552 result->Inherit({{v8_class}}::domTemplate(isolate, world));
553 data->setInterfaceTemplate(world, &domTemplateKey, result); 553 data->SetInterfaceTemplate(world, &domTemplateKey, result);
554 return result; 554 return result;
555 } 555 }
556 556
557 void {{v8_class}}Constructor::NamedConstructorAttributeGetter( 557 void {{v8_class}}Constructor::NamedConstructorAttributeGetter(
558 v8::Local<v8::Name> propertyName, 558 v8::Local<v8::Name> propertyName,
559 const v8::PropertyCallbackInfo<v8::Value>& info) { 559 const v8::PropertyCallbackInfo<v8::Value>& info) {
560 v8::Local<v8::Context> creationContext = info.Holder()->CreationContext(); 560 v8::Local<v8::Context> creationContext = info.Holder()->CreationContext();
561 V8PerContextData* perContextData = V8PerContextData::from(creationContext); 561 V8PerContextData* perContextData = V8PerContextData::From(creationContext);
562 if (!perContextData) { 562 if (!perContextData) {
563 // TODO(yukishiino): Return a valid named constructor even after the context is detached 563 // TODO(yukishiino): Return a valid named constructor even after the context is detached
564 return; 564 return;
565 } 565 }
566 566
567 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType( &{{v8_class}}Constructor::wrapperTypeInfo); 567 v8::Local<v8::Function> namedConstructor = perContextData->ConstructorForType( &{{v8_class}}Constructor::wrapperTypeInfo);
568 568
569 // Set the prototype of named constructors to the regular constructor. 569 // Set the prototype of named constructors to the regular constructor.
570 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info. GetIsolate()); 570 auto privateProperty = V8PrivateProperty::GetNamedConstructorInitialized(info. GetIsolate());
571 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext() ; 571 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext() ;
572 v8::Local<v8::Value> privateValue = privateProperty.getOrEmpty(namedConstructo r); 572 v8::Local<v8::Value> privateValue = privateProperty.GetOrEmpty(namedConstructo r);
573 573
574 if (privateValue.IsEmpty()) { 574 if (privateValue.IsEmpty()) {
575 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo); 575 v8::Local<v8::Function> interface = perContextData->ConstructorForType(&{{v8 _class}}::wrapperTypeInfo);
576 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, v8A tomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); 576 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, V8A tomicString(info.GetIsolate(), "prototype")).ToLocalChecked();
577 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI solate(), "prototype"), interfacePrototype).ToChecked(); 577 bool result = namedConstructor->Set(currentContext, V8AtomicString(info.GetI solate(), "prototype"), interfacePrototype).ToChecked();
578 if (!result) 578 if (!result)
579 return; 579 return;
580 privateProperty.set(namedConstructor, v8::True(info.GetIsolate())); 580 privateProperty.Set(namedConstructor, v8::True(info.GetIsolate()));
581 } 581 }
582 582
583 v8SetReturnValue(info, namedConstructor); 583 V8SetReturnValue(info, namedConstructor);
584 } 584 }
585 585
586 {% endif %} 586 {% endif %}
587 {% endblock %} 587 {% endblock %}
588 588
589 {##############################################################################} 589 {##############################################################################}
590 {% block overloaded_constructor %} 590 {% block overloaded_constructor %}
591 {% if constructor_overloads %} 591 {% if constructor_overloads %}
592 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { 592 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
593 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionC ontext, "{{interface_name}}"); 593 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kConstruction Context, "{{interface_name}}");
594 {# 2. Initialize argcount to be min(maxarg, n). #} 594 {# 2. Initialize argcount to be min(maxarg, n). #}
595 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { 595 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) {
596 {# 3. Remove from S all entries whose type list is not of length argcount. # } 596 {# 3. Remove from S all entries whose type list is not of length argcount. # }
597 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %} 597 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %}
598 case {{length}}: 598 case {{length}}:
599 {# Then resolve by testing argument #} 599 {# Then resolve by testing argument #}
600 {% for test, constructor in tests_constructors %} 600 {% for test, constructor in tests_constructors %}
601 {# 10. If i = d, then: #} 601 {# 10. If i = d, then: #}
602 if ({{test}}) { 602 if ({{test}}) {
603 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(info) ; 603 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(info) ;
604 return; 604 return;
605 } 605 }
606 {% endfor %} 606 {% endfor %}
607 break; 607 break;
608 {% endfor %} 608 {% endfor %}
609 default: 609 default:
610 {# Invalid arity, throw error #} 610 {# Invalid arity, throw error #}
611 {# Report full list of valid arities if gaps and above minimum #} 611 {# Report full list of valid arities if gaps and above minimum #}
612 {% if constructor_overloads.valid_arities %} 612 {% if constructor_overloads.valid_arities %}
613 if (info.Length() >= {{constructor_overloads.length}}) { 613 if (info.Length() >= {{constructor_overloads.length}}) {
614 exceptionState.throwTypeError(ExceptionMessages::invalidArity("{{constru ctor_overloads.valid_arities}}", info.Length())); 614 exceptionState.ThrowTypeError(ExceptionMessages::InvalidArity("{{constru ctor_overloads.valid_arities}}", info.Length()));
615 return; 615 return;
616 } 616 }
617 {% endif %} 617 {% endif %}
618 {# Otherwise just report "not enough arguments" #} 618 {# Otherwise just report "not enough arguments" #}
619 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{cons tructor_overloads.length}}, info.Length())); 619 exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments({{cons tructor_overloads.length}}, info.Length()));
620 return; 620 return;
621 } 621 }
622 {# No match, throw error #} 622 {# No match, throw error #}
623 exceptionState.throwTypeError("No matching constructor signature."); 623 exceptionState.ThrowTypeError("No matching constructor signature.");
624 } 624 }
625 625
626 {% endif %} 626 {% endif %}
627 {% endblock %} 627 {% endblock %}
628 628
629 629
630 {##############################################################################} 630 {##############################################################################}
631 {% block constructor_callback %} 631 {% block constructor_callback %}
632 {% if constructors or has_custom_constructor or has_event_constructor or has_htm l_constructor %} 632 {% if constructors or has_custom_constructor or has_event_constructor or has_htm l_constructor %}
633 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) { 633 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) {
634 {% if measure_as %} 634 {% if measure_as %}
635 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{me asure_as('Constructor')}}); 635 UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), UseCounter::k{{m easure_as('Constructor')}});
636 {% endif %} 636 {% endif %}
637 if (!info.IsConstructCall()) { 637 if (!info.IsConstructCall()) {
638 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("{{interface_name}}")); 638 V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::Const ructorNotCallableAsFunction("{{interface_name}}"));
639 return; 639 return;
640 } 640 }
641 641
642 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExisti ngObject) { 642 if (ConstructorMode::Current(info.GetIsolate()) == ConstructorMode::kWrapExist ingObject) {
643 v8SetReturnValue(info, info.Holder()); 643 V8SetReturnValue(info, info.Holder());
644 return; 644 return;
645 } 645 }
646 646
647 {% if has_custom_constructor %} 647 {% if has_custom_constructor %}
648 {{v8_class}}::constructorCustom(info); 648 {{v8_class}}::constructorCustom(info);
649 {% elif has_html_constructor %} 649 {% elif has_html_constructor %}
650 V8HTMLConstructor::htmlConstructor(info, {{v8_class}}::wrapperTypeInfo, HTMLEl ementType::k{{interface_name}}); 650 V8HTMLConstructor::HtmlConstructor(info, {{v8_class}}::wrapperTypeInfo, HTMLEl ementType::k{{interface_name}});
651 {% else %} 651 {% else %}
652 {{cpp_class}}V8Internal::constructor(info); 652 {{cpp_class}}V8Internal::constructor(info);
653 {% endif %} 653 {% endif %}
654 } 654 }
655 655
656 {% endif %} 656 {% endif %}
657 {% endblock %} 657 {% endblock %}
658 658
659 659
660 {##############################################################################} 660 {##############################################################################}
661 {% macro install_origin_safe_method(method, instance_template, prototype_templat e) %} 661 {% macro install_origin_safe_method(method, instance_template, prototype_templat e) %}
662 {% from 'utilities.cpp.tmpl' import property_location %} 662 {% from 'utilities.cpp.tmpl' import property_location %}
663 {# TODO(dcheng): Currently, bindings must create a function object for each 663 {# TODO(dcheng): Currently, bindings must create a function object for each
664 realm as a hack to support the incumbent realm. Clean this up when Blink 664 realm as a hack to support the incumbent realm. Clean this up when Blink
665 properly supports the incumbent realm. #} 665 properly supports the incumbent realm. #}
666 {% set getter_callback = 666 {% set getter_callback =
667 '%s::%sOriginSafeMethodGetterCallback' % 667 '%s::%sOriginSafeMethodGetterCallback' %
668 (v8_class_or_partial, method.name) %} 668 (v8_class_or_partial, method.name) %}
669 {% set setter_callback = 669 {% set setter_callback =
670 '%s::%sOriginSafeMethodSetterCallback' % (v8_class_or_partial, cpp_class) 670 '%s::%sOriginSafeMethodSetterCallback' % (v8_class_or_partial, cpp_class)
671 if not method.is_unforgeable else 'nullptr' %} 671 if not method.is_unforgeable else 'nullptr' %}
672 {% set property_attribute = 672 {% set property_attribute =
673 'static_cast<v8::PropertyAttribute>(%s)' % 673 'static_cast<v8::PropertyAttribute>(%s)' %
674 ' | '.join(method.property_attributes or ['v8::None']) %} 674 ' | '.join(method.property_attributes or ['v8::None']) %}
675 {% set holder_check = 'V8DOMConfiguration::CheckHolder' %} 675 {% set holder_check = 'V8DOMConfiguration::kCheckHolder' %}
676 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration[] = { 676 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration[] = {
677 {% if method.is_per_world_bindings %} 677 {% if method.is_per_world_bindings %}
678 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} 678 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %}
679 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback 679 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback
680 if not method.is_unforgeable else 'nullptr' %} 680 if not method.is_unforgeable else 'nullptr' %}
681 {"{{method.name}}", {{getter_callback_for_main_world}}, {{setter_callback_fo r_main_world}}, nullptr, &{{v8_class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holder_check}}, V8DOMConfiguration::MainWorld} , 681 {"{{method.name}}", {{getter_callback_for_main_world}}, {{setter_callback_fo r_main_world}}, nullptr, &{{v8_class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holder_check}}, V8DOMConfiguration::MainWorld} ,
682 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::NonMainWorlds}} 682 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::NonMainWorlds}}
683 {% else %} 683 {% else %}
684 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::AllWorlds} 684 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::kAllWorlds}
685 {% endif %} 685 {% endif %}
686 }; 686 };
687 for (const auto& attributeConfig : {{method.name}}OriginSafeAttributeConfigurati on) 687 for (const auto& attributeConfig : {{method.name}}OriginSafeAttributeConfigurati on)
688 V8DOMConfiguration::installAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig); 688 V8DOMConfiguration::InstallAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig);
689 {%- endmacro %} 689 {%- endmacro %}
690 690
691 691
692 {##############################################################################} 692 {##############################################################################}
693 {% macro install_indexed_property_handler(target) %} 693 {% macro install_indexed_property_handler(target) %}
694 {% set indexed_property_getter_callback = 694 {% set indexed_property_getter_callback =
695 '%s::indexedPropertyGetterCallback' % v8_class_or_partial %} 695 '%s::indexedPropertyGetterCallback' % v8_class_or_partial %}
696 {% set indexed_property_setter_callback = 696 {% set indexed_property_setter_callback =
697 '%s::indexedPropertySetterCallback' % v8_class_or_partial 697 '%s::indexedPropertySetterCallback' % v8_class_or_partial
698 if indexed_property_setter or named_property_setter else 'nullptr' %} 698 if indexed_property_setter or named_property_setter else 'nullptr' %}
699 {% set indexed_property_query_callback = 'nullptr' %}{# Unused #} 699 {% set indexed_property_query_callback = 'nullptr' %}{# Unused #}
700 {% set indexed_property_deleter_callback = 700 {% set indexed_property_deleter_callback =
701 '%s::indexedPropertyDeleterCallback' % v8_class_or_partial 701 '%s::indexedPropertyDeleterCallback' % v8_class_or_partial
702 if indexed_property_deleter or named_property_deleter else 'nullptr' %} 702 if indexed_property_deleter or named_property_deleter else 'nullptr' %}
703 {% set indexed_property_enumerator_callback = 703 {% set indexed_property_enumerator_callback =
704 'indexedPropertyEnumerator<%s>' % cpp_class 704 'IndexedPropertyEnumerator<%s>' % cpp_class
705 if indexed_property_getter.is_enumerable else 'nullptr' %} 705 if indexed_property_getter.is_enumerable else 'nullptr' %}
706 {% set property_handler_flags = 706 {% set property_handler_flags =
707 'v8::PropertyHandlerFlags::kNone' %} 707 'v8::PropertyHandlerFlags::kNone' %}
708 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig({{indexed_p roperty_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_prope rty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_property_ enumerator_callback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); 708 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig({{indexed_p roperty_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_prope rty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_property_ enumerator_callback}}, v8::Local<v8::Value>(), {{property_handler_flags}});
709 {{target}}->SetHandler(indexedPropertyHandlerConfig); 709 {{target}}->SetHandler(indexedPropertyHandlerConfig);
710 {%- endmacro %} 710 {%- endmacro %}
711 711
712 712
713 {##############################################################################} 713 {##############################################################################}
714 {% macro install_named_property_handler(target) %} 714 {% macro install_named_property_handler(target) %}
(...skipping 23 matching lines...) Expand all
738 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_ callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal lback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); 738 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_ callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal lback}}, v8::Local<v8::Value>(), {{property_handler_flags}});
739 {{target}}->SetHandler(namedPropertyHandlerConfig); 739 {{target}}->SetHandler(namedPropertyHandlerConfig);
740 {%- endmacro %} 740 {%- endmacro %}
741 741
742 742
743 {##############################################################################} 743 {##############################################################################}
744 {% block get_dom_template %} 744 {% block get_dom_template %}
745 {% if not is_array_buffer_or_view %} 745 {% if not is_array_buffer_or_view %}
746 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world) { 746 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world) {
747 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8_class) if has_partial_interface else 'install%sTemplate' % v8_class %} 747 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8_class) if has_partial_interface else 'install%sTemplate' % v8_class %}
748 return V8DOMConfiguration::domClassTemplate(isolate, world, const_cast<Wrapper TypeInfo*>(&wrapperTypeInfo), {{installTemplateFunction}}); 748 return V8DOMConfiguration::DomClassTemplate(isolate, world, const_cast<Wrapper TypeInfo*>(&wrapperTypeInfo), {{installTemplateFunction}});
749 } 749 }
750 750
751 {% endif %} 751 {% endif %}
752 {% endblock %} 752 {% endblock %}
753 753
754 754
755 {##############################################################################} 755 {##############################################################################}
756 {% block get_dom_template_for_named_properties_object %} 756 {% block get_dom_template_for_named_properties_object %}
757 {% if has_named_properties_object %} 757 {% if has_named_properties_object %}
758 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplateForNamedPropertiesObjec t(v8::Isolate* isolate, const DOMWrapperWorld& world) { 758 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplateForNamedPropertiesObjec t(v8::Isolate* isolate, const DOMWrapperWorld& world) {
759 v8::Local<v8::FunctionTemplate> parentTemplate = V8{{parent_interface}}::domTe mplate(isolate, world); 759 v8::Local<v8::FunctionTemplate> parentTemplate = V8{{parent_interface}}::domTe mplate(isolate, world);
760 760
761 v8::Local<v8::FunctionTemplate> namedPropertiesObjectFunctionTemplate = v8::Fu nctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode); 761 v8::Local<v8::FunctionTemplate> namedPropertiesObjectFunctionTemplate = v8::Fu nctionTemplate::New(isolate, V8ObjectConstructor::IsValidConstructorMode);
762 namedPropertiesObjectFunctionTemplate->SetClassName(v8AtomicString(isolate, "{ {interface_name}}Properties")); 762 namedPropertiesObjectFunctionTemplate->SetClassName(V8AtomicString(isolate, "{ {interface_name}}Properties"));
763 namedPropertiesObjectFunctionTemplate->Inherit(parentTemplate); 763 namedPropertiesObjectFunctionTemplate->Inherit(parentTemplate);
764 764
765 v8::Local<v8::ObjectTemplate> namedPropertiesObjectTemplate = namedPropertiesO bjectFunctionTemplate->PrototypeTemplate(); 765 v8::Local<v8::ObjectTemplate> namedPropertiesObjectTemplate = namedPropertiesO bjectFunctionTemplate->PrototypeTemplate();
766 namedPropertiesObjectTemplate->SetInternalFieldCount({{v8_class}}::internalFie ldCount); 766 namedPropertiesObjectTemplate->SetInternalFieldCount({{v8_class}}::internalFie ldCount);
767 // Named Properties object has SetPrototype method of Immutable Prototype Exot ic Objects 767 // Named Properties object has SetPrototype method of Immutable Prototype Exot ic Objects
768 namedPropertiesObjectTemplate->SetImmutableProto(); 768 namedPropertiesObjectTemplate->SetImmutableProto();
769 V8DOMConfiguration::setClassString(isolate, namedPropertiesObjectTemplate, "{{ interface_name}}Properties"); 769 V8DOMConfiguration::SetClassString(isolate, namedPropertiesObjectTemplate, "{{ interface_name}}Properties");
770 {{install_named_property_handler('namedPropertiesObjectTemplate') | indent(2)} } 770 {{install_named_property_handler('namedPropertiesObjectTemplate') | indent(2)} }
771 771
772 return namedPropertiesObjectFunctionTemplate; 772 return namedPropertiesObjectFunctionTemplate;
773 } 773 }
774 774
775 {% endif %} 775 {% endif %}
776 {% endblock %} 776 {% endblock %}
777 777
778 778
779 {##############################################################################} 779 {##############################################################################}
780 {% block has_instance %} 780 {% block has_instance %}
781 {% if not is_array_buffer_or_view %} 781 {% if not is_array_buffer_or_view %}
782 782
783 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat e) { 783 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat e) {
784 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value) ; 784 return V8PerIsolateData::From(isolate)->HasInstance(&wrapperTypeInfo, v8Value) ;
785 } 785 }
786 786
787 v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V alue> v8Value, v8::Isolate* isolate) { 787 v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V alue> v8Value, v8::Isolate* isolate) {
788 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperT ypeInfo, v8Value); 788 return V8PerIsolateData::From(isolate)->FindInstanceInPrototypeChain(&wrapperT ypeInfo, v8Value);
789 } 789 }
790 790
791 {% endif %} 791 {% endif %}
792 {% endblock %} 792 {% endblock %}
793 793
794 794
795 {##############################################################################} 795 {##############################################################################}
796 {% block to_impl %} 796 {% block to_impl %}
797 {% if interface_name == 'ArrayBuffer' or interface_name == 'SharedArrayBuffer' % } 797 {% if interface_name == 'ArrayBuffer' or interface_name == 'SharedArrayBuffer' % }
798 {{cpp_class}}* V8{{interface_name}}::toImpl(v8::Local<v8::Object> object) { 798 {{cpp_class}}* V8{{interface_name}}::toImpl(v8::Local<v8::Object> object) {
799 DCHECK(object->Is{{interface_name}}()); 799 DCHECK(object->Is{{interface_name}}());
800 v8::Local<v8::{{interface_name}}> v8buffer = object.As<v8::{{interface_name}}> (); 800 v8::Local<v8::{{interface_name}}> v8buffer = object.As<v8::{{interface_name}}> ();
801 if (v8buffer->IsExternal()) { 801 if (v8buffer->IsExternal()) {
802 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); 802 const WrapperTypeInfo* wrapperTypeInfo = ToWrapperTypeInfo(object);
803 CHECK(wrapperTypeInfo); 803 CHECK(wrapperTypeInfo);
804 CHECK_EQ(wrapperTypeInfo->ginEmbedder, gin::kEmbedderBlink); 804 CHECK_EQ(wrapperTypeInfo->gin_embedder, gin::kEmbedderBlink);
805 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); 805 return ToScriptWrappable(object)->ToImpl<{{cpp_class}}>();
806 } 806 }
807 807
808 // Transfer the ownership of the allocated memory to an {{interface_name}} wit hout 808 // Transfer the ownership of the allocated memory to an {{interface_name}} wit hout
809 // copying. 809 // copying.
810 v8::{{interface_name}}::Contents v8Contents = v8buffer->Externalize(); 810 v8::{{interface_name}}::Contents v8Contents = v8buffer->Externalize();
811 WTF::ArrayBufferContents::DataHandle data(v8Contents.Data(), WTF::ArrayBufferC ontents::freeMemory); 811 WTF::ArrayBufferContents::DataHandle data(v8Contents.Data(), WTF::ArrayBufferC ontents::FreeMemory);
812 WTF::ArrayBufferContents contents(std::move(data), v8Contents.ByteLength(), WT F::ArrayBufferContents::{% if interface_name == 'ArrayBuffer' %}Not{% endif %}Sh ared); 812 WTF::ArrayBufferContents contents(std::move(data), v8Contents.ByteLength(), WT F::ArrayBufferContents::k{% if interface_name == 'ArrayBuffer' %}Not{% endif %}S hared);
813 {{cpp_class}}* buffer = {{cpp_class}}::create(contents); 813 {{cpp_class}}* buffer = {{cpp_class}}::Create(contents);
814 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::Iso late::GetCurrent(), buffer->wrapperTypeInfo(), object); 814 v8::Local<v8::Object> associatedWrapper = buffer->AssociateWithWrapper(v8::Iso late::GetCurrent(), buffer->GetWrapperTypeInfo(), object);
815 DCHECK(associatedWrapper == object); 815 DCHECK(associatedWrapper == object);
816 816
817 return buffer; 817 return buffer;
818 } 818 }
819 819
820 {% elif interface_name == 'ArrayBufferView' %} 820 {% elif interface_name == 'ArrayBufferView' %}
821 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) { 821 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) {
822 DCHECK(object->IsArrayBufferView()); 822 DCHECK(object->IsArrayBufferView());
823 ScriptWrappable* scriptWrappable = toScriptWrappable(object); 823 ScriptWrappable* scriptWrappable = ToScriptWrappable(object);
824 if (scriptWrappable) 824 if (scriptWrappable)
825 return scriptWrappable->toImpl<{{cpp_class}}>(); 825 return scriptWrappable->ToImpl<{{cpp_class}}>();
826 826
827 if (object->IsInt8Array()) 827 if (object->IsInt8Array())
828 return V8Int8Array::toImpl(object); 828 return V8Int8Array::toImpl(object);
829 if (object->IsInt16Array()) 829 if (object->IsInt16Array())
830 return V8Int16Array::toImpl(object); 830 return V8Int16Array::toImpl(object);
831 if (object->IsInt32Array()) 831 if (object->IsInt32Array())
832 return V8Int32Array::toImpl(object); 832 return V8Int32Array::toImpl(object);
833 if (object->IsUint8Array()) 833 if (object->IsUint8Array())
834 return V8Uint8Array::toImpl(object); 834 return V8Uint8Array::toImpl(object);
835 if (object->IsUint8ClampedArray()) 835 if (object->IsUint8ClampedArray())
836 return V8Uint8ClampedArray::toImpl(object); 836 return V8Uint8ClampedArray::toImpl(object);
837 if (object->IsUint16Array()) 837 if (object->IsUint16Array())
838 return V8Uint16Array::toImpl(object); 838 return V8Uint16Array::toImpl(object);
839 if (object->IsUint32Array()) 839 if (object->IsUint32Array())
840 return V8Uint32Array::toImpl(object); 840 return V8Uint32Array::toImpl(object);
841 if (object->IsFloat32Array()) 841 if (object->IsFloat32Array())
842 return V8Float32Array::toImpl(object); 842 return V8Float32Array::toImpl(object);
843 if (object->IsFloat64Array()) 843 if (object->IsFloat64Array())
844 return V8Float64Array::toImpl(object); 844 return V8Float64Array::toImpl(object);
845 if (object->IsDataView()) 845 if (object->IsDataView())
846 return V8DataView::toImpl(object); 846 return V8DataView::toImpl(object);
847 847
848 NOTREACHED(); 848 NOTREACHED();
849 return 0; 849 return 0;
850 } 850 }
851 851
852 {% elif is_array_buffer_or_view %} 852 {% elif is_array_buffer_or_view %}
853 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) { 853 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) {
854 DCHECK(object->Is{{interface_name}}()); 854 DCHECK(object->Is{{interface_name}}());
855 ScriptWrappable* scriptWrappable = toScriptWrappable(object); 855 ScriptWrappable* scriptWrappable = ToScriptWrappable(object);
856 if (scriptWrappable) 856 if (scriptWrappable)
857 return scriptWrappable->toImpl<{{cpp_class}}>(); 857 return scriptWrappable->ToImpl<{{cpp_class}}>();
858 858
859 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>() ; 859 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>() ;
860 v8::Local<v8::Object> arrayBuffer = v8View->Buffer(); 860 v8::Local<v8::Object> arrayBuffer = v8View->Buffer();
861 {{cpp_class}}* typedArray = nullptr; 861 {{cpp_class}}* typedArray = nullptr;
862 if (arrayBuffer->IsArrayBuffer()) { 862 if (arrayBuffer->IsArrayBuffer()) {
863 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v8Vie w->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %}Len gth()); 863 typedArray = {{cpp_class}}::Create(V8ArrayBuffer::toImpl(arrayBuffer), v8Vie w->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %}Len gth());
864 } else if (arrayBuffer->IsSharedArrayBuffer()) { 864 } else if (arrayBuffer->IsSharedArrayBuffer()) {
865 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuffer), v8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %}Length()); 865 typedArray = {{cpp_class}}::Create(V8SharedArrayBuffer::toImpl(arrayBuffer), v8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %}Length());
866 } else { 866 } else {
867 NOTREACHED(); 867 NOTREACHED();
868 } 868 }
869 v8::Local<v8::Object> associatedWrapper = typedArray->associateWithWrapper(v8: :Isolate::GetCurrent(), typedArray->wrapperTypeInfo(), object); 869 v8::Local<v8::Object> associatedWrapper = typedArray->AssociateWithWrapper(v8: :Isolate::GetCurrent(), typedArray->GetWrapperTypeInfo(), object);
870 DCHECK(associatedWrapper == object); 870 DCHECK(associatedWrapper == object);
871 871
872 return typedArray->toImpl<{{cpp_class}}>(); 872 return typedArray->ToImpl<{{cpp_class}}>();
873 } 873 }
874 874
875 {% endif %} 875 {% endif %}
876 {% endblock %} 876 {% endblock %}
877 877
878 878
879 {##############################################################################} 879 {##############################################################################}
880 {% block to_impl_with_type_check %} 880 {% block to_impl_with_type_check %}
881 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local <v8::Value> value) { 881 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local <v8::Value> value) {
882 {% if is_array_buffer_or_view %} 882 {% if is_array_buffer_or_view %}
883 return value->Is{{interface_name}}() ? toImpl(v8::Local<v8::Object>::Cast(valu e)) : nullptr; 883 return value->Is{{interface_name}}() ? toImpl(v8::Local<v8::Object>::Cast(valu e)) : nullptr;
884 {% else %} 884 {% else %}
885 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr; 885 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr;
886 {% endif %} 886 {% endif %}
887 } 887 }
888 888
889 {% endblock %} 889 {% endblock %}
890 890
891 891
892 {##############################################################################} 892 {##############################################################################}
893 {% block native_value_traits %} 893 {% block native_value_traits %}
894 {{cpp_class}}* NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolat e, v8::Local<v8::Value> value, ExceptionState& exceptionState) { 894 {{cpp_class}}* NativeValueTraits<{{cpp_class}}>::NativeValue(v8::Isolate* isolat e, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
895 {{cpp_class}}* nativeValue = {{v8_class}}::toImplWithTypeCheck(isolate, value) ; 895 {{cpp_class}}* nativeValue = {{v8_class}}::toImplWithTypeCheck(isolate, value) ;
896 if (!nativeValue) 896 if (!nativeValue)
897 exceptionState.throwTypeError("Unable to convert value to {{interface_name}} ."); 897 exceptionState.ThrowTypeError("Unable to convert value to {{interface_name}} .");
898 return nativeValue; 898 return nativeValue;
899 } 899 }
900 900
901 {% endblock %} 901 {% endblock %}
902 902
903 903
904 {##############################################################################} 904 {##############################################################################}
905 {% block partial_interface %} 905 {% block partial_interface %}
906 {% if has_partial_interface %} 906 {% if has_partial_interface %}
907 {% if needs_runtime_enabled_installer %} 907 {% if needs_runtime_enabled_installer %}
(...skipping 11 matching lines...) Expand all
919 ALLOW_UNUSED_LOCAL(installRuntimeEnabledFunction); 919 ALLOW_UNUSED_LOCAL(installRuntimeEnabledFunction);
920 920
921 {{v8_class}}::install{{v8_class}}TemplateFunction = 921 {{v8_class}}::install{{v8_class}}TemplateFunction =
922 installTemplateFunction; 922 installTemplateFunction;
923 {% if needs_runtime_enabled_installer %} 923 {% if needs_runtime_enabled_installer %}
924 CHECK(installRuntimeEnabledFunction); 924 CHECK(installRuntimeEnabledFunction);
925 {{v8_class}}::install{{v8_class}}RuntimeEnabledFunction = 925 {{v8_class}}::install{{v8_class}}RuntimeEnabledFunction =
926 installRuntimeEnabledFunction; 926 installRuntimeEnabledFunction;
927 {% endif %} 927 {% endif %}
928 if (preparePrototypeAndInterfaceObjectFunction) { 928 if (preparePrototypeAndInterfaceObjectFunction) {
929 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = 929 {{v8_class}}::wrapperTypeInfo.prepare_prototype_and_interface_object_functio n =
930 preparePrototypeAndInterfaceObjectFunction; 930 preparePrototypeAndInterfaceObjectFunction;
931 } 931 }
932 } 932 }
933 933
934 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 934 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
935 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 935 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
936 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 936 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
937 } 937 }
938 938
939 {% endfor %} 939 {% endfor %}
940 {% endif %} 940 {% endif %}
941 {% endblock %} 941 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698