| Index: Source/bindings/dart/scripts/templates/interface_cpp.template
|
| diff --git a/Source/bindings/dart/scripts/templates/interface_cpp.template b/Source/bindings/dart/scripts/templates/interface_cpp.template
|
| index f795069e76d4e4c641c233d1a19878f012969c30..7eab6f48d539889774485b8c3a8803345047cd5b 100644
|
| --- a/Source/bindings/dart/scripts/templates/interface_cpp.template
|
| +++ b/Source/bindings/dart/scripts/templates/interface_cpp.template
|
| @@ -137,3 +137,67 @@ Dart_Handle toDartNoInline({{cpp_class}}* impl, DartDOMData* domData)
|
| return {{dart_class}}::toDart(impl);
|
| }
|
| {% endblock %}
|
| +
|
| +{% from 'methods_cpp.template' import static_method_name with context %}
|
| +
|
| +{##############################################################################}
|
| +{% block overloaded_constructor %}
|
| +{% if constructor_overloads %}
|
| +static void constructorCallbackDispatcher(Dart_NativeArguments args)
|
| +{
|
| + Dart_Handle exception = 0;
|
| + const int argOffset = 0;
|
| + int argCount = Dart_GetNativeArgumentCount(args) + argOffset;
|
| + {# 2. Initialize argcount to be min(maxarg, n). #}
|
| + switch (std::min({{constructor_overloads.maxarg}}, argCount)) {
|
| + {# 3. Remove from S all entries whose type list is not of length argcount. #}
|
| + {% for length, tests_constructors in constructor_overloads.length_tests_methods %}
|
| + case {{length}}:
|
| + {# Then resolve by testing argument #}
|
| + {% for test, constructor in tests_constructors %}
|
| + {# 10. If i = d, then: #}
|
| + if ({{test}}) {
|
| + {% if constructor.is_custom %}
|
| + {{static_method_name(constructor.name)}}(args);
|
| + {% else %}
|
| + {{static_method_name(constructor.name, constructor.overload_index)}}(args);
|
| + {% endif %}
|
| + return;
|
| + }
|
| + {% endfor %}
|
| + break;
|
| + {% endfor %}
|
| + default:
|
| + {# Invalid arity, throw error #}
|
| + {# Report full list of valid arities if gaps and above minimum #}
|
| + {% if constructor_overloads.valid_arities %}
|
| + if (argCount >= {{overloads.minarg}}) {
|
| + const String message = "Wrong arity, expected one of {{constructor_overloads.valid_arities}}";
|
| + exception = DartUtilities::coreArgumentErrorException(message);
|
| + goto fail;
|
| + }
|
| + {% endif %}
|
| + {# Otherwise just report "not enough arguments" #}
|
| + {
|
| + const String message = "Not enough arguments (at least {{constructor_overloads.minarg}} required)";
|
| + exception = DartUtilities::coreArgumentErrorException(message);
|
| + goto fail;
|
| + }
|
| + return;
|
| + }
|
| + {# No match, throw error #}
|
| + {
|
| + const String message = "No matching constructor signature.";
|
| + exception = DartUtilities::coreArgumentErrorException(message);
|
| + goto fail;
|
| + }
|
| + return;
|
| +fail:
|
| + Dart_ThrowException(exception);
|
| + ASSERT_NOT_REACHED();
|
| +}
|
| +{% endif %}
|
| +{% endblock %}
|
| +
|
| +
|
| +{##############################################################################}
|
|
|