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

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

Issue 2304453004: [Bindings] Expose V8 callback functions in generated code (Closed)
Patch Set: Expose call Callback functions in binding scripts Created 4 years, 3 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' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 {% set has_prepare_prototype_and_interface_object = 3 {% set has_prepare_prototype_and_interface_object =
4 unscopeables or has_conditional_attributes_on_prototype or 4 unscopeables 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::preparePrototypeAndInterfaceObject' % 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
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 {% endif %} 41 {% endif %}
42 {% endblock %} 42 {% endblock %}
43 43
44 44
45 {##############################################################################} 45 {##############################################################################}
46 {% block indexed_property_getter_callback %} 46 {% block indexed_property_getter_callback %}
47 {% if indexed_property_getter %} 47 {% if indexed_property_getter %}
48 {% set getter = indexed_property_getter %} 48 {% set getter = indexed_property_getter %}
49 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info) 49 void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInf o<v8::Value>& info)
50 { 50 {
51 {% if getter.is_custom %} 51 {% if getter.is_custom %}
52 {{v8_class}}::indexedPropertyGetterCustom(index, info); 52 {{v8_class}}::indexedPropertyGetterCustom(index, info);
53 {% else %} 53 {% else %}
54 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); 54 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info);
55 {% endif %} 55 {% endif %}
56 } 56 }
57 57
58 {% endif %} 58 {% endif %}
59 {% endblock %} 59 {% endblock %}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 {% endif %} 101 {% endif %}
102 {% endblock %} 102 {% endblock %}
103 103
104 104
105 {##############################################################################} 105 {##############################################################################}
106 {% block indexed_property_setter_callback %} 106 {% block indexed_property_setter_callback %}
107 {% if indexed_property_setter %} 107 {% if indexed_property_setter %}
108 {% set setter = indexed_property_setter %} 108 {% set setter = indexed_property_setter %}
109 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 109 void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
110 { 110 {
111 {% if setter.is_ce_reactions %} 111 {% if setter.is_ce_reactions %}
112 CEReactionsScope ceReactionsScope; 112 CEReactionsScope ceReactionsScope;
113 {% endif %} 113 {% endif %}
114 {% if setter.is_custom %} 114 {% if setter.is_custom %}
115 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info); 115 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info);
116 {% else %} 116 {% else %}
117 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info); 117 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info);
118 {% endif %} 118 {% endif %}
119 } 119 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 {% endif %} 153 {% endif %}
154 {% endblock %} 154 {% endblock %}
155 155
156 156
157 {##############################################################################} 157 {##############################################################################}
158 {% block indexed_property_deleter_callback %} 158 {% block indexed_property_deleter_callback %}
159 {% if indexed_property_deleter %} 159 {% if indexed_property_deleter %}
160 {% set deleter = indexed_property_deleter %} 160 {% set deleter = indexed_property_deleter %}
161 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal lbackInfo<v8::Boolean>& info) 161 void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackIn fo<v8::Boolean>& info)
162 { 162 {
163 {% if deleter.is_ce_reactions %} 163 {% if deleter.is_ce_reactions %}
164 CEReactionsScope ceReactionsScope; 164 CEReactionsScope ceReactionsScope;
165 {% endif %} 165 {% endif %}
166 {% if deleter.is_custom %} 166 {% if deleter.is_custom %}
167 {{v8_class}}::indexedPropertyDeleterCustom(index, info); 167 {{v8_class}}::indexedPropertyDeleterCustom(index, info);
168 {% else %} 168 {% else %}
169 {{cpp_class}}V8Internal::indexedPropertyDeleter(index, info); 169 {{cpp_class}}V8Internal::indexedPropertyDeleter(index, info);
170 {% endif %} 170 {% endif %}
171 } 171 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 207
208 {% endif %} 208 {% endif %}
209 {% endblock %} 209 {% endblock %}
210 210
211 211
212 {##############################################################################} 212 {##############################################################################}
213 {% block named_property_getter_callback %} 213 {% block named_property_getter_callback %}
214 {% if named_property_getter %} 214 {% if named_property_getter %}
215 {% set getter = named_property_getter %} 215 {% set getter = named_property_getter %}
216 static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::Prop ertyCallbackInfo<v8::Value>& info) 216 void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCal lbackInfo<v8::Value>& info)
217 { 217 {
218 if (!name->IsString()) 218 if (!name->IsString())
219 return; 219 return;
220 {% if getter.is_custom %} 220 {% if getter.is_custom %}
221 {{v8_class}}::namedPropertyGetterCustom(name, info); 221 {{v8_class}}::namedPropertyGetterCustom(name, info);
222 {% else %} 222 {% else %}
223 {{cpp_class}}V8Internal::namedPropertyGetter(name, info); 223 {{cpp_class}}V8Internal::namedPropertyGetter(name, info);
224 {% endif %} 224 {% endif %}
225 } 225 }
226 226
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 277
278 {% endif %} 278 {% endif %}
279 {% endblock %} 279 {% endblock %}
280 280
281 281
282 {##############################################################################} 282 {##############################################################################}
283 {% block named_property_setter_callback %} 283 {% block named_property_setter_callback %}
284 {% if named_property_setter %} 284 {% if named_property_setter %}
285 {% set setter = named_property_setter %} 285 {% set setter = named_property_setter %}
286 static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8:: Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 286 void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
287 { 287 {
288 if (!name->IsString()) 288 if (!name->IsString())
289 return; 289 return;
290 {% if setter.is_ce_reactions %} 290 {% if setter.is_ce_reactions %}
291 CEReactionsScope ceReactionsScope; 291 CEReactionsScope ceReactionsScope;
292 {% endif %} 292 {% endif %}
293 {% if setter.is_custom %} 293 {% if setter.is_custom %}
294 {{v8_class}}::namedPropertySetterCustom(name, v8Value, info); 294 {{v8_class}}::namedPropertySetterCustom(name, v8Value, info);
295 {% else %} 295 {% else %}
296 {{cpp_class}}V8Internal::namedPropertySetter(name, v8Value, info); 296 {{cpp_class}}V8Internal::namedPropertySetter(name, v8Value, info);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 {% endif %} 330 {% endif %}
331 {% endblock %} 331 {% endblock %}
332 332
333 333
334 {##############################################################################} 334 {##############################################################################}
335 {% block named_property_query_callback %} 335 {% block named_property_query_callback %}
336 {% if named_property_getter and named_property_getter.is_enumerable %} 336 {% if named_property_getter and named_property_getter.is_enumerable %}
337 {% set getter = named_property_getter %} 337 {% set getter = named_property_getter %}
338 static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::Prope rtyCallbackInfo<v8::Integer>& info) 338 void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCall backInfo<v8::Integer>& info)
339 { 339 {
340 if (!name->IsString()) 340 if (!name->IsString())
341 return; 341 return;
342 {% if getter.is_custom_property_query %} 342 {% if getter.is_custom_property_query %}
343 {{v8_class}}::namedPropertyQueryCustom(name, info); 343 {{v8_class}}::namedPropertyQueryCustom(name, info);
344 {% else %} 344 {% else %}
345 {{cpp_class}}V8Internal::namedPropertyQuery(name, info); 345 {{cpp_class}}V8Internal::namedPropertyQuery(name, info);
346 {% endif %} 346 {% endif %}
347 } 347 }
348 348
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 383 }
384 384
385 {% endif %} 385 {% endif %}
386 {% endblock %} 386 {% endblock %}
387 387
388 388
389 {##############################################################################} 389 {##############################################################################}
390 {% block named_property_deleter_callback %} 390 {% block named_property_deleter_callback %}
391 {% if named_property_deleter %} 391 {% if named_property_deleter %}
392 {% set deleter = named_property_deleter %} 392 {% set deleter = named_property_deleter %}
393 static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::Pro pertyCallbackInfo<v8::Boolean>& info) 393 void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCa llbackInfo<v8::Boolean>& info)
394 { 394 {
395 if (!name->IsString()) 395 if (!name->IsString())
396 return; 396 return;
397 {% if deleter.is_ce_reactions %} 397 {% if deleter.is_ce_reactions %}
398 CEReactionsScope ceReactionsScope; 398 CEReactionsScope ceReactionsScope;
399 {% endif %} 399 {% endif %}
400 {% if deleter.is_custom %} 400 {% if deleter.is_custom %}
401 {{v8_class}}::namedPropertyDeleterCustom(name, info); 401 {{v8_class}}::namedPropertyDeleterCustom(name, info);
402 {% else %} 402 {% else %}
403 {{cpp_class}}V8Internal::namedPropertyDeleter(name, info); 403 {{cpp_class}}V8Internal::namedPropertyDeleter(name, info);
(...skipping 25 matching lines...) Expand all
429 } 429 }
430 430
431 {% endif %} 431 {% endif %}
432 {% endblock %} 432 {% endblock %}
433 433
434 434
435 {##############################################################################} 435 {##############################################################################}
436 {% block named_property_enumerator_callback %} 436 {% block named_property_enumerator_callback %}
437 {% if named_property_getter and named_property_getter.is_enumerable %} 437 {% if named_property_getter and named_property_getter.is_enumerable %}
438 {% set getter = named_property_getter %} 438 {% set getter = named_property_getter %}
439 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A rray>& info) 439 void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
440 { 440 {
441 {% if getter.is_custom_property_enumerator %} 441 {% if getter.is_custom_property_enumerator %}
442 {{v8_class}}::namedPropertyEnumeratorCustom(info); 442 {{v8_class}}::namedPropertyEnumeratorCustom(info);
443 {% else %} 443 {% else %}
444 {{cpp_class}}V8Internal::namedPropertyEnumerator(info); 444 {{cpp_class}}V8Internal::namedPropertyEnumerator(info);
445 {% endif %} 445 {% endif %}
446 } 446 }
447 447
448 {% endif %} 448 {% endif %}
449 {% endblock %} 449 {% endblock %}
(...skipping 13 matching lines...) Expand all
463 v8::String::Utf8Value attributeName(name); 463 v8::String::Utf8Value attributeName(name);
464 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate()); 464 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
465 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate() ), impl, exceptionState)) { 465 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate() ), impl, exceptionState)) {
466 return; 466 return;
467 } 467 }
468 468
469 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.Holder() is an Object. #} 469 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.Holder() is an Object. #}
470 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::L ocal<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value); 470 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::L ocal<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value);
471 } 471 }
472 472
473 static void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name , v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 473 void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name, v8::L ocal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
474 { 474 {
475 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, info); 475 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, info);
476 } 476 }
477 477
478 {% endif %} 478 {% endif %}
479 {% endblock %} 479 {% endblock %}
480 480
481 481
482 {##############################################################################} 482 {##############################################################################}
483 {% block named_constructor %} 483 {% block named_constructor %}
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 934
935 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 935 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
936 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 936 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
937 { 937 {
938 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 938 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
939 } 939 }
940 940
941 {% endfor %} 941 {% endfor %}
942 {% endif %} 942 {% endif %}
943 {% endblock %} 943 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698