diff options
author | Jose <jose@zeroc.com> | 2019-07-30 12:45:29 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-07-31 13:13:40 +0200 |
commit | 3e71d9e1a29bc8169452b039bb723406ff8ef0fe (patch) | |
tree | cfde39529b1a21d6f4c4e87b2a92a366eafc9993 | |
parent | Update .npmignore to ignore .tgz files (diff) | |
download | ice-3e71d9e1a29bc8169452b039bb723406ff8ef0fe.tar.bz2 ice-3e71d9e1a29bc8169452b039bb723406ff8ef0fe.tar.xz ice-3e71d9e1a29bc8169452b039bb723406ff8ef0fe.zip |
Fixes for C++ & Swift generated code - Close #458
34 files changed, 834 insertions, 42 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 0ea48a5a2d1..de253779684 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -1619,8 +1619,12 @@ Slice::writeStreamHelpers(Output& out, } void -Slice::writeIceTuple(::IceUtilInternal::Output& out, const string& scope, DataMemberList dataMembers, int typeCtx) +Slice::writeIceTuple(::IceUtilInternal::Output& out, DataMemberList dataMembers, int typeCtx) { + // + // Use an empty scope to get full qualified names from calls to typeToString. + // + const string scope = ""; out << nl << "std::tuple<"; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { diff --git a/cpp/src/Slice/CPlusPlusUtil.h b/cpp/src/Slice/CPlusPlusUtil.h index b8fa3ad9e46..0380971c617 100644 --- a/cpp/src/Slice/CPlusPlusUtil.h +++ b/cpp/src/Slice/CPlusPlusUtil.h @@ -59,7 +59,7 @@ void writeEndCode(::IceUtilInternal::Output&, const ParamDeclList&, const Operat void writeMarshalUnmarshalDataMemberInHolder(IceUtilInternal::Output&, const std::string&, const DataMemberPtr&, bool); void writeMarshalUnmarshalAllInHolder(IceUtilInternal::Output&, const std::string&, const DataMemberList&, bool, bool); void writeStreamHelpers(::IceUtilInternal::Output&, const ContainedPtr&, DataMemberList, bool, bool, bool); -void writeIceTuple(::IceUtilInternal::Output&, const std::string&, DataMemberList, int); +void writeIceTuple(::IceUtilInternal::Output&, DataMemberList, int); bool findMetaData(const std::string&, const ClassDeclPtr&, std::string&); bool findMetaData(const std::string&, const StringList&, std::string&); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index eab9a81b8cb..bab73d8a16e 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1880,20 +1880,11 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) ContainerPtr container = p->container(); string name = fixKwd(p->name()); - string scope = ""; - StructPtr st = StructPtr::dynamicCast(container); - if(st) - { - scope = fixKwd(st->scope()); - } - - ExceptionPtr ex = ExceptionPtr::dynamicCast(container); - if(ex) - { - scope = fixKwd(ex->scope()); - } - writeDocSummary(H, p); + // + // Use an empty scope to get full qualified names from calls to typeToString. + // + const string scope = ""; H << nl << typeToString(p->type(), p->optional(), scope, p->getMetaData(), _useWstring) << ' ' << name << ';'; } @@ -3910,7 +3901,11 @@ Slice::Gen::ObjectVisitor::emitDataMember(const DataMemberPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(container); int typeContext = cl->isLocal() ? TypeContextLocal | _useWstring : _useWstring; writeDocSummary(H, p); - H << nl << typeToString(p->type(), p->optional(), fixKwd(cl->scope()), p->getMetaData(), typeContext) << ' ' + // + // Use an empty scope to get full qualified names from calls to typeToString. + // + const string scope = ""; + H << nl << typeToString(p->type(), p->optional(), scope, p->getMetaData(), typeContext) << ' ' << name << ';'; } @@ -4101,7 +4096,10 @@ void Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p) { DataMemberList allDataMembers = p->allDataMembers(); - string scope = fixKwd(p->scope()); + // + // Use an empty scope to get full qualified names from calls to typeToString. + // + const string scope = ""; if(!allDataMembers.empty()) { @@ -6447,7 +6445,7 @@ Slice::Gen::Cpp11TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << " * Obtains a tuple containing all of the exception's data members."; H << nl << " * @return The data members in a tuple."; H << nl << " */"; - writeIceTuple(H, scope, p->allDataMembers(), _useWstring); + writeIceTuple(H, p->allDataMembers(), _useWstring); H << sp; H << nl << "/**"; @@ -6607,7 +6605,7 @@ Slice::Gen::Cpp11TypesVisitor::visitStructEnd(const StructPtr& p) H << nl << " * Obtains a tuple containing all of the struct's data members."; H << nl << " * @return The data members in a tuple."; H << nl << " */"; - writeIceTuple(H, fixKwd(p->scope()), p->dataMembers(), _useWstring); + writeIceTuple(H, p->dataMembers(), _useWstring); H << eb << ';'; _useWstring = resetUseWstring(_useWstringHist); } @@ -6615,7 +6613,10 @@ Slice::Gen::Cpp11TypesVisitor::visitStructEnd(const StructPtr& p) void Slice::Gen::Cpp11TypesVisitor::visitDataMember(const DataMemberPtr& p) { - string scope = fixKwd(ContainedPtr::dynamicCast(p->container())->scope()); + // + // Use an empty scope to get full qualified names from calls to typeToString. + // + const string scope = ""; string name = fixKwd(p->name()); writeDocSummary(H, p); H << nl << typeToString(p->type(), p->optional(), scope, p->getMetaData(), _useWstring | TypeContextCpp11) @@ -6877,7 +6878,10 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) if(ret) { - futureOutParams.push_back(typeToString(ret, retIsOpt, clScope, p->getMetaData(), _useWstring | + // + // Use empty scope to get full qualified names in types used with future declarations. + // + futureOutParams.push_back(typeToString(ret, retIsOpt, "", p->getMetaData(), _useWstring | TypeContextCpp11)); lambdaOutParams.push_back(typeToString(ret, retIsOpt, clScope, p->getMetaData(), _useWstring | @@ -6893,7 +6897,10 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) if((*q)->isOutParam()) { - futureOutParams.push_back(typeToString((*q)->type(), (*q)->optional(), clScope, metaData, + // + // Use empty scope to get full qualified names in types used with future declarations. + // + futureOutParams.push_back(typeToString((*q)->type(), (*q)->optional(), "", metaData, _useWstring | TypeContextCpp11)); lambdaOutParams.push_back(typeToString((*q)->type(), (*q)->optional(), clScope, metaData, _useWstring | TypeContextInParam | TypeContextCpp11)); @@ -6980,7 +6987,7 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) H << "auto _result = "; } - H << "_makePromiseOutgoing<" << getUnqualified(futureT, cl->scoped()) << ">"; + H << "_makePromiseOutgoing<" << futureT << ">"; H << spar << "true, this" << "&" + cl->name() + "Prx::_iceI_" + name; for(ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q) @@ -7391,7 +7398,10 @@ Slice::Gen::Cpp11ObjectVisitor::emitDataMember(const DataMemberPtr& p) int typeContext = _useWstring | TypeContextCpp11; ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string scope = fixKwd(cl->scope()); + // + // Use empty scope to get full qualified names in types used with future declarations. + // + string scope = ""; if(cl->isLocal()) { typeContext |= TypeContextLocal; @@ -8512,7 +8522,7 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << " * Obtains a tuple containing all of the value's data members."; H << nl << " * @return The data members in a tuple."; H << nl << " */"; - writeIceTuple(H, fixKwd(p->scope()), p->allDataMembers(), _useWstring); + writeIceTuple(H, p->allDataMembers(), _useWstring); H << sp; H << nl << "/**"; @@ -8751,7 +8761,10 @@ void Slice::Gen::Cpp11ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p) { DataMemberList allDataMembers = p->allDataMembers(); - string scope = fixKwd(p->scope()); + // + // Use empty scope to get full qualified names in types used with future declarations. + // + string scope = ""; if(!allDataMembers.empty()) { vector<string> allParamDecls; diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp index 626b43847bc..c2d554a836b 100644 --- a/cpp/src/slice2swift/SwiftUtil.cpp +++ b/cpp/src/slice2swift/SwiftUtil.cpp @@ -1579,10 +1579,27 @@ SwiftGenerator::writeMembers(IceUtilInternal::Output& out, { DataMemberPtr member = *q; TypePtr type = member->type(); - string defaultValue = member->defaultValue(); + const string defaultValue = member->defaultValue(); + + const string memberName = fixIdent(member->name()); + string memberType = typeToString(type, p, member->getMetaData(), member->optional(), typeCtx); + + // + // If the member type is equal to the member name, create a local type alias + // to avoid ambiguity. + // + string alias; + if(!protocol && memberName == memberType && (StructPtr::dynamicCast(type) || + SequencePtr::dynamicCast(type) || + DictionaryPtr::dynamicCast(type))) + { + ModulePtr m = getTopLevelModule(type); + alias = m->name() + "_" + memberType; + out << nl << "typealias " << alias << " = " << memberType; + } + writeMemberDoc(out, member); - out << nl << access << "var " << fixIdent(member->name()) << ": " - << typeToString(type, p, member->getMetaData(), member->optional(), typeCtx); + out << nl << access << "var " << memberName << ": " << memberType; if(protocol) { out << " { get set }"; @@ -1590,8 +1607,15 @@ SwiftGenerator::writeMembers(IceUtilInternal::Output& out, else { out << " = "; - writeConstantValue(out, type, member->defaultValueType(), defaultValue, p->getMetaData(), swiftModule, - member->optional()); + if(alias.empty()) + { + writeConstantValue(out, type, member->defaultValueType(), defaultValue, p->getMetaData(), swiftModule, + member->optional()); + } + else + { + out << alias << "()"; + } } } } @@ -1728,7 +1752,26 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out, { args += ", value: "; } - args += getUnqualified(getAbsolute(type), swiftModule) + ".self"; + string memberType = getUnqualified(getAbsolute(type), swiftModule); + string memberName; + const string memberPrefix = "self."; + if(param.find(memberPrefix) == 0) + { + memberName = param.substr(memberPrefix.size()); + } + + string alias; + // + // If the member type is equal to the member name, create a local type alias + // to avoid ambiguity. + // + if(memberType == memberName) + { + ModulePtr m = getTopLevelModule(type); + alias = m->name() + "_" + memberType; + out << nl << "typealias " << alias << " = " << memberType; + } + args += (alias.empty() ? memberType : alias) + ".self"; out << nl << "try " << stream << ".read(" << args << ") { " << param << " = $0 " << "}"; } } diff --git a/cpp/test/Ice/scope/AllTests.cpp b/cpp/test/Ice/scope/AllTests.cpp index eed8c7e343b..d14ffaa1453 100644 --- a/cpp/test/Ice/scope/AllTests.cpp +++ b/cpp/test/Ice/scope/AllTests.cpp @@ -58,6 +58,24 @@ public: called(); } + void opE1(Test::E1 e) + { + test(e == Test::ICE_ENUM(E1, v1)); + called(); + } + + void opS1(const Test::S1& s) + { + test(s.s == "S1"); + called(); + } + + void opC1(const Test::C1Ptr& c) + { + test(c->s == "C1"); + called(); + } + void error(const Ice::Exception&) { test(false); @@ -385,6 +403,17 @@ allTests(Test::TestHelper* helper) Test::CMap cmap3 = i->opCMap(cmap1, cmap2); test(cmap2["a"]->s == c1->s); test(cmap3["a"]->s == c1->s); + + Test::E1 e = i->opE1(Test::ICE_ENUM(E1, v1)); + test(e == Test::ICE_ENUM(E1, v1)); + + Test::S1 s; + s.s = "S1"; + s = i->opS1(s); + test(s.s == "S1"); + + Test::C1Ptr c = i->opC1(ICE_MAKE_SHARED(Test::C1, "C1")); + test(c->s == "C1"); } #ifdef ICE_CPP11_MAPPING @@ -441,6 +470,23 @@ allTests(Test::TestHelper* helper) test(Ice::targetEqualTo(result.returnValue["a"], c1)); test(Ice::targetEqualTo(result.c2["a"], c1)); } + + { + auto result = i->opE1Async(Test::E1::v1).get(); + test(result == Test::E1::v1); + } + + { + Test::S1 s; + s.s = "S1"; + s = i->opS1Async(s).get(); + test(s.s == "S1"); + } + + { + auto result = i->opC1Async(ICE_MAKE_SHARED(Test::C1, "C1")).get(); + test(result->s == "C1"); + } } // @@ -616,6 +662,83 @@ allTests(Test::TestHelper* helper) test(false); } } + + { + promise<void> p; + auto f = p.get_future(); + auto result = i->opE1Async(Test::E1::v1, + [&p](Test::E1 v) + { + test(v == Test::E1::v1); + p.set_value(); + }, + [&p](exception_ptr e) + { + p.set_exception(e); + }); + + try + { + f.get(); + } + catch(const exception& ex) + { + cerr << ex.what() << endl; + test(false); + } + } + + { + Test::S1 s; + s.s = "S1"; + promise<void> p; + auto f = p.get_future(); + auto result = i->opS1Async(s, + [&p](Test::S1 v) + { + test(v.s == "S1"); + p.set_value(); + }, + [&p](exception_ptr e) + { + p.set_exception(e); + }); + + try + { + f.get(); + } + catch(const exception& ex) + { + cerr << ex.what() << endl; + test(false); + } + } + + { + promise<void> p; + auto f = p.get_future(); + auto result = i->opC1Async(ICE_MAKE_SHARED(Test::C1, "C1"), + [&p](Test::C1Ptr v) + { + test(v->s == "C1"); + p.set_value(); + }, + [&p](exception_ptr e) + { + p.set_exception(e); + }); + + try + { + f.get(); + } + catch(const exception& ex) + { + cerr << ex.what() << endl; + test(false); + } + } } #else // @@ -665,6 +788,17 @@ allTests(Test::TestHelper* helper) Test::CMap cmap2; Test::CMap cmap3 = i->end_opCMap(cmap2, i->begin_opCMap(cmap1)); + + Test::E1 e = i->end_opE1(i->begin_opE1(Test::ICE_ENUM(E1, v1))); + test(e == Test::ICE_ENUM(E1, v1)); + + Test::S1 s; + s.s = "S1"; + s = i->end_opS1(i->begin_opS1(s)); + test(s.s == "S1"); + + Test::C1Ptr c = i->end_opC1(i->begin_opC1(new Test::C1("C1"))); + test(c->s == "C1"); } // // C++ 98 type safe callbacks @@ -715,6 +849,22 @@ allTests(Test::TestHelper* helper) i->begin_opCMap(cmap1, opCMapCB); cb->check(); + Test::Callback_I_opE1Ptr opE1 = + Test::newCallback_I_opE1(cb, &Test::Callback::opE1, &Test::Callback::error); + i->begin_opE1(Test::ICE_ENUM(E1, v1), opE1); + cb->check(); + + Test::S1 s; + s.s = "S1"; + Test::Callback_I_opS1Ptr opS1 = + Test::newCallback_I_opS1(cb, &Test::Callback::opS1, &Test::Callback::error); + i->begin_opS1(s, opS1); + cb->check(); + + Test::Callback_I_opC1Ptr opC1 = + Test::newCallback_I_opC1(cb, &Test::Callback::opC1, &Test::Callback::error); + i->begin_opC1(new Test::C1("C1"), opC1); + cb->check(); } #endif diff --git a/cpp/test/Ice/scope/Client.cpp b/cpp/test/Ice/scope/Client.cpp index 5056556c80b..8f2105c8291 100644 --- a/cpp/test/Ice/scope/Client.cpp +++ b/cpp/test/Ice/scope/Client.cpp @@ -19,7 +19,7 @@ void Client::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - cout << "test same Slice type name in different scopes... " << flush; + cout << "test using same type name in different Slice modules... " << flush; void allTests(Test::TestHelper*); allTests(this); cout << "ok" << endl; diff --git a/cpp/test/Ice/scope/Server.cpp b/cpp/test/Ice/scope/Server.cpp index 1e4d4f9f438..5a8d2668da1 100644 --- a/cpp/test/Ice/scope/Server.cpp +++ b/cpp/test/Ice/scope/Server.cpp @@ -27,6 +27,10 @@ public: virtual Test::CSeq opCSeq(ICE_IN(Test::CSeq), Test::CSeq&, const Ice::Current&); virtual Test::CMap opCMap(ICE_IN(Test::CMap), Test::CMap&, const Ice::Current&); + virtual Test::E1 opE1(Test::E1, const Ice::Current&); + virtual Test::S1 opS1(ICE_IN(Test::S1), const Ice::Current&); + virtual Test::C1Ptr opC1(ICE_IN(Test::C1Ptr), const Ice::Current&); + virtual void shutdown(const Ice::Current&); }; @@ -149,6 +153,24 @@ I1::opCMap(ICE_IN(Test::CMap) c1, Test::CMap& c2, const Ice::Current&) return c1; } +Test::E1 +I1::opE1(Test::E1 e1, const Ice::Current&) +{ + return e1; +} + +Test::S1 +I1::opS1(ICE_IN(Test::S1) s1, const Ice::Current&) +{ + return s1; +} + +Test::C1Ptr +I1::opC1(ICE_IN(Test::C1Ptr) c1, const Ice::Current&) +{ + return c1; +} + void I1::shutdown(const Ice::Current& current) { diff --git a/cpp/test/Ice/scope/Test.ice b/cpp/test/Ice/scope/Test.ice index e2197329562..011badcf15b 100644 --- a/cpp/test/Ice/scope/Test.ice +++ b/cpp/test/Ice/scope/Test.ice @@ -22,6 +22,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -32,6 +63,10 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/csharp/test/Ice/scope/AllTests.cs b/csharp/test/Ice/scope/AllTests.cs index 17d75a346a9..b57b675f7fd 100644 --- a/csharp/test/Ice/scope/AllTests.cs +++ b/csharp/test/Ice/scope/AllTests.cs @@ -57,6 +57,15 @@ namespace Ice var cmap3 = i.opCMap(cmap1, out cmap2); test(cmap2["a"].s.Equals(s1)); test(cmap3["a"].s.Equals(s1)); + + var e = i.opE1(Test.E1.v1); + test(e == Test.E1.v1); + + var s = i.opS1(new Test.S1("S1")); + test(s.s == "S1"); + + var c = i.opC1(new Test.C1("C1")); + test(c.s == "C1"); } { @@ -96,6 +105,15 @@ namespace Ice var opCMapResult = await i.opCMapAsync(cmap1); test(opCMapResult.returnValue["a"].s.Equals(s1)); test(opCMapResult.c2["a"].s.Equals(s1)); + + var e = await i.opE1Async(Test.E1.v1); + test(e == Test.E1.v1); + + var s = await i.opS1Async(new Test.S1("S1")); + test(s.s == "S1"); + + var c = await i.opC1Async(new Test.C1("C1")); + test(c.s == "C1"); }).Wait(); } diff --git a/csharp/test/Ice/scope/Client.cs b/csharp/test/Ice/scope/Client.cs index 0a8dca18acd..ad10e08f7ed 100644 --- a/csharp/test/Ice/scope/Client.cs +++ b/csharp/test/Ice/scope/Client.cs @@ -18,7 +18,7 @@ namespace Ice using(var communicator = initialize(initData)) { var output = getWriter(); - output.Write("test same Slice type name in different scopes... "); + output.Write("test using same type name in different Slice modules... "); output.Flush(); AllTests.allTests(this); output.WriteLine("ok"); diff --git a/csharp/test/Ice/scope/Server.cs b/csharp/test/Ice/scope/Server.cs index 0507deb803b..0087dc79a44 100644 --- a/csharp/test/Ice/scope/Server.cs +++ b/csharp/test/Ice/scope/Server.cs @@ -56,6 +56,24 @@ namespace Ice return c1; } + public override Test.E1 + opE1(Test.E1 e1, Ice.Current current) + { + return e1; + } + + public override Test.S1 + opS1(Test.S1 s1, Ice.Current current) + { + return s1; + } + + public override Test.C1 + opC1(Test.C1 c1, Ice.Current current) + { + return c1; + } + override public void shutdown(Ice.Current current) { diff --git a/csharp/test/Ice/scope/Test.ice b/csharp/test/Ice/scope/Test.ice index 1ebf9c2245a..a492517e65c 100644 --- a/csharp/test/Ice/scope/Test.ice +++ b/csharp/test/Ice/scope/Test.ice @@ -24,6 +24,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -34,6 +65,10 @@ module Test CSeq opCSeq(CSeq c1, out CSeq c2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/java-compat/test/src/main/java/test/Ice/scope/AllTests.java b/java-compat/test/src/main/java/test/Ice/scope/AllTests.java index 79233bf445a..8c3ce3a5b07 100644 --- a/java-compat/test/src/main/java/test/Ice/scope/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/scope/AllTests.java @@ -95,6 +95,15 @@ public class AllTests java.util.Map<String, test.Ice.scope.Test.C> cmap3 = i.opCMap(cmap1, cmap2); test(cmap2.value.get("a").s.equals(s1)); test(cmap3.get("a").s.equals(s1)); + + test.Ice.scope.Test.E1 e = i.opE1(test.Ice.scope.Test.E1.v1); + test(e == test.Ice.scope.Test.E1.v1); + + test.Ice.scope.Test.S1 s = i.opS1(new test.Ice.scope.Test.S1("S1")); + test(s.s.equals("S1")); + + test.Ice.scope.Test.C1 c = i.opC1(new test.Ice.scope.Test.C1("C1")); + test(c.s.equals("C1")); } { @@ -138,6 +147,15 @@ public class AllTests java.util.Map<String, test.Ice.scope.Test.C> cmap3 = i.end_opCMap(cmap2, i.begin_opCMap(cmap1)); test(cmap2.value.get("a").s.equals(s1)); test(cmap3.get("a").s.equals(s1)); + + test.Ice.scope.Test.E1 e = i.end_opE1(i.begin_opE1(test.Ice.scope.Test.E1.v1)); + test(e == test.Ice.scope.Test.E1.v1); + + test.Ice.scope.Test.S1 s = i.end_opS1(i.begin_opS1(new test.Ice.scope.Test.S1("S1"))); + test(s.s.equals("S1")); + + test.Ice.scope.Test.C1 c = i.end_opC1(i.begin_opC1(new test.Ice.scope.Test.C1("C1"))); + test(c.s.equals("C1")); } { diff --git a/java-compat/test/src/main/java/test/Ice/scope/Client.java b/java-compat/test/src/main/java/test/Ice/scope/Client.java index 6d3c86d6e70..6706fe08afb 100644 --- a/java-compat/test/src/main/java/test/Ice/scope/Client.java +++ b/java-compat/test/src/main/java/test/Ice/scope/Client.java @@ -13,7 +13,7 @@ public class Client extends test.TestHelper java.io.PrintWriter out = getWriter(); try(Ice.Communicator communicator = initialize(properties)) { - out.print("test same Slice type name in different scopes... "); + out.print("test using same type name in different Slice modules... "); out.flush(); AllTests.allTests(this); out.println("ok"); diff --git a/java-compat/test/src/main/java/test/Ice/scope/Server.java b/java-compat/test/src/main/java/test/Ice/scope/Server.java index bc78df4abf6..43b3bf6284e 100644 --- a/java-compat/test/src/main/java/test/Ice/scope/Server.java +++ b/java-compat/test/src/main/java/test/Ice/scope/Server.java @@ -55,6 +55,24 @@ public class Server extends test.TestHelper return c1; } + public test.Ice.scope.Test.E1 + opE1(test.Ice.scope.Test.E1 e1, Ice.Current current) + { + return e1; + } + + public test.Ice.scope.Test.S1 + opS1(test.Ice.scope.Test.S1 s1, Ice.Current current) + { + return s1; + } + + public test.Ice.scope.Test.C1 + opC1(test.Ice.scope.Test.C1 c1, Ice.Current current) + { + return c1; + } + public void shutdown(Ice.Current current) { current.adapter.getCommunicator().shutdown(); diff --git a/java-compat/test/src/main/java/test/Ice/scope/Test.ice b/java-compat/test/src/main/java/test/Ice/scope/Test.ice index 98e620d0e8f..8eb753f9977 100644 --- a/java-compat/test/src/main/java/test/Ice/scope/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/scope/Test.ice @@ -23,6 +23,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -33,6 +64,10 @@ module Test CSeq opCSeq(CSeq c1, out CSeq c2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/java/test/src/main/java/test/Ice/scope/AllTests.java b/java/test/src/main/java/test/Ice/scope/AllTests.java index 04f2b728cb0..da912190a85 100644 --- a/java/test/src/main/java/test/Ice/scope/AllTests.java +++ b/java/test/src/main/java/test/Ice/scope/AllTests.java @@ -56,6 +56,15 @@ public class AllTests test.Ice.scope.Test.I.OpCMapResult opCMapResult = i.opCMap(cmap1); test(opCMapResult.returnValue.get("a").s.equals(s1)); test(opCMapResult.c2.get("a").s.equals(s1)); + + test.Ice.scope.Test.E1 e = i.opE1(test.Ice.scope.Test.E1.v1); + test(e == test.Ice.scope.Test.E1.v1); + + test.Ice.scope.Test.S1 s = i.opS1(new test.Ice.scope.Test.S1("S1")); + test(s.s.equals("S1")); + + test.Ice.scope.Test.C1 c = i.opC1(new test.Ice.scope.Test.C1("C1")); + test(c.s.equals("C1")); } { @@ -93,6 +102,15 @@ public class AllTests test.Ice.scope.Test.I.OpCMapResult opCMapResult = i.opCMapAsync(cmap1).join(); test(opCMapResult.returnValue.get("a").s.equals(s1)); test(opCMapResult.c2.get("a").s.equals(s1)); + + test.Ice.scope.Test.E1 e = i.opE1Async(test.Ice.scope.Test.E1.v1).join(); + test(e == test.Ice.scope.Test.E1.v1); + + test.Ice.scope.Test.S1 s = i.opS1Async(new test.Ice.scope.Test.S1("S1")).join(); + test(s.s.equals("S1")); + + test.Ice.scope.Test.C1 c = i.opC1Async(new test.Ice.scope.Test.C1("C1")).join(); + test(c.s.equals("C1")); } { diff --git a/java/test/src/main/java/test/Ice/scope/Client.java b/java/test/src/main/java/test/Ice/scope/Client.java index 8bb082f5f2f..f05187ebd4b 100644 --- a/java/test/src/main/java/test/Ice/scope/Client.java +++ b/java/test/src/main/java/test/Ice/scope/Client.java @@ -13,7 +13,7 @@ public class Client extends test.TestHelper java.io.PrintWriter out = getWriter(); try(com.zeroc.Ice.Communicator communicator = initialize(properties)) { - out.print("test same Slice type name in different scopes... "); + out.print("test using same type name in different Slice modules... "); out.flush(); AllTests.allTests(this); out.println("ok"); diff --git a/java/test/src/main/java/test/Ice/scope/Server.java b/java/test/src/main/java/test/Ice/scope/Server.java index 516f4bd4160..149ca6bf597 100644 --- a/java/test/src/main/java/test/Ice/scope/Server.java +++ b/java/test/src/main/java/test/Ice/scope/Server.java @@ -62,6 +62,24 @@ public class Server extends test.TestHelper return result; } + public test.Ice.scope.Test.E1 + opE1(test.Ice.scope.Test.E1 e1, com.zeroc.Ice.Current current) + { + return e1; + } + + public test.Ice.scope.Test.S1 + opS1(test.Ice.scope.Test.S1 s1, com.zeroc.Ice.Current current) + { + return s1; + } + + public test.Ice.scope.Test.C1 + opC1(test.Ice.scope.Test.C1 e1, com.zeroc.Ice.Current current) + { + return e1; + } + public void shutdown(com.zeroc.Ice.Current current) { current.adapter.getCommunicator().shutdown(); diff --git a/java/test/src/main/java/test/Ice/scope/Test.ice b/java/test/src/main/java/test/Ice/scope/Test.ice index 98e620d0e8f..8eb753f9977 100644 --- a/java/test/src/main/java/test/Ice/scope/Test.ice +++ b/java/test/src/main/java/test/Ice/scope/Test.ice @@ -23,6 +23,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -33,6 +64,10 @@ module Test CSeq opCSeq(CSeq c1, out CSeq c2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/js/test/Ice/scope/Client.js b/js/test/Ice/scope/Client.js index c65a92dd13e..e409baf9719 100644 --- a/js/test/Ice/scope/Client.js +++ b/js/test/Ice/scope/Client.js @@ -16,7 +16,7 @@ const out = this.getWriter(); const communicator = this.communicator(); - out.write("test same Slice type name in different scopes... "); + out.write("test using same type name in different Slice modules... "); { const i1 = await Test.IPrx.checkedCast(communicator.stringToProxy("i1:" + this.getTestEndpoint())); @@ -49,6 +49,15 @@ const [cmap2, cmap3] = await i1.opCMap(cmap1); test(cmap2.get("a").s.equals(s1)); test(cmap3.get("a").s.equals(s1)); + + const e = await i1.opE1(Test.E1.v1); + test(e == Test.E1.v1); + + const s = await i1.opS1(new Test.S1("S1")); + test(s.s == "S1"); + + const c = await i1.opC1(new Test.C1("C1")); + test(c.s == "C1"); } { diff --git a/js/test/Ice/scope/Test.ice b/js/test/Ice/scope/Test.ice index e2197329562..011badcf15b 100644 --- a/js/test/Ice/scope/Test.ice +++ b/js/test/Ice/scope/Test.ice @@ -22,6 +22,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -32,6 +63,10 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/js/test/typescript/Ice/scope/Client.ts b/js/test/typescript/Ice/scope/Client.ts index ddcbdd99edc..afa9ef32e17 100644 --- a/js/test/typescript/Ice/scope/Client.ts +++ b/js/test/typescript/Ice/scope/Client.ts @@ -15,7 +15,7 @@ export class Client extends TestHelper const out = this.getWriter(); const communicator = this.communicator(); - out.write("test same Slice type name in different scopes... "); + out.write("test using same type name in different Slice modules... "); { const i1 = await Test.IPrx.checkedCast(communicator.stringToProxy("i1:" + this.getTestEndpoint())); @@ -48,6 +48,15 @@ export class Client extends TestHelper const [cmap2, cmap3] = await i1.opCMap(cmap1); test(cmap2.get("a").s.equals(s1)); test(cmap3.get("a").s.equals(s1)); + + const e = await i1.opE1(Test.E1.v1); + test(e == Test.E1.v1); + + const s = await i1.opS1(new Test.S1("S1")); + test(s.s == "S1"); + + const c = await i1.opC1(new Test.C1("C1")); + test(c.s == "C1"); } { diff --git a/js/test/typescript/Ice/scope/Test.ice b/js/test/typescript/Ice/scope/Test.ice index 83ee03f6073..6dbe43bfdaa 100644 --- a/js/test/typescript/Ice/scope/Test.ice +++ b/js/test/typescript/Ice/scope/Test.ice @@ -24,6 +24,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -34,6 +65,10 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/php/test/Ice/scope/Client.php b/php/test/Ice/scope/Client.php index d97cd6b5695..703799eeab9 100644 --- a/php/test/Ice/scope/Client.php +++ b/php/test/Ice/scope/Client.php @@ -32,6 +32,16 @@ function allTests($helper) $smap3 = $i->opSMap($smap1, $smap2); test($smap2["a"] == $s1); test($smap3["a"] == $s1); + + $v1 = $NS ? constant("Test\\E1::v1") : constant("Test_E1::v1"); + $e = $i->opE1($v1); + test($e == $v1); + + $s = $i->opS1($NS ? eval("return new Test\\S1(\"S1\");") : eval("return new Test_S1(\"S1\");")); + test($s->s == "S1"); + + $c = $i->opC1($NS ? eval("return new Test\\C1(\"C1\");") : eval("return new Test_C1(\"C1\");")); + test($c->s == "C1"); } { @@ -119,7 +129,7 @@ class Client extends TestHelper { try { - echo "test same Slice type name in different scopes... "; + echo "test using same type name in different Slice modules... "; flush(); $communicator = $this->initialize($args); allTests($this); diff --git a/php/test/Ice/scope/Test.ice b/php/test/Ice/scope/Test.ice index e2197329562..011badcf15b 100644 --- a/php/test/Ice/scope/Test.ice +++ b/php/test/Ice/scope/Test.ice @@ -22,6 +22,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -32,6 +63,10 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/python/test/Ice/scope/AllTests.py b/python/test/Ice/scope/AllTests.py index d57d6fd85d4..d60e19cd945 100644 --- a/python/test/Ice/scope/AllTests.py +++ b/python/test/Ice/scope/AllTests.py @@ -11,7 +11,7 @@ def test(b): def allTests(helper, communicator): - sys.stdout.write("test same Slice type name in different scopes... ") + sys.stdout.write("test using same type name in different Slice modules... ") sys.stdout.flush() i1 = Test.IPrx.checkedCast(communicator.stringToProxy("i1:{0}".format(helper.getTestEndpoint()))) @@ -52,6 +52,15 @@ def allTests(helper, communicator): test(cmap2["a"].s == s1) test(cmap3["a"].s == s1) + e = i1.opE1(Test.E1.v1) + test(e == Test.E1.v1) + + s = i1.opS1(Test.S1("S1")) + test(s.s == "S1") + + c = i1.opC1(Test.C1("C1")) + test(c.s == "C1") + i2 = Test.Inner.Inner2.IPrx.checkedCast(communicator.stringToProxy("i2:{0}".format(helper.getTestEndpoint()))) s1 = Test.Inner.Inner2.S(0) diff --git a/python/test/Ice/scope/Server.py b/python/test/Ice/scope/Server.py index e322bd18640..bccd9646b9d 100755 --- a/python/test/Ice/scope/Server.py +++ b/python/test/Ice/scope/Server.py @@ -30,6 +30,15 @@ class I1(Test.I): def opCMap(self, cmap1, current=None): return (cmap1, cmap1) + def opE1(self, e1, current=None): + return e1 + + def opS1(self, s1, current=None): + return s1 + + def opC1(self, c1, current=None): + return c1 + def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/scope/Test.ice b/python/test/Ice/scope/Test.ice index e2197329562..011badcf15b 100644 --- a/python/test/Ice/scope/Test.ice +++ b/python/test/Ice/scope/Test.ice @@ -22,6 +22,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -32,6 +63,10 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/ruby/test/Ice/scope/AllTests.rb b/ruby/test/Ice/scope/AllTests.rb index 3d339869b15..78797e5bd7f 100644 --- a/ruby/test/Ice/scope/AllTests.rb +++ b/ruby/test/Ice/scope/AllTests.rb @@ -4,7 +4,7 @@ def allTests(helper, communicator) - print "test same Slice type name in different scopes... " + print "test using same type name in different Slice modules... " STDOUT.flush i1 = Test::IPrx::checkedCast(communicator.stringToProxy("i1:#{helper.getTestEndpoint()}")) @@ -41,6 +41,15 @@ def allTests(helper, communicator) test(cmap2["a"].s == s1) test(cmap3["a"].s == s1) + e = i1.opE1(Test::E1::V1) + test(e == Test::E1::V1) + + s = i1.opS1(Test::S1.new("S1")) + test(s.s == "S1") + + c = i1.opC1(Test::C1.new("C1")) + test(c.s == "C1") + i2 = Test::Inner::Inner2::IPrx::checkedCast(communicator.stringToProxy("i2:#{helper.getTestEndpoint()}")) s1 = Test::Inner::Inner2::S.new(0) diff --git a/ruby/test/Ice/scope/Test.ice b/ruby/test/Ice/scope/Test.ice index e2197329562..011badcf15b 100644 --- a/ruby/test/Ice/scope/Test.ice +++ b/ruby/test/Ice/scope/Test.ice @@ -22,6 +22,37 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + } + interface I { S opS(S s1, out S s2); @@ -32,6 +63,10 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + void shutdown(); } diff --git a/swift/test/Ice/scope/AllTests.swift b/swift/test/Ice/scope/AllTests.swift index ecd09756adf..5708c599e82 100644 --- a/swift/test/Ice/scope/AllTests.swift +++ b/swift/test/Ice/scope/AllTests.swift @@ -10,7 +10,7 @@ func allTests(helper: TestHelper) throws { try helper.test(value, file: file, line: line) } let output = helper.getWriter() - output.write("test same Slice type name in different scopes... ") + output.write("test using same type name in different Slice modules... ") let communicator = helper.communicator() do { @@ -46,6 +46,21 @@ func allTests(helper: TestHelper) throws { let (cmap3, cmap2) = try i.opCMap(cmap1) try test(cmap2["a"]!!.s == s1) try test(cmap3["a"]!!.s == s1) + + let e = try i.opE1(.v1) + try test(e == .v1) + + let s = try i.opS1(S1(s: "S1")) + try test(s.s == "S1") + + let c = try i.opC1(C1(s: "C1"))! + try test(c.s == "C1") + + let ss = try i.opS1Seq([S1(s: "S1")]) + try test(ss[0].s == "S1") + + let sm = try i.opS1Map(["s1": S1(s: "S1")]) + try test(sm["s1"]!.s == "S1") } do { diff --git a/swift/test/Ice/scope/Test.ice b/swift/test/Ice/scope/Test.ice index c27026f94a7..988e0db999d 100644 --- a/swift/test/Ice/scope/Test.ice +++ b/swift/test/Ice/scope/Test.ice @@ -22,6 +22,46 @@ module Test dictionary<string, C> CMap; sequence<C> CSeq; + enum E1 + { + v1, + v2, + v3 + } + + struct S1 + { + string s; + } + + sequence<S1> S1Seq; + dictionary<string, S1> S1Map; + + class C1 + { + string s; + } + + struct S2 + { + E1 E1; + S1 S1; + C1 C1; + + S1Seq S1Seq; + S1Map S1Map; + } + + class C2 + { + E1 E1; + S1 S1; + C1 C1; + + S1Seq S1Seq; + S1Map S1Map; + } + interface I { S opS(S s1, out S s2); @@ -32,6 +72,13 @@ module Test CSeq opCSeq(CSeq s1, out CSeq s2); CMap opCMap(CMap c1, out CMap c2); + E1 opE1(E1 E1); + S1 opS1(S1 S1); + C1 opC1(C1 C1); + + S1Seq opS1Seq(S1Seq S1Seq); + S1Map opS1Map(S1Map S1Map); + void shutdown(); } diff --git a/swift/test/Ice/scope/TestI.swift b/swift/test/Ice/scope/TestI.swift index 28024fd8943..57f61391a4e 100644 --- a/swift/test/Ice/scope/TestI.swift +++ b/swift/test/Ice/scope/TestI.swift @@ -31,6 +31,26 @@ class I1: I { return (c1, c1) } + func opE1(E1: E1, current: Current) throws -> E1 { + return E1 + } + + func opS1(S1: S1, current: Current) throws -> S1 { + return S1 + } + + func opC1(C1: C1?, current: Current) throws -> C1? { + return C1 + } + + func opS1Seq(S1Seq: S1Seq, current: Current) throws -> S1Seq { + return S1Seq + } + + func opS1Map(S1Map: S1Map, current: Current) throws -> S1Map { + return S1Map + } + func shutdown(current: Current) throws { current.adapter!.getCommunicator().shutdown() } |