 Chromium Code Reviews
 Chromium Code Reviews Issue 59853010:
  IDL compiler: [PerContextEnabled] methods  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 59853010:
  IDL compiler: [PerContextEnabled] methods  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| OLD | NEW | 
|---|---|
| 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 {"{{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}}, static_cas t<v8::AccessControl>({{attribute.access_control_list | join(' | ')}}), static_ca st<v8::PropertyAttribute>({{attribute.property_attributes | join(' | ')}}), 0 /* on instance */} | 6 {"{{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}}, static_cas t<v8::AccessControl>({{attribute.access_control_list | join(' | ')}}), static_ca st<v8::PropertyAttribute>({{attribute.property_attributes | join(' | ')}}), 0 /* on instance */} | 
| 7 {%- endmacro %} | 7 {%- endmacro %} | 
| 8 | 8 | 
| 9 | 9 | 
| 10 {##############################################################################} | 10 {##############################################################################} | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 | 
| 67 {% endif %} | 67 {% endif %} | 
| 68 {% endblock %} | 68 {% endblock %} | 
| 69 | 69 | 
| 70 | 70 | 
| 71 {##############################################################################} | 71 {##############################################################################} | 
| 72 {% block class_methods %} | 72 {% block class_methods %} | 
| 73 {# FIXME: rename to install_methods and put into configure_class_template #} | 73 {# FIXME: rename to install_methods and put into configure_class_template #} | 
| 74 {% if methods %} | 74 {% if methods %} | 
| 75 static const V8DOMConfiguration::MethodConfiguration {{v8_class_name}}Methods[] = { | 75 static const V8DOMConfiguration::MethodConfiguration {{v8_class_name}}Methods[] = { | 
| 76 {% for method in methods if method.do_not_check_signature %} | 76 {% for method in methods | 
| 77 if method.do_not_check_signature and | |
| 78 not method.per_context_enabled_function_name %} | |
| 77 {% filter conditional(method.conditional_string) %} | 79 {% filter conditional(method.conditional_string) %} | 
| 78 {{method_configuration(method)}}, | 80 {{method_configuration(method)}}, | 
| 79 {% endfilter %} | 81 {% endfilter %} | 
| 80 {% endfor %} | 82 {% endfor %} | 
| 81 }; | 83 }; | 
| 82 | 84 | 
| 83 {% endif %} | 85 {% endif %} | 
| 84 {% endblock %} | 86 {% endblock %} | 
| 85 | 87 | 
| 86 | 88 | 
| 87 {##############################################################################} | 89 {##############################################################################} | 
| 88 {% block configure_class_template %} | 90 {% block configure_class_template %} | 
| 89 {# FIXME: rename to install_dom_template and Install{{v8_class_name}}DOMTemplate #} | 91 {# FIXME: rename to install_dom_template and Install{{v8_class_name}}DOMTemplate #} | 
| 90 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current WorldType) | 92 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current WorldType) | 
| 91 { | 93 { | 
| 92 desc->ReadOnlyPrototype(); | 94 desc->ReadOnlyPrototype(); | 
| 93 | 95 | 
| 94 v8::Local<v8::Signature> defaultSignature; | 96 v8::Local<v8::Signature> defaultSignature; | 
| 95 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, "{{inte rface_name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFie ldCount, | 97 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, "{{inte rface_name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFie ldCount, | 
| 96 {# Test needed as size 0 constant arrays are not allowed in VC++ #} | 98 {# Test needed as size 0 constant arrays are not allowed in VC++ #} | 
| 97 {%+ if attributes %}{{v8_class_name}}Attributes, WTF_ARRAY_LENGTH({{v8_c lass_name}}Attributes){% else %}0, 0{% endif %}, | 99 {%+ if attributes %}{{v8_class_name}}Attributes, WTF_ARRAY_LENGTH({{v8_c lass_name}}Attributes){% else %}0, 0{% endif %}, | 
| 98 {%+ if methods %}{{v8_class_name}}Methods, WTF_ARRAY_LENGTH({{v8_class_n ame}}Methods){% else %}0, 0{% endif %}, | 100 {%+ if methods %}{{v8_class_name}}Methods, WTF_ARRAY_LENGTH({{v8_class_n ame}}Methods){% else %}0, 0{% endif %}, | 
| 99 isolate, currentWorldType); | 101 isolate, currentWorldType); | 
| 100 UNUSED_PARAM(defaultSignature); | 102 UNUSED_PARAM(defaultSignature); | 
| 101 {% if constants or has_runtime_enabled_attributes %} | 103 {% if constants or has_runtime_enabled_attributes or | 
| 
Nils Barth (inactive)
2013/11/07 04:49:35
This check is complicated and looks unnecessary;
c
 
haraken
2013/11/07 04:55:09
Yes, I think you can always include the code. Havi
 
Nils Barth (inactive)
2013/11/07 05:07:02
Agreed, it's pretty disgusting;
will do in followu
 | |
| 104 has_non_per_context_enabled_methods %} | |
| 102 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 105 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 
| 103 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 106 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 
| 104 UNUSED_PARAM(instance); | 107 UNUSED_PARAM(instance); | 
| 105 UNUSED_PARAM(proto); | 108 UNUSED_PARAM(proto); | 
| 106 {% endif %} | 109 {% endif %} | 
| 107 {% for attribute in attributes if attribute.runtime_enabled_function_name %} | 110 {% for attribute in attributes if attribute.runtime_enabled_function_name %} | 
| 108 {% filter conditional(attribute.conditional_string) %} | 111 {% filter conditional(attribute.conditional_string) %} | 
| 109 if ({{attribute.runtime_enabled_function_name}}()) { | 112 if ({{attribute.runtime_enabled_function_name}}()) { | 
| 110 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ | 113 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ | 
| 111 {{attribute_configuration(attribute)}}; | 114 {{attribute_configuration(attribute)}}; | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate); | 221 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate); | 
| 219 } | 222 } | 
| 220 {% endfor %} | 223 {% endfor %} | 
| 221 } | 224 } | 
| 222 | 225 | 
| 223 {% endif %} | 226 {% endif %} | 
| 224 {% endblock %} | 227 {% endblock %} | 
| 225 | 228 | 
| 226 | 229 | 
| 227 {##############################################################################} | 230 {##############################################################################} | 
| 231 {% block install_per_context_methods %} | |
| 232 {% if has_per_context_enabled_methods %} | |
| 233 void {{v8_class_name}}::installPerContextEnabledPrototypeProperties(v8::Handle<v 8::Object> proto, v8::Isolate* isolate) | |
| 
haraken
2013/11/07 04:55:09
installPerContextEnabledPrototypeProperties => ins
 
Nils Barth (inactive)
2013/11/07 05:07:02
Got it, will do in followup.
 | |
| 234 { | |
| 235 UNUSED_PARAM(proto); | |
| 236 {# Define per-context enabled operations #} | |
| 237 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate))); | |
| 238 UNUSED_PARAM(defaultSignature); | |
| 239 | |
| 240 ExecutionContext* context = toExecutionContext(proto->CreationContext()); | |
| 241 {% for method in methods if method.per_context_enabled_function_name %} | |
| 242 if (context && context->isDocument() && {{method.per_context_enabled_functio n_name}}(toDocument(context))) | |
| 243 proto->Set(v8::String::NewSymbol("{{method.name}}"), v8::FunctionTemplat e::New({{cpp_class_name}}V8Internal::{{method.name}}MethodCallback, v8Undefined( ), defaultSignature, {{method.number_of_required_arguments}})->GetFunction()); | |
| 244 {% endfor %} | |
| 245 } | |
| 246 | |
| 247 {% endif %} | |
| 248 {% endblock %} | |
| 249 | |
| 250 | |
| 251 {##############################################################################} | |
| 228 {% block create_wrapper_and_deref_object %} | 252 {% block create_wrapper_and_deref_object %} | 
| 229 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 253 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 
| 230 { | 254 { | 
| 231 ASSERT(impl); | 255 ASSERT(impl); | 
| 232 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate )); | 256 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate )); | 
| 233 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 257 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 
| 234 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); | 258 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); | 
| 235 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have | 259 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have | 
| 236 // the same object de-ref functions, though, so use that as the basis of the check. | 260 // the same object de-ref functions, though, so use that as the basis of the check. | 
| 237 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); | 261 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); | 
| 238 } | 262 } | 
| 239 | 263 | 
| 240 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | 264 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | 
| 241 if (UNLIKELY(wrapper.IsEmpty())) | 265 if (UNLIKELY(wrapper.IsEmpty())) | 
| 242 return wrapper; | 266 return wrapper; | 
| 243 | 267 | 
| 244 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | 268 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | 
| 245 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, WrapperConfiguration::Independent); | 269 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, WrapperConfiguration::Independent); | 
| 246 return wrapper; | 270 return wrapper; | 
| 247 } | 271 } | 
| 248 | 272 | 
| 249 void {{v8_class_name}}::derefObject(void* object) | 273 void {{v8_class_name}}::derefObject(void* object) | 
| 250 { | 274 { | 
| 251 fromInternalPointer(object)->deref(); | 275 fromInternalPointer(object)->deref(); | 
| 252 } | 276 } | 
| 253 | 277 | 
| 254 {% endblock %} | 278 {% endblock %} | 
| OLD | NEW |