OLD | NEW |
---|---|
1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% macro attribute_configuration(attribute) %} | 5 {% macro attribute_configuration(attribute) %} |
6 {% set getter_callback = | 6 {% set getter_callback = |
7 '%sV8Internal::%sAttributeGetterCallback' % | 7 '%sV8Internal::%sAttributeGetterCallback' % |
8 (interface_name, attribute.name) | 8 (interface_name, attribute.name) |
9 if not attribute.constructor_type else | 9 if not attribute.constructor_type else |
10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} | 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
123 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, jsValue, info); | 123 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, jsValue, info); |
124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
125 } | 125 } |
126 | 126 |
127 {% endif %} | 127 {% endif %} |
128 {% endblock %} | 128 {% endblock %} |
129 | 129 |
130 | 130 |
131 {##############################################################################} | 131 {##############################################################################} |
132 {% block constructor %} | |
133 {% if has_constructor %} | |
134 {# FIXME: support overloading #} | |
135 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | |
136 { | |
137 {# FIXME: support arguments #} | |
138 RefPtr<{{cpp_class}}> impl = {{cpp_class}}::create(); | |
139 v8::Handle<v8::Object> wrapper = info.Holder(); | |
140 | |
141 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent); | |
142 info.GetReturnValue().Set(wrapper); | |
haraken
2013/12/05 05:54:16
Can you use v8SetReturnValue()?
Nils Barth (inactive)
2013/12/05 06:09:20
I'll try in a followup!
| |
143 } | |
144 | |
145 {% endif %} | |
146 {% endblock %} | |
147 | |
148 | |
149 {##############################################################################} | |
150 {% block constructor_callback %} | |
151 {% if has_constructor %} | |
152 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) | |
153 { | |
154 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | |
155 if (!info.IsConstructCall()) { | |
156 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "Please use the 'new' operator, this DOM object constructor cannot be called a s a function."), info.GetIsolate()); | |
157 return; | |
158 } | |
159 | |
160 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | |
161 info.GetReturnValue().Set(info.Holder()); | |
haraken
2013/12/05 05:54:16
Ditto.
| |
162 return; | |
163 } | |
164 | |
165 {{cpp_class}}V8Internal::constructor(info); | |
166 } | |
167 | |
168 {% endif %} | |
169 {% endblock %} | |
170 | |
171 {##############################################################################} | |
132 {% block visit_dom_wrapper %} | 172 {% block visit_dom_wrapper %} |
133 {% if generate_visit_dom_wrapper_function %} | 173 {% if generate_visit_dom_wrapper_function %} |
134 void {{v8_class}}::visitDOMWrapper(void* object, const v8::Persistent<v8::Object >& wrapper, v8::Isolate* isolate) | 174 void {{v8_class}}::visitDOMWrapper(void* object, const v8::Persistent<v8::Object >& wrapper, v8::Isolate* isolate) |
135 { | 175 { |
136 {{cpp_class}}* impl = fromInternalPointer(object); | 176 {{cpp_class}}* impl = fromInternalPointer(object); |
137 if (Node* owner = impl->{{generate_visit_dom_wrapper_function}}()) { | 177 if (Node* owner = impl->{{generate_visit_dom_wrapper_function}}()) { |
138 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper, isolate); | 178 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper, isolate); |
139 return; | 179 return; |
140 } | 180 } |
141 setObjectGroup(object, wrapper, isolate); | 181 setObjectGroup(object, wrapper, isolate); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 ('%sMethods' % v8_class, | 265 ('%sMethods' % v8_class, |
226 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) | 266 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) |
227 if has_method_configuration else (0, 0) %} | 267 if has_method_configuration else (0, 0) %} |
228 {{attributes_name}}, {{attributes_length}}, | 268 {{attributes_name}}, {{attributes_length}}, |
229 {{accessors_name}}, {{accessors_length}}, | 269 {{accessors_name}}, {{accessors_length}}, |
230 {{methods_name}}, {{methods_length}}, | 270 {{methods_name}}, {{methods_length}}, |
231 isolate, currentWorldType); | 271 isolate, currentWorldType); |
232 {% endfilter %} | 272 {% endfilter %} |
233 | 273 |
234 UNUSED_PARAM(defaultSignature); | 274 UNUSED_PARAM(defaultSignature); |
275 {% if has_constructor %} | |
276 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); | |
277 {# FIXME: compute length #} | |
278 functionTemplate->SetLength(0); | |
279 {% endif %} | |
235 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate(); | 280 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate(); |
236 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate(); | 281 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate(); |
237 UNUSED_PARAM(instanceTemplate); | 282 UNUSED_PARAM(instanceTemplate); |
238 UNUSED_PARAM(prototypeTemplate); | 283 UNUSED_PARAM(prototypeTemplate); |
239 {% if is_check_security and interface_name != 'Window' %} | 284 {% if is_check_security and interface_name != 'Window' %} |
240 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); | 285 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); |
241 {% endif %} | 286 {% endif %} |
242 {% for attribute in attributes if attribute.runtime_enabled_function %} | 287 {% for attribute in attributes if attribute.runtime_enabled_function %} |
243 {% filter conditional(attribute.conditional_string) %} | 288 {% filter conditional(attribute.conditional_string) %} |
244 if ({{attribute.runtime_enabled_function}}()) { | 289 if ({{attribute.runtime_enabled_function}}()) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 fromInternalPointer(object)->deref(); | 565 fromInternalPointer(object)->deref(); |
521 } | 566 } |
522 | 567 |
523 template<> | 568 template<> |
524 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) | 569 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) |
525 { | 570 { |
526 return toV8(impl, creationContext, isolate); | 571 return toV8(impl, creationContext, isolate); |
527 } | 572 } |
528 | 573 |
529 {% endblock %} | 574 {% endblock %} |
OLD | NEW |