summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/BasicStream.h10
-rw-r--r--cpp/include/Ice/Exception.h33
-rw-r--r--cpp/include/Ice/Object.h5
-rw-r--r--cpp/include/Slice/Parser.h1
-rw-r--r--cpp/slice/Ice/LocalException.ice32
-rw-r--r--cpp/src/Ice/BasicStream.cpp66
-rw-r--r--cpp/src/Ice/Exception.cpp52
-rw-r--r--cpp/src/Ice/Incoming.cpp14
-rw-r--r--cpp/src/Ice/Outgoing.cpp11
-rw-r--r--cpp/src/Ice/Proxy.cpp4
-rw-r--r--cpp/src/Ice/TraceUtil.cpp9
-rw-r--r--cpp/src/Slice/Parser.cpp12
-rw-r--r--cpp/src/slice2cpp/Gen.cpp335
13 files changed, 354 insertions, 230 deletions
diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h
index d420e0b299c..0d98246f657 100644
--- a/cpp/include/Ice/BasicStream.h
+++ b/cpp/include/Ice/BasicStream.h
@@ -16,6 +16,13 @@
#include <Ice/ProxyF.h>
#include <Ice/Buffer.h>
+namespace Ice
+{
+
+class UserException;
+
+}
+
namespace IceInternal
{
@@ -92,6 +99,9 @@ public:
void write(const ::Ice::ObjectPtr&);
void read(::Ice::ObjectPtr&, const std::string&);
+ void write(const ::Ice::UserException&);
+ void read(::Ice::UserException*&, const std::string&);
+
private:
InstancePtr _instance;
diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h
index a32744e9d53..7e37ac8c033 100644
--- a/cpp/include/Ice/Exception.h
+++ b/cpp/include/Ice/Exception.h
@@ -14,6 +14,13 @@
#include <IceUtil/Exception.h>
#include <Ice/Config.h>
+namespace IceInternal
+{
+
+class BasicStream;
+
+}
+
namespace Ice
{
@@ -26,10 +33,10 @@ public:
LocalException(const char*, int);
LocalException(const LocalException&);
LocalException& operator=(const LocalException&);
- virtual std::string _name() const;
- virtual std::ostream& _print(std::ostream&) const;
- virtual Exception* _clone() const;
- virtual void _throw() const;
+ virtual std::string _name() const = 0;
+ virtual std::ostream& _print(std::ostream&) const = 0;
+ virtual Exception* _clone() const = 0;
+ virtual void _throw() const = 0;
};
class ICE_API UserException : public IceUtil::Exception
@@ -39,12 +46,18 @@ public:
UserException();
UserException(const UserException&);
UserException& operator=(const UserException&);
- virtual std::string _name() const;
- virtual std::ostream& _print(std::ostream&) const;
- virtual Exception* _clone() const;
- virtual void _throw() const;
+ virtual std::string _name() const = 0;
+ virtual std::ostream& _print(std::ostream&) const = 0;
+ virtual Exception* _clone() const = 0;
+ virtual void _throw() const = 0;
+
+ virtual const std::string* _exceptionIds() const = 0;
+ virtual void __write(::IceInternal::BasicStream*) const = 0;
+ virtual void __read(::IceInternal::BasicStream*) = 0;
};
+class UnknownLocalException;
+class UnknownUserException;
class UnknownException;
class VersionMismatchException;
class CommunicatorDestroyedException;
@@ -82,8 +95,8 @@ class AbortBatchRequestException;
namespace IceUtil
{
-std::ostream& printException(std::ostream&, const Ice::LocalException&);
-std::ostream& printException(std::ostream&, const Ice::UserException&);
+std::ostream& printException(std::ostream&, const Ice::UnknownLocalException&);
+std::ostream& printException(std::ostream&, const Ice::UnknownUserException&);
std::ostream& printException(std::ostream&, const Ice::UnknownException&);
std::ostream& printException(std::ostream&, const Ice::VersionMismatchException&);
std::ostream& printException(std::ostream&, const Ice::CommunicatorDestroyedException&);
diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h
index de09515af6d..b1241cbb885 100644
--- a/cpp/include/Ice/Object.h
+++ b/cpp/include/Ice/Object.h
@@ -28,7 +28,8 @@ enum DispatchStatus
DispatchLocationForward,
DispatchObjectNotExist,
DispatchOperationNotExist,
- DispatchLocalException,
+ DispatchUnknownLocalException,
+ DispatchUnknownUserException,
DispatchUnknownException
};
@@ -68,7 +69,7 @@ public:
virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const std::string&);
virtual bool __isMutating(const std::string&);
- virtual void __write(::IceInternal::BasicStream*) = 0;
+ virtual void __write(::IceInternal::BasicStream*) const = 0;
virtual void __read(::IceInternal::BasicStream*) = 0;
};
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h
index b3d9e7ec2e8..0c4b4da1de5 100644
--- a/cpp/include/Slice/Parser.h
+++ b/cpp/include/Slice/Parser.h
@@ -439,6 +439,7 @@ public:
DataMemberPtr createDataMember(const std::string&, const TypePtr&);
DataMemberList dataMembers();
ExceptionPtr base();
+ ExceptionList allBases();
bool isLocal();
virtual ContainedType containedType();
virtual bool uses(const ConstructedPtr&);
diff --git a/cpp/slice/Ice/LocalException.ice b/cpp/slice/Ice/LocalException.ice
index f59b8ebd752..d5aa67ca6ce 100644
--- a/cpp/slice/Ice/LocalException.ice
+++ b/cpp/slice/Ice/LocalException.ice
@@ -16,10 +16,40 @@ module Ice
/**
*
+ * This exception is raised if an operation call on a server raises a
+ * local exception. Since the exception is local, it is not
+ * transmitted by the Ice protocol. Instead, the client only receives
+ * an [UknownLocalException] for all local exceptions being raised by
+ * the server.
+ *
+ **/
+local exception UnknownLocalException
+{
+};
+
+/**
+ *
+ * This exception is raised if an operation call on a server raises a
+ * user exception which is not declared in the exception's
+ * <literal>throws</literal> clause. Such undeclared exceptions are
+ * not transmitted from the server to the client by the Ice protocol,
+ * but instead the client just gets an [UnknownUserException]. This is
+ * necessary in order to not violate the contract established by an
+ * operation's signature: Only local exceptions and user exceptions
+ * declared in the <literal>throws</literal> clause can be raised.
+ *
+ **/
+local exception UnknownUserException
+{
+};
+
+/**
+ *
* This exception is raised if an operation call on a server raises an
* unknown exception. For example, for C++, this exception is raised
* if the server throws a C++ exception that is not directly or
- * indirectly derived from <literal>Ice::Exception</literal>.
+ * indirectly derived from <literal>Ice::LocalException</literal> or
+ * <literal>Ice::UserException</literal>.
*
**/
local exception UnknownException
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index a2cb118e5df..245b687e5e9 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -848,3 +848,69 @@ IceInternal::BasicStream::read(ObjectPtr& v, const string& type)
throw ServantUnmarshalException(__FILE__, __LINE__);
}
+
+void
+IceInternal::BasicStream::write(const UserException& v)
+{
+ const string* exceptionIds = v._exceptionIds();
+ Int sz = 0;
+ while (exceptionIds[sz] != "::Ice::UserException")
+ {
+ ++sz;
+ }
+ write(sz);
+ for (int i = 0; i < sz; i++)
+ {
+ write(exceptionIds[i]);
+ }
+ v.__write(this);
+}
+
+void
+IceInternal::BasicStream::read(UserException*& v, const string& type)
+{
+/*
+ vector<string> exceptionIds;
+ read(exceptionIds);
+ exceptionIds.push_back("::Ice::UserException");
+ vector<string>::const_iterator p;
+ for (p = exceptionIds.begin(); p != exceptionIds.end(); ++p)
+ {
+ UserExceptionFactoryPtr factory = _instance->userExceptionFactoryManager()->find(*p);
+
+ if (factory)
+ {
+ v = factory->create(*p);
+ try
+ {
+ v->__read(this);
+ }
+ catch(...)
+ {
+ delete v;
+ throw;
+ }
+
+ for (; p != exceptionIds.end(); ++p)
+ {
+ if (*p == type)
+ {
+ return;
+ }
+ }
+
+ delete v;
+ throw UserExceptionUnmarshalException(__FILE__, __LINE__);
+ }
+
+ if (*p == type)
+ {
+ return;
+ }
+
+ skipEncaps();
+ }
+
+ throw UserExceptionUnmarshalException(__FILE__, __LINE__);
+*/
+}
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index f9e966495ab..19b2102d4dd 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -32,30 +32,6 @@ Ice::LocalException::operator=(const LocalException& ex)
return *this;
}
-string
-Ice::LocalException::_name() const
-{
- return "Ice::LocalException";
-}
-
-ostream&
-Ice::LocalException::_print(ostream& out) const
-{
- return IceUtil::printException(out, *this);
-}
-
-Exception*
-Ice::LocalException::_clone() const
-{
- return new LocalException(*this);
-}
-
-void
-Ice::LocalException::_throw() const
-{
- throw *this;
-}
-
Ice::UserException::UserException()
{
}
@@ -72,39 +48,15 @@ Ice::UserException::operator=(const UserException& ex)
return *this;
}
-string
-Ice::UserException::_name() const
-{
- return "Ice::UserException";
-}
-
-ostream&
-Ice::UserException::_print(ostream& out) const
-{
- return IceUtil::printException(out, *this);
-}
-
-Exception*
-Ice::UserException::_clone() const
-{
- return new UserException(*this);
-}
-
-void
-Ice::UserException::_throw() const
-{
- throw *this;
-}
-
ostream&
-IceUtil::printException(ostream& out, const LocalException& ex)
+IceUtil::printException(ostream& out, const UnknownLocalException& ex)
{
IceUtil::printException(out, static_cast<const IceUtil::Exception&>(ex));
return out << ": unknown local exception";
}
ostream&
-IceUtil::printException(ostream& out, const UserException& ex)
+IceUtil::printException(ostream& out, const UnknownUserException& ex)
{
IceUtil::printException(out, static_cast<const IceUtil::Exception&>(ex));
return out << ": unknown user exception";
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 6d1547eb060..03699a7938c 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -96,14 +96,24 @@ IceInternal::Incoming::invoke(BasicStream& is)
_os.write(p._prx);
return;
}
- catch(const Exception&)
+ catch(const LocalException&)
{
if (locator && servant)
{
locator->finished(_adapter, identity, servant, operation, cookie);
}
_os.b.resize(statusPos);
- _os.write(static_cast<Byte>(DispatchLocalException));
+ _os.write(static_cast<Byte>(DispatchUnknownLocalException));
+ throw;
+ }
+ catch(const UserException&)
+ {
+ if (locator && servant)
+ {
+ locator->finished(_adapter, identity, servant, operation, cookie);
+ }
+ _os.b.resize(statusPos);
+ _os.write(static_cast<Byte>(DispatchUnknownUserException));
throw;
}
catch(...)
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index 942e72c27f1..2974197d876 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -225,10 +225,17 @@ IceInternal::Outgoing::finished(BasicStream& is)
break;
}
- case DispatchLocalException:
+ case DispatchUnknownLocalException:
{
_state = StateLocalException;
- _exception = auto_ptr<LocalException>(new LocalException(__FILE__, __LINE__));
+ _exception = auto_ptr<LocalException>(new UnknownLocalException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ _state = StateLocalException;
+ _exception = auto_ptr<LocalException>(new UnknownUserException(__FILE__, __LINE__));
break;
}
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 1d2ac95ecbb..fdd541f7866 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -438,7 +438,7 @@ IceDelegateM::Ice::Object::_isA(const string& s)
__os->write(s);
if (!__out.invoke())
{
- throw ::Ice::UserException();
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__);
}
bool __ret;
__is->read(__ret);
@@ -453,7 +453,7 @@ IceDelegateM::Ice::Object::_ping()
__os->write("_ping");
if (!__out.invoke())
{
- throw ::Ice::UserException();
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__);
}
}
diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp
index aee573b13bb..0707a7ffcb5 100644
--- a/cpp/src/Ice/TraceUtil.cpp
+++ b/cpp/src/Ice/TraceUtil.cpp
@@ -173,9 +173,14 @@ IceInternal::traceReply(const char* heading, const BasicStream& str, const ::Ice
s << "(operation not exist)";
break;
}
- case DispatchLocalException:
+ case DispatchUnknownLocalException:
{
- s << "(local exception)";
+ s << "(unknown local exception)";
+ break;
+ }
+ case DispatchUnknownUserException:
+ {
+ s << "(unknown user exception)";
break;
}
case DispatchUnknownException:
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 49728aadc20..2ceef4df0e2 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -1568,6 +1568,18 @@ Slice::Exception::base()
return _base;
}
+ExceptionList
+Slice::Exception::allBases()
+{
+ ExceptionList result;
+ if (_base)
+ {
+ result = _base->allBases();
+ result.push_front(_base);
+ }
+ return result;
+}
+
bool
Slice::Exception::isLocal()
{
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 68d6bef1577..1317077be43 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -176,8 +176,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -185,8 +184,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -202,8 +200,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
string scoped = p->scoped();
ExceptionPtr base = p->base();
- H << sp;
- H << nl << "struct " << _dllExport << name << " : ";
+ H << sp << nl << "struct " << name << " : ";
H.useCurrentPosAsIndent();
if (!base)
{
@@ -225,7 +222,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if (p->isLocal())
{
- H << nl << name << "(const char*, int);";
+ H << nl << _dllExport << name << "(const char*, int);";
C << sp << nl << scoped.substr(2) << "::" << name << "(const char* file, int line) : ";
C.inc();
if (!base)
@@ -242,13 +239,13 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
}
else
{
- H << nl << name << "();";
+ H << nl << _dllExport << name << "();";
C << sp << nl << scoped.substr(2) << "::" << name << "()";
C << sb;
C << eb;
}
- H << nl << name << "(const " << name << "&);";
+ H << nl << _dllExport << name << "(const " << name << "&);";
C << sp << nl << scoped.substr(2) << "::" << name << "(const " << name << "& ex) : ";
C.inc();
if (!base)
@@ -270,7 +267,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
C << sb;
C << eb;
- H << nl << name << "& operator=(const " << name << "&);";
+ H << nl << _dllExport << name << "& operator=(const " << name << "&);";
C << sp << nl << scoped << '&' << nl << scoped.substr(2) << "::operator=(const " << name << "& ex)";
C << sb;
if (!base)
@@ -291,29 +288,60 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
C << nl << "return *this;";
C << eb;
- H << nl << "virtual ::std::string _name() const;";
+ H << nl << _dllExport << "virtual ::std::string _name() const;";
C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::_name() const";
C << sb;
C << nl << "return \"" << scoped.substr(2) << "\";";
C << eb;
- H << nl << "virtual ::std::ostream& _print(::std::ostream&) const;";
+ H << nl << _dllExport << "virtual ::std::ostream& _print(::std::ostream&) const;";
C << sp << nl << "::std::ostream&" << nl << scoped.substr(2) << "::_print(::std::ostream& out) const";
C << sb;
C << nl << "return IceUtil::printException(out, *this);";
C << eb;
- H << nl << "virtual ::Ice::Exception* _clone() const;";
+ H << nl << _dllExport << "virtual ::Ice::Exception* _clone() const;";
C << sp << nl << "::Ice::Exception*" << nl << scoped.substr(2) << "::_clone() const";
C << sb;
C << nl << "return new " << name << "(*this);";
C << eb;
- H << nl << "virtual void _throw() const;";
+ H << nl << _dllExport << "virtual void _throw() const;";
C << sp << nl << "void" << nl << scoped.substr(2) << "::_throw() const";
C << sb;
C << nl << "throw *this;";
C << eb;
+
+ if (!p->isLocal())
+ {
+ ExceptionList allBases = p->allBases();
+ StringList exceptionIds;
+ transform(allBases.begin(), allBases.end(), back_inserter(exceptionIds),
+ ::IceUtil::memFun(&Exception::scoped));
+ exceptionIds.push_front(scoped);
+ exceptionIds.push_back("::Ice::UserException");
+
+ StringList::const_iterator q;
+
+ H << sp << nl << _dllExport << "static ::std::string __exceptionIds[" << exceptionIds.size() << "];";
+ H << sp << nl << _dllExport << "virtual const ::std::string* _exceptionIds() const;";
+ C << sp << nl << "::std::string " << scoped.substr(2) << "::__exceptionIds[" << exceptionIds.size() << "] =";
+ C << sb;
+ q = exceptionIds.begin();
+ while (q != exceptionIds.end())
+ {
+ C << nl << '"' << *q << '"';
+ if (++q != exceptionIds.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+ C << sp << nl << "const ::std::string*" << nl << scoped.substr(2) << "::_exceptionIds() const";
+ C << sb;
+ C << nl << "return __exceptionIds;";
+ C << eb;
+ }
return true;
}
@@ -321,6 +349,62 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
void
Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
{
+ if (!p->isLocal())
+ {
+ string name = p->name();
+ string scoped = p->scoped();
+
+ ExceptionPtr base = p->base();
+
+ H << sp << nl << _dllExport << "virtual void __write(::IceInternal::BasicStream*) const;";
+ H << nl << _dllExport << "virtual void __read(::IceInternal::BasicStream*);";
+ TypeStringList memberList;
+ DataMemberList dataMembers = p->dataMembers();
+ for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ memberList.push_back(make_pair((*q)->type(), (*q)->name()));
+ }
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
+ C << sb;
+ C << nl << "__os->startWriteEncaps();";
+ writeMarshalCode(C, memberList, 0);
+ C << nl << "__os->endWriteEncaps();";
+ if (base)
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << base->name() << "::__write(__os);";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << base->scoped() << "::__write(__os);";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ }
+ C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
+ C << sb;
+ C << nl << "__is->startReadEncaps();";
+ writeUnmarshalCode(C, memberList, 0);
+ C << nl << "__is->endReadEncaps();";
+ if (base)
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << base->name() << "::__read(__is);";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << base->scoped() << "::__read(__is);";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ }
+ C << eb;
+ }
H << eb << ';';
}
@@ -329,8 +413,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
{
string name = p->name();
- H << sp;
- H << nl << "struct " << name;
+ H << sp << nl << "struct " << name;
H << sb;
return true;
@@ -342,8 +425,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
string name = p->name();
string scoped = p->scoped();
- H << sp;
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;"; // NOT virtual!
+ H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;"; // NOT virtual!
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*);"; // NOT virtual!
H << eb << ';';
@@ -353,13 +435,11 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
{
memberList.push_back(make_pair((*q)->type(), (*q)->name()));
}
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
writeMarshalCode(C, memberList, 0);
C << eb;
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
writeUnmarshalCode(C, memberList, 0);
C << eb;
@@ -370,8 +450,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
string name = p->name();
string s = typeToString(p->type());
- H << sp;
- H << nl << s << ' ' << name << ';';
+ H << sp << nl << s << ' ' << name << ';';
}
void
@@ -384,8 +463,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
{
s.insert(0, " ");
}
- H << sp;
- H << nl << "typedef ::std::vector<" << s << "> " << name << ';';
+ H << sp << nl << "typedef ::std::vector<" << s << "> " << name << ';';
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if (!builtin)
@@ -393,14 +471,12 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
string scoped = p->scoped();
string scope = p->scope();
- H << sp;
- H << nl << "class __U__" << name << " { };";
+ H << sp << nl << "class __U__" << name << " { };";
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name
<< ");";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped
- << "& v, " << scope << "__U__" << name << ')';
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scoped << "& v, " << scope << "__U__" << name << ")";
C << sb;
C << nl << "__os->write(::Ice::Int(v.size()));";
C << nl << scoped << "::const_iterator p;";
@@ -409,8 +485,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
writeMarshalUnmarshalCode(C, type, "*p", true);
C << eb;
C << eb;
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
<< "& v, " << scope << "__U__" << name << ')';
C << sb;
C << nl << "::Ice::Int sz;";
@@ -448,19 +523,16 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
ks.insert(0, " ");
}
string vs = typeToString(valueType);
- H << sp;
- H << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';';
+ H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';';
string scoped = p->scoped();
string scope = p->scope();
- H << sp;
- H << nl << "class __U__" << name << " { };";
+ H << sp << nl << "class __U__" << name << " { };";
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name << ");";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped
- << "& v, " << scope << "__U__" << name << ')';
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped
+ << "& v, " << scope << "__U__" << name << ")";
C << sb;
C << nl << "__os->write(::Ice::Int(v.size()));";
C << nl << scoped << "::const_iterator p;";
@@ -470,8 +542,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
writeMarshalUnmarshalCode(C, valueType, "p->second", true);
C << eb;
C << eb;
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
<< "& v, " << scope << "__U__" << name << ')';
C << sb;
C << nl << "::Ice::Int sz;";
@@ -491,8 +562,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
{
string name = p->name();
EnumeratorList enumerators = p->getEnumerators();
- H << sp;
- H << nl << "enum " << name;
+ H << sp << nl << "enum " << name;
H << sb;
EnumeratorList::const_iterator en = enumerators.begin();
while (en != enumerators.end())
@@ -510,11 +580,10 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
int sz = enumerators.size();
- H << sp;
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
+ H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped << " v)";
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
+ << " v)";
C << sb;
if (sz <= 0x7f)
{
@@ -533,8 +602,8 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
C << nl << "__os->write(static_cast< ::Ice::Long>(v));";
}
C << eb;
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped << "& v)";
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v)";
C << sb;
if (sz <= 0x7f)
{
@@ -576,8 +645,7 @@ Slice::Gen::ProxyDeclVisitor::visitUnitStart(const UnitPtr& p)
return false;
}
- H << sp;
- H << nl << "namespace IceProxy" << nl << '{';
+ H << sp << nl << "namespace IceProxy" << nl << '{';
return true;
}
@@ -585,8 +653,7 @@ Slice::Gen::ProxyDeclVisitor::visitUnitStart(const UnitPtr& p)
void
Slice::Gen::ProxyDeclVisitor::visitUnitEnd(const UnitPtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -599,8 +666,7 @@ Slice::Gen::ProxyDeclVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -608,8 +674,7 @@ Slice::Gen::ProxyDeclVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::ProxyDeclVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
void
@@ -622,8 +687,7 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p)
string name = p->name();
- H << sp;
- H << nl << "class " << name << ';';
+ H << sp << nl << "class " << name << ';';
}
Slice::Gen::ProxyVisitor::ProxyVisitor(Output& h, Output& c, const string& dllExport) :
@@ -639,8 +703,7 @@ Slice::Gen::ProxyVisitor::visitUnitStart(const UnitPtr& p)
return false;
}
- H << sp;
- H << nl << "namespace IceProxy" << nl << '{';
+ H << sp << nl << "namespace IceProxy" << nl << '{';
return true;
}
@@ -648,8 +711,7 @@ Slice::Gen::ProxyVisitor::visitUnitStart(const UnitPtr& p)
void
Slice::Gen::ProxyVisitor::visitUnitEnd(const UnitPtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -662,8 +724,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -671,8 +732,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::ProxyVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -687,8 +747,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
string scoped = p->scoped();
ClassList bases = p->bases();
- H << sp;
- H << nl << "class " << _dllExport << name << " : ";
+ H << sp << nl << "class " << _dllExport << name << " : ";
if (bases.empty())
{
H << "virtual public ::IceProxy::Ice::Object";
@@ -722,21 +781,17 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p)
string scoped = p->scoped();
H.dec();
- H << sp;
- H << nl << "private: ";
+ H << sp << nl << "private: ";
H.inc();
- H << sp;
- H << nl << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();";
+ H << sp << nl << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();";
H << nl << "virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();";
H << eb << ';';
- C << sp;
- C << nl << "::IceInternal::Handle< ::IceDelegateM::Ice::Object>";
+ C << sp << nl << "::IceInternal::Handle< ::IceDelegateM::Ice::Object>";
C << nl << "IceProxy" << scoped << "::__createDelegateM()";
C << sb;
C << nl << "return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM" << scoped << ");";
C << eb;
- C << sp;
- C << nl << "::IceInternal::Handle< ::IceDelegateD::Ice::Object>";
+ C << sp << nl << "::IceInternal::Handle< ::IceDelegateD::Ice::Object>";
C << nl << "IceProxy" << scoped << "::__createDelegateD()";
C << sb;
C << nl << "return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD" << scoped << ");";
@@ -799,10 +854,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
paramsDecl += ')';
args += ')';
- H << sp;
- H << nl << retS << ' ' << name << params << ';';
- C << sp;
- C << nl << retS << nl << "IceProxy" << scoped << paramsDecl;
+ H << sp << nl << retS << ' ' << name << params << ';';
+ C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl;
C << sb;
C << nl << "int __cnt = 0;";
C << nl << "while (true)";
@@ -859,8 +912,7 @@ Slice::Gen::DelegateVisitor::visitUnitStart(const UnitPtr& p)
return false;
}
- H << sp;
- H << nl << "namespace IceDelegate" << nl << '{';
+ H << sp << nl << "namespace IceDelegate" << nl << '{';
return true;
}
@@ -868,8 +920,7 @@ Slice::Gen::DelegateVisitor::visitUnitStart(const UnitPtr& p)
void
Slice::Gen::DelegateVisitor::visitUnitEnd(const UnitPtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -882,8 +933,7 @@ Slice::Gen::DelegateVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -891,8 +941,7 @@ Slice::Gen::DelegateVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::DelegateVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -906,8 +955,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
string name = p->name();
ClassList bases = p->bases();
- H << sp;
- H << nl << "class " << _dllExport << name << " : ";
+ H << sp << nl << "class " << _dllExport << name << " : ";
if (bases.empty())
{
H << "virtual public ::IceDelegate::Ice::Object";
@@ -978,8 +1026,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p)
params += ')';
- H << sp;
- H << nl << "virtual " << retS << ' ' << name << params << " = 0;";
+ H << sp << nl << "virtual " << retS << ' ' << name << params << " = 0;";
}
Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, const string& dllExport) :
@@ -995,8 +1042,7 @@ Slice::Gen::DelegateMVisitor::visitUnitStart(const UnitPtr& p)
return false;
}
- H << sp;
- H << nl << "namespace IceDelegateM" << nl << '{';
+ H << sp << nl << "namespace IceDelegateM" << nl << '{';
return true;
}
@@ -1004,8 +1050,7 @@ Slice::Gen::DelegateMVisitor::visitUnitStart(const UnitPtr& p)
void
Slice::Gen::DelegateMVisitor::visitUnitEnd(const UnitPtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -1018,8 +1063,7 @@ Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -1027,8 +1071,7 @@ Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::DelegateMVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -1043,8 +1086,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
string scoped = p->scoped();
ClassList bases = p->bases();
- H << sp;
- H << nl << "class " << _dllExport << name << " : ";
+ H << sp << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
H << "virtual public ::IceDelegate" << scoped << ',';
if (bases.empty())
@@ -1129,10 +1171,8 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
ExceptionList throws = p->throws();
- H << sp;
- H << nl << "virtual " << retS << ' ' << name << params << ';';
- C << sp;
- C << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl;
+ H << sp << nl << "virtual " << retS << ' ' << name << params << ';';
+ C << sp << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl;
C << sb;
C << nl << "::IceInternal::Outgoing __out(__emitter, __reference);";
if (ret || !outParams.empty() || !throws.empty())
@@ -1172,12 +1212,12 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
C << eb;
}
C << eb;
- C << nl << "throw ::Ice::UserException();";
+ C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);";
}
else
*/
{
- C << nl << "throw ::Ice::UserException();";
+ C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);";
}
C << eb;
writeAllocateCode(C, TypeStringList(), ret);
@@ -1202,8 +1242,7 @@ Slice::Gen::DelegateDVisitor::visitUnitStart(const UnitPtr& p)
return false;
}
- H << sp;
- H << nl << "namespace IceDelegateD" << nl << '{';
+ H << sp << nl << "namespace IceDelegateD" << nl << '{';
return true;
}
@@ -1211,8 +1250,7 @@ Slice::Gen::DelegateDVisitor::visitUnitStart(const UnitPtr& p)
void
Slice::Gen::DelegateDVisitor::visitUnitEnd(const UnitPtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -1225,8 +1263,7 @@ Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -1234,8 +1271,7 @@ Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::DelegateDVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
bool
@@ -1250,8 +1286,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
string scoped = p->scoped();
ClassList bases = p->bases();
- H << sp;
- H << nl << "class " << _dllExport << name << " : ";
+ H << sp << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
H << "virtual public ::IceDelegate" << scoped << ',';
if (bases.empty())
@@ -1343,10 +1378,8 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
paramsDecl += ')';
args += ')';
- H << sp;
- H << nl << "virtual " << retS << ' ' << name << params << ';';
- C << sp;
- C << nl << retS << nl << "IceDelegateD" << scoped << paramsDecl;
+ H << sp << nl << "virtual " << retS << ' ' << name << params << ';';
+ C << sp << nl << retS << nl << "IceDelegateD" << scoped << paramsDecl;
C << sb;
C << nl << "::IceInternal::Direct __direct(__adapter, __reference, \"" << name << "\");";
C << nl << cl->scoped() << "* __servant = dynamic_cast< " << cl->scoped() << "*>(__direct.servant().get());";
@@ -1378,8 +1411,7 @@ Slice::Gen::ObjectDeclVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -1387,8 +1419,7 @@ Slice::Gen::ObjectDeclVisitor::visitModuleStart(const ModulePtr& p)
void
Slice::Gen::ObjectDeclVisitor::visitModuleEnd(const ModulePtr& p)
{
- H << sp;
- H << nl << '}';
+ H << sp << nl << '}';
}
void
@@ -1396,8 +1427,7 @@ Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p)
{
string name = p->name();
- H << sp;
- H << nl << "class " << name << ';';
+ H << sp << nl << "class " << name << ';';
}
Slice::Gen::ObjectVisitor::ObjectVisitor(Output& h, Output& c, const string& dllExport) :
@@ -1415,8 +1445,7 @@ Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p)
string name = p->name();
- H << sp;
- H << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << name << nl << '{';
return true;
}
@@ -1582,18 +1611,18 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
void
Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
- string name = p->name();
- string scoped = p->scoped();
-
- ClassList bases = p->bases();
- ClassDefPtr base;
- if (!bases.empty() && !bases.front()->isInterface())
- {
- base = bases.front();
- }
-
if (!p->isLocal())
{
+ string name = p->name();
+ string scoped = p->scoped();
+
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ if (!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
+
string exp2;
if (_dllExport.size())
{
@@ -1707,7 +1736,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << eb;
}
H << sp;
- H << nl << exp2 << "virtual void __write(::IceInternal::BasicStream*);";
+ H << nl << exp2 << "virtual void __write(::IceInternal::BasicStream*) const;";
H << nl << exp2 << "virtual void __read(::IceInternal::BasicStream*);";
TypeStringList memberList;
DataMemberList dataMembers = p->dataMembers();
@@ -1716,7 +1745,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
memberList.push_back(make_pair((*q)->type(), (*q)->name()));
}
C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os)";
+ C << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
C << nl << "__os->startWriteEncaps();";
writeMarshalCode(C, memberList, 0);
@@ -1884,20 +1913,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
{
C << nl << "catch(const " << (*r)->scoped() << "& __ex)";
C << sb;
-/*
- C << nl << "__os->write(" << cnt++ << ");";
- if (ClassDeclPtr::dynamicCast(*r) || ProxyPtr::dynamicCast(*r))
- {
- string s = "static_cast< ";
- s += inputTypeToString(*r);
- s += ">(__ex)";
- writeMarshalUnmarshalCode(C, *r, s, true);
- }
- else
- {
- writeMarshalUnmarshalCode(C, *r, "__ex", true);
- }
-*/
+ C << nl << "__os->write(__ex);";
C << nl << "return ::IceInternal::DispatchUserException;";
C << eb;
}
@@ -2070,7 +2086,8 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
string scope = p->scope();
C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped << "Prx& v)";
+ C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped
+ << "Prx& v)";
C << sb;
C << nl << "__os->write(::Ice::ObjectPrx(v));";
C << eb;