OLD | NEW |
---|---|
1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% block indexed_property_getter %} | 5 {% block indexed_property_getter %} |
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} | 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
7 {% set getter = indexed_property_getter %} | 7 {% set getter = indexed_property_getter %} |
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) | 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) |
9 { | 9 { |
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
11 {% if getter.is_raises_exception %} | 11 {% if getter.is_raises_exception %} |
12 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter face_name}}", info.Holder(), info.GetIsolate()); | 12 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter face_name}}", info.Holder(), info.GetIsolate()); |
13 {% endif %} | 13 {% endif %} |
14 {% if getter.is_call_with_script_state %} | |
15 {# [CallWith=ScriptState] #} | |
haraken
2015/03/05 05:56:13
Nit: Remove this comment.
| |
16 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | |
17 {% endif %} | |
14 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} | 18 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} |
15 {% set getter_arguments = ['index', 'exceptionState'] | 19 {% set getter_arguments = ['scriptState', 'index'] |
16 if getter.is_raises_exception else ['index'] %} | 20 if getter.is_call_with_script_state else ['index'] %} |
21 {% if getter.is_raises_exception %} | |
22 {% set getter_arguments = getter_arguments + ['exceptionState'] %} | |
haraken
2015/03/05 05:56:13
You can do something like:
{% set getter_argument
| |
23 {% endif %} | |
17 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join (', ')}}); | 24 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join (', ')}}); |
18 {% if getter.is_raises_exception %} | 25 {% if getter.is_raises_exception %} |
19 if (exceptionState.throwIfNeeded()) | 26 if (exceptionState.throwIfNeeded()) |
20 return; | 27 return; |
21 {% endif %} | 28 {% endif %} |
22 if ({{getter.is_null_expression}}) | 29 if ({{getter.is_null_expression}}) |
23 return; | 30 return; |
24 {{getter.v8_set_return_value}}; | 31 {{getter.v8_set_return_value}}; |
25 } | 32 } |
26 | 33 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 {% endif %} | 68 {% endif %} |
62 {% if setter.has_type_checking_interface %} | 69 {% if setter.has_type_checking_interface %} |
63 {# Type checking for interface types (if interface not implemented, throw | 70 {# Type checking for interface types (if interface not implemented, throw |
64 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 71 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
65 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value) {% endif %}) { | 72 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value) {% endif %}) { |
66 exceptionState.throwTypeError("The provided value is not of type '{{sett er.idl_type}}'."); | 73 exceptionState.throwTypeError("The provided value is not of type '{{sett er.idl_type}}'."); |
67 exceptionState.throwIfNeeded(); | 74 exceptionState.throwIfNeeded(); |
68 return; | 75 return; |
69 } | 76 } |
70 {% endif %} | 77 {% endif %} |
78 {% if setter.is_call_with_script_state %} | |
79 {# [CallWith=ScriptState] #} | |
80 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | |
81 {% endif %} | |
71 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} | 82 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} |
72 {% set setter_arguments = ['index', 'propertyValue', 'exceptionState'] | 83 {% set setter_arguments = ['scriptState', 'index', 'propertyValue'] |
73 if setter.is_raises_exception else ['index', 'propertyValue'] %} | 84 if setter.is_call_with_script_state else ['index', 'propertyValue'] % } |
85 {% if setter.is_raises_exception %} | |
86 {% set setter_arguments = setter_arguments + ['exceptionState'] %} | |
87 {% endif %} | |
74 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); | 88 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); |
75 {% if setter.is_raises_exception %} | 89 {% if setter.is_raises_exception %} |
76 if (exceptionState.throwIfNeeded()) | 90 if (exceptionState.throwIfNeeded()) |
77 return; | 91 return; |
78 {% endif %} | 92 {% endif %} |
79 if (!result) | 93 if (!result) |
80 return; | 94 return; |
81 v8SetReturnValue(info, v8Value); | 95 v8SetReturnValue(info, v8Value); |
82 } | 96 } |
83 | 97 |
(...skipping 23 matching lines...) Expand all Loading... | |
107 {##############################################################################} | 121 {##############################################################################} |
108 {% block indexed_property_deleter %} | 122 {% block indexed_property_deleter %} |
109 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} | 123 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} |
110 {% set deleter = indexed_property_deleter %} | 124 {% set deleter = indexed_property_deleter %} |
111 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) | 125 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) |
112 { | 126 { |
113 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 127 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
114 {% if deleter.is_raises_exception %} | 128 {% if deleter.is_raises_exception %} |
115 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "{{int erface_name}}", info.Holder(), info.GetIsolate()); | 129 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "{{int erface_name}}", info.Holder(), info.GetIsolate()); |
116 {% endif %} | 130 {% endif %} |
131 {% if deleter.is_call_with_script_state %} | |
132 {# [CallWith=ScriptState] #} | |
133 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | |
134 {% endif %} | |
117 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} | 135 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} |
118 {% set deleter_arguments = ['index', 'exceptionState'] | 136 {% set deleter_arguments = ['scriptState', 'index'] |
119 if deleter.is_raises_exception else ['index'] %} | 137 if deleter.is_call_with_script_state else ['index'] %} |
138 {% if deleter.is_raises_exception %} | |
139 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} | |
140 {% endif %} | |
120 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ' )}}); | 141 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ' )}}); |
121 {% if deleter.is_raises_exception %} | 142 {% if deleter.is_raises_exception %} |
122 if (exceptionState.throwIfNeeded()) | 143 if (exceptionState.throwIfNeeded()) |
123 return; | 144 return; |
124 {% endif %} | 145 {% endif %} |
125 if (result != DeleteUnknownProperty) | 146 if (result != DeleteUnknownProperty) |
126 return v8SetReturnValueBool(info, result == DeleteSuccess); | 147 return v8SetReturnValueBool(info, result == DeleteSuccess); |
127 } | 148 } |
128 | 149 |
129 {% endif %} | 150 {% endif %} |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(nameString).IsEmpty ()) | 185 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(nameString).IsEmpty ()) |
165 return; | 186 return; |
166 | 187 |
167 {% endif %} | 188 {% endif %} |
168 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 189 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
169 AtomicString propertyName = toCoreAtomicString(nameString); | 190 AtomicString propertyName = toCoreAtomicString(nameString); |
170 {% if getter.is_raises_exception %} | 191 {% if getter.is_raises_exception %} |
171 v8::String::Utf8Value namedProperty(nameString); | 192 v8::String::Utf8Value namedProperty(nameString); |
172 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate()); | 193 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate()); |
173 {% endif %} | 194 {% endif %} |
195 {% if getter.is_call_with_script_state %} | |
196 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | |
197 {% endif %} | |
174 {% if getter.use_output_parameter_for_result %} | 198 {% if getter.use_output_parameter_for_result %} |
175 {{getter.cpp_type}} result; | 199 {{getter.cpp_type}} result; |
176 {{getter.cpp_value}}; | 200 {{getter.cpp_value}}; |
177 {% else %} | 201 {% else %} |
178 {{getter.cpp_type}} result = {{getter.cpp_value}}; | 202 {{getter.cpp_type}} result = {{getter.cpp_value}}; |
179 {% endif %} | 203 {% endif %} |
180 {% if getter.is_raises_exception %} | 204 {% if getter.is_raises_exception %} |
181 if (exceptionState.throwIfNeeded()) | 205 if (exceptionState.throwIfNeeded()) |
182 return; | 206 return; |
183 {% endif %} | 207 {% endif %} |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 {{v8_value_to_local_cpp_value(setter) | indent}} | 262 {{v8_value_to_local_cpp_value(setter) | indent}} |
239 {% if setter.has_type_checking_interface %} | 263 {% if setter.has_type_checking_interface %} |
240 {# Type checking for interface types (if interface not implemented, throw | 264 {# Type checking for interface types (if interface not implemented, throw |
241 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 265 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
242 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value) {% endif %}) { | 266 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value) {% endif %}) { |
243 exceptionState.throwTypeError("The provided value is not of type '{{sett er.idl_type}}'."); | 267 exceptionState.throwTypeError("The provided value is not of type '{{sett er.idl_type}}'."); |
244 exceptionState.throwIfNeeded(); | 268 exceptionState.throwIfNeeded(); |
245 return; | 269 return; |
246 } | 270 } |
247 {% endif %} | 271 {% endif %} |
272 {% if setter.is_call_with_script_state %} | |
273 {# [CallWith=ScriptState] #} | |
274 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | |
275 {% endif %} | |
248 {% set setter_name = setter.name or 'anonymousNamedSetter' %} | 276 {% set setter_name = setter.name or 'anonymousNamedSetter' %} |
249 {% set setter_arguments = | 277 {% set setter_arguments = |
250 ['propertyName', 'propertyValue', 'exceptionState'] | 278 ['scriptState', 'propertyName', 'propertyValue'] |
251 if setter.is_raises_exception else | 279 if setter.is_call_with_script_state else |
252 ['propertyName', 'propertyValue'] %} | 280 ['propertyName', 'propertyValue'] %} |
281 {% if setter.is_raises_exception %} | |
282 {% set setter_arguments = setter_arguments + ['exceptionState'] %} | |
283 {% endif %} | |
253 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); | 284 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); |
254 {% if setter.is_raises_exception %} | 285 {% if setter.is_raises_exception %} |
255 if (exceptionState.throwIfNeeded()) | 286 if (exceptionState.throwIfNeeded()) |
256 return; | 287 return; |
257 {% endif %} | 288 {% endif %} |
258 if (!result) | 289 if (!result) |
259 return; | 290 return; |
260 v8SetReturnValue(info, v8Value); | 291 v8SetReturnValue(info, v8Value); |
261 } | 292 } |
262 | 293 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) | 366 static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) |
336 { | 367 { |
337 if (!name->IsString()) | 368 if (!name->IsString()) |
338 return; | 369 return; |
339 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 370 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
340 AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); | 371 AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); |
341 {% if deleter.is_raises_exception %} | 372 {% if deleter.is_raises_exception %} |
342 v8::String::Utf8Value namedProperty(name); | 373 v8::String::Utf8Value namedProperty(name); |
343 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedPropert y, "{{interface_name}}", info.Holder(), info.GetIsolate()); | 374 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedPropert y, "{{interface_name}}", info.Holder(), info.GetIsolate()); |
344 {% endif %} | 375 {% endif %} |
376 {% if deleter.is_call_with_script_state %} | |
377 {# [CallWith=ScriptState] #} | |
378 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | |
379 {% endif %} | |
345 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} | 380 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} |
346 {% set deleter_arguments = ['propertyName', 'exceptionState'] | 381 {% set deleter_arguments = ['scriptState', 'propertyName'] |
347 if deleter.is_raises_exception else ['propertyName'] %} | 382 if deleter.is_call_with_script_state else ['propertyName'] %} |
383 {% if deleter.is_raises_exception %} | |
384 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} | |
385 {% endif %} | |
348 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ' )}}); | 386 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ' )}}); |
349 {% if deleter.is_raises_exception %} | 387 {% if deleter.is_raises_exception %} |
350 if (exceptionState.throwIfNeeded()) | 388 if (exceptionState.throwIfNeeded()) |
351 return; | 389 return; |
352 {% endif %} | 390 {% endif %} |
353 if (result != DeleteUnknownProperty) | 391 if (result != DeleteUnknownProperty) |
354 return v8SetReturnValueBool(info, result == DeleteSuccess); | 392 return v8SetReturnValueBool(info, result == DeleteSuccess); |
355 } | 393 } |
356 | 394 |
357 {% endif %} | 395 {% endif %} |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
989 } | 1027 } |
990 | 1028 |
991 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} | 1029 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} |
992 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 1030 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
993 { | 1031 { |
994 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 1032 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
995 } | 1033 } |
996 {% endfor %} | 1034 {% endfor %} |
997 {% endif %} | 1035 {% endif %} |
998 {% endblock %} | 1036 {% endblock %} |
OLD | NEW |