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

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

Issue 2578943002: [Bindings] Refactoring of binding code around runtime enabled features (Closed)
Patch Set: Work for a comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro generate_method(method, world_suffix) %} 4 {% macro generate_method(method, world_suffix) %}
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) { 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) {
6 {% filter format_remove_duplicates([ 6 {% filter format_remove_duplicates([
7 'ExceptionState exceptionState', 7 'ExceptionState exceptionState',
8 'ScriptState* scriptState = ']) %} 8 'ScriptState* scriptState = ']) %}
9 {% set define_exception_state -%} 9 {% set define_exception_state -%}
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}");
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 {##############################################################################} 311 {##############################################################################}
312 {% macro throw_argument_error(method, argument, error_message) %} 312 {% macro throw_argument_error(method, argument, error_message) %}
313 {% set quoted_message = '"%s"' % (error_message | replace('\"', '\\\"')) %} 313 {% set quoted_message = '"%s"' % (error_message | replace('\"', '\\\"')) %}
314 {{throw_type_error(method, quoted_message | format(index=(argument.index + 1), n ame=argument.name, type=argument.idl_type))}} 314 {{throw_type_error(method, quoted_message | format(index=(argument.index + 1), n ame=argument.name, type=argument.idl_type))}}
315 {% endmacro %} 315 {% endmacro %}
316 316
317 317
318 {##############################################################################} 318 {##############################################################################}
319 {% macro runtime_determined_length_method(overloads) %} 319 {% macro runtime_determined_length_method(overloads) %}
320 static int {{overloads.name}}MethodLength() { 320 static int {{overloads.name}}MethodLength() {
321 {% for length, runtime_enabled_functions in overloads.runtime_determined_lengt hs %} 321 {% for length, runtime_enabled_features in overloads.runtime_determined_length s %}
322 {% for runtime_enabled_function in runtime_enabled_functions %} 322 {% for runtime_enabled_feature in runtime_enabled_features %}
323 {% filter runtime_enabled(runtime_enabled_function) %} 323 {% filter runtime_enabled(runtime_enabled_feature) %}
324 return {{length}}; 324 return {{length}};
325 {% endfilter %} 325 {% endfilter %}
326 {% endfor %} 326 {% endfor %}
327 {% endfor %} 327 {% endfor %}
328 } 328 }
329 {% endmacro %} 329 {% endmacro %}
330 330
331 331
332 {##############################################################################} 332 {##############################################################################}
333 {% macro runtime_determined_maxarg_method(overloads) %} 333 {% macro runtime_determined_maxarg_method(overloads) %}
334 static int {{overloads.name}}MethodMaxArg() { 334 static int {{overloads.name}}MethodMaxArg() {
335 {% for length, runtime_enabled_functions in overloads.runtime_determined_maxar gs %} 335 {% for length, runtime_enabled_features in overloads.runtime_determined_maxarg s %}
336 {% for runtime_enabled_function in runtime_enabled_functions %} 336 {% for name in runtime_enabled_features %}
337 {% filter runtime_enabled(runtime_enabled_function) %} 337 {% filter runtime_enabled(name) %}
338 return {{length}}; 338 return {{length}};
339 {% endfilter %} 339 {% endfilter %}
340 {% endfor %} 340 {% endfor %}
341 {% endfor %} 341 {% endfor %}
342 } 342 }
343 {% endmacro %} 343 {% endmacro %}
344 344
345 345
346 {##############################################################################} 346 {##############################################################################}
347 {% macro overload_resolution_method(overloads, world_suffix) %} 347 {% macro overload_resolution_method(overloads, world_suffix) %}
(...skipping 13 matching lines...) Expand all
361 {% endif %} 361 {% endif %}
362 {# 2. Initialize argcount to be min(maxarg, n). #} 362 {# 2. Initialize argcount to be min(maxarg, n). #}
363 switch (std::min({{overloads.maxarg}}, info.Length())) { 363 switch (std::min({{overloads.maxarg}}, info.Length())) {
364 {# 3. Remove from S all entries whose type list is not of length argcount. # } 364 {# 3. Remove from S all entries whose type list is not of length argcount. # }
365 {% for length, tests_methods in overloads.length_tests_methods %} 365 {% for length, tests_methods in overloads.length_tests_methods %}
366 {# 10. If i = d, then: #} 366 {# 10. If i = d, then: #}
367 case {{length}}: 367 case {{length}}:
368 {# Then resolve by testing argument #} 368 {# Then resolve by testing argument #}
369 {% for test, method in tests_methods %} 369 {% for test, method in tests_methods %}
370 {% if method.visible %} 370 {% if method.visible %}
371 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and 371 {% filter runtime_enabled(not overloads.runtime_enabled_all and method.run time_enabled_feature_name) %}
372 method.runtime_enabled_function) %}
373 if ({{test}}) { 372 if ({{test}}) {
374 {% if method.measure_as and not overloads.measure_all_as %} 373 {% if method.measure_as and not overloads.measure_all_as %}
375 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter ::{{method.measure_as('Method')}}); 374 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter ::{{method.measure_as('Method')}});
376 {% endif %} 375 {% endif %}
377 {% if method.deprecate_as and not overloads.deprecate_all_as %} 376 {% if method.deprecate_as and not overloads.deprecate_all_as %}
378 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()) , UseCounter::{{method.deprecate_as}}); 377 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()) , UseCounter::{{method.deprecate_as}});
379 {% endif %} 378 {% endif %}
380 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info); 379 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info);
381 return; 380 return;
382 } 381 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTempla te); 626 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTempla te);
628 ExecutionContext* executionContext = toExecutionContext(prototypeObject->Creatio nContext()); 627 ExecutionContext* executionContext = toExecutionContext(prototypeObject->Creatio nContext());
629 DCHECK(executionContext); 628 DCHECK(executionContext);
630 {% for method in methods | conditionally_exposed(is_partial) %} 629 {% for method in methods | conditionally_exposed(is_partial) %}
631 {% filter secure_context(method.overloads.secure_context_test_all 630 {% filter secure_context(method.overloads.secure_context_test_all
632 if method.overloads else 631 if method.overloads else
633 method.secure_context_test) %} 632 method.secure_context_test) %}
634 {% filter exposed(method.overloads.exposed_test_all 633 {% filter exposed(method.overloads.exposed_test_all
635 if method.overloads else 634 if method.overloads else
636 method.exposed_test) %} 635 method.exposed_test) %}
637 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 636 {% filter runtime_enabled(method.overloads.runtime_enabled_all
638 if method.overloads else 637 if method.overloads else
639 method.runtime_enabled_function) %} 638 method.runtime_enabled_feature_name) %}
640 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 639 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
641 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 640 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
642 {% endfilter %}{# runtime_enabled() #} 641 {% endfilter %}{# runtime_enabled() #}
643 {% endfilter %}{# exposed() #} 642 {% endfilter %}{# exposed() #}
644 {% endfilter %}{# secure_context() #} 643 {% endfilter %}{# secure_context() #}
645 {% endfor %} 644 {% endfor %}
646 {% endif %} 645 {% endif %}
647 {%- endmacro %} 646 {%- endmacro %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698