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()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) | 54 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) |
55 { | 55 { |
56 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 56 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
57 {{setter.v8_value_to_local_cpp_value}}; | 57 {{setter.v8_value_to_local_cpp_value}}; |
58 {% if setter.has_exception_state %} | 58 {% if setter.has_exception_state %} |
59 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "{{inter
face_name}}", info.Holder(), info.GetIsolate()); | 59 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "{{inter
face_name}}", info.Holder(), info.GetIsolate()); |
60 {% endif %} | 60 {% endif %} |
61 {% if setter.has_type_checking_interface %} | 61 {% if setter.has_type_checking_interface %} |
62 {# Type checking for interface types (if interface not implemented, throw | 62 {# Type checking for interface types (if interface not implemented, throw |
63 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 63 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
64 if (!isUndefinedOrNull(v8Value) && !V8{{setter.idl_type}}::hasInstance(v8Val
ue, info.GetIsolate())) { | 64 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value)
{% endif %}) { |
65 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); | 65 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); |
66 exceptionState.throwIfNeeded(); | 66 exceptionState.throwIfNeeded(); |
67 return; | 67 return; |
68 } | 68 } |
69 {% endif %} | 69 {% endif %} |
70 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} | 70 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} |
71 {% set setter_arguments = ['index', 'propertyValue', 'exceptionState'] | 71 {% set setter_arguments = ['index', 'propertyValue', 'exceptionState'] |
72 if setter.is_raises_exception else ['index', 'propertyValue'] %} | 72 if setter.is_raises_exception else ['index', 'propertyValue'] %} |
73 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); | 73 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); |
74 {% if setter.is_raises_exception %} | 74 {% if setter.is_raises_exception %} |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 {% endif %} | 226 {% endif %} |
227 {% if setter.has_exception_state %} | 227 {% if setter.has_exception_state %} |
228 v8::String::Utf8Value namedProperty(nameString); | 228 v8::String::Utf8Value namedProperty(nameString); |
229 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 229 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
230 {% endif %} | 230 {% endif %} |
231 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 231 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
232 {# v8_value_to_local_cpp_value('DOMString', 'nameString', 'propertyName') #} | 232 {# v8_value_to_local_cpp_value('DOMString', 'nameString', 'propertyName') #} |
233 TOSTRING_VOID(V8StringResource<>, propertyName, nameString); | 233 TOSTRING_VOID(V8StringResource<>, propertyName, nameString); |
234 {{setter.v8_value_to_local_cpp_value}}; | 234 {{setter.v8_value_to_local_cpp_value}}; |
| 235 {% if setter.has_type_checking_interface %} |
| 236 {# Type checking for interface types (if interface not implemented, throw |
| 237 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 238 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value)
{% endif %}) { |
| 239 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); |
| 240 exceptionState.throwIfNeeded(); |
| 241 return; |
| 242 } |
| 243 {% endif %} |
235 {% set setter_name = setter.name or 'anonymousNamedSetter' %} | 244 {% set setter_name = setter.name or 'anonymousNamedSetter' %} |
236 {% set setter_arguments = | 245 {% set setter_arguments = |
237 ['propertyName', 'propertyValue', 'exceptionState'] | 246 ['propertyName', 'propertyValue', 'exceptionState'] |
238 if setter.is_raises_exception else | 247 if setter.is_raises_exception else |
239 ['propertyName', 'propertyValue'] %} | 248 ['propertyName', 'propertyValue'] %} |
240 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); | 249 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); |
241 {% if setter.is_raises_exception %} | 250 {% if setter.is_raises_exception %} |
242 if (exceptionState.throwIfNeeded()) | 251 if (exceptionState.throwIfNeeded()) |
243 return; | 252 return; |
244 {% endif %} | 253 {% endif %} |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 } | 979 } |
971 | 980 |
972 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 981 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
973 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 982 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
974 { | 983 { |
975 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 984 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
976 } | 985 } |
977 {% endfor %} | 986 {% endfor %} |
978 {% endif %} | 987 {% endif %} |
979 {% endblock %} | 988 {% endblock %} |
OLD | NEW |