 Chromium Code Reviews
 Chromium Code Reviews Issue 23068032:
  Add constants and primitive type readonly attributes to Python IDL compiler  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 23068032:
  Add constants and primitive type readonly attributes to Python IDL compiler  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| Index: Source/bindings/templates/interface.cpp | 
| diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp | 
| index 62c37431b8d3a9e6cc57675e240da1f630d20448..abbefb3cc1d79e637131490ed426e9d4257800bf 100644 | 
| --- a/Source/bindings/templates/interface.cpp | 
| +++ b/Source/bindings/templates/interface.cpp | 
| @@ -18,6 +18,8 @@ | 
| Boston, MA 02111-1307, USA. | 
| */ | 
| +{% from 'attributes.cpp' import attribute_getter, attribute_getter_callback, class_attributes with context %} | 
| +{% from 'constants.cpp' import class_constants, constant_configuration, install_constants with context %} | 
| #include "config.h" | 
| {% if conditional_string %} | 
| #if {{conditional_string}} | 
| @@ -25,7 +27,7 @@ | 
| #include "{{v8_class_name}}.h" | 
| {% for filename in cpp_includes %} | 
| -#include "{{ filename }}" | 
| +#include "{{filename}}" | 
| {% endfor %} | 
| namespace WebCore { | 
| @@ -57,36 +59,16 @@ namespace {{cpp_class_name}}V8Internal { | 
| template <typename T> void V8_USE(T) { } | 
| {% for attribute in attributes %} | 
| -static void {{attribute.name}}AttributeGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) | 
| -{ | 
| - {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 
| - {{attribute.cpp_type}} result = imp->{{attribute.cpp_method_name}}(); | 
| - if (result.get() && DOMDataStore::setReturnValueFromWrapper<{{attribute.v8_type}}>(info.GetReturnValue(), result.get())) | 
| - return; | 
| - v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); | 
| - if (!wrapper.IsEmpty()) { | 
| - V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attribute.name}}", wrapper); | 
| - v8SetReturnValue(info, wrapper); | 
| - } | 
| -} | 
| - | 
| -static void {{attribute.name}}AttributeGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) | 
| -{ | 
| - TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 
| - {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeGetter(name, info); | 
| - TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 
| -} | 
| - | 
| +{{attribute_getter(attribute)}} | 
| +{{attribute_getter_callback(attribute)}} | 
| {% endfor %} | 
| } // namespace {{cpp_class_name}}V8Internal | 
| {% if attributes %} | 
| -static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attributes[] = { | 
| -{% for attribute in attributes %} | 
| - {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, | 
| -{% endfor %} | 
| -}; | 
| - | 
| +{{class_attributes()}} | 
| +{% endif %} | 
| +{% if constants %} | 
| +{{class_constants()}} | 
| {% endif %} | 
| static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType) | 
| { | 
| @@ -97,6 +79,16 @@ static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H | 
| {{attribute_templates}}, {{number_of_attributes}}, | 
| 0, 0, isolate, currentWorldType); | 
| UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 
| +{% if constants %} | 
| + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 
| + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 
| + UNUSED_PARAM(instance); // In some cases, it will not be used. | 
| + UNUSED_PARAM(proto); // In some cases, it will not be used. | 
| 
haraken
2013/08/26 09:33:40
Nit: I'd drop the comment.
 
Nils Barth (inactive)
2013/08/27 02:59:27
Done, removed throughout (including Perl).
(It is
 | 
| +{% endif %} | 
| +{% for constant in constants %}{{constant_configuration(constant)}}{% endfor %} | 
| +{% if constants %} | 
| + {{install_constants()}} | 
| +{% endif %} | 
| 
haraken
2013/08/26 09:33:40
I want to simply write this as follows (See my com
 
Nils Barth (inactive)
2013/08/27 02:59:27
Per note in constants.cpp, this has a subtle issue
 | 
| // Custom toString template | 
| desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate()); |