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

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

Issue 954723002: [bindings] Support is_explicit_nullable for method arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('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 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method, world_suffix) %} 2 {% macro generate_method(method, world_suffix) %}
3 {% filter conditional(method.conditional_string) %} 3 {% filter conditional(method.conditional_string) %}
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
5 { 5 {
6 {# Local variables #} 6 {# Local variables #}
7 {% if method.has_exception_state %} 7 {% if method.has_exception_state %}
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
9 {% endif %} 9 {% endif %}
10 {# Overloaded methods have length checked during overload resolution #} 10 {# Overloaded methods have length checked during overload resolution #}
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 {% if not argument.use_permissive_dictionary_conversion %} 163 {% if not argument.use_permissive_dictionary_conversion %}
164 {# Dictionaries must have type Undefined, Null or Object: 164 {# Dictionaries must have type Undefined, Null or Object:
165 http://heycam.github.io/webidl/#es-dictionary #} 165 http://heycam.github.io/webidl/#es-dictionary #}
166 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I sObject()) { 166 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I sObject()) {
167 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % 167 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' %
168 (argument.index + 1, argument.name)) | indent}} 168 (argument.index + 1, argument.name)) | indent}}
169 return; 169 return;
170 } 170 }
171 {% endif %}{# not argument.use_permissive_dictionary_conversion #} 171 {% endif %}{# not argument.use_permissive_dictionary_conversion #}
172 {{argument.v8_value_to_local_cpp_value}}; 172 {{argument.v8_value_to_local_cpp_value}};
173 {% elif argument.is_explicit_nullable %}
174 if (!info[{{argument.index}}]->IsNull()) {
175 {{argument.v8_value_to_local_cpp_value}};
Jens Widell 2015/02/24 14:29:03 This may or may not be the only part that should b
Jens Widell 2015/02/24 14:30:28 To clarify: I think this addition here is probably
176 }
173 {% else %}{# argument.is_nullable #} 177 {% else %}{# argument.is_nullable #}
174 {{argument.v8_value_to_local_cpp_value}}; 178 {{argument.v8_value_to_local_cpp_value}};
175 {% endif %}{# argument.is_nullable #} 179 {% endif %}{# argument.is_nullable #}
176 {# Type checking, possibly throw a TypeError, per: 180 {# Type checking, possibly throw a TypeError, per:
177 http://www.w3.org/TR/WebIDL/#es-type-mapping #} 181 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
178 {% if argument.has_type_checking_interface and not argument.is_variadic_wrapper_ type %} 182 {% if argument.has_type_checking_interface and not argument.is_variadic_wrapper_ type %}
179 {# Type checking for wrapper interface types (if interface not implemented, 183 {# Type checking for wrapper interface types (if interface not implemented,
180 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface 184 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface
181 Note: for variadic arguments, the type checking is done for each matched 185 Note: for variadic arguments, the type checking is done for each matched
182 argument instead; see argument.is_variadic_wrapper_type code-path above. #} 186 argument instead; see argument.is_variadic_wrapper_type code-path above. #}
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 if method.overloads else 655 if method.overloads else
652 method.runtime_enabled_function) %} 656 method.runtime_enabled_function) %}
653 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument s}})->GetFunction()); 657 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument s}})->GetFunction());
654 {% endfilter %}{# runtime_enabled() #} 658 {% endfilter %}{# runtime_enabled() #}
655 {% endfilter %}{# exposed() #} 659 {% endfilter %}{# exposed() #}
656 {% endfilter %}{# per_context_enabled() #} 660 {% endfilter %}{# per_context_enabled() #}
657 {% endfor %} 661 {% endfor %}
658 {% endif %} 662 {% endif %}
659 } 663 }
660 {%- endmacro %} 664 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698