mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
auto merge of #2573 : Manishearth/servo/union-return, r=Ms2ger
Blocks #2559
This commit is contained in:
commit
c787fde1ec
4 changed files with 28 additions and 8 deletions
|
@ -1002,6 +1002,11 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
|
||||||
if returnType.nullable():
|
if returnType.nullable():
|
||||||
result = CGWrapper(result, pre="Option<", post=">")
|
result = CGWrapper(result, pre="Option<", post=">")
|
||||||
return result
|
return result
|
||||||
|
if returnType.isUnion():
|
||||||
|
result = CGGeneric('%s::%s' % (returnType.unroll().name, returnType.unroll().name))
|
||||||
|
if returnType.nullable():
|
||||||
|
result = CGWrapper(result, pre="Option<", post=">")
|
||||||
|
return result
|
||||||
if returnType.isAny():
|
if returnType.isAny():
|
||||||
return CGGeneric("JSVal")
|
return CGGeneric("JSVal")
|
||||||
if returnType.isObject() or returnType.isSpiderMonkeyInterface():
|
if returnType.isObject() or returnType.isSpiderMonkeyInterface():
|
||||||
|
|
|
@ -2133,7 +2133,7 @@ class IDLAttribute(IDLInterfaceMember):
|
||||||
raise WebIDLError("An attribute cannot be of a sequence type",
|
raise WebIDLError("An attribute cannot be of a sequence type",
|
||||||
[self.location])
|
[self.location])
|
||||||
if self.type.isUnion():
|
if self.type.isUnion():
|
||||||
for f in self.type.flatMemberTypes:
|
for f in self.type.unroll().flatMemberTypes:
|
||||||
if f.isDictionary():
|
if f.isDictionary():
|
||||||
raise WebIDLError("An attribute cannot be of a union "
|
raise WebIDLError("An attribute cannot be of a union "
|
||||||
"type if one of its member types (or "
|
"type if one of its member types (or "
|
||||||
|
|
|
@ -6,8 +6,8 @@ use dom::bindings::js::{JS, JSRef, Temporary};
|
||||||
use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnum;
|
use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnum;
|
||||||
use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnumValues::_empty;
|
use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnumValues::_empty;
|
||||||
use dom::bindings::codegen::UnionTypes::BlobOrString::BlobOrString;
|
use dom::bindings::codegen::UnionTypes::BlobOrString::BlobOrString;
|
||||||
use dom::bindings::codegen::UnionTypes::EventOrString::EventOrString;
|
use dom::bindings::codegen::UnionTypes::EventOrString::{EventOrString, eString};
|
||||||
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong::HTMLElementOrLong;
|
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong::{HTMLElementOrLong, eLong};
|
||||||
use dom::bindings::str::ByteString;
|
use dom::bindings::str::ByteString;
|
||||||
use dom::bindings::utils::{Reflector, Reflectable};
|
use dom::bindings::utils::{Reflector, Reflectable};
|
||||||
use dom::blob::Blob;
|
use dom::blob::Blob;
|
||||||
|
@ -56,6 +56,10 @@ pub trait TestBindingMethods {
|
||||||
fn SetEnumAttribute(&self, _: TestEnum) {}
|
fn SetEnumAttribute(&self, _: TestEnum) {}
|
||||||
fn InterfaceAttribute(&self) -> Temporary<Blob>;
|
fn InterfaceAttribute(&self) -> Temporary<Blob>;
|
||||||
fn SetInterfaceAttribute(&self, _: &JSRef<Blob>) {}
|
fn SetInterfaceAttribute(&self, _: &JSRef<Blob>) {}
|
||||||
|
fn UnionAttribute(&self) -> HTMLElementOrLong { eLong(0) }
|
||||||
|
fn SetUnionAttribute(&self, _: HTMLElementOrLong) {}
|
||||||
|
fn Union2Attribute(&self) -> EventOrString { eString("".to_string()) }
|
||||||
|
fn SetUnion2Attribute(&self, _: EventOrString) {}
|
||||||
fn AnyAttribute(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
fn AnyAttribute(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||||
fn SetAnyAttribute(&self, _: *mut JSContext, _: JSVal) {}
|
fn SetAnyAttribute(&self, _: *mut JSContext, _: JSVal) {}
|
||||||
|
|
||||||
|
@ -88,7 +92,10 @@ pub trait TestBindingMethods {
|
||||||
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) }
|
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn GetInterfaceAttributeNullable(&self) -> Option<Temporary<Blob>>;
|
fn GetInterfaceAttributeNullable(&self) -> Option<Temporary<Blob>>;
|
||||||
fn SetInterfaceAttributeNullable(&self, _: Option<JSRef<Blob>>) {}
|
fn SetInterfaceAttributeNullable(&self, _: Option<JSRef<Blob>>) {}
|
||||||
|
fn GetUnionAttributeNullable(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||||
|
fn SetUnionAttributeNullable(&self, _: Option<HTMLElementOrLong>) {}
|
||||||
|
fn GetUnion2AttributeNullable(&self) -> Option<EventOrString> { Some(eString("".to_string())) }
|
||||||
|
fn SetUnion2AttributeNullable(&self, _: Option<EventOrString>) {}
|
||||||
fn ReceiveVoid(&self) -> () {}
|
fn ReceiveVoid(&self) -> () {}
|
||||||
fn ReceiveBoolean(&self) -> bool { false }
|
fn ReceiveBoolean(&self) -> bool { false }
|
||||||
fn ReceiveByte(&self) -> i8 { 0 }
|
fn ReceiveByte(&self) -> i8 { 0 }
|
||||||
|
@ -106,6 +113,8 @@ pub trait TestBindingMethods {
|
||||||
fn ReceiveEnum(&self) -> TestEnum { _empty }
|
fn ReceiveEnum(&self) -> TestEnum { _empty }
|
||||||
fn ReceiveInterface(&self) -> Temporary<Blob>;
|
fn ReceiveInterface(&self) -> Temporary<Blob>;
|
||||||
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||||
|
fn ReceiveUnion(&self) -> HTMLElementOrLong { eLong(0) }
|
||||||
|
fn ReceiveUnion2(&self) -> EventOrString { eString("".to_string()) }
|
||||||
|
|
||||||
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
||||||
fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }
|
fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }
|
||||||
|
@ -123,6 +132,8 @@ pub trait TestBindingMethods {
|
||||||
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(_empty) }
|
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn ReceiveNullableInterface(&self) -> Option<Temporary<Blob>>;
|
fn ReceiveNullableInterface(&self) -> Option<Temporary<Blob>>;
|
||||||
fn ReceiveNullableAny(&self, _: *mut JSContext) -> Option<JSVal> { Some(NullValue()) }
|
fn ReceiveNullableAny(&self, _: *mut JSContext) -> Option<JSVal> { Some(NullValue()) }
|
||||||
|
fn ReceiveNullableUnion(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||||
|
fn ReceiveNullableUnion2(&self) -> Option<EventOrString> { Some(eString("".to_string())) }
|
||||||
|
|
||||||
fn PassBoolean(&self, _: bool) {}
|
fn PassBoolean(&self, _: bool) {}
|
||||||
fn PassByte(&self, _: i8) {}
|
fn PassByte(&self, _: i8) {}
|
||||||
|
|
|
@ -69,8 +69,8 @@ interface TestBinding {
|
||||||
attribute ByteString byteStringAttribute;
|
attribute ByteString byteStringAttribute;
|
||||||
attribute TestEnum enumAttribute;
|
attribute TestEnum enumAttribute;
|
||||||
attribute Blob interfaceAttribute;
|
attribute Blob interfaceAttribute;
|
||||||
// attribute (HTMLElement or long) unionAttribute;
|
attribute (HTMLElement or long) unionAttribute;
|
||||||
// attribute (Event or DOMString) union2Attribute;
|
attribute (Event or DOMString) union2Attribute;
|
||||||
attribute any anyAttribute;
|
attribute any anyAttribute;
|
||||||
|
|
||||||
attribute boolean? booleanAttributeNullable;
|
attribute boolean? booleanAttributeNullable;
|
||||||
|
@ -88,8 +88,8 @@ interface TestBinding {
|
||||||
attribute ByteString? byteStringAttributeNullable;
|
attribute ByteString? byteStringAttributeNullable;
|
||||||
readonly attribute TestEnum? enumAttributeNullable;
|
readonly attribute TestEnum? enumAttributeNullable;
|
||||||
attribute Blob? interfaceAttributeNullable;
|
attribute Blob? interfaceAttributeNullable;
|
||||||
// attribute (HTMLElement or long)? unionAttributeNullable;
|
attribute (HTMLElement or long)? unionAttributeNullable;
|
||||||
// attribute (Event or DOMString)? union2AttributeNullable;
|
attribute (Event or DOMString)? union2AttributeNullable;
|
||||||
|
|
||||||
void receiveVoid();
|
void receiveVoid();
|
||||||
boolean receiveBoolean();
|
boolean receiveBoolean();
|
||||||
|
@ -106,6 +106,8 @@ interface TestBinding {
|
||||||
TestEnum receiveEnum();
|
TestEnum receiveEnum();
|
||||||
Blob receiveInterface();
|
Blob receiveInterface();
|
||||||
any receiveAny();
|
any receiveAny();
|
||||||
|
(HTMLElement or long) receiveUnion();
|
||||||
|
(Event or DOMString) receiveUnion2();
|
||||||
|
|
||||||
byte? receiveNullableByte();
|
byte? receiveNullableByte();
|
||||||
boolean? receiveNullableBoolean();
|
boolean? receiveNullableBoolean();
|
||||||
|
@ -120,6 +122,8 @@ interface TestBinding {
|
||||||
ByteString? receiveNullableByteString();
|
ByteString? receiveNullableByteString();
|
||||||
TestEnum? receiveNullableEnum();
|
TestEnum? receiveNullableEnum();
|
||||||
Blob? receiveNullableInterface();
|
Blob? receiveNullableInterface();
|
||||||
|
(HTMLElement or long)? receiveNullableUnion();
|
||||||
|
(Event or DOMString)? receiveNullableUnion2();
|
||||||
|
|
||||||
void passBoolean(boolean arg);
|
void passBoolean(boolean arg);
|
||||||
void passByte(byte arg);
|
void passByte(byte arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue