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

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

Issue 2611823003: ABANDONED CL: Changes to compile and pass tests after Big Blink Rename (excluding functions). (Closed)
Patch Set: Inducing merge conflicts to force human review and changes after rename. Created 3 years, 11 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 {% set has_prepare_prototype_and_interface_object = 3 {% set has_prepare_prototype_and_interface_object =
4 unscopables or has_conditional_attributes_on_prototype or 4 unscopables or has_conditional_attributes_on_prototype or
5 methods | conditionally_exposed(is_partial) %} 5 methods | conditionally_exposed(is_partial) %}
6 {% set prepare_prototype_and_interface_object_func = 6 {% set prepare_prototype_and_interface_object_func =
7 '%s::preparePrototypeAndInterfaceObject' % v8_class 7 '%s::prepare_prototype_and_interface_object' % v8_class
8 if has_prepare_prototype_and_interface_object 8 if has_prepare_prototype_and_interface_object
9 else 'nullptr' %} 9 else 'nullptr' %}
10 10
11 11
12 {##############################################################################} 12 {##############################################################################}
13 {% block indexed_property_getter %} 13 {% block indexed_property_getter %}
14 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 14 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
15 {% set getter = indexed_property_getter %} 15 {% set getter = indexed_property_getter %}
16 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 16 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
17 {% if getter.is_raises_exception %} 17 {% if getter.is_raises_exception %}
18 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}"); 18 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedGette rContext, "{{interface_name}}");
19 {% endif %} 19 {% endif %}
20 20
21 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 21 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
22 22
23 // We assume that all the implementations support length() method, although 23 // We assume that all the implementations support length() method, although
24 // the spec doesn't require that length() must exist. It's okay that 24 // the spec doesn't require that length() must exist. It's okay that
25 // the interface does not have length attribute as long as the 25 // the interface does not have length attribute as long as the
26 // implementation supports length() member function. 26 // implementation supports length() member function.
27 if (index >= impl->length()) 27 if (index >= impl->length())
28 return; // Returns undefined due to out-of-range. 28 return; // Returns undefined due to out-of-range.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 {% endblock %} 74 {% endblock %}
75 75
76 76
77 {##############################################################################} 77 {##############################################################################}
78 {% block indexed_property_setter %} 78 {% block indexed_property_setter %}
79 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} 79 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %}
80 {% if indexed_property_setter and not indexed_property_setter.is_custom %} 80 {% if indexed_property_setter and not indexed_property_setter.is_custom %}
81 {% set setter = indexed_property_setter %} 81 {% set setter = indexed_property_setter %}
82 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { 82 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
83 {% if setter.has_exception_state %} 83 {% if setter.has_exception_state %}
84 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedSetter Context, "{{interface_name}}"); 84 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedSette rContext, "{{interface_name}}");
85 {% endif %} 85 {% endif %}
86 86
87 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 87 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
88 {{v8_value_to_local_cpp_value(setter) | indent(2)}} 88 {{v8_value_to_local_cpp_value(setter) | indent(2)}}
89 {% if setter.has_type_checking_interface %} 89 {% if setter.has_type_checking_interface %}
90 {# Type checking for interface types (if interface not implemented, throw 90 {# Type checking for interface types (if interface not implemented, throw
91 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 91 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
92 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { 92 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
93 exceptionState.throwTypeError("The provided value is not of type '{{setter.i dl_type}}'."); 93 exceptionState.throwTypeError("The provided value is not of type '{{setter.i dl_type}}'.");
94 return; 94 return;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 {% endif %} 151 {% endif %}
152 {% endblock %} 152 {% endblock %}
153 153
154 154
155 {##############################################################################} 155 {##############################################################################}
156 {% block indexed_property_deleter %} 156 {% block indexed_property_deleter %}
157 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} 157 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %}
158 {% set deleter = indexed_property_deleter %} 158 {% set deleter = indexed_property_deleter %}
159 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) { 159 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) {
160 {% if deleter.is_raises_exception %} 160 {% if deleter.is_raises_exception %}
161 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedDeleti onContext, "{{interface_name}}"); 161 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedDelet ionContext, "{{interface_name}}");
162 {% endif %} 162 {% endif %}
163 163
164 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 164 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
165 165
166 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} 166 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %}
167 {% set deleter_arguments = ['index'] %} 167 {% set deleter_arguments = ['index'] %}
168 {% if deleter.is_call_with_script_state %} 168 {% if deleter.is_call_with_script_state %}
169 ScriptState* scriptState = ScriptState::forReceiverObject(info); 169 ScriptState* scriptState = ScriptState::forReceiverObject(info);
170 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} 170 {% set deleter_arguments = ['scriptState'] + deleter_arguments %}
171 {% endif %} 171 {% endif %}
172 {% if deleter.is_raises_exception %} 172 {% if deleter.is_raises_exception %}
173 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} 173 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %}
174 {% endif %} 174 {% endif %}
175 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} }); 175 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} });
176 {% if deleter.is_raises_exception %} 176 {% if deleter.is_raises_exception %}
177 if (exceptionState.hadException()) 177 if (exceptionState.hadException())
178 return; 178 return;
179 {% endif %} 179 {% endif %}
180 if (result == DeleteUnknownProperty) 180 if (result == kDeleteUnknownProperty)
181 return; 181 return;
182 v8SetReturnValue(info, result == DeleteSuccess); 182 v8SetReturnValue(info, result == kDeleteSuccess);
183 } 183 }
184 184
185 {% endif %} 185 {% endif %}
186 {% endblock %} 186 {% endblock %}
187 187
188 188
189 {##############################################################################} 189 {##############################################################################}
190 {% block indexed_property_deleter_callback %} 190 {% block indexed_property_deleter_callback %}
191 {% if indexed_property_deleter or named_property_deleter %} 191 {% if indexed_property_deleter or named_property_deleter %}
192 {% set deleter = indexed_property_deleter or named_property_deleter %} 192 {% set deleter = indexed_property_deleter or named_property_deleter %}
(...skipping 27 matching lines...) Expand all
220 {% endblock %} 220 {% endblock %}
221 221
222 222
223 {##############################################################################} 223 {##############################################################################}
224 {% block named_property_getter %} 224 {% block named_property_getter %}
225 {% if named_property_getter and not named_property_getter.is_custom %} 225 {% if named_property_getter and not named_property_getter.is_custom %}
226 {% set getter = named_property_getter %} 226 {% set getter = named_property_getter %}
227 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall backInfo<v8::Value>& info) { 227 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall backInfo<v8::Value>& info) {
228 {% if getter.is_raises_exception %} 228 {% if getter.is_raises_exception %}
229 const CString& nameInUtf8 = name.utf8(); 229 const CString& nameInUtf8 = name.utf8();
230 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext , "{{interface_name}}", nameInUtf8.data()); 230 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContex t, "{{interface_name}}", nameInUtf8.data());
231 {% endif %} 231 {% endif %}
232 {% if getter.is_call_with_script_state %} 232 {% if getter.is_call_with_script_state %}
233 ScriptState* scriptState = ScriptState::forReceiverObject(info); 233 ScriptState* scriptState = ScriptState::forReceiverObject(info);
234 {% endif %} 234 {% endif %}
235 235
236 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 236 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
237 {% if getter.use_output_parameter_for_result %} 237 {% if getter.use_output_parameter_for_result %}
238 {{getter.cpp_type}} result; 238 {{getter.cpp_type}} result;
239 {{getter.cpp_value}}; 239 {{getter.cpp_value}};
240 {% else %} 240 {% else %}
(...skipping 29 matching lines...) Expand all
270 270
271 271
272 {##############################################################################} 272 {##############################################################################}
273 {% block named_property_setter %} 273 {% block named_property_setter %}
274 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} 274 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %}
275 {% if named_property_setter and not named_property_setter.is_custom %} 275 {% if named_property_setter and not named_property_setter.is_custom %}
276 {% set setter = named_property_setter %} 276 {% set setter = named_property_setter %}
277 static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { 277 static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
278 {% if setter.has_exception_state %} 278 {% if setter.has_exception_state %}
279 const CString& nameInUtf8 = name.utf8(); 279 const CString& nameInUtf8 = name.utf8();
280 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", nameInUtf8.data()); 280 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kSetterContex t, "{{interface_name}}", nameInUtf8.data());
281 {% endif %} 281 {% endif %}
282 {% if setter.is_call_with_script_state %} 282 {% if setter.is_call_with_script_state %}
283 ScriptState* scriptState = ScriptState::forReceiverObject(info); 283 ScriptState* scriptState = ScriptState::forReceiverObject(info);
284 {% endif %} 284 {% endif %}
285 285
286 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 286 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
287 {{v8_value_to_local_cpp_value(setter) | indent(2)}} 287 {{v8_value_to_local_cpp_value(setter) | indent(2)}}
288 {% if setter.has_type_checking_interface %} 288 {% if setter.has_type_checking_interface %}
289 {# Type checking for interface types (if interface not implemented, throw 289 {# Type checking for interface types (if interface not implemented, throw
290 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 290 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 {% endblock %} 340 {% endblock %}
341 341
342 342
343 {##############################################################################} 343 {##############################################################################}
344 {% block named_property_deleter %} 344 {% block named_property_deleter %}
345 {% if named_property_deleter and not named_property_deleter.is_custom %} 345 {% if named_property_deleter and not named_property_deleter.is_custom %}
346 {% set deleter = named_property_deleter %} 346 {% set deleter = named_property_deleter %}
347 static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) { 347 static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) {
348 {% if deleter.is_raises_exception %} 348 {% if deleter.is_raises_exception %}
349 const CString& nameInUtf8 = name.utf8(); 349 const CString& nameInUtf8 = name.utf8();
350 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionConte xt, "{{interface_name}}", nameInUtf8.data()); 350 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kDeletionCont ext, "{{interface_name}}", nameInUtf8.data());
351 {% endif %} 351 {% endif %}
352 {% if deleter.is_call_with_script_state %} 352 {% if deleter.is_call_with_script_state %}
353 ScriptState* scriptState = ScriptState::forReceiverObject(info); 353 ScriptState* scriptState = ScriptState::forReceiverObject(info);
354 {% endif %} 354 {% endif %}
355 355
356 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 356 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
357 357
358 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} 358 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %}
359 {% set deleter_arguments = ['name'] %} 359 {% set deleter_arguments = ['name'] %}
360 {% if deleter.is_call_with_script_state %} 360 {% if deleter.is_call_with_script_state %}
361 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} 361 {% set deleter_arguments = ['scriptState'] + deleter_arguments %}
362 {% endif %} 362 {% endif %}
363 {% if deleter.is_raises_exception %} 363 {% if deleter.is_raises_exception %}
364 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} 364 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %}
365 {% endif %} 365 {% endif %}
366 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} }); 366 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')} });
367 {% if deleter.is_raises_exception %} 367 {% if deleter.is_raises_exception %}
368 if (exceptionState.hadException()) 368 if (exceptionState.hadException())
369 return; 369 return;
370 {% endif %} 370 {% endif %}
371 if (result == DeleteUnknownProperty) 371 if (result == kDeleteUnknownProperty)
372 return; 372 return;
373 v8SetReturnValue(info, result == DeleteSuccess); 373 v8SetReturnValue(info, result == kDeleteSuccess);
374 } 374 }
375 375
376 {% endif %} 376 {% endif %}
377 {% endblock %} 377 {% endblock %}
378 378
379 379
380 {##############################################################################} 380 {##############################################################################}
381 {% block named_property_deleter_callback %} 381 {% block named_property_deleter_callback %}
382 {% if named_property_deleter %} 382 {% if named_property_deleter %}
383 {% set deleter = named_property_deleter %} 383 {% set deleter = named_property_deleter %}
(...skipping 19 matching lines...) Expand all
403 403
404 {##############################################################################} 404 {##############################################################################}
405 {% block named_property_query %} 405 {% block named_property_query %}
406 {% if named_property_getter and named_property_getter.is_enumerable and 406 {% if named_property_getter and named_property_getter.is_enumerable and
407 not named_property_getter.is_custom_property_query %} 407 not named_property_getter.is_custom_property_query %}
408 {% set getter = named_property_getter %} 408 {% set getter = named_property_getter %}
409 {# If there is an enumerator, there MUST be a query method to properly 409 {# If there is an enumerator, there MUST be a query method to properly
410 communicate property attributes. #} 410 communicate property attributes. #}
411 static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb ackInfo<v8::Integer>& info) { 411 static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb ackInfo<v8::Integer>& info) {
412 const CString& nameInUtf8 = name.utf8(); 412 const CString& nameInUtf8 = name.utf8();
413 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext , "{{interface_name}}", nameInUtf8.data()); 413 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContex t, "{{interface_name}}", nameInUtf8.data());
414 {% if getter.is_call_with_script_state %} 414 {% if getter.is_call_with_script_state %}
415 ScriptState* scriptState = ScriptState::forReceiverObject(info); 415 ScriptState* scriptState = ScriptState::forReceiverObject(info);
416 {% endif %} 416 {% endif %}
417 417
418 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 418 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
419 419
420 {% set getter_arguments = ['name', 'exceptionState'] %} 420 {% set getter_arguments = ['name', 'exceptionState'] %}
421 {% if getter.is_call_with_script_state %} 421 {% if getter.is_call_with_script_state %}
422 {% set getter_arguments = ['scriptState'] + getter_arguments %} 422 {% set getter_arguments = ['scriptState'] + getter_arguments %}
423 {% endif %} 423 {% endif %}
(...skipping 25 matching lines...) Expand all
449 449
450 {% endif %} 450 {% endif %}
451 {% endblock %} 451 {% endblock %}
452 452
453 453
454 {##############################################################################} 454 {##############################################################################}
455 {% block named_property_enumerator %} 455 {% block named_property_enumerator %}
456 {% if named_property_getter and named_property_getter.is_enumerable and 456 {% if named_property_getter and named_property_getter.is_enumerable and
457 not named_property_getter.is_custom_property_enumerator %} 457 not named_property_getter.is_custom_property_enumerator %}
458 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) { 458 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) {
459 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::EnumerationCo ntext, "{{interface_name}}"); 459 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kEnumerationC ontext, "{{interface_name}}");
460 460
461 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 461 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
462 462
463 Vector<String> names; 463 Vector<String> names;
464 impl->namedPropertyEnumerator(names, exceptionState); 464 impl->namedPropertyEnumerator(names, exceptionState);
465 if (exceptionState.hadException()) 465 if (exceptionState.hadException())
466 return; 466 return;
467 v8SetReturnValue(info, toV8(names, info.Holder(), info.GetIsolate()).As<v8::Ar ray>()); 467 v8SetReturnValue(info, toV8(names, info.Holder(), info.GetIsolate()).As<v8::Ar ray>());
468 } 468 }
469 469
(...skipping 24 matching lines...) Expand all
494 {% block origin_safe_method_setter %} 494 {% block origin_safe_method_setter %}
495 {% if has_origin_safe_method_setter %} 495 {% if has_origin_safe_method_setter %}
496 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { 496 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) {
497 if (!name->IsString()) 497 if (!name->IsString())
498 return; 498 return;
499 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info .Holder(), info.GetIsolate()); 499 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info .Holder(), info.GetIsolate());
500 if (holder.IsEmpty()) 500 if (holder.IsEmpty())
501 return; 501 return;
502 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 502 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
503 v8::String::Utf8Value attributeName(name); 503 v8::String::Utf8Value attributeName(name);
504 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", *attributeName); 504 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kSetterContex t, "{{interface_name}}", *attributeName);
505 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { 505 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) {
506 return; 506 return;
507 } 507 }
508 508
509 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand le if info.Holder() is an Object. #} 509 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand le if info.Holder() is an Object. #}
510 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::Loc al<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value); 510 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::Loc al<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value);
511 } 511 }
512 512
513 void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name, v8::L ocal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { 513 void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name, v8::L ocal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) {
514 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in fo); 514 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in fo);
515 } 515 }
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, 0, {{prepare_prototype_and_interface_object_func}}, "{{interface _name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::{{wra pper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inheritance}}, Wrappe rTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifetime}} }; 535 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::trace, {{v8_class}}: :traceWrappers, 0, {{prepare_prototype_and_interface_object_func}}, "{{interface _name}}", 0, WrapperTypeInfo::kWrapperTypeObjectPrototype, WrapperTypeInfo::{{wr apper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inheritance}}, Wrapp erTypeInfo::{{event_target_inheritance}}, 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, "{{cpp_class}}")); 551 result->SetClassName(v8AtomicString(isolate, "{{cpp_class}}"));
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 {% endif %} 557 {% endif %}
558 {% endblock %} 558 {% endblock %}
559 559
560 {##############################################################################} 560 {##############################################################################}
561 {% block overloaded_constructor %} 561 {% block overloaded_constructor %}
562 {% if constructor_overloads %} 562 {% if constructor_overloads %}
563 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { 563 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
564 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionC ontext, "{{interface_name}}"); 564 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kConstruction Context, "{{interface_name}}");
565 {# 2. Initialize argcount to be min(maxarg, n). #} 565 {# 2. Initialize argcount to be min(maxarg, n). #}
566 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { 566 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) {
567 {# 3. Remove from S all entries whose type list is not of length argcount. # } 567 {# 3. Remove from S all entries whose type list is not of length argcount. # }
568 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %} 568 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %}
569 case {{length}}: 569 case {{length}}:
570 {# Then resolve by testing argument #} 570 {# Then resolve by testing argument #}
571 {% for test, constructor in tests_constructors %} 571 {% for test, constructor in tests_constructors %}
572 {# 10. If i = d, then: #} 572 {# 10. If i = d, then: #}
573 if ({{test}}) { 573 if ({{test}}) {
574 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(info) ; 574 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(info) ;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 626
627 {% endif %} 627 {% endif %}
628 {% endblock %} 628 {% endblock %}
629 629
630 630
631 {##############################################################################} 631 {##############################################################################}
632 {% block constructor_callback %} 632 {% block constructor_callback %}
633 {% if constructors or has_custom_constructor or has_event_constructor or has_htm l_constructor %} 633 {% if constructors or has_custom_constructor or has_event_constructor or has_htm l_constructor %}
634 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) { 634 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) {
635 {% if measure_as %} 635 {% if measure_as %}
636 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{me asure_as('Constructor')}}); 636 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::k{{m easure_as('Constructor')}});
637 {% endif %} 637 {% endif %}
638 if (!info.IsConstructCall()) { 638 if (!info.IsConstructCall()) {
639 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("{{interface_name}}")); 639 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("{{interface_name}}"));
640 return; 640 return;
641 } 641 }
642 642
643 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExisti ngObject) { 643 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::kWrapExist ingObject) {
644 v8SetReturnValue(info, info.Holder()); 644 v8SetReturnValue(info, info.Holder());
645 return; 645 return;
646 } 646 }
647 647
648 {% if has_custom_constructor %} 648 {% if has_custom_constructor %}
649 {{v8_class}}::constructorCustom(info); 649 {{v8_class}}::constructorCustom(info);
650 {% elif has_html_constructor %} 650 {% elif has_html_constructor %}
651 V8HTMLConstructor::htmlConstructor(info, {{v8_class}}::wrapperTypeInfo, HTMLEl ementType::k{{interface_name}}); 651 V8HTMLConstructor::htmlConstructor(info, {{v8_class}}::wrapperTypeInfo, HTMLEl ementType::k{{interface_name}});
652 {% else %} 652 {% else %}
653 {{cpp_class}}V8Internal::constructor(info); 653 {{cpp_class}}V8Internal::constructor(info);
(...skipping 20 matching lines...) Expand all
674 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} 674 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %}
675 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback 675 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback
676 if not method.is_unforgeable else '0' %} 676 if not method.is_unforgeable else '0' %}
677 {% else %} 677 {% else %}
678 {% set getter_callback_for_main_world = '0' %} 678 {% set getter_callback_for_main_world = '0' %}
679 {% set setter_callback_for_main_world = '0' %} 679 {% set setter_callback_for_main_world = '0' %}
680 {% endif %} 680 {% endif %}
681 {% set property_attribute = 681 {% set property_attribute =
682 'static_cast<v8::PropertyAttribute>(%s)' % 682 'static_cast<v8::PropertyAttribute>(%s)' %
683 ' | '.join(method.property_attributes or ['v8::None']) %} 683 ' | '.join(method.property_attributes or ['v8::None']) %}
684 {% set holder_check = 'V8DOMConfiguration::CheckHolder' %} 684 {% set holder_check = 'V8DOMConfiguration::kCheckHolder' %}
685 const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSafeAttrib uteConfiguration = { 685 const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSafeAttrib uteConfiguration = {
686 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, nullptr, &{{v8_class}}: :wrapperTypeInfo, v8::DEFAULT, {{property_attribute}}, {{property_location(metho d)}}, {{holder_check}} 686 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, nullptr, &{{v8_class}}: :wrapperTypeInfo, v8::DEFAULT, {{property_attribute}}, {{property_location(metho d)}}, {{holder_check}}
687 }; 687 };
688 V8DOMConfiguration::installAttribute(isolate, world, {{instance_template}}, {{pr ototype_template}}, {{method.name}}OriginSafeAttributeConfiguration); 688 V8DOMConfiguration::installAttribute(isolate, world, {{instance_template}}, {{pr ototype_template}}, {{method.name}}OriginSafeAttributeConfiguration);
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 =
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 contents(v8Contents.Data(), v8Contents.ByteLength(), WTF::ArrayBufferContents::{% if interface_name == 'ArrayBuffer' %}Not{% endif %} Shared); 811 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(), WTF::ArrayBufferContents::k{% if interface_name == 'ArrayBuffer' %}Not{% endif % }Shared);
812 {{cpp_class}}* buffer = {{cpp_class}}::create(contents); 812 {{cpp_class}}* buffer = {{cpp_class}}::create(contents);
813 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::Iso late::GetCurrent(), buffer->wrapperTypeInfo(), object); 813 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::Iso late::GetCurrent(), buffer->wrapperTypeInfo(), object);
814 DCHECK(associatedWrapper == object); 814 DCHECK(associatedWrapper == object);
815 815
816 return buffer; 816 return buffer;
817 } 817 }
818 818
819 {% elif interface_name == 'ArrayBufferView' %} 819 {% elif interface_name == 'ArrayBufferView' %}
820 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) { 820 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) {
821 DCHECK(object->IsArrayBufferView()); 821 DCHECK(object->IsArrayBufferView());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 945
946 946
947 {##############################################################################} 947 {##############################################################################}
948 {% block partial_interface %} 948 {% block partial_interface %}
949 {% if has_partial_interface %} 949 {% if has_partial_interface %}
950 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template; 950 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template;
951 951
952 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, PreparePrototypeAndInterfaceObjectFunction preparePrototypeAndInterfac eObjectFunction) { 952 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, PreparePrototypeAndInterfaceObjectFunction preparePrototypeAndInterfac eObjectFunction) {
953 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; 953 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction;
954 if (preparePrototypeAndInterfaceObjectFunction) 954 if (preparePrototypeAndInterfaceObjectFunction)
955 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = p reparePrototypeAndInterfaceObjectFunction; 955 {{v8_class}}::wrapperTypeInfo.prepare_prototype_and_interface_object_functio n = preparePrototypeAndInterfaceObjectFunction;
956 } 956 }
957 957
958 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 958 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
959 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 959 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
960 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 960 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
961 } 961 }
962 962
963 {% endfor %} 963 {% endfor %}
964 {% endif %} 964 {% endif %}
965 {% endblock %} 965 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698