Chromium Code Reviews| Index: Source/bindings/templates/methods.cpp |
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
| index 94b70730869b707916dfc76315938738c13565d4..70f2e9ed9b87d027f73aab56b252303b3fac0706 100644 |
| --- a/Source/bindings/templates/methods.cpp |
| +++ b/Source/bindings/templates/methods.cpp |
| @@ -1,7 +1,7 @@ |
| {##############################################################################} |
| {% macro generate_method(method, world_suffix) %} |
| {% filter conditional(method.conditional_string) %} |
| -static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info{% if method.overload_index %}, int type_checked_argument_index{% endif %}) |
| { |
| {# Local variables #} |
| {% if method.has_exception_state %} |
| @@ -172,7 +172,19 @@ if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I |
| } |
| {{argument.v8_value_to_local_cpp_value}}; |
| {% else %}{# argument.is_nullable #} |
| +{# Optionally do an "unsafe" type conversion if meaningful for this argument's |
| + type and if this method is overloaded and the argument's type was checked as |
| + part of overload resolution for this particular call. #} |
| +{% if method.overload_index and |
| + argument.is_distinguishing_argument and |
| + argument.v8_value_to_local_cpp_value_unsafe %} |
| +if (type_checked_argument_index == {{argument.index}}) |
|
haraken
2014/10/14 13:54:07
Help me understand: I'm curious about the relation
Jens Widell
2014/10/14 14:37:56
Yes, it's possible. The key complexity here (which
|
| + {{argument.v8_value_to_local_cpp_value_unsafe}}; |
| +else |
| + {{argument.v8_value_to_local_cpp_value}}; |
| +{% else %} |
| {{argument.v8_value_to_local_cpp_value}}; |
| +{% endif %} |
| {% endif %}{# argument.is_nullable #} |
| {# Type checking, possibly throw a TypeError, per: |
| http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
| @@ -377,7 +389,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI |
| {# 10. If i = d, then: #} |
| case {{length}}: |
| {# Then resolve by testing argument #} |
| - {% for test, method in tests_methods %} |
| + {% for test, method, typed_checked_argument_index in tests_methods %} |
| {% filter runtime_enabled(not overloads.runtime_enabled_function_all and |
| method.runtime_enabled_function) %} |
| if ({{test}}) { |
| @@ -387,7 +399,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI |
| {% if method.deprecate_as and not overloads.deprecate_all_as %} |
| UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::{{method.deprecate_as}}); |
| {% endif %} |
| - {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info); |
| + {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info, {{typed_checked_argument_index}}); |
| return; |
| } |
| {% endfilter %} |
| @@ -547,7 +559,7 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar |
| {% set name = '%sConstructorCallback' % v8_class |
| if constructor.is_named_constructor else |
| 'constructor%s' % (constructor.overload_index or '') %} |
| -static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info{% if constructor.overload_index %}, int type_checked_argument_index{% endif %}) |
|
haraken
2014/10/14 13:54:07
type_checked_argument_index => typeCheckedArgument
|
| { |
| {% if constructor.is_named_constructor %} |
| if (!info.IsConstructCall()) { |