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

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 47023015: IDL compiler: [Default] arguments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method) %} 2 {% macro generate_method(method) %}
3 static void {{method.name}}Method(const v8::FunctionCallbackInfo<v8::Value>& arg s) 3 static void {{method.name}}Method(const v8::FunctionCallbackInfo<v8::Value>& arg s)
4 { 4 {
5 {% if method.number_of_required_arguments %} 5 {% if method.number_of_required_arguments %}
6 if (UNLIKELY(args.Length() < {{method.number_of_required_arguments}})) { 6 if (UNLIKELY(args.Length() < {{method.number_of_required_arguments}})) {
7 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ ired_arguments}}, args.Length())), args.GetIsolate()); 7 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ ired_arguments}}, args.Length())), args.GetIsolate());
8 return; 8 return;
9 } 9 }
10 {% endif %} 10 {% endif %}
11 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(args.Holder()); 11 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(args.Holder());
12 {% for argument in method.arguments %} 12 {% for argument in method.arguments %}
13 {% if argument.is_optional %} 13 {% if argument.is_optional and not argument.has_default %}
14 if (UNLIKELY(args.Length() <= {{argument.index}})) { 14 if (UNLIKELY(args.Length() <= {{argument.index}})) {
15 {{argument.cpp_method}}; 15 {{argument.cpp_method}};
16 return; 16 return;
17 } 17 }
18 {% endif %} 18 {% endif %}
19 {% if argument.is_clamp %} 19 {% if argument.is_clamp %}
20 {# FIXME: use C++ type for local variable #} 20 {# FIXME: use C++ type for local variable #}
21 {{argument.idl_type}} {{argument.name}} = 0; 21 {{argument.idl_type}} {{argument.name}} = 0;
22 V8TRYCATCH_VOID(double, {{argument.name}}NativeValue, args[{{argument.index} }]->NumberValue()); 22 V8TRYCATCH_VOID(double, {{argument.name}}NativeValue, args[{{argument.index} }]->NumberValue());
23 if (!std::isnan({{argument.name}}NativeValue)) 23 if (!std::isnan({{argument.name}}NativeValue))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 {##############################################################################} 64 {##############################################################################}
65 {% macro method_callback(method) %} 65 {% macro method_callback(method) %}
66 static void {{method.name}}MethodCallback(const v8::FunctionCallbackInfo<v8::Val ue>& args) 66 static void {{method.name}}MethodCallback(const v8::FunctionCallbackInfo<v8::Val ue>& args)
67 { 67 {
68 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 68 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
69 {{cpp_class_name}}V8Internal::{{method.name}}Method(args); 69 {{cpp_class_name}}V8Internal::{{method.name}}Method(args);
70 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 70 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
71 } 71 }
72 {% endmacro %} 72 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_methods.py ('k') | Source/bindings/tests/idls/TestObjectPython.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698