OLD | NEW |
1 {% extends 'interface_base_cpp.template' %} | 1 {% extends 'interface_base_cpp.template' %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {# Mangled Blink name used by resolver to map to static function. #} | 5 {# Mangled Blink name used by resolver to map to static function. #} |
6 {##############################################################################} | 6 {##############################################################################} |
7 {% macro resolver_callback_string(class_name, name, argument) -%} | 7 {% macro resolver_callback_string(class_name, name, argument) -%} |
8 {% set name = '__' + name + '___' -%} | 8 {% set name = '__' + name + '___' -%} |
9 {% if argument -%} | 9 {% if argument -%} |
10 {{class_name}}_{{name}}Callback_{{argument}} | 10 {{class_name}}_{{name}}Callback_{{argument}} |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 {% endblock %} | 130 {% endblock %} |
131 | 131 |
132 {##############################################################################} | 132 {##############################################################################} |
133 {% block to_dart_no_inline %} | 133 {% block to_dart_no_inline %} |
134 template<> | 134 template<> |
135 Dart_Handle toDartNoInline({{cpp_class}}* impl, DartDOMData* domData) | 135 Dart_Handle toDartNoInline({{cpp_class}}* impl, DartDOMData* domData) |
136 { | 136 { |
137 return {{dart_class}}::toDart(impl); | 137 return {{dart_class}}::toDart(impl); |
138 } | 138 } |
139 {% endblock %} | 139 {% endblock %} |
| 140 |
| 141 {% from 'methods_cpp.template' import static_method_name with context %} |
| 142 |
| 143 {##############################################################################} |
| 144 {% block overloaded_constructor %} |
| 145 {% if constructor_overloads %} |
| 146 static void constructorCallbackDispatcher(Dart_NativeArguments args) |
| 147 { |
| 148 Dart_Handle exception = 0; |
| 149 const int argOffset = 0; |
| 150 int argCount = Dart_GetNativeArgumentCount(args) + argOffset; |
| 151 {# 2. Initialize argcount to be min(maxarg, n). #} |
| 152 switch (std::min({{constructor_overloads.maxarg}}, argCount)) { |
| 153 {# 3. Remove from S all entries whose type list is not of length argcount. #
} |
| 154 {% for length, tests_constructors in constructor_overloads.length_tests_meth
ods %} |
| 155 case {{length}}: |
| 156 {# Then resolve by testing argument #} |
| 157 {% for test, constructor in tests_constructors %} |
| 158 {# 10. If i = d, then: #} |
| 159 if ({{test}}) { |
| 160 {% if constructor.is_custom %} |
| 161 {{static_method_name(constructor.name)}}(args); |
| 162 {% else %} |
| 163 {{static_method_name(constructor.name, constructor.overload_index)}}
(args); |
| 164 {% endif %} |
| 165 return; |
| 166 } |
| 167 {% endfor %} |
| 168 break; |
| 169 {% endfor %} |
| 170 default: |
| 171 {# Invalid arity, throw error #} |
| 172 {# Report full list of valid arities if gaps and above minimum #} |
| 173 {% if constructor_overloads.valid_arities %} |
| 174 if (argCount >= {{overloads.minarg}}) { |
| 175 const String message = "Wrong arity, expected one of {{constructor_o
verloads.valid_arities}}"; |
| 176 exception = DartUtilities::coreArgumentErrorException(message); |
| 177 goto fail; |
| 178 } |
| 179 {% endif %} |
| 180 {# Otherwise just report "not enough arguments" #} |
| 181 { |
| 182 const String message = "Not enough arguments (at least {{constructor
_overloads.minarg}} required)"; |
| 183 exception = DartUtilities::coreArgumentErrorException(message); |
| 184 goto fail; |
| 185 } |
| 186 return; |
| 187 } |
| 188 {# No match, throw error #} |
| 189 { |
| 190 const String message = "No matching constructor signature."; |
| 191 exception = DartUtilities::coreArgumentErrorException(message); |
| 192 goto fail; |
| 193 } |
| 194 return; |
| 195 fail: |
| 196 Dart_ThrowException(exception); |
| 197 ASSERT_NOT_REACHED(); |
| 198 } |
| 199 {% endif %} |
| 200 {% endblock %} |
| 201 |
| 202 |
| 203 {##############################################################################} |
OLD | NEW |