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

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

Issue 101443002: IDL compiler: remove redundant '_name' from template parameters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 {% endif %} 77 {% endif %}
78 {% endblock %} 78 {% endblock %}
79 79
80 80
81 {##############################################################################} 81 {##############################################################################}
82 {% block security_check_functions %} 82 {% block security_check_functions %}
83 {% if is_check_security and interface_name != 'Window' %} 83 {% if is_check_security and interface_name != 'Window' %}
84 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>) 84 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
85 { 85 {
86 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host); 86 {{cpp_class}}* imp = {{v8_class}}::toNative(host);
87 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); 87 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
88 } 88 }
89 89
90 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>) 90 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
91 { 91 {
92 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host); 92 {{cpp_class}}* imp = {{v8_class}}::toNative(host);
93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); 93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
94 } 94 }
95 95
96 {% endif %} 96 {% endif %}
97 {% endblock %} 97 {% endblock %}
98 98
99 99
100 {##############################################################################} 100 {##############################################################################}
101 {% block origin_safe_method_setter %} 101 {% block origin_safe_method_setter %}
102 {% if has_origin_safe_method_setter %} 102 {% if has_origin_safe_method_setter %}
103 static void {{cpp_class_name}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 103 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8:: Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
104 { 104 {
105 {# FIXME: don't call GetIsolate 3 times #} 105 {# FIXME: don't call GetIsolate 3 times #}
106 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 106 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
107 if (holder.IsEmpty()) 107 if (holder.IsEmpty())
108 return; 108 return;
109 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); 109 {{cpp_class}}* imp = {{v8_class}}::toNative(holder);
110 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 110 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
111 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 111 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
112 exceptionState.throwIfNeeded(); 112 exceptionState.throwIfNeeded();
113 return; 113 return;
114 } 114 }
115 115
116 info.This()->SetHiddenValue(name, jsValue); 116 info.This()->SetHiddenValue(name, jsValue);
117 } 117 }
118 118
119 static void {{cpp_class_name}}OriginSafeMethodSetterCallback(v8::Local<v8::Strin g> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& inf o) 119 static void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::String> na me, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
120 { 120 {
121 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 121 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
122 {{cpp_class_name}}V8Internal::{{cpp_class_name}}OriginSafeMethodSetter(name, jsValue, info); 122 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, jsValue, info);
123 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 123 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
124 } 124 }
125 125
126 {% endif %} 126 {% endif %}
127 {% endblock %} 127 {% endblock %}
128 128
129 129
130 {##############################################################################} 130 {##############################################################################}
131 {% block visit_dom_wrapper %} 131 {% block visit_dom_wrapper %}
132 {% if generate_visit_dom_wrapper_function %} 132 {% if generate_visit_dom_wrapper_function %}
133 void {{v8_class_name}}::visitDOMWrapper(void* object, const v8::Persistent<v8::O bject>& wrapper, v8::Isolate* isolate) 133 void {{v8_class}}::visitDOMWrapper(void* object, const v8::Persistent<v8::Object >& wrapper, v8::Isolate* isolate)
134 { 134 {
135 {{cpp_class_name}}* impl = fromInternalPointer(object); 135 {{cpp_class}}* impl = fromInternalPointer(object);
136 if (Node* owner = impl->{{generate_visit_dom_wrapper_function}}()) { 136 if (Node* owner = impl->{{generate_visit_dom_wrapper_function}}()) {
137 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper, isolate); 137 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper, isolate);
138 return; 138 return;
139 } 139 }
140 setObjectGroup(object, wrapper, isolate); 140 setObjectGroup(object, wrapper, isolate);
141 } 141 }
142 142
143 {% endif %} 143 {% endif %}
144 {% endblock %} 144 {% endblock %}
145 145
146 146
147 {##############################################################################} 147 {##############################################################################}
148 {% block class_attributes %} 148 {% block class_attributes %}
149 {# FIXME: rename to install_attributes and put into configure_class_template #} 149 {# FIXME: rename to install_attributes and put into configure_class_template #}
150 {% if attributes %} 150 {% if attributes %}
151 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { 151 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = {
152 {% for attribute in attributes 152 {% for attribute in attributes
153 if not (attribute.is_expose_js_accessors or 153 if not (attribute.is_expose_js_accessors or
154 attribute.is_static or 154 attribute.is_static or
155 attribute.runtime_enabled_function_name or 155 attribute.runtime_enabled_function or
156 attribute.per_context_enabled_function_name) %} 156 attribute.per_context_enabled_function) %}
157 {% filter conditional(attribute.conditional_string) %} 157 {% filter conditional(attribute.conditional_string) %}
158 {{attribute_configuration(attribute)}}, 158 {{attribute_configuration(attribute)}},
159 {% endfilter %} 159 {% endfilter %}
160 {% endfor %} 160 {% endfor %}
161 }; 161 };
162 162
163 {% endif %} 163 {% endif %}
164 {% endblock %} 164 {% endblock %}
165 165
166 166
167 {##############################################################################} 167 {##############################################################################}
168 {% block class_accessors %} 168 {% block class_accessors %}
169 {# FIXME: rename install_accessors and put into configure_class_template #} 169 {# FIXME: rename install_accessors and put into configure_class_template #}
170 {% if has_accessors %} 170 {% if has_accessors %}
171 static const V8DOMConfiguration::AccessorConfiguration {{v8_class_name}}Accessor s[] = { 171 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = {
172 {% for attribute in attributes if attribute.is_expose_js_accessors %} 172 {% for attribute in attributes if attribute.is_expose_js_accessors %}
173 {{attribute_configuration(attribute)}}, 173 {{attribute_configuration(attribute)}},
174 {% endfor %} 174 {% endfor %}
175 }; 175 };
176 176
177 {% endif %} 177 {% endif %}
178 {% endblock %} 178 {% endblock %}
179 179
180 180
181 {##############################################################################} 181 {##############################################################################}
182 {% block class_methods %} 182 {% block class_methods %}
183 {# FIXME: rename to install_methods and put into configure_class_template #} 183 {# FIXME: rename to install_methods and put into configure_class_template #}
184 {% if has_method_configuration %} 184 {% if has_method_configuration %}
185 static const V8DOMConfiguration::MethodConfiguration {{v8_class_name}}Methods[] = { 185 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = {
186 {% for method in methods if method.do_generate_method_configuration %} 186 {% for method in methods if method.do_generate_method_configuration %}
187 {% filter conditional(method.conditional_string) %} 187 {% filter conditional(method.conditional_string) %}
188 {{method_configuration(method)}}, 188 {{method_configuration(method)}},
189 {% endfilter %} 189 {% endfilter %}
190 {% endfor %} 190 {% endfor %}
191 }; 191 };
192 192
193 {% endif %} 193 {% endif %}
194 {% endblock %} 194 {% endblock %}
195 195
196 196
197 {##############################################################################} 197 {##############################################################################}
198 {% block configure_class_template %} 198 {% block configure_class_template %}
199 {# FIXME: rename to install_dom_template and Install{{v8_class_name}}DOMTemplate #} 199 {# FIXME: rename to install_dom_template and Install{{v8_class}}DOMTemplate #}
200 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H andle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorld Type currentWorldType) 200 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class}}Template(v8::Handle <v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
201 { 201 {
202 functionTemplate->ReadOnlyPrototype(); 202 functionTemplate->ReadOnlyPrototype();
203 203
204 v8::Local<v8::Signature> defaultSignature; 204 v8::Local<v8::Signature> defaultSignature;
205 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "{{interface_name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}: :internalFieldCount, 205 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "{{interface_name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class}}::inte rnalFieldCount,
206 {# Test needed as size 0 constant arrays are not allowed in VC++ #} 206 {# Test needed as size 0 constant arrays are not allowed in VC++ #}
207 {% set attributes_name, attributes_length = 207 {% set attributes_name, attributes_length =
208 ('%sAttributes' % v8_class_name, 208 ('%sAttributes' % v8_class,
209 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class_name) 209 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class)
210 if attributes else (0, 0) %} 210 if attributes else (0, 0) %}
211 {% set accessors_name, accessors_length = 211 {% set accessors_name, accessors_length =
212 ('%sAccessors' % v8_class_name, 212 ('%sAccessors' % v8_class,
213 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class_name) 213 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class)
214 if has_accessors else (0, 0) %} 214 if has_accessors else (0, 0) %}
215 {% set methods_name, methods_length = 215 {% set methods_name, methods_length =
216 ('%sMethods' % v8_class_name, 216 ('%sMethods' % v8_class,
217 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class_name) 217 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class)
218 if has_method_configuration else (0, 0) %} 218 if has_method_configuration else (0, 0) %}
219 {{attributes_name}}, {{attributes_length}}, 219 {{attributes_name}}, {{attributes_length}},
220 {{accessors_name}}, {{accessors_length}}, 220 {{accessors_name}}, {{accessors_length}},
221 {{methods_name}}, {{methods_length}}, 221 {{methods_name}}, {{methods_length}},
222 isolate, currentWorldType); 222 isolate, currentWorldType);
223 UNUSED_PARAM(defaultSignature); 223 UNUSED_PARAM(defaultSignature);
224 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate(); 224 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
225 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate(); 225 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
226 UNUSED_PARAM(instanceTemplate); 226 UNUSED_PARAM(instanceTemplate);
227 UNUSED_PARAM(prototypeTemplate); 227 UNUSED_PARAM(prototypeTemplate);
228 {% if is_check_security and interface_name != 'Window' %} 228 {% if is_check_security and interface_name != 'Window' %}
229 instanceTemplate->SetAccessCheckCallbacks({{cpp_class_name}}V8Internal::name dSecurityCheck, {{cpp_class_name}}V8Internal::indexedSecurityCheck, v8::External ::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class_name}}::wrapperTypeInfo) )); 229 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
230 {% endif %} 230 {% endif %}
231 {% for attribute in attributes if attribute.runtime_enabled_function_name %} 231 {% for attribute in attributes if attribute.runtime_enabled_function %}
232 {% filter conditional(attribute.conditional_string) %} 232 {% filter conditional(attribute.conditional_string) %}
233 if ({{attribute.runtime_enabled_function_name}}()) { 233 if ({{attribute.runtime_enabled_function}}()) {
234 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 234 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
235 {{attribute_configuration(attribute)}}; 235 {{attribute_configuration(attribute)}};
236 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate, currentWorldType); 236 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate, currentWorldType);
237 } 237 }
238 {% endfilter %} 238 {% endfilter %}
239 {% endfor %} 239 {% endfor %}
240 {% for method in methods if not method.do_not_check_signature %} 240 {% for method in methods if not method.do_not_check_signature %}
241 {% if method.custom_signature and not method.overload_index %} 241 {% if method.custom_signature and not method.overload_index %}
242 {# No custom signature needed for overloaded methods; 242 {# No custom signature needed for overloaded methods;
243 separate check because depends on global check for overloads #} 243 separate check because depends on global check for overloads #}
(...skipping 13 matching lines...) Expand all
257 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} 257 {{install_do_not_check_security_signature(method, 'ForMainWorld')}}
258 } else { 258 } else {
259 {{install_do_not_check_security_signature(method)}} 259 {{install_do_not_check_security_signature(method)}}
260 } 260 }
261 {% else %} 261 {% else %}
262 {{install_do_not_check_security_signature(method)}} 262 {{install_do_not_check_security_signature(method)}}
263 {% endif %} 263 {% endif %}
264 {% else %}{# is_do_not_check_security #} 264 {% else %}{# is_do_not_check_security #}
265 {% if method.is_per_world_bindings %} 265 {% if method.is_per_world_bindings %}
266 if (currentWorldType == MainWorld) { 266 if (currentWorldType == MainWorld) {
267 {% filter runtime_enabled(method.runtime_enabled_function_name) %} 267 {% filter runtime_enabled(method.runtime_enabled_function) %}
268 {{install_custom_signature(method, 'ForMainWorld')}} 268 {{install_custom_signature(method, 'ForMainWorld')}}
269 {% endfilter %} 269 {% endfilter %}
270 } else { 270 } else {
271 {% filter runtime_enabled(method.runtime_enabled_function_name) %} 271 {% filter runtime_enabled(method.runtime_enabled_function) %}
272 {{install_custom_signature(method)}} 272 {{install_custom_signature(method)}}
273 {% endfilter %} 273 {% endfilter %}
274 } 274 }
275 {% else %} 275 {% else %}
276 {% filter runtime_enabled(method.runtime_enabled_function_name) %} 276 {% filter runtime_enabled(method.runtime_enabled_function) %}
277 {{install_custom_signature(method)}} 277 {{install_custom_signature(method)}}
278 {% endfilter %} 278 {% endfilter %}
279 {% endif %} 279 {% endif %}
280 {% endif %}{# is_do_not_check_security #} 280 {% endif %}{# is_do_not_check_security #}
281 {% endfilter %} 281 {% endfilter %}
282 {% endif %}{# install_custom_signature #} 282 {% endif %}{# install_custom_signature #}
283 {% endfor %} 283 {% endfor %}
284 {% for attribute in attributes if attribute.is_static %} 284 {% for attribute in attributes if attribute.is_static %}
285 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % 285 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
286 (interface_name, attribute.name) %} 286 (interface_name, attribute.name) %}
287 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "{{ attribute.name}}", v8::String::kInternalizedString), {{getter_callback}}, {{attr ibute.setter_callback}}, v8::External::New(isolate, 0), static_cast<v8::Property Attribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::Acces sControl>(v8::DEFAULT)); 287 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "{{ attribute.name}}", v8::String::kInternalizedString), {{getter_callback}}, {{attr ibute.setter_callback}}, v8::External::New(isolate, 0), static_cast<v8::Property Attribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::Acces sControl>(v8::DEFAULT));
288 {% endfor %} 288 {% endfor %}
289 {% if constants %} 289 {% if constants %}
290 {{install_constants() | indent}} 290 {{install_constants() | indent}}
291 {% endif %} 291 {% endif %}
292 {% if has_custom_legacy_call %} 292 {% if has_custom_legacy_call %}
293 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class_na me}}::legacyCallCustom); 293 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom);
294 {% endif %} 294 {% endif %}
295 295
296 // Custom toString template 296 // Custom toString template
297 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); 297 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
298 return functionTemplate; 298 return functionTemplate;
299 } 299 }
300 300
301 {% endblock %} 301 {% endblock %}
302 302
303 303
304 {######################################} 304 {######################################}
305 {% macro install_do_not_check_security_signature(method, world_suffix) %} 305 {% macro install_do_not_check_security_signature(method, world_suffix) %}
306 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithDoNotCheckSecurityS ignature #} 306 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithDoNotCheckSecurityS ignature #}
307 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are 307 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are
308 changed and then accessed from a different origin, we do not return the 308 changed and then accessed from a different origin, we do not return the
309 underlying value, but instead return a new copy of the original function. 309 underlying value, but instead return a new copy of the original function.
310 This is achieved by storing the changed value as a hidden property. #} 310 This is achieved by storing the changed value as a hidden property. #}
311 {% set getter_callback = 311 {% set getter_callback =
312 '%sV8Internal::%sOriginSafeMethodGetterCallback%s' % 312 '%sV8Internal::%sOriginSafeMethodGetterCallback%s' %
313 (cpp_class_name, method.name, world_suffix) %} 313 (cpp_class, method.name, world_suffix) %}
314 {% set setter_callback = 314 {% set setter_callback =
315 '{0}V8Internal::{0}OriginSafeMethodSetterCallback'.format(cpp_class_name) 315 '{0}V8Internal::{0}OriginSafeMethodSetterCallback'.format(cpp_class)
316 if not method.is_read_only else '0' %} 316 if not method.is_read_only else '0' %}
317 {% set property_attribute = 317 {% set property_attribute =
318 'static_cast<v8::PropertyAttribute>(%s)' % 318 'static_cast<v8::PropertyAttribute>(%s)' %
319 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} 319 ' | '.join(method.property_attributes or ['v8::DontDelete']) %}
320 {{method.function_template}}->SetAccessor(v8::String::NewFromUtf8(isolate, "{{me thod.name}}", v8::String::kInternalizedString), {{getter_callback}}, {{setter_ca llback}}, v8Undefined(), v8::ALL_CAN_READ, {{property_attribute}}); 320 {{method.function_template}}->SetAccessor(v8::String::NewFromUtf8(isolate, "{{me thod.name}}", v8::String::kInternalizedString), {{getter_callback}}, {{setter_ca llback}}, v8Undefined(), v8::ALL_CAN_READ, {{property_attribute}});
321 {%- endmacro %} 321 {%- endmacro %}
322 322
323 323
324 {######################################} 324 {######################################}
325 {% macro install_custom_signature(method, world_suffix) %} 325 {% macro install_custom_signature(method, world_suffix) %}
326 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} 326 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #}
327 {% set method_callback = '%sV8Internal::%sMethodCallback%s' % 327 {% set method_callback = '%sV8Internal::%sMethodCallback%s' %
328 (interface_name, method.name, world_suffix) %} 328 (interface_name, method.name, world_suffix) %}
329 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 329 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
330 ' | '.join(method.property_attributes) %} 330 ' | '.join(method.property_attributes) %}
331 {{method.function_template}}->Set(v8::String::NewFromUtf8(isolate, "{{method.nam e}}", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, {{met hod_callback}}, v8Undefined(), {{method.signature}}, {{method.number_of_required _or_variadic_arguments}}){% if method.property_attributes %}, {{property_attribu te}}{% endif %}); 331 {{method.function_template}}->Set(v8::String::NewFromUtf8(isolate, "{{method.nam e}}", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, {{met hod_callback}}, v8Undefined(), {{method.signature}}, {{method.number_of_required _or_variadic_arguments}}){% if method.property_attributes %}, {{property_attribu te}}{% endif %});
332 {%- endmacro %} 332 {%- endmacro %}
333 333
334 334
335 {######################################} 335 {######################################}
336 {% macro install_constants() %} 336 {% macro install_constants() %}
337 {# FIXME: should use reflected_name instead of name #} 337 {# FIXME: should use reflected_name instead of name #}
338 {# Normal (always enabled) constants #} 338 {# Normal (always enabled) constants #}
339 static const V8DOMConfiguration::ConstantConfiguration {{v8_class_name}}Constant s[] = { 339 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = {
340 {% for constant in constants if not constant.runtime_enabled_function_name % } 340 {% for constant in constants if not constant.runtime_enabled_function %}
341 {"{{constant.name}}", {{constant.value}}}, 341 {"{{constant.name}}", {{constant.value}}},
342 {% endfor %} 342 {% endfor %}
343 }; 343 };
344 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, {{v8_c lass_name}}Constants, WTF_ARRAY_LENGTH({{v8_class_name}}Constants), isolate); 344 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, {{v8_c lass}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants), isolate);
345 {# Runtime-enabled constants #} 345 {# Runtime-enabled constants #}
346 {% for constant in constants if constant.runtime_enabled_function_name %} 346 {% for constant in constants if constant.runtime_enabled_function %}
347 if ({{constant.runtime_enabled_function_name}}()) { 347 if ({{constant.runtime_enabled_function}}()) {
348 static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"{{constant.name}}", static_cast<signed int>({{constant.value}})}; 348 static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"{{constant.name}}", static_cast<signed int>({{constant.value}})};
349 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, &c onstantConfiguration, 1, isolate); 349 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, &c onstantConfiguration, 1, isolate);
350 } 350 }
351 {% endfor %} 351 {% endfor %}
352 {# Check constants #} 352 {# Check constants #}
353 {% if not do_not_check_constants %} 353 {% if not do_not_check_constants %}
354 {% for constant in constants %} 354 {% for constant in constants %}
355 COMPILE_ASSERT({{constant.value}} == {{cpp_class_name}}::{{constant.reflected_na me}}, TheValueOf{{cpp_class_name}}_{{constant.reflected_name}}DoesntMatchWithImp lementation); 355 COMPILE_ASSERT({{constant.value}} == {{cpp_class}}::{{constant.reflected_name}}, TheValueOf{{cpp_class}}_{{constant.reflected_name}}DoesntMatchWithImplementatio n);
356 {% endfor %} 356 {% endfor %}
357 {% endif %} 357 {% endif %}
358 {% endmacro %} 358 {% endmacro %}
359 359
360 360
361 {##############################################################################} 361 {##############################################################################}
362 {% block get_template %} 362 {% block get_template %}
363 {# FIXME: rename to get_dom_template and GetDOMTemplate #} 363 {# FIXME: rename to get_dom_template and GetDOMTemplate #}
364 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso late, WrapperWorldType currentWorldType) 364 v8::Handle<v8::FunctionTemplate> {{v8_class}}::GetTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
365 { 365 {
366 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 366 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
367 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo); 367 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
368 if (result != data->templateMap(currentWorldType).end()) 368 if (result != data->templateMap(currentWorldType).end())
369 return result->value.newLocal(isolate); 369 return result->value.newLocal(isolate);
370 370
371 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 371 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
372 v8::EscapableHandleScope handleScope(isolate); 372 v8::EscapableHandleScope handleScope(isolate);
373 v8::Local<v8::FunctionTemplate> templ = 373 v8::Local<v8::FunctionTemplate> templ =
374 Configure{{v8_class_name}}Template(data->rawTemplate(&wrapperTypeInfo, c urrentWorldType), isolate, currentWorldType); 374 Configure{{v8_class}}Template(data->rawTemplate(&wrapperTypeInfo, curren tWorldType), isolate, currentWorldType);
375 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 375 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
376 return handleScope.Escape(templ); 376 return handleScope.Escape(templ);
377 } 377 }
378 378
379 {% endblock %} 379 {% endblock %}
380 380
381 381
382 {##############################################################################} 382 {##############################################################################}
383 {% block has_instance_and_has_instance_in_any_world %} 383 {% block has_instance_and_has_instance_in_any_world %}
384 bool {{v8_class_name}}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate, WrapperWorldType currentWorldType) 384 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isola te, WrapperWorldType currentWorldType)
385 { 385 {
386 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType); 386 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
387 } 387 }
388 388
389 bool {{v8_class_name}}::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8: :Isolate* isolate) 389 bool {{v8_class}}::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Isol ate* isolate)
390 { 390 {
391 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld) 391 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
392 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld) 392 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
393 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld); 393 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
394 } 394 }
395 395
396 {% endblock %} 396 {% endblock %}
397 397
398 398
399 {##############################################################################} 399 {##############################################################################}
400 {% block install_per_context_attributes %} 400 {% block install_per_context_attributes %}
401 {% if has_per_context_enabled_attributes %} 401 {% if has_per_context_enabled_attributes %}
402 void {{v8_class_name}}::installPerContextEnabledProperties(v8::Handle<v8::Object > instanceTemplate, {{cpp_class_name}}* impl, v8::Isolate* isolate) 402 void {{v8_class}}::installPerContextEnabledProperties(v8::Handle<v8::Object> ins tanceTemplate, {{cpp_class}}* impl, v8::Isolate* isolate)
403 { 403 {
404 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype()); 404 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype());
405 {% for attribute in attributes if attribute.per_context_enabled_function_nam e %} 405 {% for attribute in attributes if attribute.per_context_enabled_function %}
406 if ({{attribute.per_context_enabled_function_name}}(impl->document())) { 406 if ({{attribute.per_context_enabled_function}}(impl->document())) {
407 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 407 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
408 {{attribute_configuration(attribute)}}; 408 {{attribute_configuration(attribute)}};
409 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate); 409 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate);
410 } 410 }
411 {% endfor %} 411 {% endfor %}
412 } 412 }
413 413
414 {% endif %} 414 {% endif %}
415 {% endblock %} 415 {% endblock %}
416 416
417 417
418 {##############################################################################} 418 {##############################################################################}
419 {% block install_per_context_methods %} 419 {% block install_per_context_methods %}
420 {% if has_per_context_enabled_methods %} 420 {% if has_per_context_enabled_methods %}
421 void {{v8_class_name}}::installPerContextEnabledMethods(v8::Handle<v8::Object> p rototypeTemplate, v8::Isolate* isolate) 421 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate)
422 { 422 {
423 UNUSED_PARAM(prototypeTemplate); 423 UNUSED_PARAM(prototypeTemplate);
424 {# Define per-context enabled operations #} 424 {# Define per-context enabled operations #}
425 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, GetT emplate(isolate, worldType(isolate))); 425 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, GetT emplate(isolate, worldType(isolate)));
426 UNUSED_PARAM(defaultSignature); 426 UNUSED_PARAM(defaultSignature);
427 427
428 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext()); 428 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
429 {% for method in methods if method.per_context_enabled_function_name %} 429 {% for method in methods if method.per_context_enabled_function %}
430 if (context && context->isDocument() && {{method.per_context_enabled_functio n_name}}(toDocument(context))) 430 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context)))
431 prototypeTemplate->Set(v8::String::NewFromUtf8(isolate, "{{method.name}} ", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, {{cpp_cl ass_name}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSigna ture, {{method.number_of_required_arguments}})->GetFunction()); 431 prototypeTemplate->Set(v8::String::NewFromUtf8(isolate, "{{method.name}} ", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, {{cpp_cl ass}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFunction());
432 {% endfor %} 432 {% endfor %}
433 } 433 }
434 434
435 {% endif %} 435 {% endif %}
436 {% endblock %} 436 {% endblock %}
437 437
438 438
439 {##############################################################################} 439 {##############################################################################}
440 {% block to_active_dom_object %} 440 {% block to_active_dom_object %}
441 {% if is_active_dom_object %} 441 {% if is_active_dom_object %}
442 ActiveDOMObject* {{v8_class_name}}::toActiveDOMObject(v8::Handle<v8::Object> wra pper) 442 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
443 { 443 {
444 return toNative(wrapper); 444 return toNative(wrapper);
445 } 445 }
446 446
447 {% endif %} 447 {% endif %}
448 {% endblock %} 448 {% endblock %}
449 449
450 450
451 {##############################################################################} 451 {##############################################################################}
452 {% block create_wrapper_and_deref_object %} 452 {% block create_wrapper_and_deref_object %}
453 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 453 v8::Handle<v8::Object> {{v8_class}}::createWrapper(PassRefPtr<{{cpp_class}}> imp l, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
454 { 454 {
455 ASSERT(impl); 455 ASSERT(impl);
456 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate )); 456 ASSERT(!DOMDataStore::containsWrapper<{{v8_class}}>(impl.get(), isolate));
457 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 457 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
458 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 458 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
459 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 459 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
460 // the same object de-ref functions, though, so use that as the basis of the check. 460 // the same object de-ref functions, though, so use that as the basis of the check.
461 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 461 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
462 } 462 }
463 463
464 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 464 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
465 if (UNLIKELY(wrapper.IsEmpty())) 465 if (UNLIKELY(wrapper.IsEmpty()))
466 return wrapper; 466 return wrapper;
467 467
468 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 468 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
469 {% set wrapper_configuration = 'WrapperConfiguration::Dependent' 469 {% set wrapper_configuration = 'WrapperConfiguration::Dependent'
470 if (has_visit_dom_wrapper or 470 if (has_visit_dom_wrapper or
471 is_active_dom_object or 471 is_active_dom_object or
472 is_dependent_lifetime) else 472 is_dependent_lifetime) else
473 'WrapperConfiguration::Independent' %} 473 'WrapperConfiguration::Independent' %}
474 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}}); 474 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf o, wrapper, isolate, {{wrapper_configuration}});
475 return wrapper; 475 return wrapper;
476 } 476 }
477 477
478 void {{v8_class_name}}::derefObject(void* object) 478 void {{v8_class}}::derefObject(void* object)
479 { 479 {
480 fromInternalPointer(object)->deref(); 480 fromInternalPointer(object)->deref();
481 } 481 }
482 482
483 template<> 483 template<>
484 v8::Handle<v8::Value> toV8NoInline({{cpp_class_name}}* impl, v8::Handle<v8::Obje ct> creationContext, v8::Isolate* isolate) 484 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
485 { 485 {
486 return toV8(impl, creationContext, isolate); 486 return toV8(impl, creationContext, isolate);
487 } 487 }
488 488
489 {% endblock %} 489 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698