diff options
author | Jose <jose@zeroc.com> | 2018-09-20 14:14:45 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-09-20 14:14:45 +0200 |
commit | 260b8bf8523164f68bdf97d469616cbf01c71cc0 (patch) | |
tree | 102ff9d0f45ae66a0c38dc02aa03cbf054c65358 | |
parent | Merge branch '3.7.1-xcode10' into 3.7 (diff) | |
download | ice-260b8bf8523164f68bdf97d469616cbf01c71cc0.tar.bz2 ice-260b8bf8523164f68bdf97d469616cbf01c71cc0.tar.xz ice-260b8bf8523164f68bdf97d469616cbf01c71cc0.zip |
Test using Value as operation parameter
Fix a bug in slice2java that generate bogus code or using
Value as an Slice operation parameter
Fix a bug in JavaScript mapping that cause a run-time error
when invoking an operation that defines Value as an input
parameter
27 files changed, 473 insertions, 24 deletions
diff --git a/cpp/src/slice2java/GenCompat.cpp b/cpp/src/slice2java/GenCompat.cpp index c4e8c15ee1c..2e50562471f 100644 --- a/cpp/src/slice2java/GenCompat.cpp +++ b/cpp/src/slice2java/GenCompat.cpp @@ -669,7 +669,8 @@ Slice::JavaCompatVisitor::getArgsAsyncCB(const OperationPtr& op) if(ret) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) + if((builtin && (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue)) || + ClassDeclPtr::dynamicCast(ret)) { args.push_back("ret.value"); } @@ -685,7 +686,8 @@ Slice::JavaCompatVisitor::getArgsAsyncCB(const OperationPtr& op) if((*q)->isOutParam()) { BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type())) + if((builtin && (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue)) || + ClassDeclPtr::dynamicCast((*q)->type())) { args.push_back(fixKwd((*q)->name()) + ".value"); } @@ -745,7 +747,8 @@ Slice::JavaCompatVisitor::writeMarshalUnmarshalParams(Output& out, const string& ret = op->returnType(); BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); ClassDeclPtr cl = ClassDeclPtr::dynamicCast(ret); - returnsObject = (builtin && builtin->kind() == Builtin::KindObject) || cl; + returnsObject = (builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || cl; const bool optional = optionalMapping && op->returnIsOptional(); string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, optional); @@ -889,7 +892,8 @@ Slice::JavaCompatVisitor::writeUnmarshalDataMember(Output& out, const string& pa if(needPatcher) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type())) + if((builtin && (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue)) || + ClassDeclPtr::dynamicCast(member->type())) { ostringstream ostr; ostr << "new Patcher(" << patchIter++ << ')'; @@ -1000,14 +1004,15 @@ Slice::JavaCompatVisitor::writePatcher(Output& out, const string& package, const for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) { BuiltinPtr b = BuiltinPtr::dynamicCast((*d)->type()); - if(b && b->kind() != Builtin::KindObject) + if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindValue) { continue; } TypePtr paramType = (*d)->type(); BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + if((builtin && (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue)) || + ClassDeclPtr::dynamicCast(paramType)) { if(classMembers.size() > 1) @@ -1333,7 +1338,8 @@ Slice::JavaCompatVisitor::writeDispatchAndMarshalling(Output& out, const ClassDe else { BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + if((builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || ClassDeclPtr::dynamicCast(paramType)) { out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; } @@ -1392,7 +1398,8 @@ Slice::JavaCompatVisitor::writeDispatchAndMarshalling(Output& out, const ClassDe if(!(*pli)->optional()) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + if((builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || ClassDeclPtr::dynamicCast(paramType)) { out << ".value"; } @@ -1462,7 +1469,8 @@ Slice::JavaCompatVisitor::writeDispatchAndMarshalling(Output& out, const ClassDe else { BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + if((builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || ClassDeclPtr::dynamicCast(paramType)) { out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; } @@ -1506,7 +1514,8 @@ Slice::JavaCompatVisitor::writeDispatchAndMarshalling(Output& out, const ClassDe if(!(*pli)->optional()) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + if((builtin && (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue)) || + ClassDeclPtr::dynamicCast(paramType)) { out << ".value"; } @@ -4447,7 +4456,8 @@ Slice::GenCompat::HolderVisitor::writeHolder(const TypePtr& p) string typeS = typeToString(p, TypeModeIn, getPackage(contained)); out << nl << "public final class " << name << "Holder"; - if(!p->isLocal() && ((builtin && builtin->kind() == Builtin::KindObject) || cl)) + if(!p->isLocal() && ((builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || cl)) { out << " extends " << getUnqualified("Ice.ObjectHolderBase", package) << "<" << typeS << ">"; } @@ -4455,7 +4465,8 @@ Slice::GenCompat::HolderVisitor::writeHolder(const TypePtr& p) out << " extends " << getUnqualified("Ice.Holder", package) << "<" << typeS << ">"; } out << sb; - if(!p->isLocal() && ((builtin && builtin->kind() == Builtin::KindObject) || cl)) + if(!p->isLocal() && ((builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || cl)) { out << sp << nl << "public" << nl << name << "Holder()"; out << sb; @@ -4668,7 +4679,8 @@ Slice::GenCompat::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); if(!op->returnIsOptional() && - ((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))) + ((builtin && (builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindValue)) || ClassDeclPtr::dynamicCast(ret))) { out << nl << "return ret_.value;"; } diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp index 659ce152cff..a7ef9968ca8 100644 --- a/cpp/test/Ice/objects/AllTests.cpp +++ b/cpp/test/Ice/objects/AllTests.cpp @@ -347,6 +347,36 @@ allTests(Test::TestHelper* helper) test(l->data == "l"); cout << "ok" << endl; + cout << "testing Value as parameter..." << flush; + { + LPtr v1 = ICE_MAKE_SHARED(L, "l"); + Ice::ValuePtr v2; + Ice::ValuePtr v3 = initial->opValue(v1, v2); + test(ICE_DYNAMIC_CAST(L, v2)->data == "l"); + test(ICE_DYNAMIC_CAST(L, v3)->data == "l"); + } + + { + LPtr l = ICE_MAKE_SHARED(L, "l"); + Test::ValueSeq v1; + v1.push_back(l); + Test::ValueSeq v2; + Test::ValueSeq v3 = initial->opValueSeq(v1, v2); + test(ICE_DYNAMIC_CAST(L, v2[0])->data == "l"); + test(ICE_DYNAMIC_CAST(L, v3[0])->data == "l"); + } + + { + LPtr l = ICE_MAKE_SHARED(L, "l"); + Test::ValueMap v1; + v1["l"] = l; + Test::ValueMap v2; + Test::ValueMap v3 = initial->opValueMap(v1, v2); + test(ICE_DYNAMIC_CAST(L, v2["l"])->data == "l"); + test(ICE_DYNAMIC_CAST(L, v3["l"])->data == "l"); + } + cout << "ok" << endl; + cout << "getting D1... " << flush; D1Ptr d1 = ICE_MAKE_SHARED(D1, ICE_MAKE_SHARED(A1, "a1"), diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice index 54352db915c..e3d8b9cca1e 100644 --- a/cpp/test/Ice/objects/Test.ice +++ b/cpp/test/Ice/objects/Test.ice @@ -187,6 +187,9 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + interface Initial { void shutdown(); @@ -210,6 +213,10 @@ interface Initial I getJ(); K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp index 328238a0fe7..d4d99f7b330 100644 --- a/cpp/test/Ice/objects/TestI.cpp +++ b/cpp/test/Ice/objects/TestI.cpp @@ -335,6 +335,27 @@ InitialI::getK(const Ice::Current&) return ICE_MAKE_SHARED(K, ICE_MAKE_SHARED(L, "l")); } +Ice::ValuePtr +InitialI::opValue(ICE_IN(Ice::ValuePtr) v1, Ice::ValuePtr& v2, const Ice::Current&) +{ + v2 = v1; + return v1; +} + +Test::ValueSeq +InitialI::opValueSeq(ICE_IN(Test::ValueSeq) v1, Test::ValueSeq& v2, const Ice::Current&) +{ + v2 = v1; + return v1; +} + +Test::ValueMap +InitialI::opValueMap(ICE_IN(Test::ValueMap) v1, Test::ValueMap& v2, const Ice::Current&) +{ + v2 = v1; + return v1; +} + D1Ptr InitialI::getD1(ICE_IN(Test::D1Ptr) d1, const Ice::Current&) { diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h index 8002d37bf12..64397b0f1c4 100644 --- a/cpp/test/Ice/objects/TestI.h +++ b/cpp/test/Ice/objects/TestI.h @@ -121,6 +121,10 @@ public: virtual Test::KPtr getK(const Ice::Current&); + virtual Ice::ValuePtr opValue(ICE_IN(Ice::ValuePtr), Ice::ValuePtr&, const Ice::Current&); + virtual Test::ValueSeq opValueSeq(ICE_IN(Test::ValueSeq), Test::ValueSeq&, const Ice::Current&); + virtual Test::ValueMap opValueMap(ICE_IN(Test::ValueMap), Test::ValueMap&, const Ice::Current&); + virtual Test::D1Ptr getD1(ICE_IN(Test::D1Ptr), const Ice::Current&); virtual void throwEDerived(const Ice::Current&); diff --git a/csharp/test/Ice/objects/AllTests.cs b/csharp/test/Ice/objects/AllTests.cs index b2bbf875e0c..671302c8f43 100644 --- a/csharp/test/Ice/objects/AllTests.cs +++ b/csharp/test/Ice/objects/AllTests.cs @@ -9,6 +9,7 @@ using System; using System.Diagnostics; +using System.Collections.Generic; namespace Ice { @@ -277,11 +278,40 @@ namespace Ice output.WriteLine("ok"); output.Write("getting K... "); + { + output.Flush(); + var k = initial.getK(); + var l = k.value as L; + test(l != null); + test(l.data.Equals("l")); + } + output.WriteLine("ok"); + + output.Write("testing Value as parameter... "); output.Flush(); - var k = initial.getK(); - var l = k.value as L; - test(l != null); - test(l.data.Equals("l")); + { + Ice.Value v1 = new L("l"); + Ice.Value v2; + Ice.Value v3 = initial.opValue(v1, out v2); + test(((L)v2).data.Equals("l")); + test(((L)v3).data.Equals("l")); + } + { + L l = new L("l"); + Ice.Value[] v1 = new Ice.Value[]{ l }; + Ice.Value[] v2; + Ice.Value[] v3 = initial.opValueSeq(v1, out v2); + test(((L)v2[0]).data.Equals("l")); + test(((L)v3[0]).data.Equals("l")); + } + { + L l = new L("l"); + Dictionary<string, Ice.Value> v1 = new Dictionary<string, Ice.Value>{ {"l", l} }; + Dictionary<string, Ice.Value> v2; + Dictionary<string, Ice.Value> v3 = initial.opValueMap(v1, out v2); + test(((L)v2["l"]).data.Equals("l")); + test(((L)v3["l"]).data.Equals("l")); + } output.WriteLine("ok"); output.Write("getting D1... "); diff --git a/csharp/test/Ice/objects/InitialI.cs b/csharp/test/Ice/objects/InitialI.cs index 309f8f81352..c96d399d943 100644 --- a/csharp/test/Ice/objects/InitialI.cs +++ b/csharp/test/Ice/objects/InitialI.cs @@ -8,6 +8,7 @@ // ********************************************************************** using System.Threading.Tasks; +using System.Collections.Generic; namespace Ice { @@ -98,6 +99,26 @@ namespace Ice return new Test.K(new Test.L("l")); } + public override Ice.Value opValue(Ice.Value v1, out Ice.Value v2, Ice.Current current) + { + v2 = v1; + return v1; + } + + public override Ice.Value[] opValueSeq(Ice.Value[] v1, out Ice.Value[] v2, Ice.Current current) + { + v2 = v1; + return v1; + } + + public override Dictionary<string, Ice.Value> + opValueMap(Dictionary<string, Ice.Value> v1, out Dictionary<string, Ice.Value> v2, + Ice.Current current) + { + v2 = v1; + return v1; + } + public override void setRecursive(Test.Recursive r, Ice.Current current) { } diff --git a/csharp/test/Ice/objects/Test.ice b/csharp/test/Ice/objects/Test.ice index 194212b422b..3f505e409c8 100644 --- a/csharp/test/Ice/objects/Test.ice +++ b/csharp/test/Ice/objects/Test.ice @@ -182,6 +182,9 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + interface Initial { void shutdown(); @@ -206,6 +209,10 @@ interface Initial K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/java-compat/test/src/main/java/test/Ice/objects/AllTests.java b/java-compat/test/src/main/java/test/Ice/objects/AllTests.java index 56fa72cfd43..fc2bbf83a21 100644 --- a/java-compat/test/src/main/java/test/Ice/objects/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/objects/AllTests.java @@ -22,6 +22,10 @@ import test.Ice.objects.Test.F; import test.Ice.objects.Test.G; import test.Ice.objects.Test.H; import test.Ice.objects.Test.I; +import test.Ice.objects.Test.K; +import test.Ice.objects.Test.L; +import test.Ice.objects.Test.ValueSeqHolder; +import test.Ice.objects.Test.ValueMapHolder; import test.Ice.objects.Test.A1; import test.Ice.objects.Test.B1; import test.Ice.objects.Test.D1; @@ -202,6 +206,42 @@ public class AllTests test(h != null && ((H)h) != null); out.println("ok"); + out.print("getting K... "); + out.flush(); + { + K k = initial.getK(); + test(k.value instanceof L); + L l = (L)k.value; + test(l.data.equals("l")); + } + out.println("ok"); + + out.print("testing Value as parameter... "); + out.flush(); + { + L v1 = new L("l"); + Ice.ObjectHolder v2 = new Ice.ObjectHolder(); + Ice.Object v3 = initial.opValue(v1, v2); + test(((L)v2.value).data.equals("l")); + test(((L)v3).data.equals("l")); + } + { + L[] v1 = { new L("l") }; + ValueSeqHolder v2 = new ValueSeqHolder(); + Ice.Object[] v3 = initial.opValueSeq(v1, v2); + test(((L)v2.value[0]).data.equals("l")); + test(((L)v3[0]).data.equals("l")); + } + { + java.util.Map<String, Ice.Object> v1 = new java.util.HashMap<String, Ice.Object>(); + v1.put("l", new L("l")); + ValueMapHolder v2 = new ValueMapHolder(); + java.util.Map<String, Ice.Object> v3 = initial.opValueMap(v1, v2); + test(((L)v2.value.get("l")).data.equals("l")); + test(((L)v3.get("l")).data.equals("l")); + } + out.println("ok"); + out.print("getting D1... "); out.flush(); D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4")); diff --git a/java-compat/test/src/main/java/test/Ice/objects/InitialI.java b/java-compat/test/src/main/java/test/Ice/objects/InitialI.java index 88ca1055e02..c1c01e93659 100644 --- a/java-compat/test/src/main/java/test/Ice/objects/InitialI.java +++ b/java-compat/test/src/main/java/test/Ice/objects/InitialI.java @@ -22,6 +22,8 @@ import test.Ice.objects.Test.G; import test.Ice.objects.Test.I; import test.Ice.objects.Test.K; import test.Ice.objects.Test.L; +import test.Ice.objects.Test.ValueSeqHolder; +import test.Ice.objects.Test.ValueMapHolder; import test.Ice.objects.Test.A1; import test.Ice.objects.Test.D1; import test.Ice.objects.Test.EDerived; @@ -184,6 +186,30 @@ public final class InitialI extends Initial } @Override + public Ice.Object + opValue(Ice.Object v1, Ice.ObjectHolder v2, Ice.Current current) + { + v2.value = v1; + return v1; + } + + @Override + public Ice.Object[] + opValueSeq(Ice.Object[] v1, ValueSeqHolder v2, Ice.Current current) + { + v2.value = v1; + return v1; + } + + @Override + public java.util.Map<String, Ice.Object> + opValueMap(java.util.Map<String, Ice.Object> v1, ValueMapHolder v2, Ice.Current current) + { + v2.value = v1; + return v1; + } + + @Override public D1 getD1(D1 d1, Ice.Current current) { diff --git a/java-compat/test/src/main/java/test/Ice/objects/Test.ice b/java-compat/test/src/main/java/test/Ice/objects/Test.ice index 9d43497af31..9de9aedae73 100644 --- a/java-compat/test/src/main/java/test/Ice/objects/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/objects/Test.ice @@ -183,6 +183,9 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + class Initial { void shutdown(); @@ -207,6 +210,10 @@ class Initial K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/java/test/src/main/java/test/Ice/objects/AllTests.java b/java/test/src/main/java/test/Ice/objects/AllTests.java index 0f7d343209f..4d922616144 100644 --- a/java/test/src/main/java/test/Ice/objects/AllTests.java +++ b/java/test/src/main/java/test/Ice/objects/AllTests.java @@ -22,6 +22,10 @@ import test.Ice.objects.Test.H; import test.Ice.objects.Test.I; import test.Ice.objects.Test.K; import test.Ice.objects.Test.L; +import test.Ice.objects.Test.Initial.OpValueResult; +import test.Ice.objects.Test.Initial.OpValueSeqResult; +import test.Ice.objects.Test.Initial.OpValueMapResult; +import test.Ice.objects.Test.L; import test.Ice.objects.Test.A1; import test.Ice.objects.Test.B1; import test.Ice.objects.Test.D1; @@ -199,10 +203,36 @@ public class AllTests out.print("getting K... "); out.flush(); - K k = initial.getK(); - test(k.value instanceof L); - L l = (L)k.value; - test(l.data.equals("l")); + { + K k = initial.getK(); + test(k.value instanceof L); + L l = (L)k.value; + test(l.data.equals("l")); + } + out.println("ok"); + + out.print("testing Value as parameter... "); + { + com.zeroc.Ice.Value v1 = new L("l"); + OpValueResult result = initial.opValue(v1); + test(((L)result.returnValue).data.equals("l")); + test(((L)result.v2).data.equals("l")); + } + { + L l = new L("l"); + com.zeroc.Ice.Value[] v1 = { l }; + OpValueSeqResult result = initial.opValueSeq(v1); + test(((L)result.returnValue[0]).data.equals("l")); + test(((L)result.v2[0]).data.equals("l")); + } + { + L l = new L("l"); + java.util.Map<String, com.zeroc.Ice.Value> v1 = new java.util.HashMap<String, com.zeroc.Ice.Value>(); + v1.put("l", l); + OpValueMapResult result = initial.opValueMap(v1); + test(((L)result.returnValue.get("l")).data.equals("l")); + test(((L)result.v2.get("l")).data.equals("l")); + } out.println("ok"); out.print("getting D1... "); diff --git a/java/test/src/main/java/test/Ice/objects/InitialI.java b/java/test/src/main/java/test/Ice/objects/InitialI.java index 9ef2d5617d7..5d0ca370165 100644 --- a/java/test/src/main/java/test/Ice/objects/InitialI.java +++ b/java/test/src/main/java/test/Ice/objects/InitialI.java @@ -141,6 +141,27 @@ public final class InitialI implements Initial } @Override + public OpValueResult + opValue(com.zeroc.Ice.Value v1, com.zeroc.Ice.Current current) + { + return new OpValueResult(v1, v1); + } + + @Override + public OpValueSeqResult + opValueSeq(com.zeroc.Ice.Value[] v1, com.zeroc.Ice.Current current) + { + return new OpValueSeqResult(v1, v1); + } + + @Override + public OpValueMapResult + opValueMap(java.util.Map<String, com.zeroc.Ice.Value> v1, com.zeroc.Ice.Current current) + { + return new OpValueMapResult(v1, v1); + } + + @Override public D1 getD1(D1 d1, com.zeroc.Ice.Current current) { return d1; diff --git a/java/test/src/main/java/test/Ice/objects/Test.ice b/java/test/src/main/java/test/Ice/objects/Test.ice index 2655564b794..dbacc63b28f 100644 --- a/java/test/src/main/java/test/Ice/objects/Test.ice +++ b/java/test/src/main/java/test/Ice/objects/Test.ice @@ -183,6 +183,9 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + interface Initial { void shutdown(); @@ -207,6 +210,10 @@ interface Initial K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/js/src/Ice/Operation.js b/js/src/Ice/Operation.js index 5fd85b1404a..fbfda6c886b 100644 --- a/js/src/Ice/Operation.js +++ b/js/src/Ice/Operation.js @@ -31,7 +31,8 @@ const builtinHelpers = Ice.DoubleHelper, Ice.StringHelper, Ice.Value, - Ice.ObjectPrx + Ice.ObjectPrx, + Ice.Value ]; function parseParam(p) diff --git a/js/test/Ice/objects/Client.js b/js/test/Ice/objects/Client.js index 401f0e808a9..92b74812e17 100644 --- a/js/test/Ice/objects/Client.js +++ b/js/test/Ice/objects/Client.js @@ -273,6 +273,22 @@ test(k.value.data == "l"); out.writeLine("ok"); + out.write("test Value as parameter..."); + { + let [v1, v2] = await initial.opValue(new Test.L("l")); + test(v1.data == "l"); + test(v2.data == "l"); + + [v1, v2] = await initial.opValueSeq([new Test.L("l")]); + test(v1[0].data == "l"); + test(v2[0].data == "l"); + + [v1, v2] = await initial.opValueMap(new Map([["l", new Test.L("l")]])); + test(v1.get("l").data == "l"); + test(v2.get("l").data == "l"); + } + out.writeLine("ok"); + out.write("getting D1... "); const d1 = await initial.getD1(new Test.D1(new Test.A1("a1"), new Test.A1("a2"), diff --git a/js/test/Ice/objects/InitialI.js b/js/test/Ice/objects/InitialI.js index b0864a4280c..9885db162c1 100644 --- a/js/test/Ice/objects/InitialI.js +++ b/js/test/Ice/objects/InitialI.js @@ -259,6 +259,21 @@ return new Test.K(new Test.L("l")); } + opValue(v1, current) + { + return [v1, v1]; + } + + opValueSeq(v1, current) + { + return [v1, v1]; + } + + opValueMap(v1, current) + { + return [v1, v1]; + } + getD1(d1, current) { return d1; diff --git a/js/test/Ice/objects/Test.ice b/js/test/Ice/objects/Test.ice index aa4750b87bf..b7b6183b629 100644 --- a/js/test/Ice/objects/Test.ice +++ b/js/test/Ice/objects/Test.ice @@ -186,6 +186,9 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + interface Initial { void shutdown(); @@ -210,6 +213,10 @@ interface Initial K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/matlab/test/Ice/objects/AllTests.m b/matlab/test/Ice/objects/AllTests.m index 964c111a3ec..d2e5a7aa619 100644 --- a/matlab/test/Ice/objects/AllTests.m +++ b/matlab/test/Ice/objects/AllTests.m @@ -120,6 +120,20 @@ classdef AllTests assert(strcmp(k.value.data, 'l')); fprintf('ok\n'); + fprintf('testing Value as parameter... '); + [v2, v3] = initial.opValue(L('l')); + assert(strcmp(v2.data, 'l')); + assert(strcmp(v3.data, 'l')); + [v2, v3] = initial.opValueSeq({L('l')}); + assert(strcmp(v2{1}.data, 'l')); + assert(strcmp(v3{1}.data, 'l')); + d = containers.Map('KeyType', 'char', 'ValueType', 'any'); + d('l') = L('l'); + [v2, v3] = initial.opValueMap(d); + assert(strcmp(v2('l').data, 'l')); + assert(strcmp(v3('l').data, 'l')); + fprintf('ok\n'); + fprintf('getting D1... '); d1 = D1(A1('a1'), A1('a2'), A1('a3'), A1('a4')); d1 = initial.getD1(d1); diff --git a/matlab/test/Ice/objects/Test.ice b/matlab/test/Ice/objects/Test.ice index 1c363fc869e..2efe8719097 100644 --- a/matlab/test/Ice/objects/Test.ice +++ b/matlab/test/Ice/objects/Test.ice @@ -182,6 +182,9 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + interface Initial { void shutdown(); @@ -206,6 +209,10 @@ interface Initial K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/php/test/Ice/objects/Client.php b/php/test/Ice/objects/Client.php index 1f3fc51a491..4cfafa9c996 100644 --- a/php/test/Ice/objects/Client.php +++ b/php/test/Ice/objects/Client.php @@ -28,6 +28,7 @@ if($NS) class Ice_InterfaceByValue extends Ice\InterfaceByValue {} interface Ice_ObjectFactory extends Ice\ObjectFactory {} interface Ice_ValueFactory extends Ice\ValueFactory {} + class Test_L extends Test\L {} EOT; eval($code); } @@ -345,6 +346,37 @@ function allTests($helper) test($h != null and $h instanceof HI); echo "ok\n"; + echo "getting K... "; + flush(); + $k = $initial->getK(); + test($k->value->data == "l"); + echo "ok\n"; + + echo "testing Value as parameter... "; + flush(); + $v1 = new Test_L(); + $v1->data = "l"; + $v2 = null; + $v3 = $initial->opValue($v1, $v2); + test($v2->data == "l"); + test($v3->data == "l"); + + $v1 = array(new Test_L()); + $v1[0]->data = "l"; + $v2 = null; + $v3 = $initial->opValueSeq($v1, $v2); + test($v2[0]->data == "l"); + test($v3[0]->data == "l"); + + $v1 = array("l" => new Test_L()); + $v1["l"]->data = "l"; + $v2 = null; + $v3 = $initial->opValueMap($v1, $v2); + test($v2["l"]->data == "l"); + test($v3["l"]->data == "l"); + + echo "ok\n"; + echo "getting D1... "; flush(); $d1 = $initial->getD1(new Test_D1(new Test_A1("a1"), new Test_A1("a2"), new Test_A1("a3"), new Test_A1("a4"))); diff --git a/php/test/Ice/objects/Test.ice b/php/test/Ice/objects/Test.ice index cf2d3573fc6..a0896d24a0e 100644 --- a/php/test/Ice/objects/Test.ice +++ b/php/test/Ice/objects/Test.ice @@ -142,6 +142,19 @@ class Recursive Recursive v; } +class K +{ + Value value; +} + +class L +{ + string data; +} + +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + interface Initial { void shutdown(); @@ -160,9 +173,14 @@ interface Initial void getAll(out B b1, out B b2, out C theC, out D theD); + I getH(); I getI(); I getJ(); - I getH(); + K getK(); + + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/python/test/Ice/objects/AllTests.py b/python/test/Ice/objects/AllTests.py index 2ddefafb01b..5f59683ff33 100644 --- a/python/test/Ice/objects/AllTests.py +++ b/python/test/Ice/objects/AllTests.py @@ -118,6 +118,21 @@ def allTests(helper, communicator): test(k.value.data == "l") print("ok") + sys.stdout.write("testing Value as parameter... ") + sys.stdout.flush() + v1, v2 = initial.opValue(Test.L("l")) + test(v1.data == "l") + test(v2.data == "l") + + v1, v2 = initial.opValueSeq([Test.L("l")]) + test(v1[0].data == "l") + test(v2[0].data == "l") + + v1, v2 = initial.opValueMap({"l":Test.L("l")}) + test(v1["l"].data == "l") + test(v2["l"].data == "l") + print("ok") + sys.stdout.write("getting D1... ") sys.stdout.flush() d1 = initial.getD1(Test.D1(Test.A1("a1"), Test.A1("a2"), Test.A1("a3"), Test.A1("a4"))) diff --git a/python/test/Ice/objects/Test.ice b/python/test/Ice/objects/Test.ice index a6a3034400e..d6d3e1e381d 100644 --- a/python/test/Ice/objects/Test.ice +++ b/python/test/Ice/objects/Test.ice @@ -182,6 +182,10 @@ class L string data; } +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + + interface Initial { void shutdown(); @@ -206,6 +210,10 @@ interface Initial K getK(); + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); + D1 getD1(D1 d1); void throwEDerived() throws EDerived; diff --git a/python/test/Ice/objects/TestI.py b/python/test/Ice/objects/TestI.py index 6da50f05ef2..83cb67e51a8 100644 --- a/python/test/Ice/objects/TestI.py +++ b/python/test/Ice/objects/TestI.py @@ -156,6 +156,15 @@ class InitialI(Test.Initial): def getK(self, current=None): return Test.K(Test.L("l")) + def opValue(self, v1, current=None): + return v1, v1 + + def opValueSeq(self, v1, current=None): + return v1, v1 + + def opValueMap(self, v1, current=None): + return v1, v1 + def getD1(self, d1, current=None): return d1 diff --git a/ruby/test/Ice/objects/AllTests.rb b/ruby/test/Ice/objects/AllTests.rb index c5c0e7a63bf..a41df03cb91 100644 --- a/ruby/test/Ice/objects/AllTests.rb +++ b/ruby/test/Ice/objects/AllTests.rb @@ -219,6 +219,31 @@ def allTests(helper, communicator) test(i) puts "ok" + print "getting K... " + STDOUT.flush + k = initial.getK() + test(k.value.data == "l") + puts "ok" + + print "testing Value as parameter... " + STDOUT.flush + v1 = Test::L.new("l") + v2, v3 = initial.opValue(v1) + test(v2.data == "l") + test(v3.data == "l") + + v1 = [Test::L.new("l")] + v2, v3 = initial.opValueSeq(v1) + test(v2[0].data == "l") + test(v3[0].data == "l") + + v1 = {} + v1["l"] = Test::L.new("l") + v2, v3 = initial.opValueMap(v1) + test(v2["l"].data == "l") + test(v3["l"].data == "l") + puts "ok" + print "getting D1... " STDOUT.flush d1 = initial.getD1(Test::D1.new(Test::A1.new("a1"), Test::A1.new("a2"), Test::A1.new("a3"), Test::A1.new("a4"))) diff --git a/ruby/test/Ice/objects/Test.ice b/ruby/test/Ice/objects/Test.ice index bf3d70ca9be..2f31f0f930d 100644 --- a/ruby/test/Ice/objects/Test.ice +++ b/ruby/test/Ice/objects/Test.ice @@ -142,6 +142,19 @@ class Recursive Recursive v; } +class K +{ + Value value; +} + +class L +{ + string data; +} + +sequence<Value> ValueSeq; +dictionary<string, Value> ValueMap; + class Initial { void shutdown(); @@ -160,9 +173,15 @@ class Initial void getAll(out B b1, out B b2, out C theC, out D theD); + I getH(); I getI(); I getJ(); - I getH(); + + K getK(); + + Value opValue(Value v1, out Value v2); + ValueSeq opValueSeq(ValueSeq v1, out ValueSeq v2); + ValueMap opValueMap(ValueMap v1, out ValueMap v2); D1 getD1(D1 d1); void throwEDerived() throws EDerived; |