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

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

Issue 110023002: IDL compiler: [InitializedByEventConstructor] attribute any (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years 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 = 6 {% set getter_callback =
7 '%sV8Internal::%sAttributeGetterCallback' % 7 '%sV8Internal::%sAttributeGetterCallback' %
8 (interface_name, attribute.name) 8 (interface_name, attribute.name)
9 if not attribute.constructor_type else 9 if not attribute.constructor_type else
10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %}
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 {% block event_constructor %} 162 {% block event_constructor %}
163 {% if has_event_constructor %} 163 {% if has_event_constructor %}
164 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 164 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
165 { 165 {
166 if (info.Length() < 1) { 166 if (info.Length() < 1) {
167 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "An event name must be provided."), info.GetIsolate()); 167 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "An event name must be provided."), info.GetIsolate());
168 return; 168 return;
169 } 169 }
170 170
171 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); 171 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]);
172 {% for attribute in attributes if attribute.idl_type == 'any' %}
173 v8::Local<v8::Value> {{attribute.name}};
174 {% endfor %}
172 {{cpp_class}}Init eventInit; 175 {{cpp_class}}Init eventInit;
173 if (info.Length() >= 2) { 176 if (info.Length() >= 2) {
174 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate ())); 177 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate ()));
175 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 178 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
176 if (!initialize{{cpp_class}}(eventInit, options, exceptionState)) { 179 if (!initialize{{cpp_class}}(eventInit, options, exceptionState)) {
177 exceptionState.throwIfNeeded(); 180 exceptionState.throwIfNeeded();
178 return; 181 return;
179 } 182 }
183 {# Store attributes of type |any| on the wrapper to avoid leaking them
184 between isolated worlds. #}
185 {% for attribute in attributes if attribute.idl_type == 'any' %}
186 options.get("{{attribute.name}}", {{attribute.name}});
187 if (!{{attribute.name}}.IsEmpty())
188 info.Holder()->SetHiddenValue(V8HiddenPropertyName::{{attribute.name }}(info.GetIsolate()), {{attribute.name}});
189 {% endfor %}
180 } 190 }
181 RefPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventInit); 191 RefPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventInit);
192 {% if has_any_type_attributes %}
193 {# If we're in an isolated world, create a SerializedScriptValue and store
194 it in the event for later cloning if the property is accessed from
195 another world. The main world case is handled lazily (in custom code). #}
196 if (isolatedWorldForIsolate(info.GetIsolate())) {
197 {% for attribute in attributes if attribute.idl_type == 'any' %}
198 if (!{{attribute.name}}.IsEmpty())
199 event->{{attribute.set_serialized_script_value}}(SerializedScriptVal ue::createAndSwallowExceptions({{attribute.name}}, info.GetIsolate()));
200 {% endfor %}
201 }
202
203 {% endif %}
182 v8::Handle<v8::Object> wrapper = info.Holder(); 204 v8::Handle<v8::Object> wrapper = info.Holder();
183 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v 8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::De pendent); 205 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v 8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::De pendent);
184 v8SetReturnValue(info, wrapper); 206 v8SetReturnValue(info, wrapper);
185 } 207 }
186 208
187 {% endif %} 209 {% endif %}
188 {% endblock %} 210 {% endblock %}
189 211
190 212
191 {##############################################################################} 213 {##############################################################################}
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 {% if has_event_constructor %} 282 {% if has_event_constructor %}
261 bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const Dictionary& opt ions, ExceptionState& exceptionState, const String& forEventName) 283 bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const Dictionary& opt ions, ExceptionState& exceptionState, const String& forEventName)
262 { 284 {
263 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str ing("{{interface_name}}") : forEventName, "", exceptionState); 285 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str ing("{{interface_name}}") : forEventName, "", exceptionState);
264 {% if parent_interface %}{# any Event interface except Event itself #} 286 {% if parent_interface %}{# any Event interface except Event itself #}
265 if (!initialize{{parent_interface}}(eventInit, options, exceptionState, forE ventName.isEmpty() ? String("{{interface_name}}") : forEventName)) 287 if (!initialize{{parent_interface}}(eventInit, options, exceptionState, forE ventName.isEmpty() ? String("{{interface_name}}") : forEventName))
266 return false; 288 return false;
267 289
268 {% endif %} 290 {% endif %}
269 {% for attribute in attributes 291 {% for attribute in attributes
270 if attribute.is_initialized_by_event_constructor %} 292 if (attribute.is_initialized_by_event_constructor and
293 not attribute.idl_type == 'any')%}
271 {# FIXME: implement [ImplementedAs] #} 294 {# FIXME: implement [ImplementedAs] #}
272 {# FIXME: implement [DeprecateAs] #} 295 {# FIXME: implement [DeprecateAs] #}
273 {# FIXME: special-case any #} 296 {# FIXME: special-case any #}
274 {# FIXME: implement withPropertyAttributes #} 297 {# FIXME: implement withPropertyAttributes #}
275 if (!options.convert(conversionContext, "{{attribute.name}}", eventInit.{{at tribute.name}})) 298 if (!options.convert(conversionContext, "{{attribute.name}}", eventInit.{{at tribute.name}}))
276 return false; 299 return false;
277 {% endfor %} 300 {% endfor %}
278 return true; 301 return true;
279 } 302 }
280 303
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 fromInternalPointer(object)->deref(); 662 fromInternalPointer(object)->deref();
640 } 663 }
641 664
642 template<> 665 template<>
643 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 666 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
644 { 667 {
645 return toV8(impl, creationContext, isolate); 668 return toV8(impl, creationContext, isolate);
646 } 669 }
647 670
648 {% endblock %} 671 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_interface.py ('k') | Source/bindings/tests/idls/TestInterfaceEventConstructor.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698