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

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

Issue 534133002: [WIP] bindings: Introduce PropertyBag (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block constructor_getter %} 5 {% block constructor_getter %}
6 {% if has_constructor_attributes %} 6 {% if has_constructor_attributes %}
7 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop ertyCallbackInfo<v8::Value>& info) 7 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop ertyCallbackInfo<v8::Value>& info)
8 { 8 {
9 v8::Handle<v8::Value> data = info.Data(); 9 v8::Handle<v8::Value> data = info.Data();
10 ASSERT(data->IsExternal()); 10 ASSERT(data->IsExternal());
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 exceptionState.throwTypeError("An event name must be provided."); 575 exceptionState.throwTypeError("An event name must be provided.");
576 exceptionState.throwIfNeeded(); 576 exceptionState.throwIfNeeded();
577 return; 577 return;
578 } 578 }
579 579
580 TOSTRING_VOID(V8StringResource<>, type, info[0]); 580 TOSTRING_VOID(V8StringResource<>, type, info[0]);
581 {% for attribute in any_type_attributes %} 581 {% for attribute in any_type_attributes %}
582 v8::Local<v8::Value> {{attribute.name}}; 582 v8::Local<v8::Value> {{attribute.name}};
583 {% endfor %} 583 {% endfor %}
584 {{cpp_class}}Init eventInit; 584 {{cpp_class}}Init eventInit;
585 if (info.Length() >= 2) { 585 if (info.Length() >= 2 && !info[1].IsEmpty() && info[1]->IsObject()) {
586 TONATIVE_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate() )); 586 PropertyBag bag(info.GetIsolate(), info[1]->ToObject(), exceptionState);
587 if (!initialize{{cpp_class}}(eventInit, options, exceptionState, info)) { 587 if (!initialize{{cpp_class}}(eventInit, bag, exceptionState, info)) {
588 exceptionState.throwIfNeeded(); 588 exceptionState.throwIfNeeded();
589 return; 589 return;
590 } 590 }
591 {# Store attributes of type |any| on the wrapper to avoid leaking them 591 {# Store attributes of type |any| on the wrapper to avoid leaking them
592 between isolated worlds. #} 592 between isolated worlds. #}
593 {% for attribute in any_type_attributes %} 593 {% for attribute in any_type_attributes %}
594 options.get("{{attribute.name}}", {{attribute.name}}); 594 if (bag.hasProperty("{{attribute.name}}")) {
595 if (!{{attribute.name}}.IsEmpty()) 595 bag.convert("{{attribute.name}}", {{attribute.name}});
596 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), v8At omicString(info.GetIsolate(), "{{attribute.name}}"), {{attribute.name}}); 596 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), v8At omicString(info.GetIsolate(), "{{attribute.name}}"), {{attribute.name}});
597 }
597 {% endfor %} 598 {% endfor %}
598 } 599 }
599 {% if is_constructor_raises_exception %} 600 {% if is_constructor_raises_exception %}
600 RefPtrWillBeRawPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventI nit, exceptionState); 601 RefPtrWillBeRawPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventI nit, exceptionState);
601 if (exceptionState.throwIfNeeded()) 602 if (exceptionState.throwIfNeeded())
602 return; 603 return;
603 {% else %} 604 {% else %}
604 RefPtrWillBeRawPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventI nit); 605 RefPtrWillBeRawPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventI nit);
605 {% endif %} 606 {% endif %}
606 {% if any_type_attributes and not interface_name == 'ErrorEvent' %} 607 {% if any_type_attributes and not interface_name == 'ErrorEvent' %}
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 {% endfor %} 725 {% endfor %}
725 }; 726 };
726 727
727 {% endif %} 728 {% endif %}
728 {% endblock %} 729 {% endblock %}
729 730
730 731
731 {##############################################################################} 732 {##############################################################################}
732 {% block initialize_event %} 733 {% block initialize_event %}
733 {% if has_event_constructor %} 734 {% if has_event_constructor %}
734 bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const Dictionary& opt ions, ExceptionState& exceptionState, const v8::FunctionCallbackInfo<v8::Value>& info, const String& forEventName) 735 bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const PropertyBag& ba g, ExceptionState& exceptionState, const v8::FunctionCallbackInfo<v8::Value>& in fo, const String& forEventName)
735 { 736 {
736 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str ing("{{interface_name}}") : forEventName, "", exceptionState); 737 EventInitInitializer initializer(forEventName.isEmpty() ? String("{{interfac e_name}}") : forEventName, bag, exceptionState);
737 {% if parent_interface %}{# any Event interface except Event itself #} 738 {% if parent_interface %}{# any Event interface except Event itself #}
738 if (!initialize{{parent_interface}}(eventInit, options, exceptionState, info , forEventName.isEmpty() ? String("{{interface_name}}") : forEventName)) 739 if (!initialize{{parent_interface}}(eventInit, bag, exceptionState, info, fo rEventName.isEmpty() ? String("{{interface_name}}") : forEventName))
739 return false; 740 return false;
740 741
741 {% endif %} 742 {% endif %}
742 {% for attribute in attributes 743 {% for attribute in attributes
743 if (attribute.is_initialized_by_event_constructor and 744 if (attribute.is_initialized_by_event_constructor and
744 not attribute.idl_type == 'any')%} 745 not attribute.idl_type == 'any')%}
745 {% set is_nullable = 'true' if attribute.is_nullable else 'false' %} 746 {% set is_nullable = 'PropertyBag::IsNullable' if attribute.is_nullable else 'PropertyBag::IsNotNullable' %}
746 {% if attribute.deprecate_as %} 747 {% if attribute.deprecate_as %}
747 if (DictionaryHelper::convert(options, conversionContext.setConversionType(" {{attribute.idl_type}}", {{is_nullable}}), "{{attribute.name}}", eventInit.{{att ribute.cpp_name}})) { 748 if (initializer.initializeProperty("{{attribute.name}}", eventInit.{{attribu te.cpp_name}}, "{{attribute.idl_type}}", {{is_nullable}})) {
748 if (options.hasProperty("{{attribute.name}}")) 749 if (bag.hasProperty("{{attribute.name}}"))
749 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate ()), UseCounter::{{attribute.deprecate_as}}); 750 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate ()), UseCounter::{{attribute.deprecate_as}});
750 } else { 751 } else {
751 return false; 752 return false;
752 } 753 }
753 {% else %} 754 {% else %}
754 if (!DictionaryHelper::convert(options, conversionContext.setConversionType( "{{attribute.idl_type}}", {{is_nullable}}), "{{attribute.name}}", eventInit.{{at tribute.cpp_name}})) 755 if (!initializer.initializeProperty("{{attribute.name}}", eventInit.{{attrib ute.cpp_name}}, "{{attribute.idl_type}}", {{is_nullable}}))
755 return false; 756 return false;
756 {% endif %} 757 {% endif %}
757 {% endfor %} 758 {% endfor %}
758 return true; 759 return true;
759 } 760 }
760 761
761 {% endif %} 762 {% endif %}
762 {% endblock %} 763 {% endblock %}
763 764
764 765
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 {% endif %} 1264 {% endif %}
1264 } 1265 }
1265 1266
1266 template<> 1267 template<>
1267 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1268 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1268 { 1269 {
1269 return toV8(impl, creationContext, isolate); 1270 return toV8(impl, creationContext, isolate);
1270 } 1271 }
1271 1272
1272 {% endblock %} 1273 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/tests/results/V8SVGTestInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698