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

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

Issue 68733006: IDL compiler: Refactor attribute configuration from Python CG to Jinja template (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years, 1 month 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
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_name =
7 '%sV8Internal::%sAttributeGetterCallback' %
8 (interface_name, attribute.name)
9 if not attribute.constructor_type else
10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %}
11 {% set getter_callback_name_for_main_world =
12 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' %
13 (interface_name, attribute.name)
14 if attribute.is_per_world_bindings else '0' %}
15 {% set setter_callback_name = attribute.setter_callback_name %}
16 {% set setter_callback_name_for_main_world =
17 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' %
18 (interface_name, attribute.name)
19 if attribute.is_per_world_bindings and not attribute.is_read_only else '0 ' %}
20 {% set wrapper_type_info =
21 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' %
22 attribute.constructor_type
23 if attribute.constructor_type else '0' %}
6 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % 24 {% set access_control = 'static_cast<v8::AccessControl>(%s)' %
7 ' | '.join(attribute.access_control_list) %} 25 ' | '.join(attribute.access_control_list) %}
8 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 26 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
9 ' | '.join(attribute.property_attributes) %} 27 ' | '.join(attribute.property_attributes) %}
10 {"{{attribute.name}}", {{attribute.getter_callback_name}}, {{attribute.setter_ca llback_name}}, {{attribute.getter_callback_name_for_main_world}}, {{attribute.se tter_callback_name_for_main_world}}, {{attribute.wrapper_type_info}}, {{access_c ontrol}}, {{property_attribute}}, 0 /* on instance */} 28 {"{{attribute.name}}", {{getter_callback_name}}, {{setter_callback_name}}, {{get ter_callback_name_for_main_world}}, {{setter_callback_name_for_main_world}}, {{w rapper_type_info}}, {{access_control}}, {{property_attribute}}, 0 /* on instance */}
11 {%- endmacro %} 29 {%- endmacro %}
12 30
13 31
14 {##############################################################################} 32 {##############################################################################}
15 {% macro method_configuration(method) %} 33 {% macro method_configuration(method) %}
16 {% set callback_name_for_main_world = 34 {% set method_callback_name =
35 '%sV8Internal::%sMethodCallback' % (interface_name, method.name) %}
36 {% set method_callback_name_for_main_world =
17 '%sV8Internal::%sMethodCallbackForMainWorld' % (interface_name, method.name) 37 '%sV8Internal::%sMethodCallbackForMainWorld' % (interface_name, method.name)
18 if method.is_per_world_bindings else '0' %} 38 if method.is_per_world_bindings else '0' %}
19 {"{{method.name}}", {{interface_name}}V8Internal::{{method.name}}MethodCallback, {{callback_name_for_main_world}}, {{method.number_of_required_or_variadic_argum ents}}} 39 {"{{method.name}}", {{method_callback_name}}, {{method_callback_name_for_main_wo rld}}, {{method.number_of_required_or_variadic_arguments}}}
20 {%- endmacro %} 40 {%- endmacro %}
21 41
22 42
23 {##############################################################################} 43 {##############################################################################}
24 {% block constructor_getter %} 44 {% block constructor_getter %}
25 {% if has_constructor_attributes %} 45 {% if has_constructor_attributes %}
26 static void {{interface_name}}ConstructorGetter(v8::Local<v8::String>, const v8: :PropertyCallbackInfo<v8::Value>& info) 46 static void {{interface_name}}ConstructorGetter(v8::Local<v8::String>, const v8: :PropertyCallbackInfo<v8::Value>& info)
27 { 47 {
28 v8::Handle<v8::Value> data = info.Data(); 48 v8::Handle<v8::Value> data = info.Data();
29 ASSERT(data->IsExternal()); 49 ASSERT(data->IsExternal());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 168 }
149 {% else %} 169 {% else %}
150 {% filter runtime_enabled(method.runtime_enabled_function_name) %} 170 {% filter runtime_enabled(method.runtime_enabled_function_name) %}
151 {{install_custom_signature(method)}} 171 {{install_custom_signature(method)}}
152 {% endfilter %} 172 {% endfilter %}
153 {% endif %} 173 {% endif %}
154 {% endfilter %} 174 {% endfilter %}
155 {% endif %}{# install_custom_signature #} 175 {% endif %}{# install_custom_signature #}
156 {% endfor %} 176 {% endfor %}
157 {% for attribute in attributes if attribute.is_static %} 177 {% for attribute in attributes if attribute.is_static %}
158 desc->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.name}}"), {{a ttribute.getter_callback_name}}, {{attribute.setter_callback_name}}, v8::Externa l::New(0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Accessor Signature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 178 {% set getter_callback_name = '%sV8Internal::%sAttributeGetterCallback' %
179 (interface_name, attribute.name) %}
180 desc->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.name}}"), {{g etter_callback_name}}, {{attribute.setter_callback_name}}, v8::External::New(0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature> (), static_cast<v8::AccessControl>(v8::DEFAULT));
159 {% endfor %} 181 {% endfor %}
160 {% if constants %} 182 {% if constants %}
161 {{install_constants() | indent}} 183 {{install_constants() | indent}}
162 {% endif %} 184 {% endif %}
163 185
164 // Custom toString template 186 // Custom toString template
165 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); 187 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
166 return desc; 188 return desc;
167 } 189 }
168 190
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, WrapperConfiguration::Independent); 327 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, WrapperConfiguration::Independent);
306 return wrapper; 328 return wrapper;
307 } 329 }
308 330
309 void {{v8_class_name}}::derefObject(void* object) 331 void {{v8_class_name}}::derefObject(void* object)
310 { 332 {
311 fromInternalPointer(object)->deref(); 333 fromInternalPointer(object)->deref();
312 } 334 }
313 335
314 {% endblock %} 336 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_interface.py ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698