OLD | NEW |
1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% block constructor_getter %} | 5 {% block constructor_getter %} |
6 {% if has_constructor_attributes %} | 6 {% if has_constructor_attributes %} |
7 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop
ertyCallbackInfo<v8::Value>& info) | 7 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop
ertyCallbackInfo<v8::Value>& info) |
8 { | 8 { |
9 v8::Handle<v8::Value> data = info.Data(); | 9 v8::Handle<v8::Value> data = info.Data(); |
10 ASSERT(data->IsExternal()); | 10 ASSERT(data->IsExternal()); |
11 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 11 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
12 if (!perContextData) | 12 if (!perContextData) |
13 return; | 13 return; |
14 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | 14 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
15 } | 15 } |
16 | 16 |
17 {% endif %} | 17 {% endif %} |
18 {% endblock %} | 18 {% endblock %} |
19 | 19 |
20 | 20 |
21 {##############################################################################} | 21 {##############################################################################} |
22 {% block replaceable_attribute_setter_and_callback %} | 22 {% block replaceable_attribute_setter_and_callback %} |
23 {% if has_replaceable_attributes or has_constructor_attributes %} | 23 {% if has_replaceable_attributes or has_constructor_attributes %} |
24 static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8:
:Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | 24 static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8:
:Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
25 { | 25 { |
26 {% if is_check_security %} | 26 {% if is_check_security %} |
27 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 27 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
28 v8::String::Utf8Value attributeName(name); | 28 v8::String::Utf8Value attributeName(name); |
29 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 29 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
30 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 30 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
31 exceptionState.throwIfNeeded(); | 31 exceptionState.throwIfNeeded(); |
32 return; | 32 return; |
33 } | 33 } |
34 {% endif %} | 34 {% endif %} |
35 if (info.This()->IsObject()) | 35 if (info.This()->IsObject()) |
36 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); | 36 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); |
37 } | 37 } |
38 | 38 |
39 static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n
ame, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | 39 static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n
ame, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
40 { | 40 { |
41 {{cpp_class}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(name, v8Value,
info); | 41 {{cpp_class}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(name, v8Value,
info); |
42 } | 42 } |
43 | 43 |
44 {% endif %} | 44 {% endif %} |
45 {% endblock %} | 45 {% endblock %} |
46 | 46 |
47 | 47 |
48 {##############################################################################} | 48 {##############################################################################} |
49 {% block security_check_functions %} | 49 {% block security_check_functions %} |
50 {% if has_access_check_callbacks %} | 50 {% if has_access_check_callbacks %} |
51 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) | 51 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) |
52 { | 52 { |
53 {{cpp_class}}* impl = {{v8_class}}::toNative(host); | 53 {{cpp_class}}* impl = {{v8_class}}::toImpl(host); |
54 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(),
impl->frame(), DoNotReportSecurityError); | 54 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(),
impl->frame(), DoNotReportSecurityError); |
55 } | 55 } |
56 | 56 |
57 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
::AccessType type, v8::Local<v8::Value>) | 57 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
::AccessType type, v8::Local<v8::Value>) |
58 { | 58 { |
59 {{cpp_class}}* impl = {{v8_class}}::toNative(host); | 59 {{cpp_class}}* impl = {{v8_class}}::toImpl(host); |
60 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(),
impl->frame(), DoNotReportSecurityError); | 60 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(),
impl->frame(), DoNotReportSecurityError); |
61 } | 61 } |
62 | 62 |
63 {% endif %} | 63 {% endif %} |
64 {% endblock %} | 64 {% endblock %} |
65 | 65 |
66 | 66 |
67 {##############################################################################} | 67 {##############################################################################} |
68 {% block indexed_property_getter %} | 68 {% block indexed_property_getter %} |
69 {% if indexed_property_getter and not indexed_property_getter.is_custom %} | 69 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
70 {% set getter = indexed_property_getter %} | 70 {% set getter = indexed_property_getter %} |
71 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | 71 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) |
72 { | 72 { |
73 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 73 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
74 {% if getter.is_raises_exception %} | 74 {% if getter.is_raises_exception %} |
75 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter
face_name}}", info.Holder(), info.GetIsolate()); | 75 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter
face_name}}", info.Holder(), info.GetIsolate()); |
76 {% endif %} | 76 {% endif %} |
77 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} | 77 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} |
78 {% set getter_arguments = ['index', 'exceptionState'] | 78 {% set getter_arguments = ['index', 'exceptionState'] |
79 if getter.is_raises_exception else ['index'] %} | 79 if getter.is_raises_exception else ['index'] %} |
80 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join
(', ')}}); | 80 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join
(', ')}}); |
81 {% if getter.is_raises_exception %} | 81 {% if getter.is_raises_exception %} |
82 if (exceptionState.throwIfNeeded()) | 82 if (exceptionState.throwIfNeeded()) |
83 return; | 83 return; |
(...skipping 25 matching lines...) Expand all Loading... |
109 {% endif %} | 109 {% endif %} |
110 {% endblock %} | 110 {% endblock %} |
111 | 111 |
112 | 112 |
113 {##############################################################################} | 113 {##############################################################################} |
114 {% block indexed_property_setter %} | 114 {% block indexed_property_setter %} |
115 {% if indexed_property_setter and not indexed_property_setter.is_custom %} | 115 {% if indexed_property_setter and not indexed_property_setter.is_custom %} |
116 {% set setter = indexed_property_setter %} | 116 {% set setter = indexed_property_setter %} |
117 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) | 117 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) |
118 { | 118 { |
119 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 119 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
120 {{setter.v8_value_to_local_cpp_value}}; | 120 {{setter.v8_value_to_local_cpp_value}}; |
121 {% if setter.has_exception_state %} | 121 {% if setter.has_exception_state %} |
122 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "{{inter
face_name}}", info.Holder(), info.GetIsolate()); | 122 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "{{inter
face_name}}", info.Holder(), info.GetIsolate()); |
123 {% endif %} | 123 {% endif %} |
124 {% if setter.has_type_checking_interface %} | 124 {% if setter.has_type_checking_interface %} |
125 {# Type checking for interface types (if interface not implemented, throw | 125 {# Type checking for interface types (if interface not implemented, throw |
126 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 126 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
127 if (!isUndefinedOrNull(v8Value) && !V8{{setter.idl_type}}::hasInstance(v8Val
ue, info.GetIsolate())) { | 127 if (!isUndefinedOrNull(v8Value) && !V8{{setter.idl_type}}::hasInstance(v8Val
ue, info.GetIsolate())) { |
128 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); | 128 exceptionState.throwTypeError("The provided value is not of type '{{sett
er.idl_type}}'."); |
129 exceptionState.throwIfNeeded(); | 129 exceptionState.throwIfNeeded(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 {% endif %} | 165 {% endif %} |
166 {% endblock %} | 166 {% endblock %} |
167 | 167 |
168 | 168 |
169 {##############################################################################} | 169 {##############################################################################} |
170 {% block indexed_property_deleter %} | 170 {% block indexed_property_deleter %} |
171 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} | 171 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} |
172 {% set deleter = indexed_property_deleter %} | 172 {% set deleter = indexed_property_deleter %} |
173 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) | 173 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) |
174 { | 174 { |
175 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 175 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
176 {% if deleter.is_raises_exception %} | 176 {% if deleter.is_raises_exception %} |
177 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "{{int
erface_name}}", info.Holder(), info.GetIsolate()); | 177 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "{{int
erface_name}}", info.Holder(), info.GetIsolate()); |
178 {% endif %} | 178 {% endif %} |
179 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} | 179 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} |
180 {% set deleter_arguments = ['index', 'exceptionState'] | 180 {% set deleter_arguments = ['index', 'exceptionState'] |
181 if deleter.is_raises_exception else ['index'] %} | 181 if deleter.is_raises_exception else ['index'] %} |
182 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', '
)}}); | 182 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', '
)}}); |
183 {% if deleter.is_raises_exception %} | 183 {% if deleter.is_raises_exception %} |
184 if (exceptionState.throwIfNeeded()) | 184 if (exceptionState.throwIfNeeded()) |
185 return; | 185 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 {% set getter = named_property_getter %} | 218 {% set getter = named_property_getter %} |
219 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) | 219 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) |
220 { | 220 { |
221 {% if not is_override_builtins %} | 221 {% if not is_override_builtins %} |
222 if (info.Holder()->HasRealNamedProperty(name)) | 222 if (info.Holder()->HasRealNamedProperty(name)) |
223 return; | 223 return; |
224 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 224 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
225 return; | 225 return; |
226 | 226 |
227 {% endif %} | 227 {% endif %} |
228 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 228 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
229 AtomicString propertyName = toCoreAtomicString(name); | 229 AtomicString propertyName = toCoreAtomicString(name); |
230 {% if getter.is_raises_exception %} | 230 {% if getter.is_raises_exception %} |
231 v8::String::Utf8Value namedProperty(name); | 231 v8::String::Utf8Value namedProperty(name); |
232 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 232 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
233 {% endif %} | 233 {% endif %} |
234 {% if getter.union_arguments %} | 234 {% if getter.union_arguments %} |
235 {{union_type_method_call_and_set_return_value(getter) | indent}} | 235 {{union_type_method_call_and_set_return_value(getter) | indent}} |
236 {% else %} | 236 {% else %} |
237 {{getter.cpp_type}} result = {{getter.cpp_value}}; | 237 {{getter.cpp_type}} result = {{getter.cpp_value}}; |
238 {% if getter.is_raises_exception %} | 238 {% if getter.is_raises_exception %} |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 {% set setter = named_property_setter %} | 274 {% set setter = named_property_setter %} |
275 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | 275 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
276 { | 276 { |
277 {% if not is_override_builtins %} | 277 {% if not is_override_builtins %} |
278 if (info.Holder()->HasRealNamedProperty(name)) | 278 if (info.Holder()->HasRealNamedProperty(name)) |
279 return; | 279 return; |
280 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 280 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
281 return; | 281 return; |
282 | 282 |
283 {% endif %} | 283 {% endif %} |
284 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 284 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
285 {# v8_value_to_local_cpp_value('DOMString', 'name', 'propertyName') #} | 285 {# v8_value_to_local_cpp_value('DOMString', 'name', 'propertyName') #} |
286 TOSTRING_VOID(V8StringResource<>, propertyName, name); | 286 TOSTRING_VOID(V8StringResource<>, propertyName, name); |
287 {{setter.v8_value_to_local_cpp_value}}; | 287 {{setter.v8_value_to_local_cpp_value}}; |
288 {% if setter.has_exception_state %} | 288 {% if setter.has_exception_state %} |
289 v8::String::Utf8Value namedProperty(name); | 289 v8::String::Utf8Value namedProperty(name); |
290 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 290 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
291 {% endif %} | 291 {% endif %} |
292 {% set setter_name = setter.name or 'anonymousNamedSetter' %} | 292 {% set setter_name = setter.name or 'anonymousNamedSetter' %} |
293 {% set setter_arguments = | 293 {% set setter_arguments = |
294 ['propertyName', 'propertyValue', 'exceptionState'] | 294 ['propertyName', 'propertyValue', 'exceptionState'] |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 | 329 |
330 {##############################################################################} | 330 {##############################################################################} |
331 {% block named_property_query %} | 331 {% block named_property_query %} |
332 {% if named_property_getter and named_property_getter.is_enumerable and | 332 {% if named_property_getter and named_property_getter.is_enumerable and |
333 not named_property_getter.is_custom_property_query %} | 333 not named_property_getter.is_custom_property_query %} |
334 {# If there is an enumerator, there MUST be a query method to properly | 334 {# If there is an enumerator, there MUST be a query method to properly |
335 communicate property attributes. #} | 335 communicate property attributes. #} |
336 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | 336 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) |
337 { | 337 { |
338 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 338 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
339 AtomicString propertyName = toCoreAtomicString(name); | 339 AtomicString propertyName = toCoreAtomicString(name); |
340 v8::String::Utf8Value namedProperty(name); | 340 v8::String::Utf8Value namedProperty(name); |
341 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 341 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
342 bool result = impl->namedPropertyQuery(propertyName, exceptionState); | 342 bool result = impl->namedPropertyQuery(propertyName, exceptionState); |
343 if (exceptionState.throwIfNeeded()) | 343 if (exceptionState.throwIfNeeded()) |
344 return; | 344 return; |
345 if (!result) | 345 if (!result) |
346 return; | 346 return; |
347 v8SetReturnValueInt(info, v8::None); | 347 v8SetReturnValueInt(info, v8::None); |
348 } | 348 } |
(...skipping 20 matching lines...) Expand all Loading... |
369 {% endif %} | 369 {% endif %} |
370 {% endblock %} | 370 {% endblock %} |
371 | 371 |
372 | 372 |
373 {##############################################################################} | 373 {##############################################################################} |
374 {% block named_property_deleter %} | 374 {% block named_property_deleter %} |
375 {% if named_property_deleter and not named_property_deleter.is_custom %} | 375 {% if named_property_deleter and not named_property_deleter.is_custom %} |
376 {% set deleter = named_property_deleter %} | 376 {% set deleter = named_property_deleter %} |
377 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) | 377 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) |
378 { | 378 { |
379 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 379 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
380 AtomicString propertyName = toCoreAtomicString(name); | 380 AtomicString propertyName = toCoreAtomicString(name); |
381 {% if deleter.is_raises_exception %} | 381 {% if deleter.is_raises_exception %} |
382 v8::String::Utf8Value namedProperty(name); | 382 v8::String::Utf8Value namedProperty(name); |
383 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedPropert
y, "{{interface_name}}", info.Holder(), info.GetIsolate()); | 383 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedPropert
y, "{{interface_name}}", info.Holder(), info.GetIsolate()); |
384 {% endif %} | 384 {% endif %} |
385 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} | 385 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} |
386 {% set deleter_arguments = ['propertyName', 'exceptionState'] | 386 {% set deleter_arguments = ['propertyName', 'exceptionState'] |
387 if deleter.is_raises_exception else ['propertyName'] %} | 387 if deleter.is_raises_exception else ['propertyName'] %} |
388 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', '
)}}); | 388 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', '
)}}); |
389 {% if deleter.is_raises_exception %} | 389 {% if deleter.is_raises_exception %} |
(...skipping 26 matching lines...) Expand all Loading... |
416 {% endif %} | 416 {% endif %} |
417 {% endblock %} | 417 {% endblock %} |
418 | 418 |
419 | 419 |
420 {##############################################################################} | 420 {##############################################################################} |
421 {% block named_property_enumerator %} | 421 {% block named_property_enumerator %} |
422 {% if named_property_getter and named_property_getter.is_enumerable and | 422 {% if named_property_getter and named_property_getter.is_enumerable and |
423 not named_property_getter.is_custom_property_enumerator %} | 423 not named_property_getter.is_custom_property_enumerator %} |
424 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | 424 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) |
425 { | 425 { |
426 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 426 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
427 Vector<String> names; | 427 Vector<String> names; |
428 ExceptionState exceptionState(ExceptionState::EnumerationContext, "{{interfa
ce_name}}", info.Holder(), info.GetIsolate()); | 428 ExceptionState exceptionState(ExceptionState::EnumerationContext, "{{interfa
ce_name}}", info.Holder(), info.GetIsolate()); |
429 impl->namedPropertyEnumerator(names, exceptionState); | 429 impl->namedPropertyEnumerator(names, exceptionState); |
430 if (exceptionState.throwIfNeeded()) | 430 if (exceptionState.throwIfNeeded()) |
431 return; | 431 return; |
432 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); | 432 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); |
433 for (size_t i = 0; i < names.size(); ++i) | 433 for (size_t i = 0; i < names.size(); ++i) |
434 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIs
olate(), names[i])); | 434 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIs
olate(), names[i])); |
435 v8SetReturnValue(info, v8names); | 435 v8SetReturnValue(info, v8names); |
436 } | 436 } |
(...skipping 22 matching lines...) Expand all Loading... |
459 | 459 |
460 | 460 |
461 {##############################################################################} | 461 {##############################################################################} |
462 {% block origin_safe_method_setter %} | 462 {% block origin_safe_method_setter %} |
463 {% if has_origin_safe_method_setter %} | 463 {% if has_origin_safe_method_setter %} |
464 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8::
Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | 464 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8::
Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
465 { | 465 { |
466 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i
nfo.This(), info.GetIsolate()); | 466 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i
nfo.This(), info.GetIsolate()); |
467 if (holder.IsEmpty()) | 467 if (holder.IsEmpty()) |
468 return; | 468 return; |
469 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); | 469 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
470 v8::String::Utf8Value attributeName(name); | 470 v8::String::Utf8Value attributeName(name); |
471 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 471 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
472 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 472 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
473 exceptionState.throwIfNeeded(); | 473 exceptionState.throwIfNeeded(); |
474 return; | 474 return; |
475 } | 475 } |
476 | 476 |
477 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} | 477 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} |
478 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Handle<v8::Object>::Cas
t(info.This()), name, v8Value); | 478 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Handle<v8::Object>::Cas
t(info.This()), name, v8Value); |
479 } | 479 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 628 |
629 {% endif %} | 629 {% endif %} |
630 {% endblock %} | 630 {% endblock %} |
631 | 631 |
632 | 632 |
633 {##############################################################################} | 633 {##############################################################################} |
634 {% block visit_dom_wrapper %} | 634 {% block visit_dom_wrapper %} |
635 {% if reachable_node_function or set_wrapper_reference_to_list %} | 635 {% if reachable_node_function or set_wrapper_reference_to_list %} |
636 void {{v8_class}}::visitDOMWrapper(ScriptWrappableBase* internalPointer, const v
8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) | 636 void {{v8_class}}::visitDOMWrapper(ScriptWrappableBase* internalPointer, const v
8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) |
637 { | 637 { |
638 {{cpp_class}}* impl = fromInternalPointer(internalPointer); | 638 {{cpp_class}}* impl = internalPointer->toImpl<{{cpp_class}}>(); |
639 {% if set_wrapper_reference_to_list %} | 639 {% if set_wrapper_reference_to_list %} |
640 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate,
wrapper); | 640 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate,
wrapper); |
641 V8WrapperInstantiationScope scope(creationContext, isolate); | 641 V8WrapperInstantiationScope scope(creationContext, isolate); |
642 {% for set_wrapper_reference_to in set_wrapper_reference_to_list %} | 642 {% for set_wrapper_reference_to in set_wrapper_reference_to_list %} |
643 {{set_wrapper_reference_to.cpp_type}} {{set_wrapper_reference_to.name}} = im
pl->{{set_wrapper_reference_to.name}}(); | 643 {{set_wrapper_reference_to.cpp_type}} {{set_wrapper_reference_to.name}} = im
pl->{{set_wrapper_reference_to.name}}(); |
644 if ({{set_wrapper_reference_to.name}}) { | 644 if ({{set_wrapper_reference_to.name}}) { |
645 if (!DOMDataStore::containsWrapper<{{set_wrapper_reference_to.v8_type}}>
({{set_wrapper_reference_to.name}}, isolate)) | 645 if (!DOMDataStore::containsWrapper<{{set_wrapper_reference_to.v8_type}}>
({{set_wrapper_reference_to.name}}, isolate)) |
646 wrap({{set_wrapper_reference_to.name}}, creationContext, isolate); | 646 wrap({{set_wrapper_reference_to.name}}, creationContext, isolate); |
647 DOMDataStore::setWrapperReference<{{set_wrapper_reference_to.v8_type}}>(
wrapper, {{set_wrapper_reference_to.name}}, isolate); | 647 DOMDataStore::setWrapperReference<{{set_wrapper_reference_to.v8_type}}>(
wrapper, {{set_wrapper_reference_to.name}}, isolate); |
648 } | 648 } |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8:
:Value> v8Value, v8::Isolate* isolate) | 1026 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8:
:Value> v8Value, v8::Isolate* isolate) |
1027 { | 1027 { |
1028 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | 1028 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); |
1029 } | 1029 } |
1030 | 1030 |
1031 {% endblock %} | 1031 {% endblock %} |
1032 | 1032 |
1033 | 1033 |
1034 {##############################################################################} | 1034 {##############################################################################} |
1035 {% block to_native_with_type_check %} | 1035 {% block to_native_with_type_check %} |
1036 {{cpp_class}}* {{v8_class}}::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Han
dle<v8::Value> value) | 1036 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl
e<v8::Value> value) |
1037 { | 1037 { |
1038 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPo
inter(v8::Handle<v8::Object>::Cast(value))) : 0; | 1038 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle
<v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0; |
1039 } | 1039 } |
1040 | 1040 |
1041 {% endblock %} | 1041 {% endblock %} |
1042 | 1042 |
1043 | 1043 |
1044 {##############################################################################} | 1044 {##############################################################################} |
1045 {% block install_conditional_attributes %} | 1045 {% block install_conditional_attributes %} |
1046 {% if has_conditional_attributes %} | 1046 {% if has_conditional_attributes %} |
1047 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object>
instanceObject, v8::Isolate* isolate) | 1047 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object>
instanceObject, v8::Isolate* isolate) |
1048 { | 1048 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 | 1085 |
1086 {% endif %} | 1086 {% endif %} |
1087 {% endblock %} | 1087 {% endblock %} |
1088 | 1088 |
1089 | 1089 |
1090 {##############################################################################} | 1090 {##############################################################################} |
1091 {% block to_active_dom_object %} | 1091 {% block to_active_dom_object %} |
1092 {% if is_active_dom_object %} | 1092 {% if is_active_dom_object %} |
1093 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) | 1093 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) |
1094 { | 1094 { |
1095 return toNative(wrapper); | 1095 return toImpl(wrapper); |
1096 } | 1096 } |
1097 | 1097 |
1098 {% endif %} | 1098 {% endif %} |
1099 {% endblock %} | 1099 {% endblock %} |
1100 | 1100 |
1101 | 1101 |
1102 {##############################################################################} | 1102 {##############################################################################} |
1103 {% block to_event_target %} | 1103 {% block to_event_target %} |
1104 {% if is_event_target %} | 1104 {% if is_event_target %} |
1105 EventTarget* {{v8_class}}::toEventTarget(v8::Handle<v8::Object> object) | 1105 EventTarget* {{v8_class}}::toEventTarget(v8::Handle<v8::Object> object) |
1106 { | 1106 { |
1107 return toNative(object); | 1107 return toImpl(object); |
1108 } | 1108 } |
1109 | 1109 |
1110 {% endif %} | 1110 {% endif %} |
1111 {% endblock %} | 1111 {% endblock %} |
1112 | 1112 |
1113 | 1113 |
1114 {##############################################################################} | 1114 {##############################################################################} |
1115 {% block get_shadow_object_template %} | 1115 {% block get_shadow_object_template %} |
1116 {% if interface_name == 'Window' %} | 1116 {% if interface_name == 'Window' %} |
1117 v8::Handle<v8::ObjectTemplate> V8Window::getShadowObjectTemplate(v8::Isolate* is
olate) | 1117 v8::Handle<v8::ObjectTemplate> V8Window::getShadowObjectTemplate(v8::Isolate* is
olate) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 {% if is_document %} | 1191 {% if is_document %} |
1192 if (LocalFrame* frame = impl->frame()) { | 1192 if (LocalFrame* frame = impl->frame()) { |
1193 if (frame->script().initializeMainWorld()) { | 1193 if (frame->script().initializeMainWorld()) { |
1194 // initializeMainWorld may have created a wrapper for the object, re
try from the start. | 1194 // initializeMainWorld may have created a wrapper for the object, re
try from the start. |
1195 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<{{v8_class
}}>(impl.get(), isolate); | 1195 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<{{v8_class
}}>(impl.get(), isolate); |
1196 if (!wrapper.IsEmpty()) | 1196 if (!wrapper.IsEmpty()) |
1197 return wrapper; | 1197 return wrapper; |
1198 } | 1198 } |
1199 } | 1199 } |
1200 {% endif %} | 1200 {% endif %} |
1201 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | 1201 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, impl->toScriptWrappableBase(), isolate); |
1202 if (UNLIKELY(wrapper.IsEmpty())) | 1202 if (UNLIKELY(wrapper.IsEmpty())) |
1203 return wrapper; | 1203 return wrapper; |
1204 | 1204 |
1205 {% if is_audio_buffer %} | 1205 {% if is_audio_buffer %} |
1206 {# We only setDeallocationObservers on array buffers that are held by some | 1206 {# We only setDeallocationObservers on array buffers that are held by some |
1207 object in the V8 heap, not in the ArrayBuffer constructor itself. | 1207 object in the V8 heap, not in the ArrayBuffer constructor itself. |
1208 This is because V8 GC only cares about memory it can free on GC, and | 1208 This is because V8 GC only cares about memory it can free on GC, and |
1209 until the object is exposed to JavaScript, V8 GC doesn't affect it. #} | 1209 until the object is exposed to JavaScript, V8 GC doesn't affect it. #} |
1210 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { | 1210 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { |
1211 Float32Array* channelData = impl->getChannelData(i); | 1211 Float32Array* channelData = impl->getChannelData(i); |
1212 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation
Observer::instanceTemplate()); | 1212 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation
Observer::instanceTemplate()); |
1213 } | 1213 } |
1214 {% endif %} | 1214 {% endif %} |
1215 installConditionallyEnabledProperties(wrapper, isolate); | 1215 installConditionallyEnabledProperties(wrapper, isolate); |
1216 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf
o, wrapper, isolate); | 1216 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf
o, wrapper, isolate); |
1217 return wrapper; | 1217 return wrapper; |
1218 } | 1218 } |
1219 | 1219 |
1220 {% endif %} | 1220 {% endif %} |
1221 {% endblock %} | 1221 {% endblock %} |
1222 | 1222 |
1223 | 1223 |
1224 {##############################################################################} | 1224 {##############################################################################} |
1225 {% block deref_object_and_to_v8_no_inline %} | 1225 {% block deref_object_and_to_v8_no_inline %} |
1226 | 1226 |
1227 void {{v8_class}}::refObject(ScriptWrappableBase* internalPointer) | 1227 void {{v8_class}}::refObject(ScriptWrappableBase* internalPointer) |
1228 { | 1228 { |
1229 {% if gc_type == 'WillBeGarbageCollectedObject' %} | 1229 {% if gc_type == 'WillBeGarbageCollectedObject' %} |
1230 #if !ENABLE(OILPAN) | 1230 #if !ENABLE(OILPAN) |
1231 fromInternalPointer(internalPointer)->ref(); | 1231 internalPointer->toImpl<{{cpp_class}}>()->ref(); |
1232 #endif | 1232 #endif |
1233 {% elif gc_type == 'RefCountedObject' %} | 1233 {% elif gc_type == 'RefCountedObject' %} |
1234 fromInternalPointer(internalPointer)->ref(); | 1234 internalPointer->toImpl<{{cpp_class}}>()->ref(); |
1235 {% endif %} | 1235 {% endif %} |
1236 } | 1236 } |
1237 | 1237 |
1238 void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) | 1238 void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) |
1239 { | 1239 { |
1240 {% if gc_type == 'WillBeGarbageCollectedObject' %} | 1240 {% if gc_type == 'WillBeGarbageCollectedObject' %} |
1241 #if !ENABLE(OILPAN) | 1241 #if !ENABLE(OILPAN) |
1242 fromInternalPointer(internalPointer)->deref(); | 1242 internalPointer->toImpl<{{cpp_class}}>()->deref(); |
1243 #endif | 1243 #endif |
1244 {% elif gc_type == 'RefCountedObject' %} | 1244 {% elif gc_type == 'RefCountedObject' %} |
1245 fromInternalPointer(internalPointer)->deref(); | 1245 internalPointer->toImpl<{{cpp_class}}>()->deref(); |
1246 {% endif %} | 1246 {% endif %} |
1247 } | 1247 } |
1248 | 1248 |
1249 WrapperPersistentNode* {{v8_class}}::createPersistentHandle(ScriptWrappableBase*
internalPointer) | 1249 WrapperPersistentNode* {{v8_class}}::createPersistentHandle(ScriptWrappableBase*
internalPointer) |
1250 { | 1250 { |
1251 {% if gc_type == 'GarbageCollectedObject' %} | 1251 {% if gc_type == 'GarbageCollectedObject' %} |
1252 return new WrapperPersistent<{{cpp_class}}>(fromInternalPointer(internalPoin
ter)); | 1252 return new WrapperPersistent<{{cpp_class}}>(internalPointer->toImpl<{{cpp_cl
ass}}>()); |
1253 {% elif gc_type == 'WillBeGarbageCollectedObject' %} | 1253 {% elif gc_type == 'WillBeGarbageCollectedObject' %} |
1254 #if ENABLE(OILPAN) | 1254 #if ENABLE(OILPAN) |
1255 return new WrapperPersistent<{{cpp_class}}>(fromInternalPointer(internalPoin
ter)); | 1255 return new WrapperPersistent<{{cpp_class}}>(internalPointer->toImpl<{{cpp_cl
ass}}>()); |
1256 #else | 1256 #else |
1257 ASSERT_NOT_REACHED(); | 1257 ASSERT_NOT_REACHED(); |
1258 return 0; | 1258 return 0; |
1259 #endif | 1259 #endif |
1260 {% elif gc_type == 'RefCountedObject' %} | 1260 {% elif gc_type == 'RefCountedObject' %} |
1261 ASSERT_NOT_REACHED(); | 1261 ASSERT_NOT_REACHED(); |
1262 return 0; | 1262 return 0; |
1263 {% endif %} | 1263 {% endif %} |
1264 } | 1264 } |
1265 | 1265 |
1266 template<> | 1266 template<> |
1267 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 1267 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
1268 { | 1268 { |
1269 return toV8(impl, creationContext, isolate); | 1269 return toV8(impl, creationContext, isolate); |
1270 } | 1270 } |
1271 | 1271 |
1272 {% endblock %} | 1272 {% endblock %} |
OLD | NEW |