| OLD | NEW |
| 1 {% extends 'interface_base.cpp.tmpl' %} | 1 {% extends 'interface_base.cpp.tmpl' %} |
| 2 | 2 |
| 3 {% set has_prepare_prototype_and_interface_object = | 3 {% set has_prepare_prototype_and_interface_object = |
| 4 unscopables or has_conditional_attributes_on_prototype or | 4 unscopables or has_conditional_attributes_on_prototype or |
| 5 methods | conditionally_exposed(is_partial) %} | 5 methods | conditionally_exposed(is_partial) %} |
| 6 {% set prepare_prototype_and_interface_object_func = | 6 {% set prepare_prototype_and_interface_object_func = |
| 7 '%s::preparePrototypeAndInterfaceObject' % v8_class | 7 '%s::preparePrototypeAndInterfaceObject' % v8_class |
| 8 if has_prepare_prototype_and_interface_object | 8 if has_prepare_prototype_and_interface_object |
| 9 else 'nullptr' %} | 9 else 'nullptr' %} |
| 10 | 10 |
| 11 | 11 |
| 12 {##############################################################################} | 12 {##############################################################################} |
| 13 {% block indexed_property_getter %} | 13 {% block indexed_property_getter %} |
| 14 {% if indexed_property_getter and not indexed_property_getter.is_custom %} | 14 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
| 15 {% set getter = indexed_property_getter %} | 15 {% set getter = indexed_property_getter %} |
| 16 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | 16 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) { |
| 17 { | 17 {% if getter.is_raises_exception %} |
| 18 {% if getter.is_raises_exception %} | 18 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter
Context, "{{interface_name}}"); |
| 19 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGett
erContext, "{{interface_name}}"); | 19 {% endif %} |
| 20 {% endif %} | |
| 21 | 20 |
| 22 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 21 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 23 | 22 |
| 24 // We assume that all the implementations support length() method, although | 23 // We assume that all the implementations support length() method, although |
| 25 // the spec doesn't require that length() must exist. It's okay that | 24 // the spec doesn't require that length() must exist. It's okay that |
| 26 // the interface does not have length attribute as long as the | 25 // the interface does not have length attribute as long as the |
| 27 // implementation supports length() member function. | 26 // implementation supports length() member function. |
| 28 if (index >= impl->length()) | 27 if (index >= impl->length()) |
| 29 return; // Returns undefined due to out-of-range. | 28 return; // Returns undefined due to out-of-range. |
| 30 | 29 |
| 31 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} | 30 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} |
| 32 {% set getter_arguments = ['index'] %} | 31 {% set getter_arguments = ['index'] %} |
| 33 {% if getter.is_call_with_script_state %} | 32 {% if getter.is_call_with_script_state %} |
| 34 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 33 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 35 {% set getter_arguments = ['scriptState'] + getter_arguments %} | 34 {% set getter_arguments = ['scriptState'] + getter_arguments %} |
| 36 {% endif %} | 35 {% endif %} |
| 37 {% if getter.is_raises_exception %} | 36 {% if getter.is_raises_exception %} |
| 38 {% set getter_arguments = getter_arguments + ['exceptionState'] %} | 37 {% set getter_arguments = getter_arguments + ['exceptionState'] %} |
| 39 {% endif %} | 38 {% endif %} |
| 40 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join
(', ')}}); | 39 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join('
, ')}}); |
| 41 {{getter.v8_set_return_value}}; | 40 {{getter.v8_set_return_value}}; |
| 42 } | 41 } |
| 43 | 42 |
| 44 {% endif %} | 43 {% endif %} |
| 45 {% endblock %} | 44 {% endblock %} |
| 46 | 45 |
| 47 | 46 |
| 48 {##############################################################################} | 47 {##############################################################################} |
| 49 {% block indexed_property_getter_callback %} | 48 {% block indexed_property_getter_callback %} |
| 50 {% if indexed_property_getter or named_property_getter %} | 49 {% if indexed_property_getter or named_property_getter %} |
| 51 {% set getter = indexed_property_getter or named_property_getter %} | 50 {% set getter = indexed_property_getter or named_property_getter %} |
| 52 void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInf
o<v8::Value>& info) | 51 void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInf
o<v8::Value>& info) { |
| 53 { | 52 {% if indexed_property_getter %} |
| 54 {% if indexed_property_getter %} | |
| 55 | 53 |
| 56 {% if getter.is_custom %} | 54 {% if getter.is_custom %} |
| 57 {{v8_class}}::indexedPropertyGetterCustom(index, info); | 55 {{v8_class}}::indexedPropertyGetterCustom(index, info); |
| 58 {% else %} | 56 {% else %} |
| 59 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); | 57 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); |
| 60 {% endif %} | 58 {% endif %} |
| 61 | 59 |
| 62 {% else %}{# otherwise, named property #} | 60 {% else %}{# otherwise, named property #} |
| 63 | 61 |
| 64 const AtomicString& propertyName = AtomicString::number(index); | 62 const AtomicString& propertyName = AtomicString::number(index); |
| 65 | 63 |
| 66 {% if getter.is_custom %} | 64 {% if getter.is_custom %} |
| 67 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); | 65 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); |
| 68 {% else %} | 66 {% else %} |
| 69 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); | 67 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); |
| 70 {% endif %} | 68 {% endif %} |
| 71 | 69 |
| 72 {% endif %}{# indexed_property_getter #} | 70 {% endif %}{# indexed_property_getter #} |
| 73 } | 71 } |
| 74 | 72 |
| 75 {% endif %} | 73 {% endif %} |
| 76 {% endblock %} | 74 {% endblock %} |
| 77 | 75 |
| 78 | 76 |
| 79 {##############################################################################} | 77 {##############################################################################} |
| 80 {% block indexed_property_setter %} | 78 {% block indexed_property_setter %} |
| 81 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} | 79 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} |
| 82 {% if indexed_property_setter and not indexed_property_setter.is_custom %} | 80 {% if indexed_property_setter and not indexed_property_setter.is_custom %} |
| 83 {% set setter = indexed_property_setter %} | 81 {% set setter = indexed_property_setter %} |
| 84 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) | 82 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 85 { | 83 {% if setter.has_exception_state %} |
| 86 {% if setter.has_exception_state %} | 84 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedSetter
Context, "{{interface_name}}"); |
| 87 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedSett
erContext, "{{interface_name}}"); | 85 {% endif %} |
| 88 {% endif %} | |
| 89 | 86 |
| 90 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 87 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 91 {{v8_value_to_local_cpp_value(setter) | indent}} | 88 {{v8_value_to_local_cpp_value(setter) | indent(2)}} |
| 92 {% if setter.has_type_checking_interface %} | 89 {% if setter.has_type_checking_interface %} |
| 93 {# Type checking for interface types (if interface not implemented, throw | 90 {# Type checking for interface types (if interface not implemented, throw |
| 94 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 91 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 95 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value)
{% endif %}) { | 92 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { |
| 96 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); | 93 exceptionState.throwTypeError("The provided value is not of type '{{setter.i
dl_type}}'."); |
| 97 return; | 94 return; |
| 98 } | 95 } |
| 99 {% endif %} | 96 {% endif %} |
| 100 | 97 |
| 101 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} | 98 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} |
| 102 {% set setter_arguments = ['index', 'propertyValue'] %} | 99 {% set setter_arguments = ['index', 'propertyValue'] %} |
| 103 {% if setter.is_call_with_script_state %} | 100 {% if setter.is_call_with_script_state %} |
| 104 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 101 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 105 {% set setter_arguments = ['scriptState'] + setter_arguments %} | 102 {% set setter_arguments = ['scriptState'] + setter_arguments %} |
| 106 {% endif %} | 103 {% endif %} |
| 107 {% if setter.is_raises_exception %} | 104 {% if setter.is_raises_exception %} |
| 108 {% set setter_arguments = setter_arguments + ['exceptionState'] %} | 105 {% set setter_arguments = setter_arguments + ['exceptionState'] %} |
| 109 {% endif %} | 106 {% endif %} |
| 110 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); | 107 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); |
| 111 {% if setter.is_raises_exception %} | 108 {% if setter.is_raises_exception %} |
| 112 if (exceptionState.hadException()) | 109 if (exceptionState.hadException()) |
| 113 return; | 110 return; |
| 114 {% endif %} | 111 {% endif %} |
| 115 if (!result) | 112 if (!result) |
| 116 return; | 113 return; |
| 117 v8SetReturnValue(info, v8Value); | 114 v8SetReturnValue(info, v8Value); |
| 118 } | 115 } |
| 119 | 116 |
| 120 {% endif %} | 117 {% endif %} |
| 121 {% endblock %} | 118 {% endblock %} |
| 122 | 119 |
| 123 | 120 |
| 124 {##############################################################################} | 121 {##############################################################################} |
| 125 {% block indexed_property_setter_callback %} | 122 {% block indexed_property_setter_callback %} |
| 126 {% if indexed_property_setter or named_property_setter %} | 123 {% if indexed_property_setter or named_property_setter %} |
| 127 {% set setter = indexed_property_setter or named_property_setter %} | 124 {% set setter = indexed_property_setter or named_property_setter %} |
| 128 void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) | 125 void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 129 { | 126 {% if setter.is_ce_reactions %} |
| 130 {% if setter.is_ce_reactions %} | 127 CEReactionsScope ceReactionsScope; |
| 131 CEReactionsScope ceReactionsScope; | 128 {% endif %} |
| 132 {% endif %} | |
| 133 | 129 |
| 134 {% if indexed_property_setter %} | 130 {% if indexed_property_setter %} |
| 135 | 131 |
| 136 {% if setter.is_custom %} | 132 {% if setter.is_custom %} |
| 137 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info); | 133 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info); |
| 138 {% else %} | 134 {% else %} |
| 139 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info); | 135 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info); |
| 140 {% endif %} | 136 {% endif %} |
| 141 | 137 |
| 142 {% else %}{# otherwise, named property #} | 138 {% else %}{# otherwise, named property #} |
| 143 | 139 |
| 144 const AtomicString& propertyName = AtomicString::number(index); | 140 const AtomicString& propertyName = AtomicString::number(index); |
| 145 | 141 |
| 146 {% if setter.is_custom %} | 142 {% if setter.is_custom %} |
| 147 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); | 143 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); |
| 148 {% else %} | 144 {% else %} |
| 149 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); | 145 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); |
| 150 {% endif %} | 146 {% endif %} |
| 151 | 147 |
| 152 {% endif %}{# indexed_property_setter #} | 148 {% endif %}{# indexed_property_setter #} |
| 153 } | 149 } |
| 154 | 150 |
| 155 {% endif %} | 151 {% endif %} |
| 156 {% endblock %} | 152 {% endblock %} |
| 157 | 153 |
| 158 | 154 |
| 159 {##############################################################################} | 155 {##############################################################################} |
| 160 {% block indexed_property_deleter %} | 156 {% block indexed_property_deleter %} |
| 161 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} | 157 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} |
| 162 {% set deleter = indexed_property_deleter %} | 158 {% set deleter = indexed_property_deleter %} |
| 163 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) | 159 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) { |
| 164 { | 160 {% if deleter.is_raises_exception %} |
| 165 {% if deleter.is_raises_exception %} | 161 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedDeleti
onContext, "{{interface_name}}"); |
| 166 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedDele
tionContext, "{{interface_name}}"); | 162 {% endif %} |
| 167 {% endif %} | |
| 168 | 163 |
| 169 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 164 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 170 | 165 |
| 171 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} | 166 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} |
| 172 {% set deleter_arguments = ['index'] %} | 167 {% set deleter_arguments = ['index'] %} |
| 173 {% if deleter.is_call_with_script_state %} | 168 {% if deleter.is_call_with_script_state %} |
| 174 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 169 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 175 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} | 170 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} |
| 176 {% endif %} | 171 {% endif %} |
| 177 {% if deleter.is_raises_exception %} | 172 {% if deleter.is_raises_exception %} |
| 178 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} | 173 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} |
| 179 {% endif %} | 174 {% endif %} |
| 180 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', '
)}}); | 175 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')}
}); |
| 181 {% if deleter.is_raises_exception %} | 176 {% if deleter.is_raises_exception %} |
| 182 if (exceptionState.hadException()) | 177 if (exceptionState.hadException()) |
| 183 return; | 178 return; |
| 184 {% endif %} | 179 {% endif %} |
| 185 if (result == DeleteUnknownProperty) | 180 if (result == DeleteUnknownProperty) |
| 186 return; | 181 return; |
| 187 v8SetReturnValue(info, result == DeleteSuccess); | 182 v8SetReturnValue(info, result == DeleteSuccess); |
| 188 } | 183 } |
| 189 | 184 |
| 190 {% endif %} | 185 {% endif %} |
| 191 {% endblock %} | 186 {% endblock %} |
| 192 | 187 |
| 193 | 188 |
| 194 {##############################################################################} | 189 {##############################################################################} |
| 195 {% block indexed_property_deleter_callback %} | 190 {% block indexed_property_deleter_callback %} |
| 196 {% if indexed_property_deleter or named_property_deleter %} | 191 {% if indexed_property_deleter or named_property_deleter %} |
| 197 {% set deleter = indexed_property_deleter or named_property_deleter %} | 192 {% set deleter = indexed_property_deleter or named_property_deleter %} |
| 198 void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackIn
fo<v8::Boolean>& info) | 193 void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackIn
fo<v8::Boolean>& info) { |
| 199 { | 194 {% if deleter.is_ce_reactions %} |
| 200 {% if deleter.is_ce_reactions %} | 195 CEReactionsScope ceReactionsScope; |
| 201 CEReactionsScope ceReactionsScope; | 196 {% endif %} |
| 202 {% endif %} | |
| 203 | 197 |
| 204 {% if indexed_property_deleter %} | 198 {% if indexed_property_deleter %} |
| 205 | 199 |
| 206 {% if deleter.is_custom %} | 200 {% if deleter.is_custom %} |
| 207 {{v8_class}}::indexedPropertyDeleterCustom(index, info); | 201 {{v8_class}}::indexedPropertyDeleterCustom(index, info); |
| 208 {% else %} | 202 {% else %} |
| 209 {{cpp_class}}V8Internal::indexedPropertyDeleter(index, info); | 203 {{cpp_class}}V8Internal::indexedPropertyDeleter(index, info); |
| 210 {% endif %} | 204 {% endif %} |
| 211 | 205 |
| 212 {% else %}{# otherwise, named property #} | 206 {% else %}{# otherwise, named property #} |
| 213 | 207 |
| 214 const AtomicString& propertyName = AtomicString::number(index); | 208 const AtomicString& propertyName = AtomicString::number(index); |
| 215 | 209 |
| 216 {% if deleter.is_custom %} | 210 {% if deleter.is_custom %} |
| 217 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info); | 211 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info); |
| 218 {% else %} | 212 {% else %} |
| 219 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info); | 213 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info); |
| 220 {% endif %} | 214 {% endif %} |
| 221 | 215 |
| 222 {% endif %}{# indexed_property_deleter #} | 216 {% endif %}{# indexed_property_deleter #} |
| 223 } | 217 } |
| 224 | 218 |
| 225 {% endif %} | 219 {% endif %} |
| 226 {% endblock %} | 220 {% endblock %} |
| 227 | 221 |
| 228 | 222 |
| 229 {##############################################################################} | 223 {##############################################################################} |
| 230 {% block named_property_getter %} | 224 {% block named_property_getter %} |
| 231 {% if named_property_getter and not named_property_getter.is_custom %} | 225 {% if named_property_getter and not named_property_getter.is_custom %} |
| 232 {% set getter = named_property_getter %} | 226 {% set getter = named_property_getter %} |
| 233 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall
backInfo<v8::Value>& info) | 227 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall
backInfo<v8::Value>& info) { |
| 234 { | 228 {% if getter.is_raises_exception %} |
| 235 {% if getter.is_raises_exception %} | 229 const CString& nameInUtf8 = name.utf8(); |
| 236 const CString& nameInUtf8 = name.utf8(); | 230 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext
, "{{interface_name}}", nameInUtf8.data()); |
| 237 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterConte
xt, "{{interface_name}}", nameInUtf8.data()); | 231 {% endif %} |
| 238 {% endif %} | 232 {% if getter.is_call_with_script_state %} |
| 239 {% if getter.is_call_with_script_state %} | 233 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 240 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 234 {% endif %} |
| 241 {% endif %} | |
| 242 | 235 |
| 243 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 236 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 244 {% if getter.use_output_parameter_for_result %} | 237 {% if getter.use_output_parameter_for_result %} |
| 245 {{getter.cpp_type}} result; | 238 {{getter.cpp_type}} result; |
| 246 {{getter.cpp_value}}; | 239 {{getter.cpp_value}}; |
| 247 {% else %} | 240 {% else %} |
| 248 {{getter.cpp_type}} result = {{getter.cpp_value}}; | 241 {{getter.cpp_type}} result = {{getter.cpp_value}}; |
| 249 {% endif %} | 242 {% endif %} |
| 250 if ({{getter.is_null_expression}}) | 243 if ({{getter.is_null_expression}}) |
| 251 return; | 244 return; |
| 252 {{getter.v8_set_return_value}}; | 245 {{getter.v8_set_return_value}}; |
| 253 } | 246 } |
| 254 | 247 |
| 255 {% endif %} | 248 {% endif %} |
| 256 {% endblock %} | 249 {% endblock %} |
| 257 | 250 |
| 258 | 251 |
| 259 {##############################################################################} | 252 {##############################################################################} |
| 260 {% block named_property_getter_callback %} | 253 {% block named_property_getter_callback %} |
| 261 {% if named_property_getter %} | 254 {% if named_property_getter %} |
| 262 {% set getter = named_property_getter %} | 255 {% set getter = named_property_getter %} |
| 263 void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCal
lbackInfo<v8::Value>& info) | 256 void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCal
lbackInfo<v8::Value>& info) { |
| 264 { | 257 if (!name->IsString()) |
| 265 if (!name->IsString()) | 258 return; |
| 266 return; | 259 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| 267 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>())
; | |
| 268 | 260 |
| 269 {% if getter.is_custom %} | 261 {% if getter.is_custom %} |
| 270 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); | 262 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); |
| 271 {% else %} | 263 {% else %} |
| 272 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); | 264 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); |
| 273 {% endif %} | 265 {% endif %} |
| 274 } | 266 } |
| 275 | 267 |
| 276 {% endif %} | 268 {% endif %} |
| 277 {% endblock %} | 269 {% endblock %} |
| 278 | 270 |
| 279 | 271 |
| 280 {##############################################################################} | 272 {##############################################################################} |
| 281 {% block named_property_setter %} | 273 {% block named_property_setter %} |
| 282 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} | 274 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} |
| 283 {% if named_property_setter and not named_property_setter.is_custom %} | 275 {% if named_property_setter and not named_property_setter.is_custom %} |
| 284 {% set setter = named_property_setter %} | 276 {% set setter = named_property_setter %} |
| 285 static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v
8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | 277 static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v
8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 286 { | 278 {% if setter.has_exception_state %} |
| 287 {% if setter.has_exception_state %} | 279 const CString& nameInUtf8 = name.utf8(); |
| 288 const CString& nameInUtf8 = name.utf8(); | 280 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext
, "{{interface_name}}", nameInUtf8.data()); |
| 289 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterConte
xt, "{{interface_name}}", nameInUtf8.data()); | 281 {% endif %} |
| 290 {% endif %} | 282 {% if setter.is_call_with_script_state %} |
| 291 {% if setter.is_call_with_script_state %} | 283 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 292 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 284 {% endif %} |
| 293 {% endif %} | |
| 294 | 285 |
| 295 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 286 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 296 {{v8_value_to_local_cpp_value(setter) | indent}} | 287 {{v8_value_to_local_cpp_value(setter) | indent(2)}} |
| 297 {% if setter.has_type_checking_interface %} | 288 {% if setter.has_type_checking_interface %} |
| 298 {# Type checking for interface types (if interface not implemented, throw | 289 {# Type checking for interface types (if interface not implemented, throw |
| 299 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 290 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 300 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value)
{% endif %}) { | 291 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { |
| 301 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); | 292 exceptionState.throwTypeError("The provided value is not of type '{{setter.i
dl_type}}'."); |
| 302 return; | 293 return; |
| 303 } | 294 } |
| 304 {% endif %} | 295 {% endif %} |
| 305 | 296 |
| 306 {% set setter_name = setter.name or 'anonymousNamedSetter' %} | 297 {% set setter_name = setter.name or 'anonymousNamedSetter' %} |
| 307 {% set setter_arguments = ['name', 'propertyValue'] %} | 298 {% set setter_arguments = ['name', 'propertyValue'] %} |
| 308 {% if setter.is_call_with_script_state %} | 299 {% if setter.is_call_with_script_state %} |
| 309 {% set setter_arguments = ['scriptState'] + setter_arguments %} | 300 {% set setter_arguments = ['scriptState'] + setter_arguments %} |
| 310 {% endif %} | 301 {% endif %} |
| 311 {% if setter.is_raises_exception %} | 302 {% if setter.is_raises_exception %} |
| 312 {% set setter_arguments = setter_arguments + ['exceptionState'] %} | 303 {% set setter_arguments = setter_arguments + ['exceptionState'] %} |
| 313 {% endif %} | 304 {% endif %} |
| 314 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); | 305 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); |
| 315 {% if setter.is_raises_exception %} | 306 {% if setter.is_raises_exception %} |
| 316 if (exceptionState.hadException()) | 307 if (exceptionState.hadException()) |
| 317 return; | 308 return; |
| 318 {% endif %} | 309 {% endif %} |
| 319 if (!result) | 310 if (!result) |
| 320 return; | 311 return; |
| 321 v8SetReturnValue(info, v8Value); | 312 v8SetReturnValue(info, v8Value); |
| 322 } | 313 } |
| 323 | 314 |
| 324 {% endif %} | 315 {% endif %} |
| 325 {% endblock %} | 316 {% endblock %} |
| 326 | 317 |
| 327 | 318 |
| 328 {##############################################################################} | 319 {##############################################################################} |
| 329 {% block named_property_setter_callback %} | 320 {% block named_property_setter_callback %} |
| 330 {% if named_property_setter %} | 321 {% if named_property_setter %} |
| 331 {% set setter = named_property_setter %} | 322 {% set setter = named_property_setter %} |
| 332 void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | 323 void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 333 { | 324 if (!name->IsString()) |
| 334 if (!name->IsString()) | 325 return; |
| 335 return; | 326 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| 336 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>())
; | |
| 337 | 327 |
| 338 {% if setter.is_ce_reactions %} | 328 {% if setter.is_ce_reactions %} |
| 339 CEReactionsScope ceReactionsScope; | 329 CEReactionsScope ceReactionsScope; |
| 340 {% endif %} | 330 {% endif %} |
| 341 | 331 |
| 342 {% if setter.is_custom %} | 332 {% if setter.is_custom %} |
| 343 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); | 333 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); |
| 344 {% else %} | 334 {% else %} |
| 345 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); | 335 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); |
| 346 {% endif %} | 336 {% endif %} |
| 347 } | 337 } |
| 348 | 338 |
| 349 {% endif %} | 339 {% endif %} |
| 350 {% endblock %} | 340 {% endblock %} |
| 351 | 341 |
| 352 | 342 |
| 353 {##############################################################################} | 343 {##############################################################################} |
| 354 {% block named_property_deleter %} | 344 {% block named_property_deleter %} |
| 355 {% if named_property_deleter and not named_property_deleter.is_custom %} | 345 {% if named_property_deleter and not named_property_deleter.is_custom %} |
| 356 {% set deleter = named_property_deleter %} | 346 {% set deleter = named_property_deleter %} |
| 357 static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) | 347 static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) { |
| 358 { | 348 {% if deleter.is_raises_exception %} |
| 359 {% if deleter.is_raises_exception %} | 349 const CString& nameInUtf8 = name.utf8(); |
| 360 const CString& nameInUtf8 = name.utf8(); | 350 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionConte
xt, "{{interface_name}}", nameInUtf8.data()); |
| 361 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionCon
text, "{{interface_name}}", nameInUtf8.data()); | 351 {% endif %} |
| 362 {% endif %} | 352 {% if deleter.is_call_with_script_state %} |
| 363 {% if deleter.is_call_with_script_state %} | 353 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 364 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 354 {% endif %} |
| 365 {% endif %} | |
| 366 | 355 |
| 367 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 356 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 368 | 357 |
| 369 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} | 358 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} |
| 370 {% set deleter_arguments = ['name'] %} | 359 {% set deleter_arguments = ['name'] %} |
| 371 {% if deleter.is_call_with_script_state %} | 360 {% if deleter.is_call_with_script_state %} |
| 372 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} | 361 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} |
| 373 {% endif %} | 362 {% endif %} |
| 374 {% if deleter.is_raises_exception %} | 363 {% if deleter.is_raises_exception %} |
| 375 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} | 364 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} |
| 376 {% endif %} | 365 {% endif %} |
| 377 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', '
)}}); | 366 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')}
}); |
| 378 {% if deleter.is_raises_exception %} | 367 {% if deleter.is_raises_exception %} |
| 379 if (exceptionState.hadException()) | 368 if (exceptionState.hadException()) |
| 380 return; | 369 return; |
| 381 {% endif %} | 370 {% endif %} |
| 382 if (result == DeleteUnknownProperty) | 371 if (result == DeleteUnknownProperty) |
| 383 return; | 372 return; |
| 384 v8SetReturnValue(info, result == DeleteSuccess); | 373 v8SetReturnValue(info, result == DeleteSuccess); |
| 385 } | 374 } |
| 386 | 375 |
| 387 {% endif %} | 376 {% endif %} |
| 388 {% endblock %} | 377 {% endblock %} |
| 389 | 378 |
| 390 | 379 |
| 391 {##############################################################################} | 380 {##############################################################################} |
| 392 {% block named_property_deleter_callback %} | 381 {% block named_property_deleter_callback %} |
| 393 {% if named_property_deleter %} | 382 {% if named_property_deleter %} |
| 394 {% set deleter = named_property_deleter %} | 383 {% set deleter = named_property_deleter %} |
| 395 void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCa
llbackInfo<v8::Boolean>& info) | 384 void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCa
llbackInfo<v8::Boolean>& info) { |
| 396 { | 385 if (!name->IsString()) |
| 397 if (!name->IsString()) | 386 return; |
| 398 return; | 387 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| 399 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>())
; | |
| 400 | 388 |
| 401 {% if deleter.is_ce_reactions %} | 389 {% if deleter.is_ce_reactions %} |
| 402 CEReactionsScope ceReactionsScope; | 390 CEReactionsScope ceReactionsScope; |
| 403 {% endif %} | 391 {% endif %} |
| 404 | 392 |
| 405 {% if deleter.is_custom %} | 393 {% if deleter.is_custom %} |
| 406 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info); | 394 {{v8_class}}::namedPropertyDeleterCustom(propertyName, info); |
| 407 {% else %} | 395 {% else %} |
| 408 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info); | 396 {{cpp_class}}V8Internal::namedPropertyDeleter(propertyName, info); |
| 409 {% endif %} | 397 {% endif %} |
| 410 } | 398 } |
| 411 | 399 |
| 412 {% endif %} | 400 {% endif %} |
| 413 {% endblock %} | 401 {% endblock %} |
| 414 | 402 |
| 415 | 403 |
| 416 {##############################################################################} | 404 {##############################################################################} |
| 417 {% block named_property_query %} | 405 {% block named_property_query %} |
| 418 {% if named_property_getter and named_property_getter.is_enumerable and | 406 {% if named_property_getter and named_property_getter.is_enumerable and |
| 419 not named_property_getter.is_custom_property_query %} | 407 not named_property_getter.is_custom_property_query %} |
| 420 {% set getter = named_property_getter %} | 408 {% set getter = named_property_getter %} |
| 421 {# If there is an enumerator, there MUST be a query method to properly | 409 {# If there is an enumerator, there MUST be a query method to properly |
| 422 communicate property attributes. #} | 410 communicate property attributes. #} |
| 423 static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb
ackInfo<v8::Integer>& info) | 411 static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb
ackInfo<v8::Integer>& info) { |
| 424 { | 412 const CString& nameInUtf8 = name.utf8(); |
| 425 const CString& nameInUtf8 = name.utf8(); | 413 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext
, "{{interface_name}}", nameInUtf8.data()); |
| 426 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterConte
xt, "{{interface_name}}", nameInUtf8.data()); | 414 {% if getter.is_call_with_script_state %} |
| 427 {% if getter.is_call_with_script_state %} | 415 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 428 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 416 {% endif %} |
| 429 {% endif %} | |
| 430 | 417 |
| 431 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 418 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 432 | 419 |
| 433 {% set getter_arguments = ['name', 'exceptionState'] %} | 420 {% set getter_arguments = ['name', 'exceptionState'] %} |
| 434 {% if getter.is_call_with_script_state %} | 421 {% if getter.is_call_with_script_state %} |
| 435 {% set getter_arguments = ['scriptState'] + getter_arguments %} | 422 {% set getter_arguments = ['scriptState'] + getter_arguments %} |
| 436 {% endif %} | 423 {% endif %} |
| 437 bool result = impl->namedPropertyQuery({{getter_arguments | join(', ')}}); | 424 bool result = impl->namedPropertyQuery({{getter_arguments | join(', ')}}); |
| 438 if (!result) | 425 if (!result) |
| 439 return; | 426 return; |
| 440 v8SetReturnValueInt(info, v8::None); | 427 v8SetReturnValueInt(info, v8::None); |
| 441 } | 428 } |
| 442 | 429 |
| 443 {% endif %} | 430 {% endif %} |
| 444 {% endblock %} | 431 {% endblock %} |
| 445 | 432 |
| 446 | 433 |
| 447 {##############################################################################} | 434 {##############################################################################} |
| 448 {% block named_property_query_callback %} | 435 {% block named_property_query_callback %} |
| 449 {% if named_property_getter and named_property_getter.is_enumerable %} | 436 {% if named_property_getter and named_property_getter.is_enumerable %} |
| 450 {% set getter = named_property_getter %} | 437 {% set getter = named_property_getter %} |
| 451 void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCall
backInfo<v8::Integer>& info) | 438 void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCall
backInfo<v8::Integer>& info) { |
| 452 { | 439 if (!name->IsString()) |
| 453 if (!name->IsString()) | 440 return; |
| 454 return; | 441 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| 455 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>())
; | |
| 456 | 442 |
| 457 {% if getter.is_custom_property_query %} | 443 {% if getter.is_custom_property_query %} |
| 458 {{v8_class}}::namedPropertyQueryCustom(propertyName, info); | 444 {{v8_class}}::namedPropertyQueryCustom(propertyName, info); |
| 459 {% else %} | 445 {% else %} |
| 460 {{cpp_class}}V8Internal::namedPropertyQuery(propertyName, info); | 446 {{cpp_class}}V8Internal::namedPropertyQuery(propertyName, info); |
| 461 {% endif %} | 447 {% endif %} |
| 462 } | 448 } |
| 463 | 449 |
| 464 {% endif %} | 450 {% endif %} |
| 465 {% endblock %} | 451 {% endblock %} |
| 466 | 452 |
| 467 | 453 |
| 468 {##############################################################################} | 454 {##############################################################################} |
| 469 {% block named_property_enumerator %} | 455 {% block named_property_enumerator %} |
| 470 {% if named_property_getter and named_property_getter.is_enumerable and | 456 {% if named_property_getter and named_property_getter.is_enumerable and |
| 471 not named_property_getter.is_custom_property_enumerator %} | 457 not named_property_getter.is_custom_property_enumerator %} |
| 472 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | 458 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) { |
| 473 { | 459 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::EnumerationCo
ntext, "{{interface_name}}"); |
| 474 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::Enumeration
Context, "{{interface_name}}"); | |
| 475 | 460 |
| 476 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 461 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 477 | 462 |
| 478 Vector<String> names; | 463 Vector<String> names; |
| 479 impl->namedPropertyEnumerator(names, exceptionState); | 464 impl->namedPropertyEnumerator(names, exceptionState); |
| 480 if (exceptionState.hadException()) | 465 if (exceptionState.hadException()) |
| 481 return; | 466 return; |
| 482 v8SetReturnValue(info, toV8(names, info.Holder(), info.GetIsolate()).As<v8::
Array>()); | 467 v8SetReturnValue(info, toV8(names, info.Holder(), info.GetIsolate()).As<v8::Ar
ray>()); |
| 483 } | 468 } |
| 484 | 469 |
| 485 {% endif %} | 470 {% endif %} |
| 486 {% endblock %} | 471 {% endblock %} |
| 487 | 472 |
| 488 | 473 |
| 489 {##############################################################################} | 474 {##############################################################################} |
| 490 {% block named_property_enumerator_callback %} | 475 {% block named_property_enumerator_callback %} |
| 491 {% if named_property_getter and named_property_getter.is_enumerable %} | 476 {% if named_property_getter and named_property_getter.is_enumerable %} |
| 492 {% set getter = named_property_getter %} | 477 {% set getter = named_property_getter %} |
| 493 void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>&
info) | 478 void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>&
info) { |
| 494 { | 479 {% if getter.is_custom_property_enumerator %} |
| 495 {% if getter.is_custom_property_enumerator %} | 480 {{v8_class}}::namedPropertyEnumeratorCustom(info); |
| 496 {{v8_class}}::namedPropertyEnumeratorCustom(info); | 481 {% else %} |
| 497 {% else %} | 482 {{cpp_class}}V8Internal::namedPropertyEnumerator(info); |
| 498 {{cpp_class}}V8Internal::namedPropertyEnumerator(info); | 483 {% endif %} |
| 499 {% endif %} | |
| 500 } | 484 } |
| 501 | 485 |
| 502 {% endif %} | 486 {% endif %} |
| 503 {% endblock %} | 487 {% endblock %} |
| 504 | 488 |
| 505 | 489 |
| 506 {##############################################################################} | 490 {##############################################################################} |
| 507 {% block origin_safe_method_setter %} | 491 {% block origin_safe_method_setter %} |
| 508 {% if has_origin_safe_method_setter %} | 492 {% if has_origin_safe_method_setter %} |
| 509 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo
cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | 493 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo
cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { |
| 510 { | 494 if (!name->IsString()) |
| 511 if (!name->IsString()) | 495 return; |
| 512 return; | 496 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info
.Holder(), info.GetIsolate()); |
| 513 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in
fo.Holder(), info.GetIsolate()); | 497 if (holder.IsEmpty()) |
| 514 if (holder.IsEmpty()) | 498 return; |
| 515 return; | 499 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 516 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 500 v8::String::Utf8Value attributeName(name); |
| 517 v8::String::Utf8Value attributeName(name); | 501 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "
{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 518 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 502 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, exceptionState)) { |
| 519 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), impl, exceptionState)) { | 503 return; |
| 520 return; | 504 } |
| 521 } | |
| 522 | 505 |
| 523 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.Holder() is an Object. #} | 506 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand
le if info.Holder() is an Object. #} |
| 524 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::L
ocal<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value); | 507 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::Loc
al<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value); |
| 525 } | 508 } |
| 526 | 509 |
| 527 void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name, v8::L
ocal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | 510 void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name, v8::L
ocal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { |
| 528 { | 511 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in
fo); |
| 529 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value,
info); | |
| 530 } | 512 } |
| 531 | 513 |
| 532 {% endif %} | 514 {% endif %} |
| 533 {% endblock %} | 515 {% endblock %} |
| 534 | 516 |
| 535 | 517 |
| 536 {##############################################################################} | 518 {##############################################################################} |
| 537 {% block named_constructor %} | 519 {% block named_constructor %} |
| 538 {% from 'methods.cpp.tmpl' import generate_constructor with context %} | 520 {% from 'methods.cpp.tmpl' import generate_constructor with context %} |
| 539 {% if named_constructor %} | 521 {% if named_constructor %} |
| 540 {% set active_scriptwrappable_inheritance = | 522 {% set active_scriptwrappable_inheritance = |
| 541 'InheritFromActiveScriptWrappable' | 523 'InheritFromActiveScriptWrappable' |
| 542 if active_scriptwrappable else | 524 if active_scriptwrappable else |
| 543 'NotInheritFromActiveScriptWrappable' %} | 525 'NotInheritFromActiveScriptWrappable' %} |
| 544 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial | 526 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial |
| 545 // and does not depend on another global objects. | 527 // and does not depend on another global objects. |
| 546 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 528 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| 547 #pragma clang diagnostic push | 529 #pragma clang diagnostic push |
| 548 #pragma clang diagnostic ignored "-Wglobal-constructors" | 530 #pragma clang diagnostic ignored "-Wglobal-constructors" |
| 549 #endif | 531 #endif |
| 550 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde
rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::trace, {{v8_class}}:
:traceWrappers, 0, {{prepare_prototype_and_interface_object_func}}, "{{interface
_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::{{wra
pper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inheritance}}, Wrappe
rTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifetime}} }; | 532 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde
rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::trace, {{v8_class}}:
:traceWrappers, 0, {{prepare_prototype_and_interface_object_func}}, "{{interface
_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::{{wra
pper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inheritance}}, Wrappe
rTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifetime}} }; |
| 551 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 533 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| 552 #pragma clang diagnostic pop | 534 #pragma clang diagnostic pop |
| 553 #endif | 535 #endif |
| 554 | 536 |
| 555 {{generate_constructor(named_constructor)}} | 537 {{generate_constructor(named_constructor)}} |
| 556 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate
* isolate, const DOMWrapperWorld& world) | 538 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate
* isolate, const DOMWrapperWorld& world) { |
| 557 { | 539 static int domTemplateKey; // This address is used for a key to look up the do
m template. |
| 558 static int domTemplateKey; // This address is used for a key to look up the
dom template. | 540 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 559 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 541 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d
omTemplateKey); |
| 560 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world,
&domTemplateKey); | 542 if (!result.IsEmpty()) |
| 561 if (!result.IsEmpty()) | 543 return result; |
| 562 return result; | |
| 563 | 544 |
| 564 result = v8::FunctionTemplate::New(isolate, {{v8_class}}ConstructorCallback)
; | 545 result = v8::FunctionTemplate::New(isolate, {{v8_class}}ConstructorCallback); |
| 565 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 546 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
| 566 instanceTemplate->SetInternalFieldCount({{v8_class}}::internalFieldCount); | 547 instanceTemplate->SetInternalFieldCount({{v8_class}}::internalFieldCount); |
| 567 result->SetClassName(v8AtomicString(isolate, "{{cpp_class}}")); | 548 result->SetClassName(v8AtomicString(isolate, "{{cpp_class}}")); |
| 568 result->Inherit({{v8_class}}::domTemplate(isolate, world)); | 549 result->Inherit({{v8_class}}::domTemplate(isolate, world)); |
| 569 data->setInterfaceTemplate(world, &domTemplateKey, result); | 550 data->setInterfaceTemplate(world, &domTemplateKey, result); |
| 570 return result; | 551 return result; |
| 571 } | 552 } |
| 572 | 553 |
| 573 {% endif %} | 554 {% endif %} |
| 574 {% endblock %} | 555 {% endblock %} |
| 575 | 556 |
| 576 {##############################################################################} | 557 {##############################################################################} |
| 577 {% block overloaded_constructor %} | 558 {% block overloaded_constructor %} |
| 578 {% if constructor_overloads %} | 559 {% if constructor_overloads %} |
| 579 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 560 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 580 { | 561 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionC
ontext, "{{interface_name}}"); |
| 581 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::Constructio
nContext, "{{interface_name}}"); | 562 {# 2. Initialize argcount to be min(maxarg, n). #} |
| 582 {# 2. Initialize argcount to be min(maxarg, n). #} | 563 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { |
| 583 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { | |
| 584 {# 3. Remove from S all entries whose type list is not of length argcount. #
} | 564 {# 3. Remove from S all entries whose type list is not of length argcount. #
} |
| 585 {% for length, tests_constructors in constructor_overloads.length_tests_meth
ods %} | 565 {% for length, tests_constructors in constructor_overloads.length_tests_meth
ods %} |
| 586 case {{length}}: | 566 case {{length}}: |
| 587 {# Then resolve by testing argument #} | 567 {# Then resolve by testing argument #} |
| 588 {% for test, constructor in tests_constructors %} | 568 {% for test, constructor in tests_constructors %} |
| 589 {# 10. If i = d, then: #} | 569 {# 10. If i = d, then: #} |
| 590 if ({{test}}) { | 570 if ({{test}}) { |
| 591 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(i
nfo); | 571 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(info)
; |
| 592 return; | 572 return; |
| 593 } | 573 } |
| 594 {% endfor %} | 574 {% endfor %} |
| 595 break; | 575 break; |
| 596 {% endfor %} | 576 {% endfor %} |
| 597 default: | 577 default: |
| 598 {# Invalid arity, throw error #} | 578 {# Invalid arity, throw error #} |
| 599 {# Report full list of valid arities if gaps and above minimum #} | 579 {# Report full list of valid arities if gaps and above minimum #} |
| 600 {% if constructor_overloads.valid_arities %} | 580 {% if constructor_overloads.valid_arities %} |
| 601 if (info.Length() >= {{constructor_overloads.length}}) { | 581 if (info.Length() >= {{constructor_overloads.length}}) { |
| 602 exceptionState.throwTypeError(ExceptionMessages::invalidArity("{{con
structor_overloads.valid_arities}}", info.Length())); | 582 exceptionState.throwTypeError(ExceptionMessages::invalidArity("{{constru
ctor_overloads.valid_arities}}", info.Length())); |
| 603 return; | |
| 604 } | |
| 605 {% endif %} | |
| 606 {# Otherwise just report "not enough arguments" #} | |
| 607 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{co
nstructor_overloads.length}}, info.Length())); | |
| 608 return; | 583 return; |
| 609 } | 584 } |
| 610 {# No match, throw error #} | 585 {% endif %} |
| 611 exceptionState.throwTypeError("No matching constructor signature."); | 586 {# Otherwise just report "not enough arguments" #} |
| 587 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{cons
tructor_overloads.length}}, info.Length())); |
| 588 return; |
| 589 } |
| 590 {# No match, throw error #} |
| 591 exceptionState.throwTypeError("No matching constructor signature."); |
| 612 } | 592 } |
| 613 | 593 |
| 614 {% endif %} | 594 {% endif %} |
| 615 {% endblock %} | 595 {% endblock %} |
| 616 | 596 |
| 617 | 597 |
| 618 {##############################################################################} | 598 {##############################################################################} |
| 619 {% block visit_dom_wrapper %} | 599 {% block visit_dom_wrapper %} |
| 620 {% if has_visit_dom_wrapper %} | 600 {% if has_visit_dom_wrapper %} |
| 621 void {{v8_class}}::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* script
Wrappable, const v8::Persistent<v8::Object>& wrapper) | 601 void {{v8_class}}::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* script
Wrappable, const v8::Persistent<v8::Object>& wrapper) { |
| 622 { | 602 {% if has_visit_dom_wrapper_custom %} |
| 623 {% if has_visit_dom_wrapper_custom %} | 603 {{v8_class}}::visitDOMWrapperCustom(isolate, scriptWrappable, wrapper); |
| 624 {{v8_class}}::visitDOMWrapperCustom(isolate, scriptWrappable, wrapper); | 604 {% endif %} |
| 625 {% endif %} | 605 {% if set_wrapper_reference_to or set_wrapper_reference_from %} |
| 626 {% if set_wrapper_reference_to or set_wrapper_reference_from %} | 606 {{cpp_class}}* impl = scriptWrappable->toImpl<{{cpp_class}}>(); |
| 627 {{cpp_class}}* impl = scriptWrappable->toImpl<{{cpp_class}}>(); | 607 {% endif %} |
| 628 {% endif %} | 608 {% if set_wrapper_reference_to %} |
| 629 {% if set_wrapper_reference_to %} | 609 {{set_wrapper_reference_to.cpp_type}} {{set_wrapper_reference_to.name}} = impl
->{{set_wrapper_reference_to.name}}(); |
| 630 {{set_wrapper_reference_to.cpp_type}} {{set_wrapper_reference_to.name}} = im
pl->{{set_wrapper_reference_to.name}}(); | 610 if ({{set_wrapper_reference_to.name}}) { |
| 631 if ({{set_wrapper_reference_to.name}}) { | 611 DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, {{set_wrapper_refe
rence_to.name}}, isolate); |
| 632 DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, {{set_wrapper_
reference_to.name}}, isolate); | 612 } |
| 633 } | 613 {% endif %} |
| 634 {% endif %} | 614 {% if set_wrapper_reference_from %} |
| 635 {% if set_wrapper_reference_from %} | 615 // The {{set_wrapper_reference_from}}() method may return a reference or a poi
nter. |
| 636 // The {{set_wrapper_reference_from}}() method may return a reference or a p
ointer. | 616 if (Node* owner = WTF::getPtr(impl->{{set_wrapper_reference_from}}())) { |
| 637 if (Node* owner = WTF::getPtr(impl->{{set_wrapper_reference_from}}())) { | 617 Node* root = V8GCController::opaqueRootForGC(isolate, owner); |
| 638 Node* root = V8GCController::opaqueRootForGC(isolate, owner); | 618 isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(root)
), wrapper); |
| 639 isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(r
oot)), wrapper); | 619 return; |
| 640 return; | 620 } |
| 641 } | 621 {% endif %} |
| 642 {% endif %} | |
| 643 } | 622 } |
| 644 | 623 |
| 645 {% endif %} | 624 {% endif %} |
| 646 {% endblock %} | 625 {% endblock %} |
| 647 | 626 |
| 648 | 627 |
| 649 {##############################################################################} | 628 {##############################################################################} |
| 650 {% block constructor_callback %} | 629 {% block constructor_callback %} |
| 651 {% if constructors or has_custom_constructor or has_event_constructor or has_htm
l_constructor %} | 630 {% if constructors or has_custom_constructor or has_event_constructor or has_htm
l_constructor %} |
| 652 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>
& info) | 631 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>
& info) { |
| 653 { | 632 {% if measure_as %} |
| 654 {% if measure_as %} | 633 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionContext
(info.GetIsolate()), UseCounter::{{measure_as('Constructor')}}); |
| 655 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte
xt(info.GetIsolate()), UseCounter::{{measure_as('Constructor')}}); | 634 {% endif %} |
| 656 {% endif %} | 635 if (!info.IsConstructCall()) { |
| 657 if (!info.IsConstructCall()) { | 636 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const
ructorNotCallableAsFunction("{{interface_name}}")); |
| 658 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::c
onstructorNotCallableAsFunction("{{interface_name}}")); | 637 return; |
| 659 return; | 638 } |
| 660 } | |
| 661 | 639 |
| 662 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis
tingObject) { | 640 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExisti
ngObject) { |
| 663 v8SetReturnValue(info, info.Holder()); | 641 v8SetReturnValue(info, info.Holder()); |
| 664 return; | 642 return; |
| 665 } | 643 } |
| 666 | 644 |
| 667 {% if has_custom_constructor %} | 645 {% if has_custom_constructor %} |
| 668 {{v8_class}}::constructorCustom(info); | 646 {{v8_class}}::constructorCustom(info); |
| 669 {% elif has_html_constructor %} | 647 {% elif has_html_constructor %} |
| 670 V8HTMLConstructor::htmlConstructor(info, {{v8_class}}::wrapperTypeInfo, HTML
ElementType::k{{interface_name}}); | 648 V8HTMLConstructor::htmlConstructor(info, {{v8_class}}::wrapperTypeInfo, HTMLEl
ementType::k{{interface_name}}); |
| 671 {% else %} | 649 {% else %} |
| 672 {{cpp_class}}V8Internal::constructor(info); | 650 {{cpp_class}}V8Internal::constructor(info); |
| 673 {% endif %} | 651 {% endif %} |
| 674 } | 652 } |
| 675 | 653 |
| 676 {% endif %} | 654 {% endif %} |
| 677 {% endblock %} | 655 {% endblock %} |
| 678 | 656 |
| 679 | 657 |
| 680 {##############################################################################} | 658 {##############################################################################} |
| 681 {% macro install_do_not_check_security_method(method, world_suffix, instance_tem
plate, prototype_template) %} | 659 {% macro install_do_not_check_security_method(method, world_suffix, instance_tem
plate, prototype_template) %} |
| 682 {% from 'utilities.cpp.tmpl' import property_location %} | 660 {% from 'utilities.cpp.tmpl' import property_location %} |
| 683 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are | 661 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 'static_cast<v8::PropertyHandlerFlags>(%s)' % | 741 'static_cast<v8::PropertyHandlerFlags>(%s)' % |
| 764 ' | '.join(property_handler_flags_list) %} | 742 ' | '.join(property_handler_flags_list) %} |
| 765 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert
y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_
callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal
lback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); | 743 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert
y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_
callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal
lback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); |
| 766 {{target}}->SetHandler(namedPropertyHandlerConfig); | 744 {{target}}->SetHandler(namedPropertyHandlerConfig); |
| 767 {%- endmacro %} | 745 {%- endmacro %} |
| 768 | 746 |
| 769 | 747 |
| 770 {##############################################################################} | 748 {##############################################################################} |
| 771 {% block get_dom_template %} | 749 {% block get_dom_template %} |
| 772 {% if not is_array_buffer_or_view %} | 750 {% if not is_array_buffer_or_view %} |
| 773 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate,
const DOMWrapperWorld& world) | 751 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate,
const DOMWrapperWorld& world) { |
| 774 { | 752 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class,
v8_class) if has_partial_interface else 'install%sTemplate' % v8_class %} |
| 775 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class
, v8_class) if has_partial_interface else 'install%sTemplate' % v8_class %} | 753 return V8DOMConfiguration::domClassTemplate(isolate, world, const_cast<Wrapper
TypeInfo*>(&wrapperTypeInfo), {{installTemplateFunction}}); |
| 776 return V8DOMConfiguration::domClassTemplate(isolate, world, const_cast<Wrapp
erTypeInfo*>(&wrapperTypeInfo), {{installTemplateFunction}}); | |
| 777 } | 754 } |
| 778 | 755 |
| 779 {% endif %} | 756 {% endif %} |
| 780 {% endblock %} | 757 {% endblock %} |
| 781 | 758 |
| 782 | 759 |
| 783 {##############################################################################} | 760 {##############################################################################} |
| 784 {% block get_dom_template_for_named_properties_object %} | 761 {% block get_dom_template_for_named_properties_object %} |
| 785 {% if has_named_properties_object %} | 762 {% if has_named_properties_object %} |
| 786 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplateForNamedPropertiesObjec
t(v8::Isolate* isolate, const DOMWrapperWorld& world) | 763 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplateForNamedPropertiesObjec
t(v8::Isolate* isolate, const DOMWrapperWorld& world) { |
| 787 { | 764 v8::Local<v8::FunctionTemplate> parentTemplate = V8{{parent_interface}}::domTe
mplate(isolate, world); |
| 788 v8::Local<v8::FunctionTemplate> parentTemplate = V8{{parent_interface}}::dom
Template(isolate, world); | |
| 789 | 765 |
| 790 v8::Local<v8::FunctionTemplate> namedPropertiesObjectFunctionTemplate = v8::
FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode); | 766 v8::Local<v8::FunctionTemplate> namedPropertiesObjectFunctionTemplate = v8::Fu
nctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode); |
| 791 namedPropertiesObjectFunctionTemplate->SetClassName(v8AtomicString(isolate,
"{{interface_name}}Properties")); | 767 namedPropertiesObjectFunctionTemplate->SetClassName(v8AtomicString(isolate, "{
{interface_name}}Properties")); |
| 792 namedPropertiesObjectFunctionTemplate->Inherit(parentTemplate); | 768 namedPropertiesObjectFunctionTemplate->Inherit(parentTemplate); |
| 793 | 769 |
| 794 v8::Local<v8::ObjectTemplate> namedPropertiesObjectTemplate = namedPropertie
sObjectFunctionTemplate->PrototypeTemplate(); | 770 v8::Local<v8::ObjectTemplate> namedPropertiesObjectTemplate = namedPropertiesO
bjectFunctionTemplate->PrototypeTemplate(); |
| 795 namedPropertiesObjectTemplate->SetInternalFieldCount({{v8_class}}::internalF
ieldCount); | 771 namedPropertiesObjectTemplate->SetInternalFieldCount({{v8_class}}::internalFie
ldCount); |
| 796 V8DOMConfiguration::setClassString(isolate, namedPropertiesObjectTemplate, "
{{interface_name}}Properties"); | 772 V8DOMConfiguration::setClassString(isolate, namedPropertiesObjectTemplate, "{{
interface_name}}Properties"); |
| 797 {{install_named_property_handler('namedPropertiesObjectTemplate') | indent}} | 773 {{install_named_property_handler('namedPropertiesObjectTemplate') | indent(2)}
} |
| 798 | 774 |
| 799 return namedPropertiesObjectFunctionTemplate; | 775 return namedPropertiesObjectFunctionTemplate; |
| 800 } | 776 } |
| 801 | 777 |
| 802 {% endif %} | 778 {% endif %} |
| 803 {% endblock %} | 779 {% endblock %} |
| 804 | 780 |
| 805 | 781 |
| 806 {##############################################################################} | 782 {##############################################################################} |
| 807 {% block has_instance %} | 783 {% block has_instance %} |
| 808 {% if not is_array_buffer_or_view %} | 784 {% if not is_array_buffer_or_view %} |
| 809 | 785 |
| 810 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat
e) | 786 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat
e) { |
| 811 { | 787 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value)
; |
| 812 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
| 813 } | 788 } |
| 814 | 789 |
| 815 v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
alue> v8Value, v8::Isolate* isolate) | 790 v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
alue> v8Value, v8::Isolate* isolate) { |
| 816 { | 791 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperT
ypeInfo, v8Value); |
| 817 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
| 818 } | 792 } |
| 819 | 793 |
| 820 {% endif %} | 794 {% endif %} |
| 821 {% endblock %} | 795 {% endblock %} |
| 822 | 796 |
| 823 | 797 |
| 824 {##############################################################################} | 798 {##############################################################################} |
| 825 {% block to_impl %} | 799 {% block to_impl %} |
| 826 {% if interface_name == 'ArrayBuffer' or interface_name == 'SharedArrayBuffer' %
} | 800 {% if interface_name == 'ArrayBuffer' or interface_name == 'SharedArrayBuffer' %
} |
| 827 {{cpp_class}}* V8{{interface_name}}::toImpl(v8::Local<v8::Object> object) | 801 {{cpp_class}}* V8{{interface_name}}::toImpl(v8::Local<v8::Object> object) { |
| 828 { | 802 DCHECK(object->Is{{interface_name}}()); |
| 829 ASSERT(object->Is{{interface_name}}()); | 803 v8::Local<v8::{{interface_name}}> v8buffer = object.As<v8::{{interface_name}}>
(); |
| 830 v8::Local<v8::{{interface_name}}> v8buffer = object.As<v8::{{interface_name}
}>(); | 804 if (v8buffer->IsExternal()) { |
| 831 if (v8buffer->IsExternal()) { | 805 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
| 832 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); | 806 CHECK(wrapperTypeInfo); |
| 833 RELEASE_ASSERT(wrapperTypeInfo); | 807 CHECK_EQ(wrapperTypeInfo->ginEmbedder, gin::kEmbedderBlink); |
| 834 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); | 808 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); |
| 835 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); | 809 } |
| 836 } | |
| 837 | 810 |
| 838 // Transfer the ownership of the allocated memory to an {{interface_name}} w
ithout | 811 // Transfer the ownership of the allocated memory to an {{interface_name}} wit
hout |
| 839 // copying. | 812 // copying. |
| 840 v8::{{interface_name}}::Contents v8Contents = v8buffer->Externalize(); | 813 v8::{{interface_name}}::Contents v8Contents = v8buffer->Externalize(); |
| 841 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, WTF::ArrayBufferContents::{% if interface_name == 'ArrayBuffer' %}Not{% endif
%}Shared); | 814 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(),
WTF::ArrayBufferContents::{% if interface_name == 'ArrayBuffer' %}Not{% endif %}
Shared); |
| 842 {{cpp_class}}* buffer = {{cpp_class}}::create(contents); | 815 {{cpp_class}}* buffer = {{cpp_class}}::create(contents); |
| 843 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::I
solate::GetCurrent(), buffer->wrapperTypeInfo(), object); | 816 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::Iso
late::GetCurrent(), buffer->wrapperTypeInfo(), object); |
| 844 DCHECK(associatedWrapper == object); | 817 DCHECK(associatedWrapper == object); |
| 845 | 818 |
| 846 return buffer; | 819 return buffer; |
| 847 } | 820 } |
| 848 | 821 |
| 849 {% elif interface_name == 'ArrayBufferView' %} | 822 {% elif interface_name == 'ArrayBufferView' %} |
| 850 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) | 823 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) { |
| 851 { | 824 DCHECK(object->IsArrayBufferView()); |
| 852 ASSERT(object->IsArrayBufferView()); | 825 ScriptWrappable* scriptWrappable = toScriptWrappable(object); |
| 853 ScriptWrappable* scriptWrappable = toScriptWrappable(object); | 826 if (scriptWrappable) |
| 854 if (scriptWrappable) | 827 return scriptWrappable->toImpl<{{cpp_class}}>(); |
| 855 return scriptWrappable->toImpl<{{cpp_class}}>(); | |
| 856 | 828 |
| 857 if (object->IsInt8Array()) | 829 if (object->IsInt8Array()) |
| 858 return V8Int8Array::toImpl(object); | 830 return V8Int8Array::toImpl(object); |
| 859 if (object->IsInt16Array()) | 831 if (object->IsInt16Array()) |
| 860 return V8Int16Array::toImpl(object); | 832 return V8Int16Array::toImpl(object); |
| 861 if (object->IsInt32Array()) | 833 if (object->IsInt32Array()) |
| 862 return V8Int32Array::toImpl(object); | 834 return V8Int32Array::toImpl(object); |
| 863 if (object->IsUint8Array()) | 835 if (object->IsUint8Array()) |
| 864 return V8Uint8Array::toImpl(object); | 836 return V8Uint8Array::toImpl(object); |
| 865 if (object->IsUint8ClampedArray()) | 837 if (object->IsUint8ClampedArray()) |
| 866 return V8Uint8ClampedArray::toImpl(object); | 838 return V8Uint8ClampedArray::toImpl(object); |
| 867 if (object->IsUint16Array()) | 839 if (object->IsUint16Array()) |
| 868 return V8Uint16Array::toImpl(object); | 840 return V8Uint16Array::toImpl(object); |
| 869 if (object->IsUint32Array()) | 841 if (object->IsUint32Array()) |
| 870 return V8Uint32Array::toImpl(object); | 842 return V8Uint32Array::toImpl(object); |
| 871 if (object->IsFloat32Array()) | 843 if (object->IsFloat32Array()) |
| 872 return V8Float32Array::toImpl(object); | 844 return V8Float32Array::toImpl(object); |
| 873 if (object->IsFloat64Array()) | 845 if (object->IsFloat64Array()) |
| 874 return V8Float64Array::toImpl(object); | 846 return V8Float64Array::toImpl(object); |
| 875 if (object->IsDataView()) | 847 if (object->IsDataView()) |
| 876 return V8DataView::toImpl(object); | 848 return V8DataView::toImpl(object); |
| 877 | 849 |
| 878 ASSERT_NOT_REACHED(); | 850 NOTREACHED(); |
| 879 return 0; | 851 return 0; |
| 880 } | 852 } |
| 881 | 853 |
| 882 {% elif is_array_buffer_or_view %} | 854 {% elif is_array_buffer_or_view %} |
| 883 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) | 855 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) { |
| 884 { | 856 DCHECK(object->Is{{interface_name}}()); |
| 885 ASSERT(object->Is{{interface_name}}()); | 857 ScriptWrappable* scriptWrappable = toScriptWrappable(object); |
| 886 ScriptWrappable* scriptWrappable = toScriptWrappable(object); | 858 if (scriptWrappable) |
| 887 if (scriptWrappable) | 859 return scriptWrappable->toImpl<{{cpp_class}}>(); |
| 888 return scriptWrappable->toImpl<{{cpp_class}}>(); | |
| 889 | 860 |
| 890 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); | 861 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>()
; |
| 891 v8::Local<v8::Object> arrayBuffer = v8View->Buffer(); | 862 v8::Local<v8::Object> arrayBuffer = v8View->Buffer(); |
| 892 {{cpp_class}}* typedArray = nullptr; | 863 {{cpp_class}}* typedArray = nullptr; |
| 893 if (arrayBuffer->IsArrayBuffer()) { | 864 if (arrayBuffer->IsArrayBuffer()) { |
| 894 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v
8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %
}Length()); | 865 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v8Vie
w->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %}Len
gth()); |
| 895 } else if (arrayBuffer->IsSharedArrayBuffer()) { | 866 } else if (arrayBuffer->IsSharedArrayBuffer()) { |
| 896 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuff
er), v8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% e
ndif %}Length()); | 867 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuffer),
v8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif
%}Length()); |
| 897 } else { | 868 } else { |
| 898 ASSERT_NOT_REACHED(); | 869 NOTREACHED(); |
| 899 } | 870 } |
| 900 v8::Local<v8::Object> associatedWrapper = typedArray->associateWithWrapper(v
8::Isolate::GetCurrent(), typedArray->wrapperTypeInfo(), object); | 871 v8::Local<v8::Object> associatedWrapper = typedArray->associateWithWrapper(v8:
:Isolate::GetCurrent(), typedArray->wrapperTypeInfo(), object); |
| 901 DCHECK(associatedWrapper == object); | 872 DCHECK(associatedWrapper == object); |
| 902 | 873 |
| 903 return typedArray->toImpl<{{cpp_class}}>(); | 874 return typedArray->toImpl<{{cpp_class}}>(); |
| 904 } | 875 } |
| 905 | 876 |
| 906 {% endif %} | 877 {% endif %} |
| 907 {% endblock %} | 878 {% endblock %} |
| 908 | 879 |
| 909 | 880 |
| 910 {##############################################################################} | 881 {##############################################################################} |
| 911 {% block to_impl_with_type_check %} | 882 {% block to_impl_with_type_check %} |
| 912 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local
<v8::Value> value) | 883 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local
<v8::Value> value) { |
| 913 { | |
| 914 {% if is_array_buffer_or_view %} | 884 {% if is_array_buffer_or_view %} |
| 915 return value->Is{{interface_name}}() ? toImpl(v8::Local<v8::Object>::Cast(va
lue)) : nullptr; | 885 return value->Is{{interface_name}}() ? toImpl(v8::Local<v8::Object>::Cast(valu
e)) : nullptr; |
| 916 {% else %} | 886 {% else %} |
| 917 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(valu
e)) : nullptr; | 887 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)
) : nullptr; |
| 918 {% endif %} | 888 {% endif %} |
| 919 } | 889 } |
| 920 | 890 |
| 921 {% endblock %} | 891 {% endblock %} |
| 922 | 892 |
| 923 | 893 |
| 924 {##############################################################################} | 894 {##############################################################################} |
| 925 {% block prepare_prototype_and_interface_object %} | 895 {% block prepare_prototype_and_interface_object %} |
| 926 {% from 'methods.cpp.tmpl' import install_conditionally_enabled_methods with con
text %} | 896 {% from 'methods.cpp.tmpl' import install_conditionally_enabled_methods with con
text %} |
| 927 {% if has_prepare_prototype_and_interface_object %} | 897 {% if has_prepare_prototype_and_interface_object %} |
| 928 void {{v8_class}}::preparePrototypeAndInterfaceObject(v8::Local<v8::Context> con
text, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeObject, v8::L
ocal<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTem
plate) | 898 void {{v8_class}}::preparePrototypeAndInterfaceObject(v8::Local<v8::Context> con
text, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeObject, v8::L
ocal<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTem
plate) { |
| 929 { | 899 v8::Isolate* isolate = context->GetIsolate(); |
| 930 v8::Isolate* isolate = context->GetIsolate(); | |
| 931 {% if unscopables %} | 900 {% if unscopables %} |
| 932 {{install_unscopables() | indent}} | 901 {{install_unscopables() | indent(2)}} |
| 933 {% endif %} | 902 {% endif %} |
| 934 {% if has_conditional_attributes_on_prototype %} | 903 {% if has_conditional_attributes_on_prototype %} |
| 935 {{install_conditionally_enabled_attributes_on_prototype() | indent}} | 904 {{install_conditionally_enabled_attributes_on_prototype() | indent(2)}} |
| 936 {% endif %} | 905 {% endif %} |
| 937 {% if methods | conditionally_exposed(is_partial) %} | 906 {% if methods | conditionally_exposed(is_partial) %} |
| 938 {{install_conditionally_enabled_methods() | indent}} | 907 {{install_conditionally_enabled_methods() | indent(2)}} |
| 939 {% endif %} | 908 {% endif %} |
| 940 } | 909 } |
| 941 | 910 |
| 942 {% endif %} | 911 {% endif %} |
| 943 {% endblock %} | 912 {% endblock %} |
| 944 | 913 |
| 945 | 914 |
| 946 {##############################################################################} | 915 {##############################################################################} |
| 947 {% macro install_unscopables() %} | 916 {% macro install_unscopables() %} |
| 948 v8::Local<v8::Name> unscopablesSymbol(v8::Symbol::GetUnscopables(isolate)); | 917 v8::Local<v8::Name> unscopablesSymbol(v8::Symbol::GetUnscopables(isolate)); |
| 949 v8::Local<v8::Object> unscopables; | 918 v8::Local<v8::Object> unscopables; |
| 950 if (v8CallBoolean(prototypeObject->HasOwnProperty(context, unscopablesSymbol))) | 919 if (v8CallBoolean(prototypeObject->HasOwnProperty(context, unscopablesSymbol))) |
| 951 unscopables = prototypeObject->Get(context, unscopablesSymbol).ToLocalChecke
d().As<v8::Object>(); | 920 unscopables = prototypeObject->Get(context, unscopablesSymbol).ToLocalChecked(
).As<v8::Object>(); |
| 952 else | 921 else |
| 953 unscopables = v8::Object::New(isolate); | 922 unscopables = v8::Object::New(isolate); |
| 954 {% for name, runtime_enabled_function in unscopables %} | 923 {% for name, runtime_enabled_function in unscopables %} |
| 955 {% filter runtime_enabled(runtime_enabled_function) %} | 924 {% filter runtime_enabled(runtime_enabled_function) %} |
| 956 unscopables->CreateDataProperty(context, v8AtomicString(isolate, "{{name}}"), v8
::True(isolate)).FromJust(); | 925 unscopables->CreateDataProperty(context, v8AtomicString(isolate, "{{name}}"), v8
::True(isolate)).FromJust(); |
| 957 {% endfilter %} | 926 {% endfilter %} |
| 958 {% endfor %} | 927 {% endfor %} |
| 959 prototypeObject->CreateDataProperty(context, unscopablesSymbol, unscopables).Fro
mJust(); | 928 prototypeObject->CreateDataProperty(context, unscopablesSymbol, unscopables).Fro
mJust(); |
| 960 {% endmacro %} | 929 {% endmacro %} |
| 961 | 930 |
| 962 | 931 |
| 963 {##############################################################################} | 932 {##############################################################################} |
| (...skipping 12 matching lines...) Expand all Loading... |
| 976 {% endfilter %}{# exposed #} | 945 {% endfilter %}{# exposed #} |
| 977 {% endfor %} | 946 {% endfor %} |
| 978 {% endmacro %} | 947 {% endmacro %} |
| 979 | 948 |
| 980 | 949 |
| 981 {##############################################################################} | 950 {##############################################################################} |
| 982 {% block partial_interface %} | 951 {% block partial_interface %} |
| 983 {% if has_partial_interface %} | 952 {% if has_partial_interface %} |
| 984 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins
tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template; | 953 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins
tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template; |
| 985 | 954 |
| 986 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate
Function, PreparePrototypeAndInterfaceObjectFunction preparePrototypeAndInterfac
eObjectFunction) | 955 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate
Function, PreparePrototypeAndInterfaceObjectFunction preparePrototypeAndInterfac
eObjectFunction) { |
| 987 { | 956 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; |
| 988 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; | 957 if (preparePrototypeAndInterfaceObjectFunction) |
| 989 if (preparePrototypeAndInterfaceObjectFunction) | 958 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = p
reparePrototypeAndInterfaceObjectFunction; |
| 990 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction
= preparePrototypeAndInterfaceObjectFunction; | |
| 991 } | 959 } |
| 992 | 960 |
| 993 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 961 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
| 994 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 962 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { |
| 995 { | 963 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
| 996 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | |
| 997 } | 964 } |
| 998 | 965 |
| 999 {% endfor %} | 966 {% endfor %} |
| 1000 {% endif %} | 967 {% endif %} |
| 1001 {% endblock %} | 968 {% endblock %} |
| OLD | NEW |