summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-11-08 21:06:20 +0000
committerMark Spruiell <mes@zeroc.com>2004-11-08 21:06:20 +0000
commit69f279879d34fd7092366a86a0818c71a68e4af0 (patch)
tree84df6c42c2b3eefd09c1e79ae0c38c9e1c47716b /cpp/src
parentadding adapter property <name>.PublishedEndpoints (diff)
downloadice-69f279879d34fd7092366a86a0818c71a68e4af0.tar.bz2
ice-69f279879d34fd7092366a86a0818c71a68e4af0.tar.xz
ice-69f279879d34fd7092366a86a0818c71a68e4af0.zip
always generate stream functions for class, exception
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp74
1 files changed, 58 insertions, 16 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index ddd280da4a7..8f49c312083 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -193,12 +193,6 @@ Slice::Gen::generate(const UnitPtr& p)
H << "\n#include <Ice/IncomingAsync.h>";
}
H << "\n#include <Ice/Direct.h>";
- if(_stream)
- {
- H << "\n#include <Ice/StreamF.h>";
- C << "\n#include <Ice/Stream.h>";
- }
-
C << "\n#include <Ice/LocalException.h>";
C << "\n#include <Ice/ObjectFactory.h>";
}
@@ -219,6 +213,21 @@ Slice::Gen::generate(const UnitPtr& p)
C << "\n#include <Ice/Object.h>";
}
+ if(_stream || p->hasNonLocalClassDefs() || p->hasNonLocalExceptions())
+ {
+ H << "\n#include <Ice/StreamF.h>";
+
+ if(!p->hasNonLocalClassDefs())
+ {
+ C << "\n#include <Ice/LocalException.h>";
+ }
+
+ if(_stream)
+ {
+ C << "\n#include <Ice/Stream.h>";
+ }
+ }
+
if(_checksum)
{
C << "\n#include <Ice/SliceChecksums.h>";
@@ -459,11 +468,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
H << sp << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
- if(_stream)
- {
- H << sp << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
- H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
- }
+ H << sp << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
+ H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
TypeStringList memberList;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -568,6 +574,25 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
C << eb;
}
+ else
+ {
+ //
+ // Emit placeholder functions to catch errors.
+ //
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr&) const";
+ C << sb;
+ C << nl << "Ice::MarshalException ex(__FILE__, __LINE__);";
+ C << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";";
+ C << nl << "throw ex;";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr&, bool)";
+ C << sb;
+ C << nl << "Ice::MarshalException ex(__FILE__, __LINE__);";
+ C << nl << "ex.reason = \"exception " << scoped .substr(2)<< " was not generated with stream support\";";
+ C << nl << "throw ex;";
+ C << eb;
+ }
if(p->usesClasses())
{
@@ -2375,11 +2400,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
H << sp;
H << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
- if(_stream)
- {
- H << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
- H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
- }
+ H << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
+ H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
TypeStringList memberList;
DataMemberList dataMembers = p->dataMembers();
@@ -2475,6 +2497,26 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C.restoreIndent();
C << eb;
}
+ else
+ {
+ //
+ // Emit placeholder functions to catch errors.
+ //
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr&) const";
+ C << sb;
+ C << nl << "Ice::MarshalException ex(__FILE__, __LINE__);";
+ C << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
+ C << nl << "throw ex;";
+ C << eb;
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr&, bool)";
+ C << sb;
+ C << nl << "Ice::MarshalException ex(__FILE__, __LINE__);";
+ C << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
+ C << nl << "throw ex;";
+ C << eb;
+ }
if(!p->isAbstract())
{