summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2012-05-16 16:05:50 -0700
committerMark Spruiell <mes@zeroc.com>2012-05-16 16:05:50 -0700
commit3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569 (patch)
treeedfa533e67fb4ee003d1afbb2e1ba8a9b03ef3f3 /cpp
parentporting ami test changes to python (diff)
downloadice-3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569.tar.bz2
ice-3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569.tar.xz
ice-3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569.zip
* Ruby port of sliced/compact/preserved
* Python clean up * More changes to exceptions test
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/src/Slice/RubyUtil.cpp22
-rw-r--r--cpp/test/Ice/slicing/exceptions/AllTests.cpp22
-rw-r--r--cpp/test/Ice/slicing/exceptions/ClientPrivate.ice2
-rw-r--r--cpp/test/Ice/slicing/exceptions/ServerPrivate.ice15
-rw-r--r--cpp/test/Ice/slicing/exceptions/ServerPrivateAMD.ice15
-rw-r--r--cpp/test/Ice/slicing/exceptions/Test.ice11
-rw-r--r--cpp/test/Ice/slicing/exceptions/TestAMD.ice11
-rw-r--r--cpp/test/Ice/slicing/exceptions/TestAMDI.cpp46
-rw-r--r--cpp/test/Ice/slicing/exceptions/TestAMDI.h16
-rw-r--r--cpp/test/Ice/slicing/exceptions/TestI.cpp44
-rw-r--r--cpp/test/Ice/slicing/exceptions/TestI.h6
11 files changed, 200 insertions, 10 deletions
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index 4d941c7c6a8..c9a3bae5820 100755
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -607,7 +607,9 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_classHistory.insert(scoped); // Avoid redundant declarations.
bool isAbstract = p->isInterface() || p->allOperations().size() > 0; // Don't use isAbstract() here - see bug 3739
- _out << sp << nl << "T_" << name << ".defineClass(" << name << ", " << (isAbstract ? "true" : "false") << ", ";
+ const bool preserved = p->hasMetaData("preserve-slice") || p->inheritsMetaData("preserve-slice");
+ _out << sp << nl << "T_" << name << ".defineClass(" << name << ", " << (isAbstract ? "true" : "false") << ", "
+ << (preserved ? "true" : "false") << ", ";
if(!base)
{
_out << "nil";
@@ -675,7 +677,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Define each operation. The arguments to __defineOperation are:
//
- // 'opName', Mode, [InParams], [OutParams], ReturnType, [Exceptions]
+ // 'opName', Mode, IsAmd, FormatType, [InParams], [OutParams], ReturnType, [Exceptions]
//
// where InParams and OutParams are arrays of type descriptions, and Exceptions
// is an array of exception types.
@@ -694,6 +696,19 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
ParamDeclList params = (*s)->parameters();
ParamDeclList::iterator t;
int count;
+ string format;
+ switch((*s)->format())
+ {
+ case DefaultFormat:
+ format = "nil";
+ break;
+ case CompactFormat:
+ format = "::Ice::FormatType::CompactFormat";
+ break;
+ case SlicedFormat:
+ format = "::Ice::FormatType::SlicedFormat";
+ break;
+ }
_out << nl << name << "_mixin::OP_" << (*s)->name() << " = ::Ice::__defineOperation('"
<< (*s)->name() << "', ";
@@ -722,7 +737,8 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << "::Ice::OperationMode::Idempotent";
break;
}
- _out << ", " << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "true" : "false") << ", [";
+ _out << ", " << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "true" : "false") << ", " << format
+ << ", [";
for(t = params.begin(), count = 0; t != params.end(); ++t)
{
if(!(*t)->isOutParam())
diff --git a/cpp/test/Ice/slicing/exceptions/AllTests.cpp b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
index d1102c0dd7e..74ce31bba6c 100644
--- a/cpp/test/Ice/slicing/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
@@ -327,17 +327,19 @@ class RelayI : public Relay
{
virtual void knownPreservedAsBase(const ::Ice::Current&)
{
- KnownPreserved ex;
+ KnownPreservedDerived ex;
ex.b = "base";
ex.kp = "preserved";
+ ex.kpd = "derived";
throw ex;
}
virtual void knownPreservedAsKnownPreserved(const ::Ice::Current&)
{
- KnownPreserved ex;
+ KnownPreservedDerived ex;
ex.b = "base";
ex.kp = "preserved";
+ ex.kpd = "derived";
throw ex;
}
@@ -346,6 +348,7 @@ class RelayI : public Relay
Preserved2 ex;
ex.b = "base";
ex.kp = "preserved";
+ ex.kpd = "derived";
ex.p1 = new PreservedClass("bc", "pc");
ex.p2 = ex.p1;
throw ex;
@@ -356,6 +359,7 @@ class RelayI : public Relay
Preserved2 ex;
ex.b = "base";
ex.kp = "preserved";
+ ex.kpd = "derived";
ex.p1 = new PreservedClass("bc", "pc");
ex.p2 = ex.p1;
throw ex;
@@ -795,10 +799,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
test->relayKnownPreservedAsBase(relay);
test(false);
}
- catch(const KnownPreserved& ex)
+ catch(const KnownPreservedDerived& ex)
{
test(ex.b == "base");
test(ex.kp == "preserved");
+ test(ex.kpd == "derived");
}
catch(...)
{
@@ -810,10 +815,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
test->relayKnownPreservedAsKnownPreserved(relay);
test(false);
}
- catch(const KnownPreserved& ex)
+ catch(const KnownPreservedDerived& ex)
{
test(ex.b == "base");
test(ex.kp == "preserved");
+ test(ex.kpd == "derived");
}
catch(...)
{
@@ -829,13 +835,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
test(ex.b == "base");
test(ex.kp == "preserved");
+ test(ex.kpd == "derived");
test(ex.p1->ice_id() == PreservedClass::ice_staticId());
PreservedClassPtr pc = PreservedClassPtr::dynamicCast(ex.p1);
test(pc->bc == "bc");
test(pc->pc == "pc");
test(ex.p2 == ex.p1);
}
- catch(const KnownPreserved& ex)
+ catch(const KnownPreservedDerived& ex)
{
//
// For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
@@ -843,6 +850,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(test->ice_getEncodingVersion() == Ice::Encoding_1_0);
test(ex.b == "base");
test(ex.kp == "preserved");
+ test(ex.kpd == "derived");
}
catch(...)
{
@@ -858,13 +866,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
test(ex.b == "base");
test(ex.kp == "preserved");
+ test(ex.kpd == "derived");
test(ex.p1->ice_id() == PreservedClass::ice_staticId());
PreservedClassPtr pc = PreservedClassPtr::dynamicCast(ex.p1);
test(pc->bc == "bc");
test(pc->pc == "pc");
test(ex.p2 == ex.p1);
}
- catch(const KnownPreserved& ex)
+ catch(const KnownPreservedDerived& ex)
{
//
// For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
@@ -872,6 +881,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(test->ice_getEncodingVersion() == Ice::Encoding_1_0);
test(ex.b == "base");
test(ex.kp == "preserved");
+ test(ex.kpd == "derived");
}
catch(...)
{
diff --git a/cpp/test/Ice/slicing/exceptions/ClientPrivate.ice b/cpp/test/Ice/slicing/exceptions/ClientPrivate.ice
index 9b2e381798a..029e6d5d37e 100644
--- a/cpp/test/Ice/slicing/exceptions/ClientPrivate.ice
+++ b/cpp/test/Ice/slicing/exceptions/ClientPrivate.ice
@@ -19,7 +19,7 @@ class PreservedClass extends BaseClass
string pc;
};
-exception Preserved1 extends KnownPreserved
+exception Preserved1 extends KnownPreservedDerived
{
BaseClass p1;
};
diff --git a/cpp/test/Ice/slicing/exceptions/ServerPrivate.ice b/cpp/test/Ice/slicing/exceptions/ServerPrivate.ice
index df89aa2efea..e03994a4641 100644
--- a/cpp/test/Ice/slicing/exceptions/ServerPrivate.ice
+++ b/cpp/test/Ice/slicing/exceptions/ServerPrivate.ice
@@ -34,4 +34,19 @@ exception UnknownMostDerived2 extends UnknownIntermediate
string umd2;
};
+class SPreservedClass extends BaseClass
+{
+ string spc;
+};
+
+exception SPreserved1 extends KnownPreservedDerived
+{
+ BaseClass p1;
+};
+
+exception SPreserved2 extends SPreserved1
+{
+ BaseClass p2;
+};
+
};
diff --git a/cpp/test/Ice/slicing/exceptions/ServerPrivateAMD.ice b/cpp/test/Ice/slicing/exceptions/ServerPrivateAMD.ice
index 59542af8d16..7d99c0182c4 100644
--- a/cpp/test/Ice/slicing/exceptions/ServerPrivateAMD.ice
+++ b/cpp/test/Ice/slicing/exceptions/ServerPrivateAMD.ice
@@ -34,4 +34,19 @@ exception UnknownMostDerived2 extends UnknownIntermediate
string umd2;
};
+class SPreservedClass extends BaseClass
+{
+ string spc;
+};
+
+exception SPreserved1 extends KnownPreservedDerived
+{
+ BaseClass p1;
+};
+
+exception SPreserved2 extends SPreserved1
+{
+ BaseClass p2;
+};
+
};
diff --git a/cpp/test/Ice/slicing/exceptions/Test.ice b/cpp/test/Ice/slicing/exceptions/Test.ice
index f210b8e2c46..ddf84d47e82 100644
--- a/cpp/test/Ice/slicing/exceptions/Test.ice
+++ b/cpp/test/Ice/slicing/exceptions/Test.ice
@@ -38,6 +38,11 @@ exception KnownPreserved extends Base
string kp;
};
+exception KnownPreservedDerived extends KnownPreserved
+{
+ string kpd;
+};
+
["preserve-slice"]
class BaseClass
{
@@ -75,9 +80,15 @@ interface TestIntf
["format:compact"] void unknownMostDerived2AsBaseCompact() throws Base;
+ void knownPreservedAsBase() throws Base;
+ void knownPreservedAsKnownPreserved() throws KnownPreserved;
+
void relayKnownPreservedAsBase(Relay* r) throws Base;
void relayKnownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
+ void unknownPreservedAsBase() throws Base;
+ void unknownPreservedAsKnownPreserved() throws KnownPreserved;
+
void relayUnknownPreservedAsBase(Relay* r) throws Base;
void relayUnknownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
diff --git a/cpp/test/Ice/slicing/exceptions/TestAMD.ice b/cpp/test/Ice/slicing/exceptions/TestAMD.ice
index d9e69f00b05..9d5e2422550 100644
--- a/cpp/test/Ice/slicing/exceptions/TestAMD.ice
+++ b/cpp/test/Ice/slicing/exceptions/TestAMD.ice
@@ -38,6 +38,11 @@ exception KnownPreserved extends Base
string kp;
};
+exception KnownPreservedDerived extends KnownPreserved
+{
+ string kpd;
+};
+
["preserve-slice"]
class BaseClass
{
@@ -75,9 +80,15 @@ interface TestIntf
["format:compact"] void unknownMostDerived2AsBaseCompact() throws Base;
+ void knownPreservedAsBase() throws Base;
+ void knownPreservedAsKnownPreserved() throws KnownPreserved;
+
void relayKnownPreservedAsBase(Relay* r) throws Base;
void relayKnownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
+ void unknownPreservedAsBase() throws Base;
+ void unknownPreservedAsKnownPreserved() throws KnownPreserved;
+
void relayUnknownPreservedAsBase(Relay* r) throws Base;
void relayUnknownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
diff --git a/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp b/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp
index f8358484dfb..f87288d4f08 100644
--- a/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp
+++ b/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp
@@ -156,6 +156,27 @@ TestI::unknownMostDerived2AsBaseCompact_async(const AMD_TestIntf_unknownMostDeri
}
void
+TestI::knownPreservedAsBase_async(const AMD_TestIntf_knownPreservedAsBasePtr& cb, const ::Ice::Current&)
+{
+ KnownPreservedDerived ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ cb->ice_exception(ex);
+}
+
+void
+TestI::knownPreservedAsKnownPreserved_async(const AMD_TestIntf_knownPreservedAsKnownPreservedPtr& cb,
+ const ::Ice::Current&)
+{
+ KnownPreservedDerived ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ cb->ice_exception(ex);
+}
+
+void
TestI::relayKnownPreservedAsBase_async(const AMD_TestIntf_relayKnownPreservedAsBasePtr& cb, const RelayPrx& r,
const ::Ice::Current&)
{
@@ -186,6 +207,31 @@ TestI::relayKnownPreservedAsKnownPreserved_async(const AMD_TestIntf_relayKnownPr
}
void
+TestI::unknownPreservedAsBase_async(const AMD_TestIntf_unknownPreservedAsBasePtr& cb, const ::Ice::Current&)
+{
+ SPreserved2 ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ ex.p1 = new SPreservedClass("bc", "spc");
+ ex.p2 = ex.p1;
+ cb->ice_exception(ex);
+}
+
+void
+TestI::unknownPreservedAsKnownPreserved_async(const AMD_TestIntf_unknownPreservedAsKnownPreservedPtr& cb,
+ const ::Ice::Current&)
+{
+ SPreserved2 ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ ex.p1 = new SPreservedClass("bc", "spc");
+ ex.p2 = ex.p1;
+ cb->ice_exception(ex);
+}
+
+void
TestI::relayUnknownPreservedAsBase_async(const AMD_TestIntf_relayUnknownPreservedAsBasePtr& cb, const RelayPrx& r,
const ::Ice::Current&)
{
diff --git a/cpp/test/Ice/slicing/exceptions/TestAMDI.h b/cpp/test/Ice/slicing/exceptions/TestAMDI.h
index 58772018430..13b3edcd1ff 100644
--- a/cpp/test/Ice/slicing/exceptions/TestAMDI.h
+++ b/cpp/test/Ice/slicing/exceptions/TestAMDI.h
@@ -54,6 +54,14 @@ public:
const ::Test::AMD_TestIntf_unknownMostDerived2AsBaseCompactPtr&,
const ::Ice::Current&);
+ virtual void knownPreservedAsBase_async(
+ const ::Test::AMD_TestIntf_knownPreservedAsBasePtr&,
+ const ::Ice::Current&);
+
+ virtual void knownPreservedAsKnownPreserved_async(
+ const ::Test::AMD_TestIntf_knownPreservedAsKnownPreservedPtr&,
+ const ::Ice::Current&);
+
virtual void relayKnownPreservedAsBase_async(
const ::Test::AMD_TestIntf_relayKnownPreservedAsBasePtr&,
const ::Test::RelayPrx&,
@@ -64,6 +72,14 @@ public:
const ::Test::RelayPrx&,
const ::Ice::Current&);
+ virtual void unknownPreservedAsBase_async(
+ const ::Test::AMD_TestIntf_unknownPreservedAsBasePtr&,
+ const ::Ice::Current&);
+
+ virtual void unknownPreservedAsKnownPreserved_async(
+ const ::Test::AMD_TestIntf_unknownPreservedAsKnownPreservedPtr&,
+ const ::Ice::Current&);
+
virtual void relayUnknownPreservedAsBase_async(
const ::Test::AMD_TestIntf_relayUnknownPreservedAsBasePtr&,
const ::Test::RelayPrx&,
diff --git a/cpp/test/Ice/slicing/exceptions/TestI.cpp b/cpp/test/Ice/slicing/exceptions/TestI.cpp
index 7a982738d21..6cbff79f8cc 100644
--- a/cpp/test/Ice/slicing/exceptions/TestI.cpp
+++ b/cpp/test/Ice/slicing/exceptions/TestI.cpp
@@ -151,6 +151,26 @@ TestI::unknownMostDerived2AsBaseCompact(const ::Ice::Current&)
}
void
+TestI::knownPreservedAsBase(const ::Ice::Current&)
+{
+ KnownPreservedDerived ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ throw ex;
+}
+
+void
+TestI::knownPreservedAsKnownPreserved(const ::Ice::Current&)
+{
+ KnownPreservedDerived ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ throw ex;
+}
+
+void
TestI::relayKnownPreservedAsBase(const RelayPrx& r, const ::Ice::Current&)
{
r->knownPreservedAsBase();
@@ -165,6 +185,30 @@ TestI::relayKnownPreservedAsKnownPreserved(const RelayPrx& r, const ::Ice::Curre
}
void
+TestI::unknownPreservedAsBase(const ::Ice::Current&)
+{
+ SPreserved2 ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ ex.p1 = new SPreservedClass("bc", "spc");
+ ex.p2 = ex.p1;
+ throw ex;
+}
+
+void
+TestI::unknownPreservedAsKnownPreserved(const ::Ice::Current&)
+{
+ SPreserved2 ex;
+ ex.b = "base";
+ ex.kp = "preserved";
+ ex.kpd = "derived";
+ ex.p1 = new SPreservedClass("bc", "spc");
+ ex.p2 = ex.p1;
+ throw ex;
+}
+
+void
TestI::relayUnknownPreservedAsBase(const RelayPrx& r, const ::Ice::Current&)
{
r->unknownPreservedAsBase();
diff --git a/cpp/test/Ice/slicing/exceptions/TestI.h b/cpp/test/Ice/slicing/exceptions/TestI.h
index b9ae73b51ae..7514794ef0a 100644
--- a/cpp/test/Ice/slicing/exceptions/TestI.h
+++ b/cpp/test/Ice/slicing/exceptions/TestI.h
@@ -35,9 +35,15 @@ public:
virtual void unknownMostDerived2AsBaseCompact(const ::Ice::Current&);
+ virtual void knownPreservedAsBase(const ::Ice::Current&);
+ virtual void knownPreservedAsKnownPreserved(const ::Ice::Current&);
+
virtual void relayKnownPreservedAsBase(const ::Test::RelayPrx&, const ::Ice::Current&);
virtual void relayKnownPreservedAsKnownPreserved(const ::Test::RelayPrx&, const ::Ice::Current&);
+ virtual void unknownPreservedAsBase(const ::Ice::Current&);
+ virtual void unknownPreservedAsKnownPreserved(const ::Ice::Current&);
+
virtual void relayUnknownPreservedAsBase(const ::Test::RelayPrx&, const ::Ice::Current&);
virtual void relayUnknownPreservedAsKnownPreserved(const ::Test::RelayPrx&, const ::Ice::Current&);