diff options
author | bors-servo <release+servo@mozilla.com> | 2014-06-03 12:58:23 -0400 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2014-06-03 12:58:23 -0400 |
commit | d448e97c6ac7c73336056be875ca99e5d63d75c3 (patch) | |
tree | 85bd791bdddcff520d3346428e71886fcc278312 /src | |
parent | 052a0ffdf00bf36bdbb511173f88ada3c6296cfc (diff) | |
parent | d8801da9c5e3bc1d1fe4f40853ce9422aedb6103 (diff) | |
download | servo-d448e97c6ac7c73336056be875ca99e5d63d75c3.tar.gz servo-d448e97c6ac7c73336056be875ca99e5d63d75c3.zip |
auto merge of #2558 : Ms2ger/servo/mod-unions, r=jdm
This will allow multiple unions to contain the same type.
Diffstat (limited to 'src')
4 files changed, 29 insertions, 19 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 5f613f8790e..62cb66d5f1f 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -555,7 +555,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, raise TypeError("Can't handle unions as members, we have a " "holderType") - declType = CGGeneric(type.name) + declType = CGGeneric(type.name + "::" + type.name) if type.nullable(): declType = CGWrapper(declType, pre="Option<", post=" >") @@ -1657,6 +1657,20 @@ def UnionTypes(descriptors, dictionaries, callbacks, config): Returns a CGList containing CGUnionStructs for every union. """ + imports = [ + 'dom::bindings::utils::unwrap_jsmanaged', + 'dom::bindings::codegen::PrototypeList', + 'dom::bindings::conversions::FromJSValConvertible', + 'dom::bindings::conversions::ToJSValConvertible', + 'dom::bindings::conversions::Default', + 'dom::bindings::error::throw_not_in_union', + 'dom::bindings::js::JS', + 'dom::types::*', + 'js::jsapi::JSContext', + 'js::jsval::JSVal', + 'servo_util::str::DOMString', + ] + # Now find all the things we'll need as arguments and return values because # we need to wrap or unwrap them. unionStructs = dict() @@ -1668,7 +1682,12 @@ def UnionTypes(descriptors, dictionaries, callbacks, config): name = str(t) if not name in unionStructs: provider = descriptor or config.getDescriptorProvider() - unionStructs[name] = CGList([CGUnionStruct(t, provider), CGUnionConversionStruct(t, provider)]) + unionStructs[name] = CGNamespace(name, + CGImports(CGList([ + CGUnionStruct(t, provider), + CGUnionConversionStruct(t, provider) + ]), [], imports), + public=True) return CGList(SortedDictValues(unionStructs), "\n\n") @@ -4531,7 +4550,7 @@ class CGNativeMember(ClassMethod): if type.isUnion(): if type.nullable(): type = type.inner - return str(type), False, True + return str(type) + "::" + str(type), False, True if type.isGeckoInterface() and not type.isCallbackInterface(): iface = type.unroll().inner @@ -5315,20 +5334,6 @@ class GlobalGenRoots(): config.getCallbacks(), config) - curr = CGImports(curr, [], [ - 'dom::bindings::utils::unwrap_jsmanaged', - 'dom::bindings::codegen::PrototypeList', - 'dom::bindings::conversions::FromJSValConvertible', - 'dom::bindings::conversions::ToJSValConvertible', - 'dom::bindings::conversions::Default', - 'dom::bindings::error::throw_not_in_union', - 'dom::bindings::js::JS', - 'dom::types::*', - 'js::jsapi::JSContext', - 'js::jsval::JSVal', - 'servo_util::str::DOMString', - ]) - # Add the auto-generated comment. curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) diff --git a/src/components/script/dom/htmlselectelement.rs b/src/components/script/dom/htmlselectelement.rs index 666bbebdee0..21a0b73fc27 100644 --- a/src/components/script/dom/htmlselectelement.rs +++ b/src/components/script/dom/htmlselectelement.rs @@ -4,7 +4,8 @@ use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSelectElementDerived; -use dom::bindings::codegen::UnionTypes::{HTMLElementOrLong, HTMLOptionElementOrHTMLOptGroupElement}; +use dom::bindings::codegen::UnionTypes::HTMLElementOrLong::HTMLElementOrLong; +use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement::HTMLOptionElementOrHTMLOptGroupElement; use dom::bindings::js::{JSRef, Temporary}; use dom::document::Document; use dom::element::HTMLSelectElementTypeId; diff --git a/src/components/script/dom/testbinding.rs b/src/components/script/dom/testbinding.rs index 28f9a4c432e..4f6020e8c20 100644 --- a/src/components/script/dom/testbinding.rs +++ b/src/components/script/dom/testbinding.rs @@ -5,7 +5,9 @@ use dom::bindings::js::{JS, JSRef, Temporary}; use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnum; use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnumValues::_empty; -use dom::bindings::codegen::UnionTypes::{HTMLElementOrLong, EventOrString}; +use dom::bindings::codegen::UnionTypes::BlobOrString::BlobOrString; +use dom::bindings::codegen::UnionTypes::EventOrString::EventOrString; +use dom::bindings::codegen::UnionTypes::HTMLElementOrLong::HTMLElementOrLong; use dom::bindings::str::ByteString; use dom::bindings::utils::{Reflector, Reflectable}; use dom::blob::Blob; @@ -139,6 +141,7 @@ pub trait TestBindingMethods { fn PassInterface(&self, _: &JSRef<Blob>) {} fn PassUnion(&self, _: HTMLElementOrLong) {} fn PassUnion2(&self, _: EventOrString) {} + fn PassUnion3(&self, _: BlobOrString) {} fn PassAny(&self, _: *mut JSContext, _: JSVal) {} fn PassNullableBoolean(&self, _: Option<bool>) {} diff --git a/src/components/script/dom/webidls/TestBinding.webidl b/src/components/script/dom/webidls/TestBinding.webidl index e2e45b03c83..0a93b01fa15 100644 --- a/src/components/script/dom/webidls/TestBinding.webidl +++ b/src/components/script/dom/webidls/TestBinding.webidl @@ -138,6 +138,7 @@ interface TestBinding { void passInterface(Blob arg); void passUnion((HTMLElement or long) arg); void passUnion2((Event or DOMString) data); + void passUnion3((Blob or DOMString) data); void passAny(any arg); void passNullableBoolean(boolean? arg); |