Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: Source/bindings/templates/interface_wip.cpp

Issue 17572008: WIP IDL compiler rewrite (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Branch: const + primitive type readonly attributes Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/templates/interface_wip.h ('k') | Source/bindings/templates/macros.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 This file is part of the Blink open source project.
3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21 {% from 'attributes_wip.cpp' import attribute_getter, attribute_getter_callback, attribute_setter, attribute_setter_callback, batched_attribute, enabled_at_runt ime_batched_attribute with context %}
22 {% from 'constants.cpp' import class_consts, const_data, batch_configure_constan ts with context %}
23 {% from 'constructors.cpp' import constructor_callback, make_constructors, more_ constructor_stuff with context %}
24 {% from 'macros.cpp' import method, method_callback, parameters_check, function_ call, feature_observation, deprecation_notification, custom_element_invocation, if_else_statement with context %}
25 #include "config.h"
26 {% if conditional_string %}
27 #if {{conditional_string}}
28 {% endif %}
29 #include "{{v8_class_name}}.h"
30
31 {% for filename in cpp_includes %}
32 #include "{{filename}}"
33 {% endfor %}
34
35 namespace WebCore {
36
37 static void initializeScriptWrappableForInterface({{cpp_class_name}}* object)
38 {
39 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
40 ScriptWrappable::setTypeInfoInObject(object, &{{v8_class_name}}::info);
41 else
42 ASSERT_NOT_REACHED();
43 }
44
45 } // namespace WebCore
46
47 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
48 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
49 // in the global namespace.
50 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
51 void webCoreInitializeScriptWrappableForInterface({{namespace_for_interface=='We bCore' and 'WebCore::' or ''}}{{cpp_class_name}}* object)
52 {
53 WebCore::initializeScriptWrappableForInterface(object);
54 }
55
56 namespace WebCore {
57 WrapperTypeInfo {{v8_class_name}}::info = { {{v8_class_name}}::GetTemplate, {{v8 _class_name}}::derefObject, {{to_active_dom_object}}, {{to_event_target}}, {{roo t_for_gc}}, {{v8_class_name}}::installPerContextPrototypeProperties, {{parent_cl ass_info}}, {{wrapper_type_prototype}} };
58
59 namespace {{cpp_class_name}}V8Internal {
60
61 template <typename T> void V8_USE(T) { }
62
63 {# ############################################## Attributes #}
64 {% for attribute in attributes %}
65 {% for for_main_world_suffix in attribute.for_main_world_suffixes %}
66 {{attribute_getter(attribute, for_main_world_suffix) -}}
67 {{attribute_getter_callback(attribute, for_main_world_suffix)}}{% endfor %}
68 {% for for_main_world_suffix in attribute.for_main_world_suffixes %}
69 {% if attribute.has_normal_setter and not attribute.has_custom_setter %}
70 {{attribute_setter(attribute, for_main_world_suffix)}}{% endif %}
71 {% if attribute.has_normal_setter %}
72 {{attribute_setter_callback(attribute, for_main_world_suffix)}}{% endif %}
73 {% endfor %}
74 {% endfor %}
75 {# ############################################## Functions #}
76 {% for function in functions %}
77 {% if function.name and not function.is_custom %}
78 {% for for_main_world_suffix in function.for_main_world_suffixes %}
79 {{method(function, for_main_world_suffix)}}{% endfor %}
80 {% endif %}
81 {# ###### Function callback #}
82 {% for for_main_world_suffix in function.for_main_world_suffixes %}
83 {{method_callback(function, for_main_world_suffix)}}{% endfor %}
84 {% endfor %}
85 {# for functions #}
86 {##############################################################################}
87 {# Constructors #}
88 {##############################################################################}
89 {% if not has_custom_constructor %}
90 {{make_constructors()}}{% endif %}
91 {##############################################################################}
92 {# GenerateImplementationIndexedPropertyAccessors #}
93 {# GenerateImplementationIndexedPropertyGetter #}
94 {% if special_accessors.indexed.getter.enabled and not special_accessors.indexed .getter.is_custom %}
95 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
96 {
97 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
98 {{cpp_class_name}}* collection = {{v8_class_name}}::toNative(info.Holder());
99 {% if special_accessors.indexed.getter.raises_exceptions %}
100 ExceptionState es(info.GetIsolate());
101 {% endif %}
102 {# TODO use function_call {{function_call(indexed_getter.function_call_parameter )}}#}
103 {{special_accessors.indexed.getter.function_call}}
104 {% if special_accessors.indexed.getter.raises_exceptions %}
105 if (es.throwIfNeeded())
106 return;
107 {% endif %}
108 {% if special_accessors.indexed.getter.return_type_is_union %}
109 {#TODO#}
110 {{special_accessors.indexed.getter.return_js_value_statement | indent}}
111 return;
112 {% else %}
113 if ({{special_accessors.indexed.getter.is_null_expression}})
114 return;
115 {{special_accessors.indexed.getter.return_js_value_statement | indent}}
116 {% endif %}
117 }
118
119 {% endif %}
120 {# GenerateImplementationIndexedPropertyGetterCallback #}
121 {% if special_accessors.indexed.getter.enabled %}
122 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info)
123 {
124 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
125 {% if special_accessors.indexed.getter.is_custom %}
126 {{v8_class_name}}::indexedPropertyGetterCustom(index, info);
127 {% else %}
128 {{cpp_class_name}}V8Internal::indexedPropertyGetter(index, info);
129 {% endif %}
130 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
131 }
132
133 {% endif %}
134 {# GenerateImplementationIndexedPropertySetter #}
135 {% if special_accessors.indexed.setter.enabled and not special_accessors.indexed .setter.is_custom %}
136 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, co nst v8::PropertyCallbackInfo<v8::Value>& info)
137 {
138 {{cpp_class_name}}* collection = {{v8_class_name}}::toNative(info.Holder());
139 {{special_accessors.indexed.setter.js_to_native_statement}}
140 {% if special_accessors.indexed.setter.raises_exceptions %}
141 ExceptionState es(info.GetIsolate());
142 {% endif %}
143 {{if_else_statement('bool', 'result', special_accessors.indexed.setter.condition _and_statements)}}
144 if (!result)
145 return;
146 {% if special_accessors.indexed.setter.raises_exceptions %}
147 if (es.throwIfNeeded())
148 return;
149 {% endif %}
150 v8SetReturnValue(info, value);
151 }
152
153 {% endif %}
154 {# GenerateImplementationIndexedPropertySetterCallback #}
155 {% if special_accessors.indexed.setter.enabled %}
156 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v alue, const v8::PropertyCallbackInfo<v8::Value>& info)
157 {
158 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
159 {% if special_accessors.indexed.getter.is_custom %}
160 {{v8_class_name}}::indexedPropertySetterCustom(index, value, info);
161 {% else %}
162 {{cpp_class_name}}V8Internal::indexedPropertySetter(index, value, info);
163 {% endif %}
164 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
165 }
166
167 {% endif %}
168 {# GenerateImplementationIndexedPropertyDeleter #}
169 {# GenerateImplementationIndexedPropertyDeleterCallback #}
170 {##############################################################################}
171 {##############################################################################}
172 {# GenerateImplementationNamedPropertyAccessors #}
173 {# GenerateImplementationNamedPropertyGetter #}
174 {% if special_accessors.named.getter.enabled and not special_accessors.named.get ter.is_custom %}
175 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa llbackInfo<v8::Value>& info)
176 {
177 {% if not special_accessors.named.getter.override_builtins %}
178 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
179 return;
180 if (info.Holder()->HasRealNamedCallbackProperty(name))
181 return;
182 if (info.Holder()->HasRealNamedProperty(name))
183 return;
184
185 {% endif %}
186 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
187 {{cpp_class_name}}* collection = {{v8_class_name}}::toNative(info.Holder());
188 AtomicString propertyName = toWebCoreAtomicString(name);
189 {% if special_accessors.named.getter.raises_exceptions %}
190 ExceptionState es(info.GetIsolate());
191 {% endif %}
192 {{special_accessors.named.getter.function_call}}
193 {% if special_accessors.named.getter.raises_exceptions %}
194 if (es.throwIfNeeded())
195 return;
196 {% endif %}
197 {% if special_accessors.named.getter.is_return_type_union %}
198 {{special_accessors.named.getter.return_js_value_code}}
199 return;
200 {% else %}
201 if ({{special_accessors.named.getter.is_null_expression}})
202 return;
203 {{special_accessors.named.getter.return_js_value_code}}
204 {% endif %}
205 }
206
207 {% endif %}
208 {# GenerateImplementationNamedPropertyGetterCallback #}
209 {% if special_accessors.named.getter.enabled %}
210 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr opertyCallbackInfo<v8::Value>& info)
211 {
212 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
213 {% if special_accessors.named.getter.is_custom %}
214 {{v8_class_name}}::namedPropertyGetterCustom(name, info);
215 {% else %}
216 {{cpp_class_name}}V8Internal::namedPropertyGetter(name, info);
217 {% endif %}
218 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
219 }
220
221 {% endif %}
222 {# GenerateImplementationNamedPropertySetter #}
223 {# GenerateImplementationNamedPropertySetterCallback #}
224 {% if special_accessors.named.setter.enabled %}
225 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8 ::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
226 {
227 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
228 {% if special_accessors.named.setter.is_custom %}
229 {{v8_class_name}}::namedPropertySetterCustom(name, value, info);
230 {% else %}
231 {{cpp_class_name}}V8Internal::namedPropertySetter(name, value, info);
232 {% endif %}
233 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
234 }
235
236 {% endif %}
237 {# GenerateImplementationNamedPropertyDeleter #}
238 {# GenerateImplementationNamedPropertyDeleterCallback #}
239 {% if special_accessors.named.deleter.enabled %}
240 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, v8::Local<v 8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
241 {
242 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
243 {% if special_accessors.named.deleter.is_custom %}
244 {{v8_class_name}}::namedPropertyDeleterCustom(name, info);
245 {% else %}
246 {{cpp_class_name}}V8Internal::namedPropertyDeleter(name, info);
247 {% endif %}
248 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
249 }
250 {% endif %}
251 {# GenerateImplementationNamedPropertyEnumerator #}
252 {# GenerateImplementationNamedPropertyQuery #}
253 {# GenerateImplementationNamedPropertyEnumeratorCallback #}
254 {# GenerateImplementationNamedPropertyQueryCallback #}
255 {##############################################################################}
256 {##############################################################################}
257 {# GenerateImplementationNamedPropertyAccessors #}
258 {# GenerateImplementationMasqueradesAsUndefined #}
259 {##############################################################################}
260 } // namespace {{cpp_class_name}}V8Internal
261
262 {% if needs_opaque_root_for_gc %}
263 void* {{v8_class_name}}::opaqueRootForGC(void* object, v8::Isolate* isolate)
264 {
265 {{cpp_class_name}}* impl = fromInternalPointer(object);
266 {% if is_reachable_method %}
267 if (Node* owner = impl->{{is_reachable_method}}())
268 return V8GCController::opaqueRootForGC(owner, isolate);
269 {% endif %}
270 return object;
271 }
272
273 {% endif %}
274 {% if not has_custom_constructor %}
275 {{more_constructor_stuff()}}{% endif %}
276 {# FIXME: pass a list of normal_attributes, instead of length and is_normal #}
277 {% if number_of_normal_attributes %}
278 {{batched_attribute()}}
279 {% endif %}
280 {# ### BatchedFunction #}
281 {% if function_callbacks %}
282 static const V8DOMConfiguration::BatchedMethod {{v8_class_name}}Methods[] = {
283 {% for function in functions %}
284 {% if function.create_callback %}
285 {% if function.conditional_string %}
286 #if {{function.conditional_string}}
287 {% endif %}
288 {"{{function.name}}", {{cpp_class_name}}V8Internal::{{function.name}}MethodC allback, {{function.method_for_main_world}}, {{function.length}}},
289 {% if function.conditional_string %}
290 #endif // {{function.conditional_string}}
291 {% endif %}
292 {% endif %}
293 {% endfor %}
294 };
295
296 {% endif %}
297 {% if constants %}
298 {{class_consts()}}
299 {% endif %}
300 {% if not has_custom_constructor %}
301 {% if is_constructor_template_of_event %}
302 bool fill{{cpp_class_name}}Init({{cpp_class_name}}Init& eventInit, const Diction ary& options)
303 {
304 {% if parent %}
305 if (!fill{{parent}}Init(eventInit, options))
306 return false;
307
308 {% endif %}
309 {% for attribute in attributes %}
310 {% if attribute.type != 'any' and attribute.initialized_by_event_constructor %}
311 options.get("{{attribute.name}}", eventInit.{{attribute.name}});
312 {% endif %}
313 {% endfor %}
314 return true;
315 }
316
317 {% endif %}
318 {% endif %}
319 {% if is_constructable %}
320 {{constructor_callback()}}
321 {% endif %}
322 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current WorldType)
323 {
324 desc->ReadOnlyPrototype();
325
326 v8::Local<v8::Signature> defaultSignature;
327 {% if enabled_at_runtime %}
328 if (!{{enable_function}}())
329 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "", {{par ent_class_template}}, {{v8_class_name}}::internalFieldCount, 0, 0, 0, 0, isolate , currentWorldType);
330 else
331 {% endif %}
332 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_ name}}", {{parent_class_template}}, {{v8_class_name}}::internalFieldCount,
333 {{configure_template_batched_attribute}}, {{configure_template_attribute _count}},
334 {{configure_template_batched_method}}, {{configure_template_method_count }}, isolate, currentWorldType);
335 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
336 {% if is_constructable %}
337 desc->SetCallHandler({{v8_class_name}}::constructorCallback);
338 desc->SetLength({{interface_length}});
339 {% endif %}
340 {% if access_check or number_of_enabled_at_runtime_attributes or number_of_norma l_functions or constants %}
341 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
342 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
343 UNUSED_PARAM(instance); // In some cases, it will not be used.
344 UNUSED_PARAM(proto); // In some cases, it will not be used.
345 {% endif %}
346 {% if access_check %}
347 instance->SetAccessCheckCallbacks({{cpp_class_name}}V8Internal::namedSecurit yCheck, {{cpp_class_name}}V8Internal::indexedSecurityCheck, v8::External::New(&{ {v8_class_name}}::info));
348 {% endif %}
349 {# FIXME: instead pass a list of enabled_at_runtime_attributes #}
350 {% if number_of_enabled_at_runtime_attributes %}
351 {{enabled_at_runtime_batched_attribute()}}{% endif %}
352 {% for constant in constants %}{{const_data(constant)}}{% endfor %}
353 {# TODO GenerateImplementationIndexedPropertyAccessors #}
354 {% if special_accessors.indexed.getter.enabled %}
355 desc->{{special_accessors.set_on}}Template()->SetIndexedPropertyHandler({{sp ecial_accessors.indexed.getter.callback_name}}, {{special_accessors.indexed.sett er.callback_name}}, {{special_accessors.indexed.query.callback_name}}, {{special _accessors.indexed.deleter.callback_name}}, {{special_accessors.indexed.enumerat or.callback_name}});
356 {% endif %}
357 {# TODO GenerateImplementationNamedPropertyAccessors #}
358 {% if special_accessors.named.getter.enabled %}
359 desc->{{special_accessors.set_on}}Template()->SetNamedPropertyHandler({{spec ial_accessors.named.getter.callback_name}}, {{special_accessors.named.setter.cal lback_name}}, {{special_accessors.named.query.callback_name}}, {{special_accesso rs.named.deleter.callback_name}}, {{special_accessors.named.enumerator.callback_ name}});
360 {% endif %}
361 {# TODO GenerateImplementationLegacyCall #}
362 {% if custom_legacy_call %}
363 desc->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class_name}}::legacy CallCustom);
364 {% endif %}
365 {# TODO GenerateImplementationMasqueradesAsUndefined #}
366 {% for function in functions %}
367 {% if function.is_representative and function.is_normal_function and not functio n.is_standard_function %}
368 {% if check_security and function.do_not_check_security %}
369
370 // {{function.comment_info}}
371 {{function.conditional_runtime}}{{function.template}}->SetAccessor(v8::Strin g::NewSymbol("{{function.name}}"), {{cpp_class_name}}V8Internal::{{function.name }}AttrGetterCallback, {{function.setter}}, v8Undefined(), v8::ALL_CAN_READ, stat ic_cast<v8::PropertyAttribute>({{function.property_attributes}}));
372
373 {% else %}
374 {% if function.conditional_string %}
375 #if {{function.conditional_string}}
376 {%- endif %}
377 {% if function.requires_custom_signature %}
378
379 // Custom Signature '{{function.name}}'
380 const int {{function.name}}Argc = {{function.parameters | length}};
381 v8::Handle<v8::FunctionTemplate> {{function.name}}Argv[{{function.name}}Argc ] = { {{function.custom_signature}} };
382 v8::Handle<v8::Signature> {{function.name}}Signature = v8::Signature::New(de sc, {{function.name}}Argc, {{function.name}}Argv);
383 {% endif %}
384 {# see end of GenerateNonStandardFunction in perl #}
385 {% if function.per_world_bindings %}
386 if (currentWorldType == MainWorld) {
387 {{function.conditional_runtime}}{{function.template}}->Set(v8::String::N ewSymbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Int ernal::{{function.name}}MethodCallbackForMainWorld, v8Undefined(), {{function.si gnature}}, {{function.mandatory_parameters}}){{function.property_attributes}});
388 } else {
389 {{function.conditional_runtime}}{{function.template}}->Set(v8::String::N ewSymbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Int ernal::{{function.name}}MethodCallback, v8Undefined(), {{function.signature}}, { {function.mandatory_parameters}}){{function.property_attributes}});
390 }
391 {% else %}
392 {{function.conditional_runtime}}{{function.template}}->Set(v8::String::NewSy mbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Interna l::{{function.name}}MethodCallback, v8Undefined(), {{function.signature}}, {{fun ction.mandatory_parameters}}){{function.property_attributes}});
393 {% endif %}
394 {% if function.conditional_string %}
395 #endif // {{function.conditional_string}}{% endif %}
396 {% endif %}
397 {% endif %}
398 {% endfor %}
399 {% if constants %}
400 {{batch_configure_constants()}}
401 {% endif %}
402
403 // Custom toString template
404 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
405 return desc;
406 }
407
408 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso late, WrapperWorldType currentWorldType)
409 {
410 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
411 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info);
412 if (result != data->templateMap(currentWorldType).end())
413 return result->value.newLocal(isolate);
414
415 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
416 v8::HandleScope handleScope(isolate);
417 v8::Handle<v8::FunctionTemplate> templ =
418 Configure{{v8_class_name}}Template(data->rawTemplate(&info, currentWorld Type), isolate, currentWorldType);
419 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function Template>(isolate, templ));
420 return handleScope.Close(templ);
421 }
422
423 bool {{v8_class_name}}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* is olate, WrapperWorldType currentWorldType)
424 {
425 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType);
426 }
427
428 bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I solate* isolate)
429 {
430 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
431 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld)
432 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d);
433 }
434
435 {% if number_of_enabled_per_context_functions %}
436 void {{v8_class_name}}::installPerContextPrototypeProperties(v8::Handle<v8::Obje ct> proto, v8::Isolate* isolate)
437 {
438 UNUSED_PARAM(proto);
439 {# Setup the enable-by-settings functions if we have them #}
440 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate)));
441 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
442
443 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext());
444 {% for function in functions %}
445 {% if function.is_enabled_per_context_function %}
446 {% if function.conditional_string %}
447 #if {{function.conditional_string}}
448 {% endif %}
449 if (context && context->isDocument() && {{function.enable_function}}(toDocum ent(context)))
450 proto->Set(v8::String::NewSymbol("{{function.name}}"), v8::FunctionTempl ate::New({{cpp_class_name}}V8Internal::{{function.name}}MethodCallback, v8Undefi ned(), defaultSignature, {{function.mandatory_parameters}})->GetFunction());
451 {% if function.conditional_string %}
452 #endif // {{function.conditional_string}}
453 {% endif %}
454
455 {% endif %}
456 {% endfor %}
457 }
458 {% endif %}
459 {% if inherits_extended_attribute_active_dom_object %}
460 ActiveDOMObject* {{v8_class_name}}::toActiveDOMObject(v8::Handle<v8::Object> obj ect)
461 {
462 return {{active_dom_object_return_value}};
463 }
464
465 {% endif %}
466 {% if inherits_event_target %}
467 EventTarget* {{v8_class_name}}::toEventTarget(v8::Handle<v8::Object> object)
468 {
469 return toNative(object);
470 }
471
472 {% endif %}
473 {% if create_wrapper %}
474
475 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{create_wrap per_argument_type}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
476 {
477 ASSERT(impl.get());
478 ASSERT(DOMDataStore::getWrapper<{{v8_class_name}}>(impl.get(), isolate).IsEm pty());
479 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
480 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
481 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have
482 // the same object de-ref functions, though, so use that as the basis of the check.
483 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction);
484 }
485
486 {% if inherit_document %}
487 if (Frame* frame = impl->frame()) {
488 if (frame->script()->initializeMainWorld()) {
489 // initializeMainWorld may have created a wrapper for the object, re try from the start.
490 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<{{v8_class _name}}>(impl.get(), isolate);
491 if (!wrapper.IsEmpty())
492 return wrapper;
493 }
494 }
495 {% endif %}
496
497 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate);
498 if (UNLIKELY(wrapper.IsEmpty()))
499 return wrapper;
500 {% if interface_name == 'ArrayBuffer' %}
501 if (!impl->hasDeallocationObserver()) {
502 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->byteLength());
503 impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanc e());
504 }
505 {% elif is_typed_array_type %}
506 if (!impl->buffer()->hasDeallocationObserver()) {
507 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->buffer()->byteLength ());
508 impl->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserve r::instance());
509 }
510 {% endif %}
511 installPerContextProperties(wrapper, impl.get(), isolate);
512 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra pper, isolate, {{wrapper_configuration}});
513 return wrapper;
514 }
515 {% endif %}
516 void {{v8_class_name}}::derefObject(void* object)
517 {
518 fromInternalPointer(object)->deref();
519 }
520
521 } // namespace WebCore
522 {% if conditional_string %}
523
524 #endif // {{conditional_string}}
525 {% endif %}
526
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_wip.h ('k') | Source/bindings/templates/macros.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698