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

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

Issue 26547005: IDL compiler: [PerContextEnabled] for getters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix caps Created 7 years, 2 months 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) %}
6 {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}Attribute GetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>({{attribute.access_co ntrol_list | join(' | ')}}), static_cast<v8::PropertyAttribute>({{attribute.prop erty_attributes | join(' | ')}}), 0 /* on instance */}{% endmacro %}
7
8
9 {##############################################################################}
5 {% block class_attributes %} 10 {% block class_attributes %}
6 {# FIXME: rename to install_attributes and put into configure_class_template #} 11 {# FIXME: rename to install_attributes and put into configure_class_template #}
7 {% if attributes %} 12 {% if attributes %}
8 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { 13 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = {
9 {% for attribute in attributes 14 {% for attribute in attributes
10 if not (attribute.runtime_enabled_function_name or attribute.is_static) % } 15 if not (attribute.runtime_enabled_function_name or
16 attribute.per_context_enabled_function_name or
17 attribute.is_static) %}
11 {% filter conditional(attribute.conditional_string) %} 18 {% filter conditional(attribute.conditional_string) %}
12 {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}Attri buteGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>({{attribute.acces s_control_list | join(' | ')}}), static_cast<v8::PropertyAttribute>({{attribute. property_attributes | join(' | ')}}), 0 /* on instance */}, 19 {{attribute_configuration(attribute)}},
13 {% endfilter %} 20 {% endfilter %}
14 {% endfor %} 21 {% endfor %}
15 }; 22 };
16 23
17 {% endif %} 24 {% endif %}
18 {% endblock %} 25 {% endblock %}
19 26
20 27
21 {##############################################################################} 28 {##############################################################################}
22 {% block configure_class_template %} 29 {% block configure_class_template %}
(...skipping 10 matching lines...) Expand all
33 {% if constants or has_runtime_enabled_attributes %} 40 {% if constants or has_runtime_enabled_attributes %}
34 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); 41 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
35 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); 42 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
36 UNUSED_PARAM(instance); 43 UNUSED_PARAM(instance);
37 UNUSED_PARAM(proto); 44 UNUSED_PARAM(proto);
38 {% endif %} 45 {% endif %}
39 {% for attribute in attributes if attribute.runtime_enabled_function_name %} 46 {% for attribute in attributes if attribute.runtime_enabled_function_name %}
40 {% filter conditional(attribute.conditional_string) %} 47 {% filter conditional(attribute.conditional_string) %}
41 if ({{attribute.runtime_enabled_function_name}}()) { 48 if ({{attribute.runtime_enabled_function_name}}()) {
42 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 49 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
43 {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}A ttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 50 {{attribute_configuration(attribute)}};
44 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate, currentWorldType); 51 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate, currentWorldType);
45 } 52 }
46 {% endfilter %} 53 {% endfilter %}
47 {% endfor %} 54 {% endfor %}
48 {% for attribute in attributes if attribute.is_static %} 55 {% for attribute in attributes if attribute.is_static %}
49 desc->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.name}}"), {{c pp_class_name}}V8Internal::{{attribute.name}}AttributeGetterCallback, 0, v8::Ext ernal::New(0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acce ssorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 56 desc->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.name}}"), {{c pp_class_name}}V8Internal::{{attribute.name}}AttributeGetterCallback, 0, v8::Ext ernal::New(0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acce ssorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
50 {% endfor %} 57 {% endfor %}
51 {% if constants %} 58 {% if constants %}
52 {{install_constants() | indent}} 59 {{install_constants() | indent}}
53 {% endif %} 60 {% endif %}
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 { 125 {
119 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) 126 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
120 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) 127 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld)
121 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); 128 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d);
122 } 129 }
123 130
124 {% endblock %} 131 {% endblock %}
125 132
126 133
127 {##############################################################################} 134 {##############################################################################}
135 {% block install_per_context_attributes %}
136 {% if has_per_context_enabled_attributes %}
137 void {{v8_class_name}}::installPerContextProperties(v8::Handle<v8::Object> insta nce, {{cpp_class_name}}* impl, v8::Isolate* isolate)
haraken 2013/10/16 05:28:06 installPerContextProperties => installPerContextEn
Nils Barth (inactive) 2013/10/16 06:05:17 Done! (Results in lots of test result changes.)
138 {
139 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type());
140 {% for attribute in attributes if attribute.per_context_enabled_function_nam e %}
141 if ({{attribute.per_context_enabled_function_name}}(impl->document())) {
142 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
143 {{attribute_configuration(attribute)}};
144 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate);
145 }
146 {% endfor %}
147 }
148
149 {% endif %}
150 {% endblock %}
151
152
153 {##############################################################################}
128 {% block create_wrapper_and_deref_object %} 154 {% block create_wrapper_and_deref_object %}
129 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 155 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
130 { 156 {
131 ASSERT(impl); 157 ASSERT(impl);
132 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate )); 158 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate ));
133 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 159 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
134 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 160 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
135 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have 161 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have
136 // the same object de-ref functions, though, so use that as the basis of the check. 162 // the same object de-ref functions, though, so use that as the basis of the check.
137 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); 163 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction);
138 } 164 }
139 165
140 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate); 166 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate);
141 if (UNLIKELY(wrapper.IsEmpty())) 167 if (UNLIKELY(wrapper.IsEmpty()))
142 return wrapper; 168 return wrapper;
143 169
144 installPerContextProperties(wrapper, impl.get(), isolate); 170 installPerContextProperties(wrapper, impl.get(), isolate);
145 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra pper, isolate, WrapperConfiguration::Independent); 171 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra pper, isolate, WrapperConfiguration::Independent);
146 return wrapper; 172 return wrapper;
147 } 173 }
148 174
149 void {{v8_class_name}}::derefObject(void* object) 175 void {{v8_class_name}}::derefObject(void* object)
150 { 176 {
151 fromInternalPointer(object)->deref(); 177 fromInternalPointer(object)->deref();
152 } 178 }
153 179
154 {% endblock %} 180 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698