summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Freeze/DBI.cpp2
-rw-r--r--cpp/src/Ice/BasicStream.cpp141
-rw-r--r--cpp/src/Ice/Exception.cpp24
-rw-r--r--cpp/src/Ice/StreamI.cpp4
-rw-r--r--cpp/src/Ice/StreamI.h2
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp22
-rw-r--r--cpp/src/slice2cpp/Gen.cpp22
7 files changed, 80 insertions, 137 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp
index 4afec5642d0..6eae037d8b4 100644
--- a/cpp/src/Freeze/DBI.cpp
+++ b/cpp/src/Freeze/DBI.cpp
@@ -520,7 +520,7 @@ Freeze::DBI::getServant(const string& ident)
stream.i = stream.b.begin();
ObjectPtr servant;
- stream.read(servant, "::Ice::Object");
+ stream.read("", servant);
if (!servant)
{
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index 18240487944..ad1ce577113 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -653,7 +653,7 @@ IceInternal::BasicStream::read(string& v)
{
if (static_cast<vector<string>::size_type>(-(len + 1)) >= _encapsStack.back().stringsRead.size())
{
- throw StringEncodingException(__FILE__, __LINE__);
+ throw IllegalIndirectionException(__FILE__, __LINE__);
}
v = _encapsStack.back().stringsRead[-(len + 1)];
}
@@ -742,7 +742,7 @@ IceInternal::BasicStream::read(wstring& v)
{
if (static_cast<vector<wstring>::size_type>(-(len + 1)) >= _encapsStack.back().wstringsRead.size())
{
- throw StringEncodingException(__FILE__, __LINE__);
+ throw IllegalIndirectionException(__FILE__, __LINE__);
}
v = _encapsStack.back().wstringsRead[-(len + 1)];
}
@@ -809,138 +809,93 @@ IceInternal::BasicStream::write(const ObjectPtr& v)
else
{
write(Int(-1));
- const char** classIds = v->__getClassIds();
- Int sz = 0;
- while (strcmp(classIds[sz], "::Ice::Object") != 0)
- {
- ++sz;
- }
- write(sz);
- for (int i = 0; i < sz; i++)
- {
- write(string(classIds[i]));
- }
+ write(v->__getClassIds()[0]);
v->__write(this);
Int num = _encapsStack.back().objectsWritten.size();
_encapsStack.back().objectsWritten[v] = num;
}
}
-void
-IceInternal::BasicStream::read(ObjectPtr& v, const char* type)
+bool
+IceInternal::BasicStream::read(const char* signatureType, ObjectPtr& v)
{
Int pos;
read(pos);
-
+
if (pos >= 0)
{
if (static_cast<vector<ObjectPtr>::size_type>(pos) >= _encapsStack.back().objectsRead.size())
{
- throw ObjectEncodingException(__FILE__, __LINE__);
+ throw IllegalIndirectionException(__FILE__, __LINE__);
}
v = _encapsStack.back().objectsRead[pos];
+ return true;
}
else
{
- vector<string> classIds;
- read(classIds);
- classIds.push_back("::Ice::Object");
- for (vector<string>::const_iterator p = classIds.begin(); p != classIds.end(); ++p)
+ string id;
+ read(id);
+ ObjectFactoryPtr factory = _instance->servantFactoryManager()->find(id);
+
+ if (factory)
{
- ObjectFactoryPtr factory = _instance->servantFactoryManager()->find(*p);
-
- if (factory)
- {
- v = factory->create(*p);
- v->__read(this);
-
- for (; p != classIds.end(); ++p)
- {
- if (*p == type)
- {
- _encapsStack.back().objectsRead.push_back(v);
- return;
- }
- }
-
- throw ServantUnmarshalException(__FILE__, __LINE__);
- }
-
- if (*p == type)
+ v = factory->create(id);
+ if (v)
{
- if (!v)
- {
- throw NoObjectFactoryException(__FILE__, __LINE__);
- }
v->__read(this);
- _encapsStack.back().objectsRead.push_back(v);
- return;
+ return true;
}
-
- skipEncaps();
}
-
- throw ServantUnmarshalException(__FILE__, __LINE__);
+
+ if (id == signatureType)
+ {
+ return false;
+ }
+
+ throw NoObjectFactoryException(__FILE__, __LINE__);
}
}
void
IceInternal::BasicStream::write(const UserException& v)
{
- const char** exceptionIds = v.__getExceptionIds();
- Int sz = 0;
- while (strcmp(exceptionIds[sz], "::Ice::UserException") != 0)
- {
- ++sz;
- }
- write(sz);
- for (int i = 0; i < sz; i++)
- {
- write(string(exceptionIds[i]));
- }
+ write(v.__getExceptionIds()[0]);
v.__write(this);
}
Int
-IceInternal::BasicStream::throwException(const char** typesBegin, const char** typesEnd)
+IceInternal::BasicStream::throwException(const char** throwsBegin, const char** throwsEnd)
{
- vector<string> exceptionIds;
- read(exceptionIds);
- exceptionIds.push_back("::Ice::UserException");
- for (vector<string>::const_iterator p = exceptionIds.begin(); p != exceptionIds.end(); ++p)
- {
- UserExceptionFactoryPtr factory = _instance->userExceptionFactoryManager()->find(*p);
+ string id;
+ read(id);
+ UserExceptionFactoryPtr factory = _instance->userExceptionFactoryManager()->find(id);
- if (factory)
+ if (factory)
+ {
+ try
{
- try
- {
- factory->createAndThrow(*p);
- }
- catch (UserException& ex)
+ factory->createAndThrow(id);
+ }
+ catch (UserException& ex)
+ {
+ for (const char** p = ex.__getExceptionIds(); strcmp(*p, "::Ice::UserException") != 0; ++p)
{
- ex.__read(this);
- for (; p != exceptionIds.end(); ++p)
+ if (binary_search(throwsBegin, throwsEnd, *p))
{
- pair<const char**, const char**> q = equal_range(typesBegin, typesEnd, *p);
- if (q.first != q.second)
- {
- ex._throw();
- }
+ ex.__read(this);
+ ex._throw();
}
}
-
- throw UserExceptionUnmarshalException(__FILE__, __LINE__);
- }
-
- pair<const char**, const char**> q = equal_range(typesBegin, typesEnd, *p);
- if (q.first != q.second)
- {
- return q.first - typesBegin;
- }
- skipEncaps();
+ throw UnknownUserException(__FILE__, __LINE__);
+ }
}
- throw UserExceptionUnmarshalException(__FILE__, __LINE__);
+ pair<const char**, const char**> p = equal_range(throwsBegin, throwsEnd, id);
+ if (p.first != p.second)
+ {
+ return p.first - throwsBegin;
+ }
+
+ throw NoUserExceptionFactoryException(__FILE__, __LINE__);
}
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index 501bcf45c77..3f9a618d3bf 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -186,21 +186,14 @@ void
Ice::NoObjectFactoryException::_print(ostream& out) const
{
Exception::_print(out);
- out << ":\nprotocol error: no object factory found for servant with operations";
+ out << ":\nprotocol error: no suitable object factory found";
}
void
-Ice::ServantUnmarshalException::_print(ostream& out) const
+Ice::NoUserExceptionFactoryException::_print(ostream& out) const
{
Exception::_print(out);
- out << ":\nprotocol error: servant type unknown or doesn't match signature";
-}
-
-void
-Ice::UserExceptionUnmarshalException::_print(ostream& out) const
-{
- Exception::_print(out);
- out << ":\nprotocol error: exception type unknown or doesn't match signature";
+ out << ":\nprotocol error: no suitable user exception factory found";
}
void
@@ -211,17 +204,10 @@ Ice::ProxyUnmarshalException::_print(ostream& out) const
}
void
-Ice::StringEncodingException::_print(ostream& out) const
-{
- Exception::_print(out);
- out << ":\nprotocol error: string or wide string encoding error";
-}
-
-void
-Ice::ObjectEncodingException::_print(ostream& out) const
+Ice::IllegalIndirectionException::_print(ostream& out) const
{
Exception::_print(out);
- out << ":\nprotocol error: object encoding error";
+ out << ":\nprotocol error: encountered illegal protocol indirection";
}
void
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
index 733135b765e..061fb9fe130 100644
--- a/cpp/src/Ice/StreamI.cpp
+++ b/cpp/src/Ice/StreamI.cpp
@@ -296,7 +296,7 @@ Ice::StreamI::writeObject(const ObjectPtr& value)
}
void
-Ice::StreamI::readObject(const string& signature, ObjectPtr& value)
+Ice::StreamI::readObject(ObjectPtr& value)
{
- _stream.read(value, signature.c_str());
+ _stream.read("", value);
}
diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h
index f29e501ed00..8214dceb9c5 100644
--- a/cpp/src/Ice/StreamI.h
+++ b/cpp/src/Ice/StreamI.h
@@ -69,7 +69,7 @@ public:
virtual void writeProxy(const ObjectPrx&);
virtual void readProxy(ObjectPrx&);
virtual void writeObject(const ObjectPtr&);
- virtual void readObject(const ::std::string&, ObjectPtr&);
+ virtual void readObject(ObjectPtr&);
private:
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 2f66f9fcbab..3ca1969af42 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -304,25 +304,29 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
if (marshal)
{
out << nl << "::Ice::ObjectPtr " << obj << " = " << param << ';';
- out << nl << stream << deref << "write(" << obj << ");";
+ out << nl << stream << deref << func << obj << ");";
}
else
{
+ out << nl << "::Ice::ObjectPtr " << obj << ';';
ClassDefPtr def = cl->definition();
if (def && !def->isAbstract())
{
- out << nl << "::Ice::ObjectPtr " << obj << " = new " << cl->scoped() << ';';
+ out << nl << "if (" << stream << deref << func << cl->scoped() << "::__classIds[0], " << obj << "))";
+ out << sb;
+ out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << param << " = new " << cl->scoped() << ';';
+ out << nl << param << "->__" << func << stream << ");";
+ out << eb;
}
else
{
- out << nl << "::Ice::ObjectPtr " << obj << ';';
+ out << nl << stream << deref << func << "\"\"," << obj << ");";
+ out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");";
}
- out << nl << stream << deref << "read(" << obj << ", " << cl->scoped() << "::__classIds[0]);";
- out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");";
- out << nl << "if (!" << param << ')';
- out << sb;
- out << nl << "throw ::Ice::ServantUnmarshalException(__FILE__, __LINE__);";
- out << eb;
}
out << eb;
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 32e8434eb02..204ac5b076d 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -321,9 +321,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
- C << nl << "__os->startWriteEncaps();";
+// C << nl << "__os->startWriteEncaps();";
writeMarshalCode(C, memberList, 0);
- C << nl << "__os->endWriteEncaps();";
+// C << nl << "__os->endWriteEncaps();";
if (base)
{
C.zeroIndent();
@@ -341,9 +341,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << eb;
C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
- C << nl << "__is->startReadEncaps();";
+// C << nl << "__is->startReadEncaps();";
writeUnmarshalCode(C, memberList, 0);
- C << nl << "__is->endReadEncaps();";
+// C << nl << "__is->endReadEncaps();";
if (base)
{
C.zeroIndent();
@@ -1155,8 +1155,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
}
}
C << eb << ';';
- C << nl << "::Ice::Int __throwsIdx = __is->throwException(__throws, __throws + " << throws.size() << ");";
- C << nl << "switch (__throwsIdx)";
+ C << nl << "switch (__is->throwException(__throws, __throws + " << throws.size() << "))";
C << sb;
int cnt = 0;
for (r = throws.begin(); r != throws.end(); ++r)
@@ -1574,8 +1573,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << sb;
C << nl << "const char** b = __ids;";
C << nl << "const char** e = __ids + " << ids.size() << ';';
- C << nl << "::std::pair< const char**, const char**> r = ::std::equal_range(b, e, s);";
- C << nl << "return r.first != r.second;";
+ C << nl << "return ::std::binary_search(b, e, s);";
C << eb;
C << sp;
C << nl << "const char**" << nl << scoped.substr(2) << "::__getClassIds()";
@@ -1726,9 +1724,9 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << sp;
C << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
- C << nl << "__os->startWriteEncaps();";
+// C << nl << "__os->startWriteEncaps();";
writeMarshalCode(C, memberList, 0);
- C << nl << "__os->endWriteEncaps();";
+// C << nl << "__os->endWriteEncaps();";
if (base)
{
C.zeroIndent();
@@ -1747,9 +1745,9 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << sp;
C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
- C << nl << "__is->startReadEncaps();";
+// C << nl << "__is->startReadEncaps();";
writeUnmarshalCode(C, memberList, 0);
- C << nl << "__is->endReadEncaps();";
+// C << nl << "__is->endReadEncaps();";
if (base)
{
C.zeroIndent();