summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2010-03-09 16:01:54 -0800
committerMark Spruiell <mes@zeroc.com>2010-03-09 16:01:54 -0800
commitd14b4973bf8f25282b70e72ec5f577f71dfcded7 (patch)
tree3651f5139695829d2bf882b7422116662a2d39f8 /cpp
parentbug 4704 - template error in nested Slice definition (diff)
downloadice-d14b4973bf8f25282b70e72ec5f577f71dfcded7.tar.bz2
ice-d14b4973bf8f25282b70e72ec5f577f71dfcded7.tar.xz
ice-d14b4973bf8f25282b70e72ec5f577f71dfcded7.zip
Cleaning up translator and adding tests related to bug 4704.
This commit does NOT need to be included in the official patch for this bug.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp22
-rw-r--r--cpp/src/slice2cpp/Gen.h2
-rwxr-xr-xcpp/test/Ice/stream/Client.cpp100
-rw-r--r--cpp/test/Ice/stream/Test.ice32
4 files changed, 118 insertions, 38 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 4e68b64aa84..998dd7ed2ec 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -6621,14 +6621,11 @@ Slice::Gen::StreamVisitor::StreamVisitor(Output& h, Output& c) :
bool
Slice::Gen::StreamVisitor::visitModuleStart(const ModulePtr& m)
{
- if(!m->hasOtherConstructedOrExceptions())
- {
- return false;
- }
- else if(m->structs().empty() && m->enums().empty() && m->exceptions().empty())
+ if(m->structs().empty() && m->enums().empty() && m->exceptions().empty())
{
return false;
}
+
if(UnitPtr::dynamicCast(m->container()))
{
//
@@ -6641,6 +6638,7 @@ Slice::Gen::StreamVisitor::visitModuleStart(const ModulePtr& m)
H.restoreIndent();
H << nl << "namespace Ice" << nl << '{';
}
+
return true;
}
@@ -6671,12 +6669,7 @@ Slice::Gen::StreamVisitor::visitExceptionStart(const ExceptionPtr& p)
H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeUserException;";
H << eb << ";" << nl;
}
- return true;
-}
-
-void
-Slice::Gen::StreamVisitor::visitExceptionEnd(const ExceptionPtr&)
-{
+ return false;
}
bool
@@ -6707,12 +6700,7 @@ Slice::Gen::StreamVisitor::visitStructStart(const StructPtr& p)
H << nl << "static const int minWireSize = " << p->minWireSize() << ";";
H << eb << ";" << nl;
}
- return true;
-}
-
-void
-Slice::Gen::StreamVisitor::visitStructEnd(const StructPtr&)
-{
+ return false;
}
void
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index 3a514499bf0..b262fbae6fb 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -445,9 +445,7 @@ private:
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
virtual bool visitStructStart(const StructPtr&);
- virtual void visitStructEnd(const StructPtr&);
virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual void visitExceptionEnd(const ExceptionPtr&);
virtual void visitEnum(const EnumPtr&);
private:
diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp
index 7e95b713264..7f4952be9cc 100755
--- a/cpp/test/Ice/stream/Client.cpp
+++ b/cpp/test/Ice/stream/Client.cpp
@@ -165,7 +165,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
{
#if defined(_MSC_VER) && (_MSC_VER < 1300)
//
-// VC++ 6 compiler bugs doesn't allow to write
+// VC++ 6 compiler bugs doesn't allow to write
// the Stream API using c++ templates.
//
// see: http://support.microsoft.com/kb/240866
@@ -183,7 +183,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
#if defined(_MSC_VER) && (_MSC_VER < 1300)
//
-// VC++ 6 compiler bugs doesn't allow to write
+// VC++ 6 compiler bugs doesn't allow to write
// the Stream API using c++ templates.
//
// see: http://support.microsoft.com/kb/240866
@@ -367,7 +367,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arr);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::BoolS arr2;
in->read(arr2);
@@ -381,7 +381,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::BoolSS arr2S;
in->read(arr2S);
@@ -411,7 +411,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::ByteSS arr2S;
in->read(arr2S);
@@ -440,7 +440,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::ShortSS arr2S;
in->read(arr2S);
@@ -469,7 +469,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::IntSS arr2S;
in->read(arr2S);
@@ -498,7 +498,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::LongSS arr2S;
in->read(arr2S);
@@ -527,7 +527,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::FloatSS arr2S;
in->read(arr2S);
@@ -556,7 +556,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::DoubleSS arr2S;
in->read(arr2S);
@@ -585,7 +585,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::StringSS arr2S;
in->read(arr2S);
@@ -615,7 +615,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::MyEnumSS arr2S;
in->read(arr2S);
@@ -661,7 +661,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::SmallStructSS arr2S;
in->read(arr2S);
@@ -758,7 +758,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
out = Ice::createOutputStream(communicator);
out->write(arrS);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
Test::MyClassSS arr2S;
in->read(arr2S);
@@ -811,7 +811,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
test(reader->obj->s.e == Test::enum2);
factoryWrapper->setFactory(0);
}
-
+
{
out = Ice::createOutputStream(communicator);
Test::MyException ex;
@@ -865,10 +865,10 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
c->seq9.push_back(Test::enum1);
ex.c = c;
-
+
out->write(ex);
out->finished(data);
-
+
in = Ice::createInputStream(communicator, data);
try
{
@@ -961,6 +961,68 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
test(dict2["key2"] && (dict2["key2"]->s.e == Test::enum3));
}
+ {
+ out = Ice::createOutputStream(communicator);
+ out->write(Test::Sub::nestedEnum3);
+ out->finished(data);
+ in = Ice::createInputStream(communicator, data);
+ Test::Sub::NestedEnum e;
+ in->read(e);
+ test(e == Test::Sub::nestedEnum3);
+ }
+
+ {
+ out = Ice::createOutputStream(communicator);
+ Test::Sub::NestedStruct s;
+ s.bo = true;
+ s.by = 1;
+ s.sh = 2;
+ s.i = 3;
+ s.l = 4;
+ s.f = 5.0;
+ s.d = 6.0;
+ s.str = "7";
+ s.e = Test::Sub::nestedEnum2;
+ out->write(s);
+ out->finished(data);
+ in = Ice::createInputStream(communicator, data);
+ Test::Sub::NestedStruct s2;
+ in->read(s2);
+ test(s2 == s);
+ }
+
+ {
+ out = Ice::createOutputStream(communicator);
+ Test::Sub::NestedClassStructPtr s = new Test::Sub::NestedClassStruct();
+ s->i = 10;
+ out->write(s);
+ out->finished(data);
+ in = Ice::createInputStream(communicator, data);
+ Test::Sub::NestedClassStructPtr s2 = new Test::Sub::NestedClassStruct();
+ in->read(s2);
+ test(s2->i == s->i);
+ }
+
+ {
+ out = Ice::createOutputStream(communicator);
+ Test::Sub::NestedException ex;
+ ex.str = "str";
+
+ out->write(ex);
+ out->finished(data);
+
+ in = Ice::createInputStream(communicator, data);
+ try
+ {
+ in->throwException();
+ test(false);
+ }
+ catch(const Test::Sub::NestedException& ex1)
+ {
+ test(ex1.str == ex.str);
+ }
+ }
+
cout << "ok" << endl;
#endif
@@ -1070,7 +1132,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
#if defined(_MSC_VER) && (_MSC_VER < 1300)
//
-// VC++ 6 compiler bugs doesn't allow to write
+// VC++ 6 compiler bugs doesn't allow to write
// the Stream API using c++ templates.
//
// see: http://support.microsoft.com/kb/240866
@@ -1237,7 +1299,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
}
#if defined(_MSC_VER) && (_MSC_VER < 1300)
//
-// VC++ 6 compiler bugs doesn't allow to write
+// VC++ 6 compiler bugs doesn't allow to write
// the Stream API using c++ templates.
//
// see: http://support.microsoft.com/kb/240866
diff --git a/cpp/test/Ice/stream/Test.ice b/cpp/test/Ice/stream/Test.ice
index d9b6bc10e72..7834dd1af10 100644
--- a/cpp/test/Ice/stream/Test.ice
+++ b/cpp/test/Ice/stream/Test.ice
@@ -98,6 +98,38 @@ exception MyException
MyClass c;
};
+module Sub
+{
+ enum NestedEnum
+ {
+ nestedEnum1,
+ nestedEnum2,
+ nestedEnum3
+ };
+
+ struct NestedStruct
+ {
+ bool bo;
+ byte by;
+ short sh;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ NestedEnum e;
+ };
+
+ ["cpp:class"] struct NestedClassStruct
+ {
+ int i;
+ };
+
+ exception NestedException
+ {
+ string str;
+ };
+};
};
#endif