Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / templates / interface_base.cpp
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6
7 #include "config.h"
8 {% filter conditional(conditional_string) %}
9 #include "{{v8_class}}.h"
10
11 {% for filename in cpp_includes if filename != '%s.h' % v8_class %}
12 #include "{{filename}}"
13 {% endfor %}
14
15 namespace blink {
16
17 static void initializeScriptWrappableForInterface({{cpp_class}}* object)
18 {
19     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
20         ScriptWrappable::fromObject(object)->setTypeInfo(&{{v8_class}}::wrapperTypeInfo);
21     else
22         ASSERT_NOT_REACHED();
23 }
24
25 } // namespace blink
26
27 {#
28 In ScriptWrappable::init, the use of a local function declaration has an
29 issue on Windows: the local declaration does not pick up the surrounding
30 namespace. Therefore, we provide this function in the global namespace.
31 More info on the MSVC bug here (Bug 664619):
32 The namespace of local function declarations in C++ by Uray M. János
33 http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c
34 #}
35 void webCoreInitializeScriptWrappableForInterface(blink::{{cpp_class}}* object)
36 {
37     blink::initializeScriptWrappableForInterface(object);
38 }
39
40 namespace blink {
41 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
42                               if is_active_dom_object else '0' %}
43 {% set to_event_target = '%s::toEventTarget' % v8_class
44                          if is_event_target else '0' %}
45 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class
46                            if has_visit_dom_wrapper else '0' %}
47 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface
48                                   if parent_interface else '0' %}
49 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else
50                                 'WrapperTypeObjectPrototype' %}
51 const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{v8_class}}::domTemplate, {{v8_class}}::derefObject, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{parent_wrapper_type_info}}, {{wrapper_type_prototype}}, {{gc_type}} };
52
53 namespace {{cpp_class}}V8Internal {
54
55 template <typename T> void V8_USE(T) { }
56
57 {# Attributes #}
58 {% from 'attributes.cpp' import constructor_getter_callback,
59        attribute_getter, attribute_getter_callback,
60        attribute_setter, attribute_setter_callback,
61        attribute_getter_implemented_in_private_script,
62        attribute_setter_implemented_in_private_script
63        with context %}
64 {% for attribute in attributes if not attribute.constructor_type %}
65 {% if attribute.should_be_exposed_to_script %}
66 {% for world_suffix in attribute.world_suffixes %}
67 {% if not attribute.has_custom_getter %}
68 {{attribute_getter(attribute, world_suffix)}}
69 {% endif %}
70 {{attribute_getter_callback(attribute, world_suffix)}}
71 {% if not attribute.is_read_only or attribute.put_forwards %}
72 {% if not attribute.has_custom_setter %}
73 {{attribute_setter(attribute, world_suffix)}}
74 {% endif %}
75 {{attribute_setter_callback(attribute, world_suffix)}}
76 {% endif %}
77 {% endfor %}
78 {% endif %}
79 {% endfor %}
80 {% block constructor_getter %}{% endblock %}
81 {% for attribute in attributes if attribute.needs_constructor_getter_callback %}
82 {% for world_suffix in attribute.world_suffixes %}
83 {{constructor_getter_callback(attribute, world_suffix)}}
84 {% endfor %}
85 {% endfor %}
86 {% block replaceable_attribute_setter_and_callback %}{% endblock %}
87 {% block security_check_functions %}{% endblock %}
88 {# Methods #}
89 {% from 'methods.cpp' import generate_method, overload_resolution_method,
90        method_callback, origin_safe_method_getter, generate_constructor,
91        method_implemented_in_private_script
92        with context %}
93 {% for method in methods %}
94 {% if method.should_be_exposed_to_script %}
95 {% for world_suffix in method.world_suffixes %}
96 {% if not method.is_custom %}
97 {{generate_method(method, world_suffix)}}
98 {% endif %}
99 {% if method.overloads %}
100 {{overload_resolution_method(method.overloads, world_suffix)}}
101 {% endif %}
102 {% if not method.overload_index or method.overloads %}
103 {# A single callback is generated for overloaded methods #}
104 {{method_callback(method, world_suffix)}}
105 {% endif %}
106 {% if method.is_do_not_check_security %}
107 {{origin_safe_method_getter(method, world_suffix)}}
108 {% endif %}
109 {% endfor %}
110 {% endif %}
111 {% endfor %}
112 {% block origin_safe_method_setter %}{% endblock %}
113 {# Constructors #}
114 {% for constructor in constructors %}
115 {{generate_constructor(constructor)}}
116 {% endfor %}
117 {% block overloaded_constructor %}{% endblock %}
118 {% block event_constructor %}{% endblock %}
119 {# Special operations (methods) #}
120 {% block indexed_property_getter %}{% endblock %}
121 {% block indexed_property_getter_callback %}{% endblock %}
122 {% block indexed_property_setter %}{% endblock %}
123 {% block indexed_property_setter_callback %}{% endblock %}
124 {% block indexed_property_deleter %}{% endblock %}
125 {% block indexed_property_deleter_callback %}{% endblock %}
126 {% block named_property_getter %}{% endblock %}
127 {% block named_property_getter_callback %}{% endblock %}
128 {% block named_property_setter %}{% endblock %}
129 {% block named_property_setter_callback %}{% endblock %}
130 {% block named_property_query %}{% endblock %}
131 {% block named_property_query_callback %}{% endblock %}
132 {% block named_property_deleter %}{% endblock %}
133 {% block named_property_deleter_callback %}{% endblock %}
134 {% block named_property_enumerator %}{% endblock %}
135 {% block named_property_enumerator_callback %}{% endblock %}
136 } // namespace {{cpp_class}}V8Internal
137
138 {% block visit_dom_wrapper %}{% endblock %}
139 {% block shadow_attributes %}{% endblock %}
140 {% block install_attributes %}{% endblock %}
141 {% block install_accessors %}{% endblock %}
142 {% block install_methods %}{% endblock %}
143 {% block named_constructor %}{% endblock %}
144 {% block initialize_event %}{% endblock %}
145 {% block constructor_callback %}{% endblock %}
146 {% block configure_shadow_object_template %}{% endblock %}
147 {% block install_dom_template %}{% endblock %}
148 {% block get_dom_template %}{% endblock %}
149 {% block has_instance %}{% endblock %}
150 {% block to_native_with_type_check %}{% endblock %}
151 {% block install_conditional_attributes %}{% endblock %}
152 {% block install_conditional_methods %}{% endblock %}
153 {% block to_active_dom_object %}{% endblock %}
154 {% block to_event_target %}{% endblock %}
155 {% block get_shadow_object_template %}{% endblock %}
156 {% block wrap %}{% endblock %}
157 {% block create_wrapper %}{% endblock %}
158 {% block deref_object_and_to_v8_no_inline %}{% endblock %}
159 {% for method in methods if method.is_implemented_in_private_script %}
160 {{method_implemented_in_private_script(method)}}
161 {% endfor %}
162 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
163 {{attribute_getter_implemented_in_private_script(attribute)}}
164 {% if not attribute.is_read_only or attribute.put_forwards %}
165 {{attribute_setter_implemented_in_private_script(attribute)}}
166 {% endif %}
167 {% endfor %}
168 } // namespace blink
169 {% endfilter %}