 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| Index: Source/bindings/templates/interface.cpp | 
| diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp | 
| index 3b0c90ed60882a8afa2111e51198b8d508704f1f..49c1f0a56db3a88a290913378e4910fd802d6b0f 100644 | 
| --- a/Source/bindings/templates/interface.cpp | 
| +++ b/Source/bindings/templates/interface.cpp | 
| @@ -73,7 +73,9 @@ static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu | 
| {# FIXME: rename to install_methods and put into configure_class_template #} | 
| {% if methods %} | 
| static const V8DOMConfiguration::MethodConfiguration {{v8_class_name}}Methods[] = { | 
| - {% for method in methods if method.do_not_check_signature %} | 
| + {% for method in methods | 
| + if method.do_not_check_signature and | 
| + not method.per_context_enabled_function_name %} | 
| {% filter conditional(method.conditional_string) %} | 
| {{method_configuration(method)}}, | 
| {% endfilter %} | 
| @@ -98,7 +100,8 @@ static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H | 
| {%+ if methods %}{{v8_class_name}}Methods, WTF_ARRAY_LENGTH({{v8_class_name}}Methods){% else %}0, 0{% endif %}, | 
| isolate, currentWorldType); | 
| UNUSED_PARAM(defaultSignature); | 
| - {% if constants or has_runtime_enabled_attributes %} | 
| + {% 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
 | 
| + has_non_per_context_enabled_methods %} | 
| v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 
| v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 
| UNUSED_PARAM(instance); | 
| @@ -225,6 +228,27 @@ void {{v8_class_name}}::installPerContextEnabledProperties(v8::Handle<v8::Object | 
| {##############################################################################} | 
| +{% block install_per_context_methods %} | 
| +{% if has_per_context_enabled_methods %} | 
| +void {{v8_class_name}}::installPerContextEnabledPrototypeProperties(v8::Handle<v8::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.
 | 
| +{ | 
| + UNUSED_PARAM(proto); | 
| + {# Define per-context enabled operations #} | 
| + v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(isolate, worldType(isolate))); | 
| + UNUSED_PARAM(defaultSignature); | 
| + | 
| + ExecutionContext* context = toExecutionContext(proto->CreationContext()); | 
| + {% for method in methods if method.per_context_enabled_function_name %} | 
| + if (context && context->isDocument() && {{method.per_context_enabled_function_name}}(toDocument(context))) | 
| + proto->Set(v8::String::NewSymbol("{{method.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFunction()); | 
| + {% endfor %} | 
| +} | 
| + | 
| +{% endif %} | 
| +{% endblock %} | 
| + | 
| + | 
| +{##############################################################################} | 
| {% block create_wrapper_and_deref_object %} | 
| v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_name}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 
| { |