diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp index 1253299ec1e..ecddb57125d 100644 --- a/cpp/test/Ice/optional/AllTests.cpp +++ b/cpp/test/Ice/optional/AllTests.cpp @@ -1216,38 +1216,27 @@ allTests(Test::TestHelper* helper, bool) } { - // TODO: remove this testing for tagged classes alongside the tagged class support. - optional p1; - optional p3; - optional p2 = initial->opOneOptional(p1, p3); - test(!p2 && !p3); - - if (initial->supportsNullOptional()) - { - p2 = initial->opOneOptional(OneOptionalPtr(), p3); - test(*p2 == nullptr && *p3 == nullptr); - } + OneOptionalPtr p1 = make_shared(); + OneOptionalPtr p3; + OneOptionalPtr p2 = initial->opOneOptional(p1, p3); + test(!p2->a && !p3->a); p1 = make_shared(58); p2 = initial->opOneOptional(p1, p3); - test((*p2)->a == 58 && (*p3)->a == 58); + test(p2->a == 58 && p3->a == 58); Ice::OutputStream out(communicator); out.startEncapsulation(); - out.write(2, p1); + out.write(p1); out.endEncapsulation(); out.finished(inEncaps); initial->ice_invoke("opOneOptional", Ice::OperationMode::Normal, inEncaps, outEncaps); Ice::InputStream in(communicator, out.getEncoding(), outEncaps); in.startEncapsulation(); - in.read(1, p2); - in.read(3, p3); + in.read(p2); + in.read(p3); in.endEncapsulation(); - test((*p2)->a == 58 && (*p3)->a == 58); - - Ice::InputStream in2(communicator, out.getEncoding(), outEncaps); - in2.startEncapsulation(); - in2.endEncapsulation(); + test(p2->a == 58 && p3->a == 58); } { @@ -1668,59 +1657,52 @@ allTests(Test::TestHelper* helper, bool) { try { - initial->opOptionalException(nullopt, nullopt, nullopt); + initial->opOptionalException(nullopt, nullopt); test(false); } catch (const OptionalException& ex) { test(!ex.a); test(!ex.b); - test(!ex.o); } try { - initial->opOptionalException(30, string("test"), make_shared(53)); + initial->opOptionalException(30, string("test")); test(false); } catch (const OptionalException& ex) { test(ex.a == 30); test(ex.b == string("test")); - test((*ex.o)->a = 53); } try { // - // Use the 1.0 encoding with an exception whose only class members are optional. + // Use the 1.0 encoding with an exception whose only data members are optional. // - initial->ice_encodingVersion(Ice::Encoding_1_0) - ->opOptionalException(30, string("test"), make_shared(53)); + initial->ice_encodingVersion(Ice::Encoding_1_0)->opOptionalException(30, string("test")); test(false); } catch (const OptionalException& ex) { test(!ex.a); test(!ex.b); - test(!ex.o); } try { optional a; optional b; - optional o; - initial->opDerivedException(a, b, o); + initial->opDerivedException(a, b); test(false); } catch (const DerivedException& ex) { test(!ex.a); test(!ex.b); - test(!ex.o); test(!ex.ss); - test(!ex.o2); test(ex.d1 == "d1"); test(ex.d2 == "d2"); } @@ -1733,17 +1715,14 @@ allTests(Test::TestHelper* helper, bool) { optional a = 30; optional b = string("test2"); - optional o = make_shared(53); - initial->opDerivedException(a, b, o); + initial->opDerivedException(a, b); test(false); } catch (const DerivedException& ex) { test(ex.a == 30); test(ex.b == string("test2")); - test((*ex.o)->a == 53); test(ex.ss == string("test2")); - test((*ex.o2)->a == 53); test(ex.d1 == "d1"); test(ex.d2 == "d2"); } @@ -1756,17 +1735,14 @@ allTests(Test::TestHelper* helper, bool) { optional a; optional b; - optional o; - initial->opRequiredException(a, b, o); + initial->opRequiredException(a, b); test(false); } catch (const RequiredException& ex) { test(!ex.a); test(!ex.b); - test(!ex.o); test(ex.ss == string("test")); - test(!ex.o2); } catch (const OptionalException&) { @@ -1777,17 +1753,14 @@ allTests(Test::TestHelper* helper, bool) { optional a = 30; optional b = string("test2"); - optional o = make_shared(53); - initial->opRequiredException(a, b, o); + initial->opRequiredException(a, b); test(false); } catch (const RequiredException& ex) { test(ex.a == 30); test(ex.b == string("test2")); - test((*ex.o)->a == 53); test(ex.ss == string("test2")); - test(ex.o2->a == 53); } catch (const OptionalException&) { @@ -1801,7 +1774,6 @@ allTests(Test::TestHelper* helper, bool) test(initial->opMStruct1()); test(initial->opMDict1()); test(initial->opMSeq1()); - test(initial->opMG1()); { optional p1, p2, p3; @@ -1834,15 +1806,6 @@ allTests(Test::TestHelper* helper, bool) p3 = initial->opMDict2(p1, p2); test(p2 == p1 && p3 == p1); } - { - optional p1, p2, p3; - p3 = initial->opMG2(nullopt, p2); - test(!p2 && !p3); - - p1 = make_shared(); - p3 = initial->opMG2(p1, p2); - test(p2 && p3 && *p3 == *p2); - } } cout << "ok" << endl; return initial; diff --git a/cpp/test/Ice/optional/Test.ice b/cpp/test/Ice/optional/Test.ice index 4399663da4c..1640552ff7e 100644 --- a/cpp/test/Ice/optional/Test.ice +++ b/cpp/test/Ice/optional/Test.ice @@ -136,21 +136,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -193,13 +190,13 @@ interface Initial ["marshaled-result"] Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -226,10 +223,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + // Custom mapping operations ["cpp:array"] optional(1) ByteSeq opByteSeq(["cpp:array"] optional(2) ByteSeq p1, out ["cpp:array"] optional(3) ByteSeq p3); @@ -294,21 +291,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - // TODO: remove. - // This test actually uses this flag only for tagged classes (to be removed), not tagged proxies. - // For tagged proxies: in IceRPC and from Ice 3.8 on, we don't distinguish between a not-set tagged - // proxy and a tagged proxy set to nullopt. We encode as not-set in both cases, and decode successfully both to - // nulltopt. - bool supportsNullOptional(); } } diff --git a/cpp/test/Ice/optional/TestAMD.ice b/cpp/test/Ice/optional/TestAMD.ice index 10b7a4e67be..335ba47ec49 100644 --- a/cpp/test/Ice/optional/TestAMD.ice +++ b/cpp/test/Ice/optional/TestAMD.ice @@ -136,21 +136,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -194,13 +191,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -227,10 +224,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + // Custom mapping operations ["cpp:array"] optional(1) ByteSeq opByteSeq(["cpp:array"] optional(2) ByteSeq p1, out ["cpp:array"] optional(3) ByteSeq p3); @@ -294,17 +291,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - // TODO: remove. See Test.ice comment. - bool supportsNullOptional(); } } diff --git a/cpp/test/Ice/optional/TestAMDI.cpp b/cpp/test/Ice/optional/TestAMDI.cpp index 1b0d99515c4..a2fd80ad239 100644 --- a/cpp/test/Ice/optional/TestAMDI.cpp +++ b/cpp/test/Ice/optional/TestAMDI.cpp @@ -33,31 +33,28 @@ void InitialI::opOptionalExceptionAsync( optional a, optional b, - optional> o, function, function ex, const Ice::Current&) { - ex(make_exception_ptr(OptionalException(false, a, b, o))); + ex(make_exception_ptr(OptionalException(false, a, b))); } void InitialI::opDerivedExceptionAsync( optional a, optional b, - optional> o, function, function ex, const Ice::Current&) { - ex(make_exception_ptr(DerivedException(false, a, b, o, "d1", b, o, "d2"))); + ex(make_exception_ptr(DerivedException(false, a, b, "d1", b, "d2"))); } void InitialI::opRequiredExceptionAsync( optional a, optional b, - optional> o, function, function ex, const Ice::Current&) @@ -65,15 +62,10 @@ InitialI::opRequiredExceptionAsync( RequiredException e; e.a = a; e.b = b; - e.o = o; if (b) { e.ss = b.value(); } - if (o) - { - e.o2 = o.value(); - } ex(make_exception_ptr(e)); } @@ -199,10 +191,9 @@ InitialI::opVarStructAsync( } void -InitialI::opOneOptionalAsync( - optional> p1, - function>&, const optional>&)> - response, +InitialI::opMyInterfaceProxyAsync( + optional<::MyInterfacePrx> p1, + function&, const optional<::MyInterfacePrx>&)> response, function, const Ice::Current&) { @@ -210,9 +201,9 @@ InitialI::opOneOptionalAsync( } void -InitialI::opMyInterfaceProxyAsync( - optional<::MyInterfacePrx> p1, - function&, const optional<::MyInterfacePrx>&)> response, +InitialI::opOneOptionalAsync( + shared_ptr p1, + function&, const shared_ptr&)> response, function, const Ice::Current&) { @@ -481,25 +472,6 @@ InitialI::opMDict2Async( response(OpMDict2MarshaledResult(p1, p1, current)); } -void -InitialI::opMG1Async( - function response, - function, - const Ice::Current& current) -{ - response(OpMG1MarshaledResult(std::make_shared(), current)); -} - -void -InitialI::opMG2Async( - optional p1, - function response, - function, - const Ice::Current& current) -{ - response(OpMG2MarshaledResult(p1, p1, current)); -} - void InitialI::supportsRequiredParamsAsync(function response, function, const Ice::Current&) { @@ -523,9 +495,3 @@ InitialI::supportsCsharpSerializableAsync( { response(true); } - -void -InitialI::supportsNullOptionalAsync(function response, function, const Ice::Current&) -{ - response(false); -} diff --git a/cpp/test/Ice/optional/TestAMDI.h b/cpp/test/Ice/optional/TestAMDI.h index d4bb286ba8e..83651f38fa8 100644 --- a/cpp/test/Ice/optional/TestAMDI.h +++ b/cpp/test/Ice/optional/TestAMDI.h @@ -23,7 +23,6 @@ class InitialI final : public Test::Initial void opOptionalExceptionAsync( std::optional, std::optional, - std::optional>, std::function, std::function, const Ice::Current&) final; @@ -31,7 +30,6 @@ class InitialI final : public Test::Initial void opDerivedExceptionAsync( std::optional, std::optional, - std::optional>, std::function, std::function, const Ice::Current&) final; @@ -39,7 +37,6 @@ class InitialI final : public Test::Initial void opRequiredExceptionAsync( std::optional, std::optional, - std::optional>, std::function, std::function, const Ice::Current&) final; @@ -116,20 +113,18 @@ class InitialI final : public Test::Initial std::function, const Ice::Current&) final; - void opOneOptionalAsync( - std::optional>, - std::function>&, - const std::optional>&)>, - std::function, - const Ice::Current&) final; - void opMyInterfaceProxyAsync( std::optional, std::function&, const std::optional&)>, std::function, const Ice::Current&) final; + void opOneOptionalAsync( + std::shared_ptr, + std::function&, const std::shared_ptr&)>, + std::function, + const Ice::Current&) final; + void opByteSeqAsync( std::optional>, std::function, const Ice::Current&) final; - void opMG1Async( - std::function, - std::function, - const Ice::Current&) final; - - void opMG2Async( - std::optional, - std::function, - std::function, - const Ice::Current&) final; - void supportsRequiredParamsAsync( std::function, std::function, @@ -327,11 +311,6 @@ class InitialI final : public Test::Initial std::function, std::function, const Ice::Current&) final; - - void supportsNullOptionalAsync( - std::function, - std::function, - const Ice::Current&) final; }; #endif diff --git a/cpp/test/Ice/optional/TestI.cpp b/cpp/test/Ice/optional/TestI.cpp index 0eedee5bf3b..6b3c495f618 100644 --- a/cpp/test/Ice/optional/TestI.cpp +++ b/cpp/test/Ice/optional/TestI.cpp @@ -25,44 +25,36 @@ InitialI::pingPong(shared_ptr obj, const Current& current) } void -InitialI::opOptionalException(optional a, optional b, optional o, const Ice::Current&) +InitialI::opOptionalException(optional a, optional b, const Ice::Current&) { OptionalException ex; ex.a = a; ex.b = b; - ex.o = o; throw ex; } void -InitialI::opDerivedException(optional a, optional b, optional o, const Ice::Current&) +InitialI::opDerivedException(optional a, optional b, const Ice::Current&) { DerivedException ex; ex.a = a; ex.b = b; - ex.o = o; ex.ss = b; - ex.o2 = o; ex.d1 = "d1"; ex.d2 = "d2"; throw ex; } void -InitialI::opRequiredException(optional a, optional b, optional o, const Ice::Current&) +InitialI::opRequiredException(optional a, optional b, const Ice::Current&) { RequiredException ex; ex.a = a; ex.b = b; - ex.o = o; if (b) { ex.ss = b.value(); } - if (o) - { - ex.o2 = o.value(); - } throw ex; } @@ -150,15 +142,15 @@ InitialI::opVarStruct(optional p1, optional& p3, const Cur return p1; } -optional -InitialI::opOneOptional(optional p1, optional& p3, const Current&) +optional +InitialI::opMyInterfaceProxy(optional p1, optional& p3, const Current&) { p3 = p1; return p1; } -optional -InitialI::opMyInterfaceProxy(optional p1, optional& p3, const Current&) +OneOptionalPtr +InitialI::opOneOptional(OneOptionalPtr p1, OneOptionalPtr& p3, const Current&) { p3 = p1; return p1; @@ -386,18 +378,6 @@ InitialI::opMDict2(optional p1, const Ice::Current& current return OpMDict2MarshaledResult(p1, p1, current); } -InitialI::OpMG1MarshaledResult -InitialI::opMG1(const Ice::Current& current) -{ - return OpMG1MarshaledResult(make_shared(), current); -} - -InitialI::OpMG2MarshaledResult -InitialI::opMG2(optional p1, const Ice::Current& current) -{ - return OpMG2MarshaledResult(p1, p1, current); -} - bool InitialI::supportsRequiredParams(const Ice::Current&) { @@ -415,9 +395,3 @@ InitialI::supportsCsharpSerializable(const Ice::Current&) { return true; } - -bool -InitialI::supportsNullOptional(const Ice::Current&) -{ - return false; -} diff --git a/cpp/test/Ice/optional/TestI.h b/cpp/test/Ice/optional/TestI.h index 5a7f8564bb3..c1d38177542 100644 --- a/cpp/test/Ice/optional/TestI.h +++ b/cpp/test/Ice/optional/TestI.h @@ -15,23 +15,11 @@ class InitialI : public Test::Initial virtual void shutdown(const Ice::Current&); virtual PingPongMarshaledResult pingPong(Ice::ValuePtr, const Ice::Current&); - virtual void opOptionalException( - std::optional, - std::optional, - std::optional, - const Ice::Current&); + virtual void opOptionalException(std::optional, std::optional, const Ice::Current&); - virtual void opDerivedException( - std::optional, - std::optional, - std::optional, - const Ice::Current&); + virtual void opDerivedException(std::optional, std::optional, const Ice::Current&); - virtual void opRequiredException( - std::optional, - std::optional, - std::optional, - const Ice::Current&); + virtual void opRequiredException(std::optional, std::optional, const Ice::Current&); virtual std::optional opByte(std::optional, std::optional&, const Ice::Current&); @@ -66,12 +54,11 @@ class InitialI : public Test::Initial virtual std::optional opVarStruct(std::optional, std::optional&, const Ice::Current&); - virtual std::optional - opOneOptional(std::optional, std::optional&, const Ice::Current&); - virtual std::optional opMyInterfaceProxy(std::optional, std::optional&, const Ice::Current&); + virtual Test::OneOptionalPtr opOneOptional(Test::OneOptionalPtr, Test::OneOptionalPtr&, const Ice::Current&); + virtual std::optional<::Test::ByteSeq> opByteSeq( std::optional>, std::optional<::Test::ByteSeq>&, @@ -163,17 +150,11 @@ class InitialI : public Test::Initial virtual OpMDict2MarshaledResult opMDict2(std::optional, const Ice::Current&); - virtual OpMG1MarshaledResult opMG1(const Ice::Current&); - - virtual OpMG2MarshaledResult opMG2(std::optional, const Ice::Current&); - virtual bool supportsRequiredParams(const Ice::Current&); virtual bool supportsJavaSerializable(const Ice::Current&); virtual bool supportsCsharpSerializable(const Ice::Current&); - - virtual bool supportsNullOptional(const Ice::Current&); }; #endif diff --git a/csharp/test/Ice/optional/AllTests.cs b/csharp/test/Ice/optional/AllTests.cs index af3964ab664..75402e9a8d5 100644 --- a/csharp/test/Ice/optional/AllTests.cs +++ b/csharp/test/Ice/optional/AllTests.cs @@ -1025,6 +1025,38 @@ public class AllTests : global::Test.AllTests @in.endEncapsulation(); } + { + Test.OneOptional p1 = new Test.OneOptional(); + Test.OneOptional p3; + Test.OneOptional p2 = initial.opOneOptional(p1, out p3); + test(!p2.a.HasValue && !p3.a.HasValue); + + p1 = new Test.OneOptional(58); + p2 = initial.opOneOptional(p1, out p3); + test(p2.a.Value == 58 && p3.a.Value == 58); + + var result = await initial.opOneOptionalAsync(p1); + test(result.returnValue.a.Value == 58 && result.p3.a.Value == 58); + + p2 = initial.opOneOptional(new Test.OneOptional(), out p3); + test(!p2.a.HasValue && !p3.a.HasValue); // Ensure out parameter is cleared. + + os = new OutputStream(communicator); + os.startEncapsulation(); + os.writeValue(p1); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opOneOptional", OperationMode.Normal, inEncaps, out outEncaps); + @in = new InputStream(communicator, outEncaps); + @in.startEncapsulation(); + ReadValueCallbackI p2cb = new ReadValueCallbackI(); + @in.readValue(p2cb.invoke); + ReadValueCallbackI p3cb = new ReadValueCallbackI(); + @in.readValue(p3cb.invoke); + @in.endEncapsulation(); + test(((Test.OneOptional)p2cb.obj).a.Value == 58 && ((Test.OneOptional)p3cb.obj).a.Value == 58); + } + { byte[] p1 = null; byte[] p3; @@ -1720,7 +1752,7 @@ public class AllTests : global::Test.AllTests try { // - // Use the 1.0 encoding with an exception whose only class members are optional. + // Use the 1.0 encoding with an exception whose only data members are optional. // Test.InitialPrx initial2 = (Test.InitialPrx)initial.ice_encodingVersion(Ice.Util.Encoding_1_0); int? a = 30; diff --git a/csharp/test/Ice/optional/Test.ice b/csharp/test/Ice/optional/Test.ice index beefeddd6b3..33cbd240177 100644 --- a/csharp/test/Ice/optional/Test.ice +++ b/csharp/test/Ice/optional/Test.ice @@ -216,6 +216,8 @@ interface Initial optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -267,8 +269,6 @@ interface Initial bool supportsRequiredParams(); bool supportsJavaSerializable(); - - bool supportsNullOptional(); } } diff --git a/csharp/test/Ice/optional/TestAMD.ice b/csharp/test/Ice/optional/TestAMD.ice index a88c4e59eb5..2beb3f1466f 100644 --- a/csharp/test/Ice/optional/TestAMD.ice +++ b/csharp/test/Ice/optional/TestAMD.ice @@ -219,6 +219,8 @@ interface Initial optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -270,8 +272,6 @@ interface Initial bool supportsRequiredParams(); bool supportsJavaSerializable(); - - bool supportsNullOptional(); } } diff --git a/csharp/test/Ice/optional/TestAMDI.cs b/csharp/test/Ice/optional/TestAMDI.cs index 246d3fef17f..d26fd8dc670 100644 --- a/csharp/test/Ice/optional/TestAMDI.cs +++ b/csharp/test/Ice/optional/TestAMDI.cs @@ -129,6 +129,12 @@ public override Task return Task.FromResult(new Test.Initial_OpMyInterfaceProxyResult(p1, p1)); } + public override Task + opOneOptionalAsync(Test.OneOptional p1, Ice.Current current) + { + return Task.FromResult(new Test.Initial_OpOneOptionalResult(p1, p1)); + } + public override Task opByteSeqAsync(byte[] p1, Ice.Current current) { @@ -290,12 +296,6 @@ public override Task { return Task.FromResult(false); } - - public override Task - supportsNullOptionalAsync(Ice.Current current) - { - return Task.FromResult(true); - } } } } diff --git a/csharp/test/Ice/optional/TestI.cs b/csharp/test/Ice/optional/TestI.cs index 271e0f2304f..89db5330c19 100644 --- a/csharp/test/Ice/optional/TestI.cs +++ b/csharp/test/Ice/optional/TestI.cs @@ -149,6 +149,14 @@ public override Test.MyInterfacePrx return p1; } + public override Test.OneOptional opOneOptional(Test.OneOptional p1, + out Test.OneOptional p3, + Ice.Current current) + { + p3 = p1; + return p1; + } + public override byte[] opByteSeq(byte[] p1, out byte[] p3, Ice.Current current) @@ -334,11 +342,6 @@ public override bool supportsJavaSerializable(Ice.Current current) { return false; } - - public override bool supportsNullOptional(Ice.Current current) - { - return true; - } } } } diff --git a/java/test/src/main/java/test/Ice/optional/AMDInitialI.java b/java/test/src/main/java/test/Ice/optional/AMDInitialI.java index 0188c3731bf..701420fb27b 100644 --- a/java/test/src/main/java/test/Ice/optional/AMDInitialI.java +++ b/java/test/src/main/java/test/Ice/optional/AMDInitialI.java @@ -28,8 +28,7 @@ public CompletionStage pingPongAsync( @Override public CompletionStage opOptionalExceptionAsync( - OptionalInt a, Optional b, Optional o, Current current) - throws OptionalException { + OptionalInt a, Optional b, Current current) throws OptionalException { OptionalException ex = new OptionalException(); if (a.isPresent()) { ex.setA(a.getAsInt()); @@ -39,9 +38,6 @@ public CompletionStage opOptionalExceptionAsync( if (b.isPresent()) { ex.setB(b.get()); } - if (o.isPresent()) { - ex.setO(o.get()); - } CompletableFuture f = new CompletableFuture<>(); f.completeExceptionally(ex); return f; @@ -49,8 +45,7 @@ public CompletionStage opOptionalExceptionAsync( @Override public CompletionStage opDerivedExceptionAsync( - OptionalInt a, Optional b, Optional o, Current current) - throws OptionalException { + OptionalInt a, Optional b, Current current) throws OptionalException { DerivedException ex = new DerivedException(); if (a.isPresent()) { ex.setA(a.getAsInt()); @@ -63,10 +58,6 @@ public CompletionStage opDerivedExceptionAsync( } else { ex.clearSs(); // The member "ss" has a default value. } - if (o.isPresent()) { - ex.setO(o.get()); - ex.setO2(o.get()); - } ex.d1 = "d1"; ex.d2 = "d2"; CompletableFuture f = new CompletableFuture<>(); @@ -76,8 +67,7 @@ public CompletionStage opDerivedExceptionAsync( @Override public CompletionStage opRequiredExceptionAsync( - OptionalInt a, Optional b, Optional o, Current current) - throws OptionalException { + OptionalInt a, Optional b, Current current) throws OptionalException { RequiredException ex = new RequiredException(); if (a.isPresent()) { ex.setA(a.getAsInt()); @@ -88,10 +78,6 @@ public CompletionStage opRequiredExceptionAsync( ex.setB(b.get()); ex.ss = b.get(); } - if (o.isPresent()) { - ex.setO(o.get()); - ex.o2 = o.get(); - } CompletableFuture f = new CompletableFuture<>(); f.completeExceptionally(ex); return f; @@ -232,18 +218,6 @@ public CompletionStage opVarStructReqAsync( return CompletableFuture.completedFuture(new Initial.OpVarStructReqResult(p1, p1)); } - @Override - public CompletionStage opOneOptionalAsync( - Optional p1, Current current) { - return CompletableFuture.completedFuture(new Initial.OpOneOptionalResult(p1, p1)); - } - - @Override - public CompletionStage opOneOptionalReqAsync( - Optional p1, Current current) { - return CompletableFuture.completedFuture(new Initial.OpOneOptionalReqResult(p1, p1)); - } - @Override public CompletionStage opMyInterfaceProxyAsync( Optional p1, Current current) { @@ -256,6 +230,12 @@ public CompletionStage opMyInterfaceProxyRe return CompletableFuture.completedFuture(new Initial.OpMyInterfaceProxyReqResult(p1, p1)); } + @Override + public CompletionStage opOneOptionalAsync( + OneOptional p1, Current current) { + return CompletableFuture.completedFuture(new Initial.OpOneOptionalResult(p1, p1)); + } + @Override public CompletionStage opByteSeqAsync( Optional p1, Current current) { @@ -511,17 +491,6 @@ public CompletionStage opMDict2Async( return CompletableFuture.completedFuture(new OpMDict2MarshaledResult(p1, p1, current)); } - @Override - public CompletionStage opMG1Async(Current current) { - return CompletableFuture.completedFuture( - new OpMG1MarshaledResult(Optional.of(new G()), current)); - } - - @Override - public CompletionStage opMG2Async(Optional p1, Current current) { - return CompletableFuture.completedFuture(new OpMG2MarshaledResult(p1, p1, current)); - } - @Override public CompletionStage supportsRequiredParamsAsync(Current current) { return CompletableFuture.completedFuture(true); @@ -536,13 +505,4 @@ public CompletionStage supportsJavaSerializableAsync(Current current) { public CompletionStage supportsCsharpSerializableAsync(Current current) { return CompletableFuture.completedFuture(false); } - - @Override - public CompletionStage supportsNullOptionalAsync(Current current) { - // - // The java.util.Optional class does not support a null value. Constructing an Optional - // using Optional.ofNullable(null) returns an optional whose value is NOT present. - // - return CompletableFuture.completedFuture(false); - } } diff --git a/java/test/src/main/java/test/Ice/optional/AllTests.java b/java/test/src/main/java/test/Ice/optional/AllTests.java index 44a242b33b8..cf66c413e56 100644 --- a/java/test/src/main/java/test/Ice/optional/AllTests.java +++ b/java/test/src/main/java/test/Ice/optional/AllTests.java @@ -1049,41 +1049,33 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { } { - Optional p1 = Optional.empty(); - Initial.OpOneOptionalResult r = initial.opOneOptional(p1); - test(!r.returnValue.isPresent() && !r.p3.isPresent()); - - p1 = Optional.of(new OneOptional(58)); - r = initial.opOneOptional(p1); - test(r.returnValue.get().getA() == 58 && r.p3.get().getA() == 58); - r = initial.opOneOptionalAsync(p1).join(); - test(r.returnValue.get().getA() == 58 && r.p3.get().getA() == 58); - if (reqParams) { - Initial.OpOneOptionalReqResult rr = initial.opOneOptionalReq(p1.get()); - test(rr.returnValue.get().getA() == 58 && rr.p3.get().getA() == 58); - rr = initial.opOneOptionalReqAsync(p1.get()).join(); - test(rr.returnValue.get().getA() == 58 && rr.p3.get().getA() == 58); + OneOptional p1 = new OneOptional(); + Initial.OpOneOptionalResult r = initial.opOneOptional(p1); + test(!r.returnValue.hasA() && !r.p3.hasA()); + r = initial.opOneOptionalAsync(p1).join(); + test(!r.returnValue.hasA() && !r.p3.hasA()); + + p1 = new OneOptional(58); + r = initial.opOneOptional(p1); + test(r.returnValue.getA() == 58 && r.p3.getA() == 58); + r = initial.opOneOptionalAsync(p1).join(); + test(r.returnValue.getA() == 58 && r.p3.getA() == 58); os = new OutputStream(communicator); os.startEncapsulation(); - os.writeOptional(2, OptionalFormat.Class); - os.writeValue(p1.get()); + os.writeValue(p1); os.endEncapsulation(); inEncaps = os.finished(); - inv = initial.ice_invoke("opOneOptionalReq", OperationMode.Normal, inEncaps); - in = new InputStream(communicator, inv.outParams); - in.startEncapsulation(); - Wrapper> p2cb = new Wrapper<>(); - in.readValue(1, v -> p2cb.value = v, OneOptional.class); - Wrapper> p3cb = new Wrapper<>(); - in.readValue(3, v -> p3cb.value = v, OneOptional.class); - in.endEncapsulation(); - test(p2cb.value.get().getA() == 58 && p3cb.value.get().getA() == 58); - + inv = initial.ice_invoke("opOneOptional", OperationMode.Normal, inEncaps); in = new InputStream(communicator, inv.outParams); in.startEncapsulation(); + Wrapper p2cb = new Wrapper<>(); + in.readValue(v -> p2cb.value = v, OneOptional.class); + Wrapper p3cb = new Wrapper<>(); + in.readValue(v -> p3cb.value = v, OneOptional.class); in.endEncapsulation(); + test(p2cb.value.getA() == 58 && p3cb.value.getA() == 58); } } @@ -1980,51 +1972,42 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { try { OptionalInt a = OptionalInt.empty(); Optional b = Optional.empty(); - Optional o = Optional.empty(); - initial.opOptionalException(a, b, o); + initial.opOptionalException(a, b); } catch (OptionalException ex) { test(!ex.hasA()); test(!ex.hasB()); - test(!ex.hasO()); } try { OptionalInt a = OptionalInt.of(30); Optional b = Optional.of("test"); - Optional o = Optional.of(new OneOptional(53)); - initial.opOptionalException(a, b, o); + initial.opOptionalException(a, b); } catch (OptionalException ex) { test(ex.getA() == 30); test(ex.getB().equals("test")); - test(ex.getO().getA() == 53); } try { // - // Use the 1.0 encoding with an exception whose only class members are optional. + // Use the 1.0 encoding with an exception whose only data members are optional. // InitialPrx initial2 = initial.ice_encodingVersion(com.zeroc.Ice.Util.Encoding_1_0); OptionalInt a = OptionalInt.of(30); Optional b = Optional.of("test"); - Optional o = Optional.of(new OneOptional(53)); - initial2.opOptionalException(a, b, o); + initial2.opOptionalException(a, b); } catch (OptionalException ex) { test(!ex.hasA()); test(!ex.hasB()); - test(!ex.hasO()); } try { OptionalInt a = OptionalInt.empty(); Optional b = Optional.empty(); - Optional o = Optional.empty(); - initial.opDerivedException(a, b, o); + initial.opDerivedException(a, b); } catch (DerivedException ex) { test(!ex.hasA()); test(!ex.hasB()); - test(!ex.hasO()); test(!ex.hasSs()); - test(!ex.hasO2()); test(ex.d1.equals("d1")); test(ex.d2.equals("d2")); } catch (OptionalException ex) { @@ -2034,14 +2017,11 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { try { OptionalInt a = OptionalInt.of(30); Optional b = Optional.of("test2"); - Optional o = Optional.of(new OneOptional(53)); - initial.opDerivedException(a, b, o); + initial.opDerivedException(a, b); } catch (DerivedException ex) { test(ex.getA() == 30); test(ex.getB().equals("test2")); - test(ex.getO().getA() == 53); test(ex.getSs().equals("test2")); - test(ex.getO2().getA() == 53); test(ex.d1.equals("d1")); test(ex.d2.equals("d2")); } catch (OptionalException ex) { @@ -2051,14 +2031,11 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { try { OptionalInt a = OptionalInt.empty(); Optional b = Optional.empty(); - Optional o = Optional.empty(); - initial.opRequiredException(a, b, o); + initial.opRequiredException(a, b); } catch (RequiredException ex) { test(!ex.hasA()); test(!ex.hasB()); - test(!ex.hasO()); test(ex.ss.equals("test")); - test(ex.o2 == null); } catch (OptionalException ex) { test(false); } @@ -2066,14 +2043,11 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { try { OptionalInt a = OptionalInt.of(30); Optional b = Optional.of("test2"); - Optional o = Optional.of(new OneOptional(53)); - initial.opRequiredException(a, b, o); + initial.opRequiredException(a, b); } catch (RequiredException ex) { test(ex.getA() == 30); test(ex.getB().equals("test2")); - test(ex.getO().getA() == 53); test(ex.ss.equals("test2")); - test(ex.o2.getA() == 53); } catch (OptionalException ex) { test(false); } @@ -2086,7 +2060,6 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { test(initial.opMStruct1().isPresent()); test(initial.opMDict1().isPresent()); test(initial.opMSeq1().isPresent()); - test(initial.opMG1().isPresent()); { Initial.OpMStruct2Result result = initial.opMStruct2(Optional.empty()); @@ -2115,14 +2088,6 @@ public static InitialPrx allTests(test.TestHelper helper, boolean collocated) { result = initial.opMDict2(Optional.of(p1)); test(result.p2.get().equals(p1) && result.returnValue.get().equals(p1)); } - { - Initial.OpMG2Result result = initial.opMG2(Optional.empty()); - test(!result.p2.isPresent() && !result.returnValue.isPresent()); - - G p1 = new G(); - result = initial.opMG2(Optional.of(p1)); - test(result.p2.get() == result.returnValue.get()); - } } out.println("ok"); diff --git a/java/test/src/main/java/test/Ice/optional/InitialI.java b/java/test/src/main/java/test/Ice/optional/InitialI.java index 2a0d90e7975..fb90ad2d115 100644 --- a/java/test/src/main/java/test/Ice/optional/InitialI.java +++ b/java/test/src/main/java/test/Ice/optional/InitialI.java @@ -23,8 +23,7 @@ public com.zeroc.Ice.Value pingPong(com.zeroc.Ice.Value obj, Current current) { } @Override - public void opOptionalException( - OptionalInt a, Optional b, Optional o, Current current) + public void opOptionalException(OptionalInt a, Optional b, Current current) throws OptionalException { OptionalException ex = new OptionalException(); if (a.isPresent()) { @@ -35,15 +34,11 @@ public void opOptionalException( if (b.isPresent()) { ex.setB(b.get()); } - if (o.isPresent()) { - ex.setO(o.get()); - } throw ex; } @Override - public void opDerivedException( - OptionalInt a, Optional b, Optional o, Current current) + public void opDerivedException(OptionalInt a, Optional b, Current current) throws OptionalException { DerivedException ex = new DerivedException(); if (a.isPresent()) { @@ -57,18 +52,13 @@ public void opDerivedException( } else { ex.clearSs(); // The member "ss" has a default value. } - if (o.isPresent()) { - ex.setO(o.get()); - ex.setO2(o.get()); - } ex.d1 = "d1"; ex.d2 = "d2"; throw ex; } @Override - public void opRequiredException( - OptionalInt a, Optional b, Optional o, Current current) + public void opRequiredException(OptionalInt a, Optional b, Current current) throws OptionalException { RequiredException ex = new RequiredException(); if (a.isPresent()) { @@ -80,10 +70,6 @@ public void opRequiredException( ex.setB(b.get()); ex.ss = b.get(); } - if (o.isPresent()) { - ex.setO(o.get()); - ex.o2 = o.get(); - } throw ex; } @@ -222,17 +208,6 @@ public Initial.OpVarStructReqResult opVarStructReq(Optional p1, Curre return new Initial.OpVarStructReqResult(p1, p1); } - @Override - public Initial.OpOneOptionalResult opOneOptional(Optional p1, Current current) { - return new Initial.OpOneOptionalResult(p1, p1); - } - - @Override - public Initial.OpOneOptionalReqResult opOneOptionalReq( - Optional p1, Current current) { - return new Initial.OpOneOptionalReqResult(p1, p1); - } - @Override public Initial.OpMyInterfaceProxyResult opMyInterfaceProxy( Optional p1, Current current) { @@ -245,6 +220,11 @@ public Initial.OpMyInterfaceProxyReqResult opMyInterfaceProxyReq( return new Initial.OpMyInterfaceProxyReqResult(p1, p1); } + @Override + public Initial.OpOneOptionalResult opOneOptional(OneOptional p1, Current current) { + return new Initial.OpOneOptionalResult(p1, p1); + } + @Override public Initial.OpByteSeqResult opByteSeq(Optional p1, Current current) { return new Initial.OpByteSeqResult(p1, p1); @@ -474,16 +454,6 @@ public OpMDict2MarshaledResult opMDict2( return new OpMDict2MarshaledResult(p1, p1, current); } - @Override - public OpMG1MarshaledResult opMG1(Current current) { - return new OpMG1MarshaledResult(Optional.of(new G()), current); - } - - @Override - public OpMG2MarshaledResult opMG2(Optional p1, Current current) { - return new OpMG2MarshaledResult(p1, p1, current); - } - @Override public boolean supportsRequiredParams(Current current) { return true; @@ -498,13 +468,4 @@ public boolean supportsJavaSerializable(Current current) { public boolean supportsCsharpSerializable(Current current) { return false; } - - @Override - public boolean supportsNullOptional(Current current) { - // - // The java.util.Optional class does not support a null value. Constructing an Optional - // using Optional.ofNullable(null) returns an optional whose value is NOT present. - // - return false; - } } diff --git a/java/test/src/main/java/test/Ice/optional/Test.ice b/java/test/src/main/java/test/Ice/optional/Test.ice index 95ffc42a33a..d6db8c62e4b 100644 --- a/java/test/src/main/java/test/Ice/optional/Test.ice +++ b/java/test/src/main/java/test/Ice/optional/Test.ice @@ -133,21 +133,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -190,13 +187,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; ["java:optional"] optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -235,13 +232,12 @@ interface Initial ["java:optional"] optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); optional(1) VarStruct opVarStructReq(optional(2) VarStruct p1, out optional(3) VarStruct p3); - ["java:optional"] optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) OneOptional opOneOptionalReq(optional(2) OneOptional p1, out optional(3) OneOptional p3); - ["java:optional"] optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); optional(1) MyInterface* opMyInterfaceProxyReq(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + ["java:optional"] optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) ByteSeq opByteSeqReq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); @@ -323,16 +319,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/java/test/src/main/java/test/Ice/optional/TestAMD.ice b/java/test/src/main/java/test/Ice/optional/TestAMD.ice index f7e78cf862d..fe0bc857651 100644 --- a/java/test/src/main/java/test/Ice/optional/TestAMD.ice +++ b/java/test/src/main/java/test/Ice/optional/TestAMD.ice @@ -133,21 +133,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -191,13 +188,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; ["java:optional"] optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -236,14 +233,12 @@ interface Initial ["java:optional"] optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); optional(1) VarStruct opVarStructReq(optional(2) VarStruct p1, out optional(3) VarStruct p3); - ["java:optional"] optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) OneOptional opOneOptionalReq(optional(2) OneOptional p1, out optional(3) OneOptional p3); - ["java:optional"] optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); - optional(1) MyInterface* opMyInterfaceProxyReq(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + ["java:optional"] optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) ByteSeq opByteSeqReq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); @@ -325,16 +320,11 @@ interface Initial ["marshaled-result", "java:optional"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result", "java:optional"] optional(1) G opMG1(); - ["marshaled-result", "java:optional"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/js/test/Ice/optional/AMDInitialI.js b/js/test/Ice/optional/AMDInitialI.js index 25be7a9fe93..281092af9fb 100644 --- a/js/test/Ice/optional/AMDInitialI.js +++ b/js/test/Ice/optional/AMDInitialI.js @@ -18,7 +18,7 @@ return obj; } - opOptionalException(a, b, o, current) + opOptionalException(a, b, current) { const ex = new Test.OptionalException(); if(a !== undefined) @@ -33,14 +33,10 @@ { ex.b = b; } - if(o !== undefined) - { - ex.o = o; - } throw ex; } - opDerivedException(a, b, o, current) + opDerivedException(a, b, current) { const ex = new Test.DerivedException(); if(a !== undefined) @@ -60,17 +56,12 @@ { ex.ss = undefined; // The member "ss" has a default value. } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } ex.d1 = "d1"; ex.d2 = "d2"; throw ex; } - opRequiredException(a, b, o, current) + opRequiredException(a, b, current) { const ex = new Test.RequiredException(); if(a !== undefined) @@ -86,11 +77,6 @@ ex.b = b; ex.ss = b; } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } throw ex; } @@ -292,16 +278,6 @@ return [p1, p1]; } - opMG1(current) - { - return new Test.G(); - } - - opMG2(p1, current) - { - return [p1, p1]; - } - supportsRequiredParams(current) { return false; @@ -316,11 +292,6 @@ { return false; } - - supportsNullOptional(current) - { - return true; - } } exports.AMDInitialI = AMDInitialI; diff --git a/js/test/Ice/optional/Client.js b/js/test/Ice/optional/Client.js index 70721f50e45..8f1c6cffc73 100644 --- a/js/test/Ice/optional/Client.js +++ b/js/test/Ice/optional/Client.js @@ -418,16 +418,9 @@ [p1, p2] = await initial.opVarStruct(new Test.VarStruct("test")); test(p1.equals(new Test.VarStruct("test"))); test(p2.equals(new Test.VarStruct("test"))); - [p1, p2] = await initial.opOneOptional(); - test(p1 === undefined); - test(p2 === undefined); - if(await initial.supportsNullOptional()) - { - - [p1, p2] = await initial.opOneOptional(null); - test(p1 === null); - test(p2 === null); - } + [p1, p2] = await initial.opOneOptional(new Test.OneOptional()); + test(p1 === p2); + test(p2.a === undefined); [p1, p2] = await initial.opOneOptional(new Test.OneOptional(58)); test(p1 === p2); test(p2.a === 58); @@ -661,12 +654,11 @@ test(ex instanceof Test.OptionalException, ex); test(ex.a === undefined); test(ex.b === undefined); - test(ex.o === undefined); } try { - await initial.opOptionalException(30, "test", new Test.OneOptional(53)); + await initial.opOptionalException(30, "test"); test(false); } catch(ex) @@ -674,7 +666,6 @@ test(ex instanceof Test.OptionalException, ex); test(ex.a === 30); test(ex.b == "test"); - test(ex.o.a == 53); } try @@ -687,16 +678,14 @@ test(ex instanceof Test.DerivedException, ex); test(ex.a === undefined); test(ex.b === undefined); - test(ex.o === undefined); test(ex.ss === undefined); - test(ex.o2 === undefined); test(ex.d1 == "d1"); test(ex.d2 == "d2"); } try { - await initial.opDerivedException(30, "test2", new Test.OneOptional(53)); + await initial.opDerivedException(30, "test2"); test(false); } catch(ex) @@ -704,9 +693,7 @@ test(ex instanceof Test.DerivedException, ex); test(ex.a === 30); test(ex.b == "test2"); - test(ex.o.a === 53); test(ex.ss == "test2"); - test(ex.o2.a === 53); } out.writeLine("ok"); @@ -716,7 +703,6 @@ test(await initial.opMStruct1() !== undefined); test(await initial.opMDict1() !== undefined); test(await initial.opMSeq1() !== undefined); - test(await initial.opMG1() !== undefined); { let [p3, p2] = await initial.opMStruct2(); @@ -745,14 +731,6 @@ [p3, p2] = await initial.opMDict2(p1); test(Ice.MapUtil.equals(p2, p1) && Ice.MapUtil.equals(p3, p1)); } - { - let [p3, p2] = await initial.opMG2(); - test(p2 === undefined && p3 === undefined); - - const p1 = new Test.G(); - [p3, p2] = await initial.opMG2(p1); - test(p3 !== undefined && p2 !== undefined && p3 === p2); - } out.writeLine("ok"); diff --git a/js/test/Ice/optional/InitialI.js b/js/test/Ice/optional/InitialI.js index ac45092b47d..440e284410d 100644 --- a/js/test/Ice/optional/InitialI.js +++ b/js/test/Ice/optional/InitialI.js @@ -18,7 +18,7 @@ return obj; } - opOptionalException(a, b, o, current) + opOptionalException(a, b, current) { const ex = new Test.OptionalException(); if(a !== undefined) @@ -33,14 +33,10 @@ { ex.b = b; } - if(o !== undefined) - { - ex.o = o; - } throw ex; } - opDerivedException(a, b, o, current) + opDerivedException(a, b, current) { const ex = new Test.DerivedException(); if(a !== undefined) @@ -60,17 +56,12 @@ { ex.ss = undefined; // The member "ss" has a default value. } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } ex.d1 = "d1"; ex.d2 = "d2"; throw ex; } - opRequiredException(a, b, o, current) + opRequiredException(a, b, current) { const ex = new Test.RequiredException(); if(a !== undefined) @@ -86,11 +77,6 @@ ex.b = b; ex.ss = b; } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } throw ex; } @@ -292,16 +278,6 @@ return [p1, p1]; } - opMG1(current) - { - return new Test.G(); - } - - opMG2(p1, current) - { - return [p1, p1]; - } - supportsRequiredParams(current) { return false; @@ -316,11 +292,6 @@ { return false; } - - supportsNullOptional(current) - { - return true; - } } exports.InitialI = InitialI; }(typeof global !== "undefined" && typeof global.process !== "undefined" ? module : undefined, diff --git a/js/test/Ice/optional/Test.ice b/js/test/Ice/optional/Test.ice index 15c44c0c8e0..9b07528a28d 100644 --- a/js/test/Ice/optional/Test.ice +++ b/js/test/Ice/optional/Test.ice @@ -132,21 +132,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -189,13 +186,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -222,10 +219,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -279,16 +276,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } interface Echo diff --git a/js/test/typescript/Ice/optional/AMDInitialI.ts b/js/test/typescript/Ice/optional/AMDInitialI.ts index 84fae160e28..105950904cd 100644 --- a/js/test/typescript/Ice/optional/AMDInitialI.ts +++ b/js/test/typescript/Ice/optional/AMDInitialI.ts @@ -17,7 +17,7 @@ export class AMDInitialI extends Test.Initial return obj; } - opOptionalException(a:number, b:string, o:Test.OneOptional, current:Ice.Current):void + opOptionalException(a:number, b:string, current:Ice.Current):void { const ex = new Test.OptionalException(); if(a !== undefined) @@ -32,14 +32,10 @@ export class AMDInitialI extends Test.Initial { ex.b = b; } - if(o !== undefined) - { - ex.o = o; - } throw ex; } - opDerivedException(a:number, b:string, o:Test.OneOptional, current:Ice.Current):void + opDerivedException(a:number, b:string, current:Ice.Current):void { const ex = new Test.DerivedException(); if(a !== undefined) @@ -59,17 +55,12 @@ export class AMDInitialI extends Test.Initial { ex.ss = undefined; // The member "ss" has a default value. } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } ex.d1 = "d1"; ex.d2 = "d2"; throw ex; } - opRequiredException(a:number, b:string, o:Test.OneOptional, current:Ice.Current):void + opRequiredException(a:number, b:string, current:Ice.Current):void { const ex = new Test.RequiredException(); if(a !== undefined) @@ -85,11 +76,6 @@ export class AMDInitialI extends Test.Initial ex.b = b; ex.ss = b; } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } throw ex; } @@ -291,16 +277,6 @@ export class AMDInitialI extends Test.Initial return [p1, p1]; } - opMG1(current:Ice.Current):Test.G - { - return new Test.G(); - } - - opMG2(p1:Test.G, current:Ice.Current):[Test.G, Test.G] - { - return [p1, p1]; - } - supportsRequiredParams(current:Ice.Current):boolean { return false; @@ -315,9 +291,4 @@ export class AMDInitialI extends Test.Initial { return false; } - - supportsNullOptional(current:Ice.Current):boolean - { - return true; - } } diff --git a/js/test/typescript/Ice/optional/Client.ts b/js/test/typescript/Ice/optional/Client.ts index 2d99c7bfb2c..ed5c80f9fc8 100644 --- a/js/test/typescript/Ice/optional/Client.ts +++ b/js/test/typescript/Ice/optional/Client.ts @@ -450,16 +450,9 @@ export class Client extends TestHelper } { - let [p1, p2] = await initial.opOneOptional(); - test(p1 === undefined); - test(p2 === undefined); - if(await initial.supportsNullOptional()) - { - - [p1, p2] = await initial.opOneOptional(null); - test(p1 === null); - test(p2 === null); - } + let [p1, p2] = await initial.opOneOptional(new Test.OneOptional()); + test(p1 === p2); + test(p2.a === undefined); [p1, p2] = await initial.opOneOptional(new Test.OneOptional(58)); test(p1 === p2); test(p2.a === 58); @@ -738,12 +731,11 @@ export class Client extends TestHelper test(ex instanceof Test.OptionalException, ex); test(ex.a === undefined); test(ex.b === undefined); - test(ex.o === undefined); } try { - await initial.opOptionalException(30, "test", new Test.OneOptional(53)); + await initial.opOptionalException(30, "test"); test(false); } catch(ex) @@ -751,7 +743,6 @@ export class Client extends TestHelper test(ex instanceof Test.OptionalException, ex); test(ex.a === 30); test(ex.b == "test"); - test(ex.o.a == 53); } try @@ -764,16 +755,14 @@ export class Client extends TestHelper test(ex instanceof Test.DerivedException, ex); test(ex.a === undefined); test(ex.b === undefined); - test(ex.o === undefined); test(ex.ss === undefined); - test(ex.o2 === undefined); test(ex.d1 == "d1"); test(ex.d2 == "d2"); } try { - await initial.opDerivedException(30, "test2", new Test.OneOptional(53)); + await initial.opDerivedException(30, "test2"); test(false); } catch(ex) @@ -781,9 +770,7 @@ export class Client extends TestHelper test(ex instanceof Test.DerivedException, ex); test(ex.a === 30); test(ex.b == "test2"); - test(ex.o.a === 53); test(ex.ss == "test2"); - test(ex.o2.a === 53); test(ex.d1 == "d1"); test(ex.d2 == "d2"); } @@ -795,7 +782,6 @@ export class Client extends TestHelper test(await initial.opMStruct1() !== undefined); test(await initial.opMDict1() !== undefined); test(await initial.opMSeq1() !== undefined); - test(await initial.opMG1() !== undefined); { let [p3, p2] = await initial.opMStruct2(); @@ -824,14 +810,6 @@ export class Client extends TestHelper [p3, p2] = await initial.opMDict2(p1); test(Ice.MapUtil.equals(p2, p1) && Ice.MapUtil.equals(p3, p1)); } - { - let [p3, p2] = await initial.opMG2(); - test(p2 === undefined && p3 === undefined); - - const p1 = new Test.G(); - [p3, p2] = await initial.opMG2(p1); - test(p3 !== undefined && p2 !== undefined && p3 === p2); - } out.writeLine("ok"); diff --git a/js/test/typescript/Ice/optional/InitialI.ts b/js/test/typescript/Ice/optional/InitialI.ts index 68aad568d42..38fed51daa2 100644 --- a/js/test/typescript/Ice/optional/InitialI.ts +++ b/js/test/typescript/Ice/optional/InitialI.ts @@ -17,7 +17,7 @@ export class InitialI extends Test.Initial return obj; } - opOptionalException(a:number, b:string, o:Test.OneOptional, current:Ice.Current):void + opOptionalException(a:number, b:string, current:Ice.Current):void { const ex = new Test.OptionalException(); if(a !== undefined) @@ -32,14 +32,10 @@ export class InitialI extends Test.Initial { ex.b = b; } - if(o !== undefined) - { - ex.o = o; - } throw ex; } - opDerivedException(a:number, b:string, o:Test.OneOptional, current:Ice.Current):void + opDerivedException(a:number, b:string, current:Ice.Current):void { const ex = new Test.DerivedException(); if(a !== undefined) @@ -59,17 +55,12 @@ export class InitialI extends Test.Initial { ex.ss = undefined; // The member "ss" has a default value. } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } ex.d1 = "d1"; ex.d2 = "d2"; throw ex; } - opRequiredException(a:number, b:string, o:Test.OneOptional, current:Ice.Current):void + opRequiredException(a:number, b:string, current:Ice.Current):void { const ex = new Test.RequiredException(); if(a !== undefined) @@ -85,11 +76,6 @@ export class InitialI extends Test.Initial ex.b = b; ex.ss = b; } - if(o !== undefined) - { - ex.o = o; - ex.o2 = o; - } throw ex; } @@ -291,16 +277,6 @@ export class InitialI extends Test.Initial return [p1, p1]; } - opMG1(current:Ice.Current):Test.G - { - return new Test.G(); - } - - opMG2(p1:Test.G, current:Ice.Current):[Test.G, Test.G] - { - return [p1, p1]; - } - supportsRequiredParams(current:Ice.Current):boolean { return false; @@ -315,9 +291,4 @@ export class InitialI extends Test.Initial { return false; } - - supportsNullOptional(current:Ice.Current):boolean - { - return true; - } } diff --git a/js/test/typescript/Ice/optional/Test.ice b/js/test/typescript/Ice/optional/Test.ice index 91e359cc7f4..50077ff46bd 100644 --- a/js/test/typescript/Ice/optional/Test.ice +++ b/js/test/typescript/Ice/optional/Test.ice @@ -134,21 +134,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -191,13 +188,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -224,10 +221,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -281,16 +278,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } interface Echo diff --git a/matlab/test/Ice/optional/AllTests.m b/matlab/test/Ice/optional/AllTests.m index 6047dfc8ea4..72401d1d2f8 100644 --- a/matlab/test/Ice/optional/AllTests.m +++ b/matlab/test/Ice/optional/AllTests.m @@ -518,12 +518,9 @@ [p2, p3] = f.fetchOutputs(); assert(p2 == p1 && p3 == p1); - [p2, p3] = initial.opOneOptional(Ice.Unset); - assert(p2 == Ice.Unset && p3 == Ice.Unset); - if initial.supportsNullOptional() - [p2, p3] = initial.opOneOptional([]); - assert(isempty(p2) && isempty(p3)); - end + p1 = OneOptional(); + [p2, p3] = initial.opOneOptional(p1); + assert(p2.a == Ice.Unset && p3.a == Ice.Unset); p1 = OneOptional(58); [p2, p3] = initial.opOneOptional(p1); assert(p2.a == p1.a && p3.a == p1.a); @@ -729,81 +726,70 @@ fprintf('testing exception optionals... '); try - initial.opOptionalException(Ice.Unset, Ice.Unset, Ice.Unset); + initial.opOptionalException(Ice.Unset, Ice.Unset); catch ex assert(isa(ex, 'Test.OptionalException')); assert(ex.a == Ice.Unset); assert(ex.b == Ice.Unset); - assert(ex.o == Ice.Unset); end try - initial.opOptionalException(30, 'test', OneOptional(53)); + initial.opOptionalException(30, 'test'); catch ex assert(isa(ex, 'Test.OptionalException')); assert(ex.a == 30); assert(strcmp(ex.b, 'test')); - assert(ex.o.a == 53); end try % - % Use the 1.0 encoding with an exception whose only class members are optional. + % Use the 1.0 encoding with an exception whose only data members are optional. % - initial.ice_encodingVersion(Ice.EncodingVersion(1, 0)).opOptionalException(30, 'test', OneOptional(53)); + initial.ice_encodingVersion(Ice.EncodingVersion(1, 0)).opOptionalException(30, 'test'); catch ex assert(isa(ex, 'Test.OptionalException')); assert(ex.a == Ice.Unset); assert(ex.b == Ice.Unset); - assert(ex.o == Ice.Unset); end try - initial.opDerivedException(Ice.Unset, Ice.Unset, Ice.Unset); + initial.opDerivedException(Ice.Unset, Ice.Unset); catch ex assert(isa(ex, 'Test.DerivedException')); assert(ex.a == Ice.Unset); assert(ex.b == Ice.Unset); - assert(ex.o == Ice.Unset); assert(ex.ss == Ice.Unset); - assert(ex.o2 == Ice.Unset); assert(strcmp(ex.d1, 'd1')); assert(strcmp(ex.d2, 'd2')); end try - initial.opDerivedException(30, 'test2', OneOptional(53)); + initial.opDerivedException(30, 'test2'); catch ex assert(isa(ex, 'Test.DerivedException')); assert(ex.a == 30); assert(strcmp(ex.b, 'test2')); - assert(ex.o.a == 53); assert(strcmp(ex.ss, 'test2')); - assert(ex.o2 == ex.o); assert(strcmp(ex.d1, 'd1')); assert(strcmp(ex.d2, 'd2')); end try - initial.opRequiredException(Ice.Unset, Ice.Unset, Ice.Unset); + initial.opRequiredException(Ice.Unset, Ice.Unset); catch ex assert(isa(ex, 'Test.RequiredException')); assert(ex.a == Ice.Unset); assert(ex.b == Ice.Unset); - assert(ex.o == Ice.Unset); assert(strcmp(ex.ss, 'test')); - assert(isempty(ex.o2)); end try - initial.opRequiredException(30, 'test2', OneOptional(53)); + initial.opRequiredException(30, 'test2'); catch ex assert(isa(ex, 'Test.RequiredException')); assert(ex.a == 30); assert(strcmp(ex.b, 'test2')); - assert(ex.o.a == 53); assert(strcmp(ex.ss, 'test2')); - assert(ex.o2 == ex.o); end fprintf('ok\n'); diff --git a/matlab/test/Ice/optional/Test.ice b/matlab/test/Ice/optional/Test.ice index f395b6c0289..a064f211d11 100644 --- a/matlab/test/Ice/optional/Test.ice +++ b/matlab/test/Ice/optional/Test.ice @@ -133,21 +133,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -190,13 +187,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -223,10 +220,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -287,16 +284,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/php/test/Ice/optional/Client.php b/php/test/Ice/optional/Client.php index 58c9cae39c1..40946d649f2 100644 --- a/php/test/Ice/optional/Client.php +++ b/php/test/Ice/optional/Client.php @@ -493,13 +493,9 @@ function allTests($helper) $p3 = $initial->opVarStruct($p1, $p2); test($p2 == $p1 && $p3 == $p1); - $p3 = $initial->opOneOptional(Ice\None, $p2); - test($p2 == Ice\None && $p3 == Ice\None); - if($initial->supportsNullOptional()) - { - $p3 = $initial->opOneOptional(null, $p2); - test($p2 == null && $p3 == null); - } + $p1 = new Test\OneOptional; + $p3 = $initial->opOneOptional($p1, $p2); + test($p2->a == Ice\None && $p3->a == Ice\None); $p1 = new Test\OneOptional(58); $p3 = $initial->opOneOptional($p1, $p2); test($p2->a == $p1->a && $p3->a == $p1->a); @@ -644,94 +640,83 @@ function allTests($helper) try { - $initial->opOptionalException(Ice\None, Ice\None, Ice\None); + $initial->opOptionalException(Ice\None, Ice\None); } catch(Test\OptionalException $ex) { test($ex->a == Ice\None); test($ex->b == Ice\None); - test($ex->o == Ice\None); } try { - $initial->opOptionalException(30, "test", new Test\OneOptional(53)); + $initial->opOptionalException(30, "test"); } catch(Exception $ex) { test($ex->a == 30); test($ex->b == "test"); - test($ex->o->a == 53); } try { // - // Use the 1.0 encoding with an exception whose only class members are optional. + // Use the 1.0 encoding with an exception whose only data members are optional. // - $initial->ice_encodingVersion($Ice_Encoding_1_0)->opOptionalException(30, "test", new Test\OneOptional(53)); + $initial->ice_encodingVersion($Ice_Encoding_1_0)->opOptionalException(30, "test"); } catch(Exception $ex) { test($ex->a == Ice\None); test($ex->b == Ice\None); - test($ex->o == Ice\None); } try { - $initial->opDerivedException(Ice\None, Ice\None, Ice\None); + $initial->opDerivedException(Ice\None, Ice\None); } catch(Exception $ex) { test($ex->a == Ice\None); test($ex->b == Ice\None); - test($ex->o == Ice\None); test($ex->ss == Ice\None); - test($ex->o2 == Ice\None); test($ex->d1 == "d1"); test($ex->d2 == "d2"); } try { - $initial->opDerivedException(30, "test", new Test\OneOptional(53)); + $initial->opDerivedException(30, "test"); } catch(Exception $ex) { test($ex->a == 30); test($ex->b == "test"); - test($ex->o->a == 53); test($ex->ss == "test"); - test($ex->o2 == $ex->o); test($ex->d1 == "d1"); test($ex->d2 == "d2"); } try { - $initial->opRequiredException(Ice\None, Ice\None, Ice\None); + $initial->opRequiredException(Ice\None, Ice\None); } catch(Exception $ex) { test($ex->a == Ice\None); test($ex->b == Ice\None); - test($ex->o == Ice\None); test($ex->ss != Ice\None); - test($ex->o2 != Ice\None); } try { - $initial->opRequiredException(30, "test", new Test\OneOptional(53)); + $initial->opRequiredException(30, "test"); } catch(Exception $ex) { test($ex->a == 30); test($ex->b == "test"); - test($ex->o->a == 53); test($ex->ss == "test"); - test($ex->o2 == $ex->o); } echo "ok\n"; @@ -742,7 +727,6 @@ function allTests($helper) test($initial->opMStruct1() != Ice\None); test($initial->opMDict1() != Ice\None); test($initial->opMSeq1() != Ice\None); - test($initial->opMG1() != Ice\None); $p3 = $initial->opMStruct2(Ice\None, $p2); test($p2 == Ice\None && $p3 == Ice\None); @@ -765,13 +749,6 @@ function allTests($helper) $p3 = $initial->opMDict2($p1, $p2); test($p2["test"] == 54 && $p3["test"] == 54); - $p3 = $initial->opMG2(Ice\None, $p2); - test($p2 == Ice\None && $p3 == Ice\None); - - $p1 = new Test\G; - $p3 = $initial->opMG2($p1, $p2); - test($p2 != Ice\None && $p3 != Ice\None && $p3 == $p2); - echo "ok\n"; return $initial; diff --git a/php/test/Ice/optional/Test.ice b/php/test/Ice/optional/Test.ice index d571918dc9f..cea99611cac 100644 --- a/php/test/Ice/optional/Test.ice +++ b/php/test/Ice/optional/Test.ice @@ -132,21 +132,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -189,13 +186,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -222,10 +219,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -277,16 +274,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/python/test/Ice/optional/AllTests.py b/python/test/Ice/optional/AllTests.py index 407aaf3b73a..2225e172ca2 100644 --- a/python/test/Ice/optional/AllTests.py +++ b/python/test/Ice/optional/AllTests.py @@ -558,11 +558,9 @@ def allTests(helper, communicator): (p2, p3) = f.result() test(p2 == p1 and p3 == p1) - (p2, p3) = initial.opOneOptional(Ice.Unset) - test(p2 is Ice.Unset and p3 is Ice.Unset) - if initial.supportsNullOptional(): - (p2, p3) = initial.opOneOptional(None) - test(p2 is None and p3 is None) + p1 = Test.OneOptional() + (p2, p3) = initial.opOneOptional(p1) + test(p2.a is Ice.Unset and p3.a is Ice.Unset) p1 = Test.OneOptional(58) (p2, p3) = initial.opOneOptional(p1) test(p2.a == p1.a and p3.a == p1.a) @@ -751,70 +749,57 @@ def allTests(helper, communicator): sys.stdout.flush() try: - initial.opOptionalException(Ice.Unset, Ice.Unset, Ice.Unset) + initial.opOptionalException(Ice.Unset, Ice.Unset) except Test.OptionalException as ex: test(ex.a is Ice.Unset) test(ex.b is Ice.Unset) - test(ex.o is Ice.Unset) try: - initial.opOptionalException(30, "test", Test.OneOptional(53)) + initial.opOptionalException(30, "test") except Test.OptionalException as ex: test(ex.a == 30) test(ex.b == "test") - test(ex.o.a == 53) try: # - # Use the 1.0 encoding with an exception whose only class members are optional. + # Use the 1.0 encoding with an exception whose only data members are optional. # - initial.ice_encodingVersion(Ice.Encoding_1_0).opOptionalException( - 30, "test", Test.OneOptional(53) - ) + initial.ice_encodingVersion(Ice.Encoding_1_0).opOptionalException(30, "test") except Test.OptionalException as ex: test(ex.a is Ice.Unset) test(ex.b is Ice.Unset) - test(ex.o is Ice.Unset) try: - initial.opDerivedException(Ice.Unset, Ice.Unset, Ice.Unset) + initial.opDerivedException(Ice.Unset, Ice.Unset) except Test.DerivedException as ex: test(ex.a is Ice.Unset) test(ex.b is Ice.Unset) - test(ex.o is Ice.Unset) test(ex.ss is Ice.Unset) - test(ex.o2 is Ice.Unset) test(ex.d1 == "d1") test(ex.d2 == "d2") try: - initial.opDerivedException(30, "test2", Test.OneOptional(53)) + initial.opDerivedException(30, "test2") except Test.DerivedException as ex: test(ex.a == 30) test(ex.b == "test2") - test(ex.o.a == 53) test(ex.ss == "test2") - test(ex.o2 == ex.o) test(ex.d1 == "d1") test(ex.d2 == "d2") try: - initial.opRequiredException(Ice.Unset, Ice.Unset, Ice.Unset) + initial.opRequiredException(Ice.Unset, Ice.Unset) except Test.RequiredException as ex: test(ex.a is Ice.Unset) test(ex.b is Ice.Unset) - test(ex.o is Ice.Unset) test(ex.ss == "test") - test(ex.o2 is None) try: - initial.opRequiredException(30, "test2", Test.OneOptional(53)) + initial.opRequiredException(30, "test2") except Test.RequiredException as ex: test(ex.a == 30) test(ex.b == "test2") - test(ex.o.a == 53) test(ex.ss == "test2") - test(ex.o2 == ex.o) print("ok") @@ -824,7 +809,6 @@ def allTests(helper, communicator): test(initial.opMStruct1() != Ice.Unset) test(initial.opMDict1() != Ice.Unset) test(initial.opMSeq1() != Ice.Unset) - test(initial.opMG1() != Ice.Unset) (p3, p2) = initial.opMStruct2(Ice.Unset) test(p2 == Ice.Unset and p3 == Ice.Unset) @@ -847,13 +831,6 @@ def allTests(helper, communicator): (p3, p2) = initial.opMDict2(p1) test(p2["test"] == 54 and p3["test"] == 54) - (p3, p2) = initial.opMG2(Ice.Unset) - test(p2 == Ice.Unset and p3 == Ice.Unset) - - p1 = Test.G() - (p3, p2) = initial.opMG2(p1) - test(p2 != Ice.Unset and p3 != Ice.Unset and p3 == p2) - print("ok") return initial diff --git a/python/test/Ice/optional/Server.py b/python/test/Ice/optional/Server.py index 31a16fd4199..66a89b21bad 100755 --- a/python/test/Ice/optional/Server.py +++ b/python/test/Ice/optional/Server.py @@ -17,21 +17,18 @@ def shutdown(self, current=None): def pingPong(self, o, current=None): return o - def opOptionalException(self, a, b, o, current=None): - raise Test.OptionalException(False, a, b, o) + def opOptionalException(self, a, b, current=None): + raise Test.OptionalException(False, a, b) - def opDerivedException(self, a, b, o, current=None): - raise Test.DerivedException(False, a, b, o, "d1", b, o, "d2") + def opDerivedException(self, a, b, current=None): + raise Test.DerivedException(False, a, b, "d1", b, "d2") - def opRequiredException(self, a, b, o, current=None): + def opRequiredException(self, a, b, current=None): e = Test.RequiredException() e.a = a e.b = b - e.o = o if b is not Ice.Unset: e.ss = b - if o is not Ice.Unset: - e.o2 = o raise e def opByte(self, p1, current=None): @@ -154,12 +151,6 @@ def opMDict1(self, current): def opMDict2(self, p1, current): return Test.Initial.OpMDict2MarshaledResult((p1, p1), current) - def opMG1(self, current): - return Test.Initial.OpMG1MarshaledResult(Test.G(), current) - - def opMG2(self, p1, current): - return Test.Initial.OpMG2MarshaledResult((p1, p1), current) - def opRequiredAfterOptional(self, p1, p2, p3, current): return (p1, p2, p3) @@ -175,9 +166,6 @@ def supportsJavaSerializable(self, current=None): def supportsCsharpSerializable(self, current=None): return True - def supportsNullOptional(self, current=None): - return True - class Server(TestHelper): def run(self, args): diff --git a/python/test/Ice/optional/ServerAMD.py b/python/test/Ice/optional/ServerAMD.py index c6d02101d05..4ac69883274 100755 --- a/python/test/Ice/optional/ServerAMD.py +++ b/python/test/Ice/optional/ServerAMD.py @@ -17,25 +17,22 @@ def shutdown(self, current=None): def pingPong(self, o, current=None): return Ice.Future.completed(o) - def opOptionalException(self, a, b, o, current=None): + def opOptionalException(self, a, b, current=None): f = Ice.Future() - f.set_exception(Test.OptionalException(False, a, b, o)) + f.set_exception(Test.OptionalException(False, a, b)) return f - def opDerivedException(self, a, b, o, current=None): + def opDerivedException(self, a, b, current=None): f = Ice.Future() - f.set_exception(Test.DerivedException(False, a, b, o, "d1", b, o, "d2")) + f.set_exception(Test.DerivedException(False, a, b, "d1", b, "d2")) return f - def opRequiredException(self, a, b, o, current=None): + def opRequiredException(self, a, b, current=None): e = Test.RequiredException() e.a = a e.b = b - e.o = o if b is not Ice.Unset: e.ss = b - if o is not Ice.Unset: - e.o2 = o f = Ice.Future() f.set_exception(e) return f @@ -168,16 +165,6 @@ def opMDict2(self, p1, current): Test.Initial.OpMDict2MarshaledResult((p1, p1), current) ) - def opMG1(self, current): - return Ice.Future.completed( - Test.Initial.OpMG1MarshaledResult(Test.G(), current) - ) - - def opMG2(self, p1, current): - return Ice.Future.completed( - Test.Initial.OpMG2MarshaledResult((p1, p1), current) - ) - def opRequiredAfterOptional(self, p1, p2, p3, current): return Ice.Future.completed((p1, p2, p3)) @@ -193,9 +180,6 @@ def supportsJavaSerializable(self, current=None): def supportsCsharpSerializable(self, current=None): return Ice.Future.completed(False) - def supportsNullOptional(self, current=None): - return Ice.Future.completed(True) - class ServerAMD(TestHelper): def run(self, args): diff --git a/python/test/Ice/optional/Test.ice b/python/test/Ice/optional/Test.ice index 8781edbb972..b4075e68709 100644 --- a/python/test/Ice/optional/Test.ice +++ b/python/test/Ice/optional/Test.ice @@ -132,21 +132,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -189,13 +186,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -222,10 +219,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -283,16 +280,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/ruby/test/Ice/optional/AllTests.rb b/ruby/test/Ice/optional/AllTests.rb index 1fba65d14b1..979a1ffc5a6 100644 --- a/ruby/test/Ice/optional/AllTests.rb +++ b/ruby/test/Ice/optional/AllTests.rb @@ -488,12 +488,9 @@ def allTests(helper, communicator) p2, p3 = initial.opVarStruct(p1) test(p2 == p1 && p3 == p1) - p2, p3 = initial.opOneOptional(Ice::Unset) - test(p2 == Ice::Unset && p3 == Ice::Unset) - if initial.supportsNullOptional() then - p2, p3 = initial.opOneOptional(nil) - test(p2 == nil && p3 == nil) - end + p1 = Test::OneOptional.new() + p2, p3 = initial.opOneOptional(p1) + test(p2.a == Ice::Unset && p3.a == Ice::Unset) p1 = Test::OneOptional.new(58) p2, p3 = initial.opOneOptional(p1) test(p2.a == p1.a && p3.a == p1.a) @@ -647,74 +644,63 @@ def allTests(helper, communicator) STDOUT.flush begin - initial.opOptionalException(Ice::Unset, Ice::Unset, Ice::Unset) + initial.opOptionalException(Ice::Unset, Ice::Unset) rescue Test::OptionalException => ex test(ex.a == Ice::Unset) test(ex.b == Ice::Unset) - test(ex.o == Ice::Unset) end begin - initial.opOptionalException(30, "test", Test::OneOptional.new(53)) + initial.opOptionalException(30, "test") rescue Test::OptionalException => ex test(ex.a == 30) test(ex.b == "test") - test(ex.o.a == 53) end begin # - # Use the 1.0 encoding with an exception whose only class members are optional. + # Use the 1.0 encoding with an exception whose only data members are optional. # - initial.ice_encodingVersion(Ice::Encoding_1_0).opOptionalException(30, "test", Test::OneOptional.new(53)) + initial.ice_encodingVersion(Ice::Encoding_1_0).opOptionalException(30, "test") rescue Test::OptionalException => ex test(ex.a == Ice::Unset) test(ex.b == Ice::Unset) - test(ex.o == Ice::Unset) end begin - initial.opDerivedException(Ice::Unset, Ice::Unset, Ice::Unset) + initial.opDerivedException(Ice::Unset, Ice::Unset) rescue Test::DerivedException => ex test(ex.a == Ice::Unset) test(ex.b == Ice::Unset) - test(ex.o == Ice::Unset) test(ex.ss == Ice::Unset) - test(ex.o2 == Ice::Unset) test(ex.d1 == "d1") test(ex.d2 == "d2") end begin - initial.opDerivedException(30, "test", Test::OneOptional.new(53)) + initial.opDerivedException(30, "test") rescue Test::DerivedException => ex test(ex.a == 30) test(ex.b == "test") - test(ex.o.a == 53) test(ex.ss == "test") - test(ex.o2 == ex.o) test(ex.d1 == "d1") test(ex.d2 == "d2") end begin - initial.opRequiredException(Ice::Unset, Ice::Unset, Ice::Unset) + initial.opRequiredException(Ice::Unset, Ice::Unset) rescue Test::RequiredException => ex test(ex.a == Ice::Unset) test(ex.b == Ice::Unset) - test(ex.o == Ice::Unset) test(ex.ss != Ice::Unset) - test(ex.o2 != Ice::Unset) end begin - initial.opRequiredException(30, "test", Test::OneOptional.new(53)) + initial.opRequiredException(30, "test") rescue Test::RequiredException => ex test(ex.a == 30) test(ex.b == "test") - test(ex.o.a == 53) test(ex.ss == "test") - test(ex.o2 == ex.o) end puts "ok" @@ -726,7 +712,6 @@ def allTests(helper, communicator) #test(initial.opMStruct1() != Ice::Unset) test(initial.opMDict1() != Ice::Unset) test(initial.opMSeq1() != Ice::Unset) - test(initial.opMG1() != Ice::Unset) (p3, p2) = initial.opMStruct2(Ice::Unset) test(p2 == Ice::Unset && p3 == Ice::Unset) @@ -749,13 +734,6 @@ def allTests(helper, communicator) (p3, p2) = initial.opMDict2(p1) test(p2["test"] == 54 && p3["test"] == 54) - (p3, p2) = initial.opMG2(Ice::Unset) - test(p2 == Ice::Unset && p3 == Ice::Unset) - - p1 = Test::G.new() - (p3, p2) = initial.opMG2(p1) - test(p2 != Ice::Unset && p3 != Ice::Unset && p3 == p2) - puts "ok" return initial diff --git a/ruby/test/Ice/optional/Test.ice b/ruby/test/Ice/optional/Test.ice index ba8f107e5cc..591bb4cccf0 100644 --- a/ruby/test/Ice/optional/Test.ice +++ b/ruby/test/Ice/optional/Test.ice @@ -132,21 +132,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -189,13 +186,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -222,10 +219,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -279,16 +276,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/swift/test/Ice/optional/AllTests.swift b/swift/test/Ice/optional/AllTests.swift index 14badaad761..d6d275d5213 100644 --- a/swift/test/Ice/optional/AllTests.swift +++ b/swift/test/Ice/optional/AllTests.swift @@ -130,7 +130,7 @@ class FValueReader: Ice.Value { istr.startValue() _ = try istr.startSlice() // Don't read fsf on purpose - // in.read(1, _f.fsf); + // in.read(1, _f.fsf) try istr.endSlice() _ = try istr.startSlice() self._f.fse = try istr.read() @@ -1809,31 +1809,15 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { var p2: OneOptional? var p3: OneOptional? + p1 = OneOptional() (p2, p3) = try initial.opOneOptional(p1) - try test(p2 == nil && p3 == nil) - - (p2, p3) = try initial.opOneOptional(nil) - try test(p2 == nil && p3 == nil) - - (p2, p3) = try initial.opOneOptional() - try test(p2 == nil && p3 == nil) - - try Promise { seal in - firstly { - initial.opOneOptionalAsync(nil) - }.done { p2, p3 in - try test(p2 == nil && p3 == nil) - seal.fulfill(()) - }.catch { e in - seal.reject(e) - } - }.wait() + try test(p2!.a == nil && p3!.a == nil) try Promise { seal in firstly { - initial.opOneOptionalAsync() + initial.opOneOptionalAsync(p1) }.done { p2, p3 in - try test(p2 == nil && p3 == nil) + try test(p2!.a == nil && p3!.a == nil) seal.fulfill(()) }.catch { e in seal.reject(e) @@ -1855,44 +1839,24 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { } }.wait() - (p2, p3) = try initial.opOneOptional(OneOptional(a: 58)) - try test(p2!.a! == 58 && p3!.a! == 58) - - try Promise { seal in - firstly { - initial.opOneOptionalAsync(OneOptional(a: 58)) - }.done { p2, p3 in - try test(p2!.a! == 58 && p3!.a! == 58) - seal.fulfill(()) - }.catch { e in - seal.reject(e) - } - }.wait() - - (p2, p3) = try initial.opOneOptional(nil) - try test(p2 == nil && p3 == nil) // Ensure out parameter is cleared. + (p2, p3) = try initial.opOneOptional(OneOptional()) + try test(p2!.a == nil && p3!.a == nil) // Ensure out parameter is cleared. let ostr = Ice.OutputStream(communicator: communicator) ostr.startEncapsulation() - ostr.write(tag: 2, value: p1) + ostr.write(p1) ostr.endEncapsulation() let inEncaps = ostr.finished() let result = try initial.ice_invoke( operation: "opOneOptional", mode: .Normal, inEncaps: inEncaps) - var istr = Ice.InputStream(communicator: communicator, bytes: result.outEncaps) + let istr = Ice.InputStream(communicator: communicator, bytes: result.outEncaps) _ = try istr.startEncapsulation() - try test(istr.readOptional(tag: 1, expectedFormat: .Class)) var v1: Ice.Value? try istr.read { v1 = $0 } - try test(istr.readOptional(tag: 3, expectedFormat: .Class)) var v2: Ice.Value? try istr.read { v2 = $0 } try istr.endEncapsulation() try test((v1 as! OneOptional).a! == 58 && (v2 as! OneOptional).a == 58) - - istr = Ice.InputStream(communicator: communicator, bytes: result.outEncaps) - _ = try istr.startEncapsulation() - try istr.endEncapsulation() } do { @@ -3176,19 +3140,17 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { output.write("testing exception optionals... ") do { - try initial.opOptionalException(a: nil, b: nil, o: nil) + try initial.opOptionalException(a: nil, b: nil) } catch let ex as OptionalException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) } do { - try initial.opOptionalException(o: nil) + try initial.opOptionalException() } catch let ex as OptionalException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) } do { @@ -3196,7 +3158,6 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { } catch let ex as OptionalException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) } do { @@ -3204,61 +3165,52 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { } catch let ex as OptionalException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) } do { - try initial.opOptionalException(a: 30, b: "test", o: OneOptional(a: 53)) + try initial.opOptionalException(a: 30, b: "test") } catch let ex as OptionalException { try test(ex.a == 30) try test(ex.b == "test") - try test(ex.o!.a == 53) } do { // - // Use the 1.0 encoding with an exception whose only class members are optional. + // Use the 1.0 encoding with an exception whose only data members are optional. // let initial2 = initial.ice_encodingVersion(Ice.Encoding_1_0) - try initial2.opOptionalException(a: 30, b: "test", o: OneOptional(a: 53)) + try initial2.opOptionalException(a: 30, b: "test") } catch let ex as OptionalException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) } do { - try initial.opDerivedException(a: nil, b: nil, o: nil) + try initial.opDerivedException(a: nil, b: nil) } catch let ex as DerivedException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) try test(ex.ss == nil) - try test(ex.o2 == nil) try test(ex.d1 == "d1") try test(ex.d2 == "d2") } do { - try initial.opDerivedException(a: 30, b: "test2", o: OneOptional(a: 53)) + try initial.opDerivedException(a: 30, b: "test2") } catch let ex as DerivedException { try test(ex.a == 30) try test(ex.b == "test2") - try test(ex.o!.a == 53) try test(ex.ss == "test2") - try test(ex.o2!.a == 53) try test(ex.d1 == "d1") try test(ex.d2 == "d2") } do { - try initial.opRequiredException(a: nil, b: nil, o: nil) + try initial.opRequiredException(a: nil, b: nil) } catch let ex as RequiredException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) try test(ex.ss == "test") - try test(ex.o2 == nil) } do { @@ -3266,19 +3218,15 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { } catch let ex as RequiredException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) try test(ex.ss == "test") - try test(ex.o2 == nil) } do { - try initial.opRequiredException(o: nil) + try initial.opRequiredException() } catch let ex as RequiredException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) try test(ex.ss == "test") - try test(ex.o2 == nil) } do { @@ -3286,19 +3234,15 @@ func allTests(_ helper: TestHelper) throws -> InitialPrx { } catch let ex as RequiredException { try test(ex.a == nil) try test(ex.b == nil) - try test(ex.o == nil) try test(ex.ss == "test") - try test(ex.o2 == nil) } do { - try initial.opRequiredException(a: 30, b: "test2", o: OneOptional(a: 53)) + try initial.opRequiredException(a: 30, b: "test2") } catch let ex as RequiredException { try test(ex.a == 30) try test(ex.b == "test2") - try test(ex.o!.a == 53) try test(ex.ss == "test2") - try test(ex.o2!.a == 53) } output.writeLine("ok") diff --git a/swift/test/Ice/optional/Test.ice b/swift/test/Ice/optional/Test.ice index 1348e421a83..d8016c0c144 100644 --- a/swift/test/Ice/optional/Test.ice +++ b/swift/test/Ice/optional/Test.ice @@ -136,21 +136,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -193,13 +190,13 @@ interface Initial ["marshaled-result"] Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -228,10 +225,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -286,16 +283,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/swift/test/Ice/optional/TestAMD.ice b/swift/test/Ice/optional/TestAMD.ice index 57d31dee89a..73745e2edb8 100644 --- a/swift/test/Ice/optional/TestAMD.ice +++ b/swift/test/Ice/optional/TestAMD.ice @@ -134,21 +134,18 @@ exception OptionalException bool req = false; optional(1) int a = 5; optional(2) string b; - optional(50) OneOptional o; } exception DerivedException extends OptionalException { string d1; optional(600) string ss = "test"; - optional(601) OneOptional o2; string d2; } exception RequiredException extends OptionalException { string ss = "test"; - OneOptional o2; } class OptionalWithCustom @@ -192,13 +189,13 @@ interface Initial Object pingPong(Object o); - void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opOptionalException(optional(1) int a, optional(2) string b) throws OptionalException; - void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opDerivedException(optional(1) int a, optional(2) string b) throws OptionalException; - void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + void opRequiredException(optional(1) int a, optional(2) string b) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); @@ -225,10 +222,10 @@ interface Initial optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); - optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); - optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3); + OneOptional opOneOptional(OneOptional p1, out OneOptional p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); @@ -282,16 +279,11 @@ interface Initial ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1, out optional(3) StringIntDict p2); - ["marshaled-result"] optional(1) G opMG1(); - ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2); - bool supportsRequiredParams(); bool supportsJavaSerializable(); bool supportsCsharpSerializable(); - - bool supportsNullOptional(); } } diff --git a/swift/test/Ice/optional/TestAMDI.swift b/swift/test/Ice/optional/TestAMDI.swift index 7e31b87ae72..5e2e2ae9194 100644 --- a/swift/test/Ice/optional/TestAMDI.swift +++ b/swift/test/Ice/optional/TestAMDI.swift @@ -19,34 +19,32 @@ class InitialI: Initial { return Promise.value(o) } - func opOptionalExceptionAsync(a: Int32?, b: String?, o: OneOptional?, current _: Current) + func opOptionalExceptionAsync(a: Int32?, b: String?, current _: Current) -> Promise { return Promise { seal in - seal.reject(OptionalException(req: false, a: a, b: b, o: o)) + seal.reject(OptionalException(req: false, a: a, b: b)) } } - func opDerivedExceptionAsync(a: Int32?, b: String?, o: OneOptional?, current _: Current) + func opDerivedExceptionAsync(a: Int32?, b: String?, current _: Current) -> Promise { return Promise { seal in - seal.reject(DerivedException(req: false, a: a, b: b, o: o, d1: "d1", ss: b, o2: o, d2: "d2")) + seal.reject(DerivedException(req: false, a: a, b: b, d1: "d1", ss: b, d2: "d2")) } } - func opRequiredExceptionAsync(a: Int32?, b: String?, o: OneOptional?, current _: Current) + func opRequiredExceptionAsync(a: Int32?, b: String?, current _: Current) -> Promise { return Promise { seal in let e = RequiredException() e.a = a e.b = b - e.o = o if let b = b { e.ss = b } - e.o2 = o seal.reject(e) } @@ -292,14 +290,6 @@ class InitialI: Initial { return Promise.value((p1, p1)) } - func opMG1Async(current _: Current) -> Promise { - return Promise.value(G()) - } - - func opMG2Async(p1: G?, current _: Current) -> Promise<(returnValue: G?, p2: G?)> { - return Promise.value((p1, p1)) - } - func supportsRequiredParamsAsync(current _: Current) -> Promise { return Promise.value(false) } @@ -311,8 +301,4 @@ class InitialI: Initial { func supportsCsharpSerializableAsync(current _: Current) -> Promise { return Promise.value(false) } - - func supportsNullOptionalAsync(current _: Current) -> Promise { - return Promise.value(false) - } } diff --git a/swift/test/Ice/optional/TestI.swift b/swift/test/Ice/optional/TestI.swift index d6370629154..5a8efdce795 100644 --- a/swift/test/Ice/optional/TestI.swift +++ b/swift/test/Ice/optional/TestI.swift @@ -18,35 +18,30 @@ class InitialI: Initial { func opOptionalException( a: Int32?, b: String?, - o: OneOptional?, current _: Ice.Current ) throws { - throw OptionalException(req: false, a: a, b: b, o: o) + throw OptionalException(req: false, a: a, b: b) } func opDerivedException( a: Int32?, b: String?, - o: OneOptional?, current _: Ice.Current ) throws { - throw DerivedException(req: false, a: a, b: b, o: o, d1: "d1", ss: b, o2: o, d2: "d2") + throw DerivedException(req: false, a: a, b: b, d1: "d1", ss: b, d2: "d2") } func opRequiredException( a: Int32?, b: String?, - o: OneOptional?, current _: Ice.Current ) throws { let e = RequiredException() e.a = a e.b = b - e.o = o if let b = b { e.ss = b } - e.o2 = o throw e } @@ -268,10 +263,6 @@ class InitialI: Initial { return false } - func supportsNullOptional(current _: Ice.Current) throws -> Bool { - return false - } - func opMStruct1(current _: Current) throws -> SmallStruct? { return SmallStruct() } @@ -301,12 +292,4 @@ class InitialI: Initial { ) { return (p1, p1) } - - func opMG1(current _: Current) throws -> G? { - return G() - } - - func opMG2(p1: G?, current _: Current) throws -> (returnValue: G?, p2: G?) { - return (p1, p1) - } }