summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/Gen.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2002-01-23 16:22:43 +0000
committerMatthew Newhook <matthew@zeroc.com>2002-01-23 16:22:43 +0000
commit48b22912b2d0b30ed6a4bf3b175801c57f12525b (patch)
tree0ce25e038871c5f8607794af01b16aa2095175bf /cpp/src/slice2cpp/Gen.cpp
parentfixes (diff)
downloadice-48b22912b2d0b30ed6a4bf3b175801c57f12525b.tar.bz2
ice-48b22912b2d0b30ed6a4bf3b175801c57f12525b.tar.xz
ice-48b22912b2d0b30ed6a4bf3b175801c57f12525b.zip
Initial commit of generic marshaling.
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp430
1 files changed, 340 insertions, 90 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 7d6f343009b..76d5929520b 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -158,6 +158,7 @@ Slice::Gen::operator!() const
void
Slice::Gen::generate(const UnitPtr& unit)
{
+ C << "\n#include <Ice/Stream.h>";
C << "\n#include <";
if (_include.size())
{
@@ -169,6 +170,11 @@ Slice::Gen::generate(const UnitPtr& unit)
H << "\n#include <Ice/ObjectF.h>";
H << "\n#include <Ice/LocalObjectF.h>";
H << "\n#include <Ice/Exception.h>";
+ //
+ // TODO: ObjectFactory is only necessary if there are non-abstract
+ // objects - so it's not necessary to always include this.
+ //
+ H << "\n#include <Ice/ObjectFactoryF.h>";
if (unit->hasProxies())
{
H << "\n#include <Ice/Proxy.h>";
@@ -184,6 +190,8 @@ Slice::Gen::generate(const UnitPtr& unit)
C << "\n#include <Ice/Proxy.h>";
C << "\n#include <Ice/Object.h>";
}
+ C << "\n#include <Ice/ObjectFactory.h>";
+
StringList includes = unit->includeFiles();
for (StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
@@ -405,6 +413,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
H << sp << nl << _dllExport << "virtual void __write(::IceInternal::BasicStream*) const;";
H << nl << _dllExport << "virtual void __read(::IceInternal::BasicStream*);";
+ H << sp << nl << _dllExport << "virtual void __marshal(const ::Ice::StreamPtr&) const;";
+ H << nl << _dllExport << "virtual void __unmarshal(const ::Ice::StreamPtr&);";
+ H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&);";
TypeStringList memberList;
DataMemberList dataMembers = p->dataMembers();
for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -414,40 +425,36 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
writeMarshalCode(C, memberList, 0);
- 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();
- }
+ emitExceptionBase(base, "__write(__os)");
C << eb;
C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
writeUnmarshalCode(C, memberList, 0);
- 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();
- }
+ emitExceptionBase(base, "__read(__is)");
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::__marshal(const ::Ice::StreamPtr& __os) const";
+ C << sb;
+ emitExceptionBase(base, "__marshal(__os)"); // Base must come first (due to schema rules).
+ writeGenericMarshalCode(C, memberList, 0);
+ C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__unmarshal(const ::Ice::StreamPtr& __is)";
+ C << sb;
+ emitExceptionBase(base, "__unmarshal(__is)"); // Base must come first (due to schema rules).
+ writeGenericUnmarshalCode(C, memberList, 0);
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_unmarshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __is)";
+ C << sb;
+ C << nl << "__is->startReadException(__name);";
+ C << nl << "__unmarshal(__is);";
+ C << nl << "__is->endReadException();";
C << eb;
}
+
+
H << eb << ';';
}
@@ -516,9 +523,13 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if (!p->isLocal())
{
- H << sp;
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;"; // NOT virtual!
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*);"; // NOT virtual!
+ //
+ // Neither of these four member functions are virtual!
+ //
+ H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*);";
+ H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&) const;";
+ H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&);";
TypeStringList memberList;
for (q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -533,6 +544,21 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
C << sb;
writeUnmarshalCode(C, memberList, 0);
C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::ice_marshal(const ::std::string& __name, const ::Ice::StreamPtr& __os) const";
+ C << sb;
+ C << nl << "__os->startWriteStruct(__name);";
+ writeGenericMarshalCode(C, memberList, 0);
+ C << nl << "__os->endWriteStruct();";
+ C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::ice_unmarshal(const ::std::string& __name, const ::Ice::StreamPtr& __is)";
+ C << sb;
+ C << nl << "__is->startReadStruct(__name);";
+ writeGenericUnmarshalCode(C, memberList, 0);
+ C << nl << "__is->endReadStruct();";
+ C << eb;
}
H << eb << ';';
@@ -568,6 +594,12 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name
<< ");";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
+ H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const "
+ << name << "&, __U__" << name
+ << ");";
+ H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, "
+ << name << "&, __U__" << name << ");";
+
C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
<< scoped << "& v, " << scope << "__U__" << name << ")";
C << sb;
@@ -583,8 +615,10 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
C << sb;
C << nl << "::Ice::Int sz;";
C << nl << "__is->read(sz);";
- // Don't use v.resize(sz) or v.reserve(sz) here, as it
- // cannot be checked whether sz is a reasonable value
+ //
+ // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot
+ // be checked whether sz is a reasonable value.
+ //
C << nl << "while (sz--)";
C << sb;
C.zeroIndent();
@@ -601,6 +635,46 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
writeMarshalUnmarshalCode(C, type, "v.back()", false);
C << eb;
C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2)
+ << "ice_marshal(const ::std::string& __name, const ::Ice::StreamPtr& __os, const "
+ << scoped << "& v, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "__os->startWriteSequence(__name, ::Ice::Int(v.size()));";
+ C << nl << scoped << "::const_iterator p;";
+ C << nl << "for (p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeGenericMarshalUnmarshalCode(C, type, "(*p)", true, "\"e\"");
+ C << eb;
+ C << nl << "__os->endWriteSequence();";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __is, " << scoped << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->startReadSequence(__name, sz);";
+ //
+ // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot
+ // be checked whether sz is a reasonable value.
+ //
+ C << nl << "while (sz--)";
+ C << sb;
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // STLBUG
+ C.restoreIndent();
+ C << nl << "v.push_back(" << typeToString(type) << "());";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << "v.push_back();";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ writeGenericMarshalUnmarshalCode(C, type, "v.back()", false);
+ C << eb;
+ C << nl << "__is->endReadSequence();";
+ C << eb;
}
}
@@ -627,6 +701,12 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name
<< ");";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
+ H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const "
+ << name << "&, __U__" << name
+ << ");";
+ H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, "
+ << name << "&, __U__" << name << ");";
+
C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
<< scoped << "& v, " << scope << "__U__" << name << ")";
C << sb;
@@ -651,6 +731,35 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
C << nl << "v.insert(v.end(), pair);";
C << eb;
C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2)
+ << "ice_marshal(const ::std::string& __name, const ::Ice::StreamPtr& __os, const "
+ << scoped << "& v, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "__os->startWriteDictionary(__name, ::Ice::Int(v.size()));";
+ C << nl << scoped << "::const_iterator p;";
+ C << nl << "for (p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeGenericMarshalUnmarshalCode(C, keyType, "p->first", true, "\"key\"");
+ writeGenericMarshalUnmarshalCode(C, valueType, "p->second", true, "\"value\"");
+ C << eb;
+ C << nl << "__os->endWriteDictionary();";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __is, " << scoped << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->startReadDictionary(__name, sz);";
+ C << nl << "while (sz--)";
+ C << sb;
+ C << nl << "::std::pair<" << ks << ", " << vs << "> pair;";
+ writeGenericMarshalUnmarshalCode(C, keyType, "pair.first", false);
+ writeGenericMarshalUnmarshalCode(C, valueType, "pair.second", false);
+ C << nl << "v.insert(v.end(), pair);";
+ C << eb;
+ C << nl << "__is->endReadDictionary();";
+ C << eb;
}
}
@@ -682,6 +791,11 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
+ H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, "
+ << name << ");";
+ H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, "
+ << name << "&);";
+
C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
<< " v)";
C << sb;
@@ -720,6 +834,58 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
C << nl << "v = static_cast< " << scoped << ">(val);";
}
C << eb;
+
+ string tableName = "__T__";
+ tableName += name;
+
+ C << sp;
+ C << nl << "static const ::std::string " << "__RT__" << name << "[] =";
+ C << sb;
+ en = enumerators.begin();
+ while (en != enumerators.end())
+ {
+ C << nl << "\"" << (*en)->name() << "\"";
+ if (++en != enumerators.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ";";
+ C << nl << "static const ::Ice::StringSeq __T__" << name << "(&__RT__" << name << "[0], "
+ << "&__RT__" << name << "[" << enumerators.size() << "]);";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_marshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __os, " << scoped << " v)";
+ C << sb;
+ C << nl << "__os->writeEnum(__name, " << "__T__" << name << ", v);";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __is, " << scoped << "& v)";
+ C << sb;
+ C << nl << "::Ice::Int ordinal;";
+ C << nl << "__is->readEnum(__name, __T__" << name << ", ordinal);";
+ C << nl << "v = static_cast< " << scoped << ">(ordinal);";
+ C << eb;
+ }
+}
+
+void
+Slice::Gen::TypesVisitor::emitExceptionBase(const ExceptionPtr& base, const std::string& call)
+{
+ if (base)
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << base->name() << "::" << call << ";";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << base->scoped() << "::" << call << ";";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
}
}
@@ -1689,6 +1855,11 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
H << nl << exp2 << "static const ::std::string __classIds[" << classIds.size() << "];";
H << nl << exp2 << "virtual bool ice_isA(const ::std::string&, const ::Ice::Current& = ::Ice::Current());";
H << nl << exp2 << "virtual const ::std::string* __getClassIds() const;";
+ if (!p->isAbstract())
+ {
+ H << sp << nl << exp2 << "static ::Ice::ObjectFactoryPtr _factory;";
+ H << nl << exp2 << "static const ::Ice::ObjectFactoryPtr& ice_factory();";
+ }
C << sp;
C << nl << "const ::std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] =";
C << sb;
@@ -1729,7 +1900,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
return true;
}
-
+
void
Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
@@ -1810,9 +1981,22 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << nl << "return ::IceInternal::DispatchOperationNotExist;";
C << eb;
}
+
H << sp;
H << nl << exp2 << "virtual void __write(::IceInternal::BasicStream*) const;";
H << nl << exp2 << "virtual void __read(::IceInternal::BasicStream*);";
+
+ H << sp;
+ H << nl << exp2 << "virtual void __marshal(const ::Ice::StreamPtr&) const;";
+ H << nl << exp2 << "virtual void __unmarshal(const ::Ice::StreamPtr&);";
+
+ H << sp;
+ H << nl << exp2 << "static void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, "
+ << scoped << "Ptr&);";
+
+ H << sp;
+ H << nl << exp2 << "static const ::std::string& ice_id();";
+
TypeStringList memberList;
DataMemberList dataMembers = p->dataMembers();
for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -1823,70 +2007,74 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
writeMarshalCode(C, memberList, 0);
- 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();
- }
- else
- {
- C.zeroIndent();
- C << nl << "#ifdef WIN32"; // COMPILERBUG
- C.restoreIndent();
- C << nl << "Object::__write(__os);";
- C.zeroIndent();
- C << nl << "#else";
- C.restoreIndent();
- C << nl << "::Ice::Object::__write(__os);";
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
+ emitClassBase(base, "__write(__os)");
C << eb;
C << sp;
C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
writeUnmarshalCode(C, memberList, 0);
- 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();
- }
- else
+ emitClassBase(base, "__read(__is)");
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2)
+ << "::__marshal(const ::Ice::StreamPtr& __os) const";
+ C << sb;
+ emitClassBase(base, "__marshal(__os)"); // Base must come first (due to schema rules).
+ writeGenericMarshalCode(C, memberList, 0);
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__unmarshal(const ::Ice::StreamPtr& __is)";
+ C << sb;
+ emitClassBase(base, "__unmarshal(__is)"); // Base must come first (due to schema rules).
+ writeGenericUnmarshalCode(C, memberList, 0);
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::ice_unmarshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __is, " << scoped << "Ptr& value)";
+ C << sb;
+ writeGenericMarshalUnmarshalCode(C, p->declaration(), "value", false, "__name");
+ C << eb;
+
+ C << sp;
+ C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_id()";
+ C << sb;
+ C << nl << "return __classIds[0];";
+ C << eb;
+
+ if (!p->isAbstract())
{
- C.zeroIndent();
- C << nl << "#ifdef WIN32"; // COMPILERBUG
- C.restoreIndent();
- C << nl << "Object::__read(__is);";
- C.zeroIndent();
- C << nl << "#else";
- C.restoreIndent();
- C << nl << "::Ice::Object::__read(__is);";
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
+ string name = p->name();
+ string factoryName = "__F__";
+ factoryName += name;
+ C << sp;
+ C << nl << "class " << factoryName << " : public ::Ice::ObjectFactory";
+ C << sb;
+ C.dec();
+ C << nl << "public:";
+ C.inc();
+ C << sp << nl << "virtual ::Ice::ObjectPtr" << nl << "create(const ::std::string& type)";
+ C << sb;
+ C << nl << "assert(type == " << scoped << "::__classIds[0]);";
+ C << nl << "return new " << scoped << ";";
+ C << eb;
+ C << sp << nl << "virtual void" << nl << "destroy()";
+ C << sb;
+ C << eb;
+ C << eb << ";";
+ C << sp;
+ C << nl << "::Ice::ObjectFactoryPtr " << scoped.substr(2) << "::_factory = new "
+ << "__F__" << p->name() << ";";
+ C << sp << nl << "const ::Ice::ObjectFactoryPtr&" << nl << scoped.substr(2) << "::ice_factory()";
+ C << sb;
+ C << nl << "return _factory;";
+ C << eb;
}
- C << eb;
}
+
H << eb << ';';
if (p->isLocal())
@@ -1911,7 +2099,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << eb;
}
else
- {
+ {
C << sp;
C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
<< "& l, const " << scoped << "& r)";
@@ -2092,6 +2280,40 @@ Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p)
H << nl << s << ' ' << name << ';';
}
+void
+Slice::Gen::ObjectVisitor::emitClassBase(const ClassDefPtr& base, const std::string& call)
+{
+ if (base)
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << base->name() << "::" << call << ";";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << base->scoped() << "::" << call << ";";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ }
+ else
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << "Object::" << call << ";";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << "::Ice::Object::" << call << ";";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ }
+}
+
+
Slice::Gen::IceInternalVisitor::IceInternalVisitor(Output& h, Output& c, const string& dllExport) :
H(h), C(c), _dllExport(dllExport)
{
@@ -2277,6 +2499,12 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p)
H << sp;
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);";
H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);";
+
+ H << sp;
+ H << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const "
+ << name << "Prx&);";
+ H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, "
+ << name << "Prx&);";
}
}
@@ -2310,6 +2538,28 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
C << nl << "v->__copyFrom(proxy);";
C << eb;
C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2)
+ << "ice_marshal(const ::std::string& __name, const ::Ice::StreamPtr& __os, const " << scoped << "Prx& v)";
+ C << sb;
+ C << nl << "__os->writeProxy(__name, v);";
+ C << eb;
+ C << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
+ << "const ::Ice::StreamPtr& __is, " << scoped << "Prx& v)";
+ C << sb;
+ C << nl << "::Ice::ObjectPrx proxy;";
+ C << nl << "__is->readProxy(__name, proxy);";
+ C << nl << "if (!proxy)";
+ C << sb;
+ C << nl << "v = 0;";
+ C << eb;
+ C << nl << "else";
+ C << sb;
+ C << nl << "v = new ::IceProxy" << scoped << ';';
+ C << nl << "v->__copyFrom(proxy);";
+ C << eb;
+ C << eb;
}
return true;