Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / templates / interface_base.cpp
1 {# http://www.chromium.org/blink/coding-style#TOC-License #}
2 /*
3  * Copyright (C) 2013 Google Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 {# FIXME: Rename to Python when switch #}
33 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
34
35 #include "config.h"
36 {% filter conditional(conditional_string) %}
37 #include "{{v8_class}}.h"
38
39 {% for filename in cpp_includes if filename != '%s.h' % v8_class %}
40 #include "{{filename}}"
41 {% endfor %}
42
43 namespace WebCore {
44
45 static void initializeScriptWrappableForInterface({{cpp_class}}* object)
46 {
47     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
48         ScriptWrappable::setTypeInfoInObject(object, &{{v8_class}}::wrapperTypeInfo);
49     else
50         ASSERT_NOT_REACHED();
51 }
52
53 } // namespace WebCore
54
55 // In ScriptWrappable::init, the use of a local function declaration has an issue on Windows:
56 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
57 // in the global namespace.
58 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
59 void webCoreInitializeScriptWrappableForInterface(WebCore::{{cpp_class}}* object)
60 {
61     WebCore::initializeScriptWrappableForInterface(object);
62 }
63
64 namespace WebCore {
65 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
66                               if is_active_dom_object else '0' %}
67 {% set to_event_target = '%s::toEventTarget' % v8_class
68                          if is_event_target else '0' %}
69 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class
70                            if has_visit_dom_wrapper else '0' %}
71 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface
72                                   if parent_interface else '0' %}
73 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else
74                                 'WrapperTypeObjectPrototype' %}
75 {% set will_be_garbage_collected = 'true'
76        if is_will_be_garbage_collected else 'false' %}
77 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}}::installPerContextEnabledMethods, {{parent_wrapper_type_info}}, {{wrapper_type_prototype}}, {{will_be_garbage_collected}} };
78
79 namespace {{cpp_class}}V8Internal {
80
81 template <typename T> void V8_USE(T) { }
82
83 {# Attributes #}
84 {% from 'attributes.cpp' import attribute_getter, attribute_getter_callback,
85        attribute_setter, attribute_setter_callback
86    with context %}
87 {% for attribute in attributes if not attribute.constructor_type %}
88 {% for world_suffix in attribute.world_suffixes %}
89 {% if not attribute.has_custom_getter %}
90 {{attribute_getter(attribute, world_suffix)}}
91 {% endif %}
92 {{attribute_getter_callback(attribute, world_suffix)}}
93 {% if not attribute.is_read_only or attribute.put_forwards %}
94 {% if not attribute.has_custom_setter %}
95 {{attribute_setter(attribute, world_suffix)}}
96 {% endif %}
97 {{attribute_setter_callback(attribute, world_suffix)}}
98 {% endif %}
99 {% endfor %}
100 {% endfor %}
101 {% block constructor_getter %}{% endblock %}
102 {% block replaceable_attribute_setter_and_callback %}{% endblock %}
103 {% block security_check_functions %}{% endblock %}
104 {# Methods #}
105 {% from 'methods.cpp' import generate_method, overload_resolution_method,
106        method_callback, origin_safe_method_getter, generate_constructor
107        with context %}
108 {% for method in methods %}
109 {% for world_suffix in method.world_suffixes %}
110 {% if not method.is_custom %}
111 {{generate_method(method, world_suffix)}}
112 {% endif %}
113 {% if method.overloads %}
114 {{overload_resolution_method(method.overloads, world_suffix)}}
115 {% endif %}
116 {% if not method.overload_index or method.overloads %}
117 {# A single callback is generated for overloaded methods #}
118 {{method_callback(method, world_suffix)}}
119 {% endif %}
120 {% if method.is_do_not_check_security %}
121 {{origin_safe_method_getter(method, world_suffix)}}
122 {% endif %}
123 {% endfor %}
124 {% endfor %}
125 {% block origin_safe_method_setter %}{% endblock %}
126 {# Constructors #}
127 {% for constructor in constructors %}
128 {{generate_constructor(constructor)}}
129 {% endfor %}
130 {% block overloaded_constructor %}{% endblock %}
131 {% block event_constructor %}{% endblock %}
132 {# Special operations (methods) #}
133 {% block indexed_property_getter %}{% endblock %}
134 {% block indexed_property_getter_callback %}{% endblock %}
135 {% block indexed_property_setter %}{% endblock %}
136 {% block indexed_property_setter_callback %}{% endblock %}
137 {% block indexed_property_deleter %}{% endblock %}
138 {% block indexed_property_deleter_callback %}{% endblock %}
139 {% block named_property_getter %}{% endblock %}
140 {% block named_property_getter_callback %}{% endblock %}
141 {% block named_property_setter %}{% endblock %}
142 {% block named_property_setter_callback %}{% endblock %}
143 {% block named_property_query %}{% endblock %}
144 {% block named_property_query_callback %}{% endblock %}
145 {% block named_property_deleter %}{% endblock %}
146 {% block named_property_deleter_callback %}{% endblock %}
147 {% block named_property_enumerator %}{% endblock %}
148 {% block named_property_enumerator_callback %}{% endblock %}
149 } // namespace {{cpp_class}}V8Internal
150
151 {% block visit_dom_wrapper %}{% endblock %}
152 {% block shadow_attributes %}{% endblock %}
153 {% block class_attributes %}{% endblock %}
154 {% block class_accessors %}{% endblock %}
155 {% block class_methods %}{% endblock %}
156 {% block named_constructor %}{% endblock %}
157 {% block initialize_event %}{% endblock %}
158 {% block constructor_callback %}{% endblock %}
159 {% block configure_shadow_object_template %}{% endblock %}
160 {% block configure_class_template %}{% endblock %}
161 {% block get_template %}{% endblock %}
162 {% block has_instance %}{% endblock %}
163 {% block install_per_context_attributes %}{% endblock %}
164 {% block install_per_context_methods %}{% endblock %}
165 {% block to_active_dom_object %}{% endblock %}
166 {% block to_event_target %}{% endblock %}
167 {% block get_shadow_object_template %}{% endblock %}
168 {% block wrap %}{% endblock %}
169 {% block create_wrapper %}{% endblock %}
170 {% block deref_object_and_to_v8_no_inline %}{% endblock %}
171 } // namespace WebCore
172 {% endfilter %}