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

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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 {% block event_constructor %} 156 {% block event_constructor %}
157 {% if has_event_constructor %} 157 {% if has_event_constructor %}
158 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 158 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
159 { 159 {
160 if (info.Length() < 1) { 160 if (info.Length() < 1) {
161 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "An event name must be provided."), info.GetIsolate()); 161 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "An event name must be provided."), info.GetIsolate());
162 return; 162 return;
163 } 163 }
164 164
165 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); 165 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]);
166 {% for attribute in attributes if attribute.idl_type == 'any' %}
167 v8::Local<v8::Value> {{attribute.name}};
168 {% endfor %}
166 {{cpp_class}}Init eventInit; 169 {{cpp_class}}Init eventInit;
167 if (info.Length() >= 2) { 170 if (info.Length() >= 2) {
168 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate ())); 171 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate ()));
169 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 172 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
170 if (!initialize{{cpp_class}}(eventInit, options, exceptionState)) { 173 if (!initialize{{cpp_class}}(eventInit, options, exceptionState)) {
171 exceptionState.throwIfNeeded(); 174 exceptionState.throwIfNeeded();
172 return; 175 return;
173 } 176 }
177 {# Store attributes of type |any| on the wrapper to avoid leaking them
178 between isolated worlds. #}
179 {% for attribute in attributes if attribute.idl_type == 'any' %}
180 options.get("{{attribute.name}}", {{attribute.name}});
181 if (!{{attribute.name}}.IsEmpty())
182 info.Holder()->SetHiddenValue(V8HiddenPropertyName::{{attribute.name }}(info.GetIsolate()), {{attribute.name}});
183 {% endfor %}
174 } 184 }
175 RefPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventInit); 185 RefPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventInit);
186 {% if has_any_type_attributes %}
haraken 2013/12/09 08:37:00 Nit: You're passing the result of any(attribute
Nils Barth (inactive) 2013/12/09 09:55:01 In this case, no, because we need to add a special
187 {# If we're in an isolated world, create a SerializedScriptValue and store
188 it in the event for later cloning if the property is accessed from
189 another world. The main world case is handled lazily (in Custom code). #}
haraken 2013/12/09 08:37:00 Custom => custom
Nils Barth (inactive) 2013/12/09 09:55:01 Done.
190 if (isolatedWorldForIsolate(info.GetIsolate())) {
191 {% for attribute in attributes if attribute.idl_type == 'any' %}
192 if (!{{attribute.name}}.IsEmpty())
193 event->{{attribute.set_serialized}}(SerializedScriptValue::createAnd SwallowExceptions({{attribute.name}}, info.GetIsolate()));
haraken 2013/12/09 08:37:00 set_serialized => set_serialized_script_value (sin
Nils Barth (inactive) 2013/12/09 09:55:01 Done.
194 {% endfor %}
195 }
196
197 {% endif %}
176 v8::Handle<v8::Object> wrapper = info.Holder(); 198 v8::Handle<v8::Object> wrapper = info.Holder();
177 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v 8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::De pendent); 199 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v 8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::De pendent);
178 v8SetReturnValue(info, wrapper); 200 v8SetReturnValue(info, wrapper);
179 } 201 }
180 202
181 {% endif %} 203 {% endif %}
182 {% endblock %} 204 {% endblock %}
183 205
184 206
185 {##############################################################################} 207 {##############################################################################}
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 {% if has_event_constructor %} 276 {% if has_event_constructor %}
255 bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const Dictionary& opt ions, ExceptionState& exceptionState, const String& forEventName) 277 bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const Dictionary& opt ions, ExceptionState& exceptionState, const String& forEventName)
256 { 278 {
257 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str ing("{{interface_name}}") : forEventName, "", exceptionState); 279 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str ing("{{interface_name}}") : forEventName, "", exceptionState);
258 {% if parent_interface %}{# any Event interface except Event itself #} 280 {% if parent_interface %}{# any Event interface except Event itself #}
259 if (!initialize{{parent_interface}}(eventInit, options, exceptionState, forE ventName.isEmpty() ? String("{{interface_name}}") : forEventName)) 281 if (!initialize{{parent_interface}}(eventInit, options, exceptionState, forE ventName.isEmpty() ? String("{{interface_name}}") : forEventName))
260 return false; 282 return false;
261 283
262 {% endif %} 284 {% endif %}
263 {% for attribute in attributes 285 {% for attribute in attributes
264 if attribute.is_initialized_by_event_constructor %} 286 if (attribute.is_initialized_by_event_constructor and
287 not attribute.idl_type == 'any')%}
265 {# FIXME: implement [ImplementedAs] #} 288 {# FIXME: implement [ImplementedAs] #}
266 {# FIXME: implement [DeprecateAs] #} 289 {# FIXME: implement [DeprecateAs] #}
267 {# FIXME: special-case any #} 290 {# FIXME: special-case any #}
268 {# FIXME: implement withPropertyAttributes #} 291 {# FIXME: implement withPropertyAttributes #}
269 if (!options.convert(conversionContext, "{{attribute.name}}", eventInit.{{at tribute.name}})) 292 if (!options.convert(conversionContext, "{{attribute.name}}", eventInit.{{at tribute.name}}))
270 return false; 293 return false;
271 {% endfor %} 294 {% endfor %}
272 return true; 295 return true;
273 } 296 }
274 297
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 fromInternalPointer(object)->deref(); 656 fromInternalPointer(object)->deref();
634 } 657 }
635 658
636 template<> 659 template<>
637 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 660 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
638 { 661 {
639 return toV8(impl, creationContext, isolate); 662 return toV8(impl, creationContext, isolate);
640 } 663 }
641 664
642 {% endblock %} 665 {% 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