| OLD | NEW |
| (Empty) | |
| 1 {% extends 'interface_base_cpp.template' %} |
| 2 |
| 3 |
| 4 {# TODO(terry): Implement setter and deleter too #} |
| 5 |
| 6 |
| 7 {##############################################################################} |
| 8 {% block indexed_property_getter %} |
| 9 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
| 10 {% set getter = indexed_property_getter %} |
| 11 static void indexedPropertyGetter(Dart_NativeArguments args) |
| 12 { |
| 13 {{cpp_class}}* /* FIXME(vsm): Remove this. */ ALLOW_UNUSED receiver = GetRec
eiver<{{cpp_class}}>(args); |
| 14 Dart_Handle exception = nullptr; |
| 15 { |
| 16 {% if indexed_property_getter.is_raises_exception %} |
| 17 ExceptionState es; |
| 18 {% endif %} |
| 19 |
| 20 {# TODO(terry): Assume index is unsigned long, which all currently are.
#} |
| 21 unsigned index = DartConverter<unsigned>::FromArguments(args, 1, excepti
on); |
| 22 if (exception) |
| 23 goto fail; |
| 24 {{indexed_property_getter.cpp_type}} result = {{indexed_property_getter.
cpp_value}}; |
| 25 if (!result) |
| 26 return; |
| 27 {{indexed_property_getter.dart_set_return_value}}; |
| 28 |
| 29 return; |
| 30 } |
| 31 |
| 32 fail: |
| 33 Dart_ThrowException(exception); |
| 34 ASSERT_NOT_REACHED(); |
| 35 } |
| 36 |
| 37 {% endif %} |
| 38 {# TODO(terry): Should handle custom index getter - none today. #} |
| 39 {% endblock %} |
| 40 |
| 41 |
| 42 {##############################################################################} |
| 43 {% block indexed_property_getter_resolver %} |
| 44 {# TODO(terry): Support all indexed and named properties today only indexed
getter is supported. #} |
| 45 {# Resolver indexed properties #} |
| 46 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
| 47 {% for native_entry in indexed_property_getter.native_entries %} |
| 48 {% set resolver_string = native_entry.resolver_string %} |
| 49 if (argumentCount == 2 && name == "{{resolver_string}}") { |
| 50 *autoSetupScope = true; |
| 51 return {{dart_class}}Internal::indexedPropertyGetter; |
| 52 } |
| 53 {% endfor %} |
| 54 {% endif %} |
| 55 {% endblock %} |
| 56 |
| 57 {##############################################################################} |
| 58 {% block named_property_getter_resolver %} |
| 59 {# Resolver named properties #} |
| 60 {% if named_property_getter %} |
| 61 {% for native_entry in named_property_getter.native_entries %} |
| 62 {% set resolver_string = native_entry.resolver_string %} |
| 63 if (argumentCount == 2 && (name == "{{resolver_string}}")) { |
| 64 *autoSetupScope = true; |
| 65 return {{dart_class}}Internal::propertyQuery; |
| 66 } |
| 67 {% endfor %} |
| 68 {% endif %} |
| 69 {% endblock %} |
| 70 |
| 71 {##############################################################################} |
| 72 {% block generate_symbolizer_indexed_property_getter %} |
| 73 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
| 74 {% for native_entry in indexed_property_getter.native_entries %} |
| 75 {% set resolver_string = native_entry.resolver_string %} |
| 76 if (native_function == {{dart_class}}Internal::indexedPropertyGetter) { |
| 77 return reinterpret_cast<const uint8_t*>("{{resolver_string}}"); |
| 78 } |
| 79 {% endfor %} |
| 80 {% endif %} |
| 81 {% endblock %} |
| 82 |
| 83 {##############################################################################} |
| 84 {% block generate_symbolizer_named_property_getter %} |
| 85 {# Resolver named properties #} |
| 86 {% if named_property_getter %} |
| 87 {% for native_entry in named_property_getter.native_entries %} |
| 88 {% set resolver_string = native_entry.resolver_string %} |
| 89 if (native_function == {{dart_class}}Internal::propertyQuery) { |
| 90 return reinterpret_cast<const uint8_t*>("{{resolver_string}}"); |
| 91 } |
| 92 {% endfor %} |
| 93 {% endif %} |
| 94 {% endblock %} |
| 95 |
| 96 {##############################################################################} |
| 97 |
| 98 {% from 'methods_cpp.template' import static_method_name with context %} |
| 99 |
| 100 {##############################################################################} |
| 101 {% block overloaded_constructor %} |
| 102 {% if constructor_overloads %} |
| 103 static void constructorCallbackDispatcher(Dart_NativeArguments args) |
| 104 { |
| 105 Dart_Handle exception = nullptr; |
| 106 const int argOffset = 0; |
| 107 int argCount = Dart_GetNativeArgumentCount(args) + argOffset; |
| 108 {# 2. Initialize argcount to be min(maxarg, n). #} |
| 109 switch (std::min({{constructor_overloads.maxarg}}, argCount)) { |
| 110 {# 3. Remove from S all entries whose type list is not of length argcount. #
} |
| 111 {% for length, tests_constructors in constructor_overloads.length_tests_meth
ods %} |
| 112 case {{length}}: |
| 113 {# Then resolve by testing argument #} |
| 114 {% for test, constructor in tests_constructors %} |
| 115 {# 10. If i = d, then: #} |
| 116 if ({{test}}) { |
| 117 {% if constructor.is_custom %} |
| 118 {{static_method_name(constructor.name)}}(args); |
| 119 {% else %} |
| 120 {{static_method_name(constructor.name, constructor.overload_index)}}
(args); |
| 121 {% endif %} |
| 122 return; |
| 123 } |
| 124 {% endfor %} |
| 125 break; |
| 126 {% endfor %} |
| 127 default: |
| 128 {# Invalid arity, throw error #} |
| 129 {# Report full list of valid arities if gaps and above minimum #} |
| 130 {% if constructor_overloads.valid_arities %} |
| 131 if (argCount >= {{overloads.minarg}}) { |
| 132 const String message = "Wrong arity, expected one of {{constructor_o
verloads.valid_arities}}"; |
| 133 // TODO(dart): exception = DartUtilities::coreArgumentErrorException
(message); |
| 134 goto fail; |
| 135 } |
| 136 {% endif %} |
| 137 {# Otherwise just report "not enough arguments" #} |
| 138 { |
| 139 const String message = "Not enough arguments (at least {{constructor
_overloads.minarg}} required)"; |
| 140 // TODO(dart): exception = DartUtilities::coreArgumentErrorException
(message); |
| 141 goto fail; |
| 142 } |
| 143 return; |
| 144 } |
| 145 {# No match, throw error #} |
| 146 { |
| 147 const String message = "No matching constructor signature."; |
| 148 // TODO(dart): exception = DartUtilities::coreArgumentErrorException(mes
sage); |
| 149 goto fail; |
| 150 } |
| 151 return; |
| 152 fail: |
| 153 Dart_ThrowException(exception); |
| 154 ASSERT_NOT_REACHED(); |
| 155 } |
| 156 {% endif %} |
| 157 {% endblock %} |
| 158 |
| 159 |
| 160 {##############################################################################} |
| OLD | NEW |