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

Side by Side Diff: sky/engine/bindings-dart/dart/scripts/templates/interface_cpp.template

Issue 918273002: Remove bindings-dart (Closed) Base URL: git@github.com:domokit/mojo.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
OLDNEW
(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 = DartDO MWrapper::receiver< {{cpp_class}} >(args);
14 Dart_Handle exception = 0;
15 {
16 {% if indexed_property_getter.is_raises_exception %}
17 DartExceptionState es;
18 {% endif %}
19
20 {# TODO(terry): Assume index is unsigned long, which all currently are. #}
21 unsigned index = DartUtilities::dartToUnsigned(args, 1, exception);
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 (nf == {{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 (nf == {{dart_class}}Internal::propertyQuery) {
90 return reinterpret_cast<const uint8_t*>("{{resolver_string}}");
91 }
92 {% endfor %}
93 {% endif %}
94 {% endblock %}
95
96 {##############################################################################}
97 {% block to_dart_no_inline %}
98 template<>
99 Dart_Handle toDartNoInline({{cpp_class}}* impl, DartDOMData* domData)
100 {
101 return {{dart_class}}::toDart(impl);
102 }
103 {% endblock %}
104
105 {% from 'methods_cpp.template' import static_method_name with context %}
106
107 {##############################################################################}
108 {% block overloaded_constructor %}
109 {% if constructor_overloads %}
110 static void constructorCallbackDispatcher(Dart_NativeArguments args)
111 {
112 Dart_Handle exception = 0;
113 const int argOffset = 0;
114 int argCount = Dart_GetNativeArgumentCount(args) + argOffset;
115 {# 2. Initialize argcount to be min(maxarg, n). #}
116 switch (std::min({{constructor_overloads.maxarg}}, argCount)) {
117 {# 3. Remove from S all entries whose type list is not of length argcount. # }
118 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %}
119 case {{length}}:
120 {# Then resolve by testing argument #}
121 {% for test, constructor in tests_constructors %}
122 {# 10. If i = d, then: #}
123 if ({{test}}) {
124 {% if constructor.is_custom %}
125 {{static_method_name(constructor.name)}}(args);
126 {% else %}
127 {{static_method_name(constructor.name, constructor.overload_index)}} (args);
128 {% endif %}
129 return;
130 }
131 {% endfor %}
132 break;
133 {% endfor %}
134 default:
135 {# Invalid arity, throw error #}
136 {# Report full list of valid arities if gaps and above minimum #}
137 {% if constructor_overloads.valid_arities %}
138 if (argCount >= {{overloads.minarg}}) {
139 const String message = "Wrong arity, expected one of {{constructor_o verloads.valid_arities}}";
140 exception = DartUtilities::coreArgumentErrorException(message);
141 goto fail;
142 }
143 {% endif %}
144 {# Otherwise just report "not enough arguments" #}
145 {
146 const String message = "Not enough arguments (at least {{constructor _overloads.minarg}} required)";
147 exception = DartUtilities::coreArgumentErrorException(message);
148 goto fail;
149 }
150 return;
151 }
152 {# No match, throw error #}
153 {
154 const String message = "No matching constructor signature.";
155 exception = DartUtilities::coreArgumentErrorException(message);
156 goto fail;
157 }
158 return;
159 fail:
160 Dart_ThrowException(exception);
161 ASSERT_NOT_REACHED();
162 }
163 {% endif %}
164 {% endblock %}
165
166
167 {##############################################################################}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698