summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp1897
-rw-r--r--cpp/src/slice2cpp/Gen.h21
-rw-r--r--cpp/src/slice2cpp/Makefile.mak12
3 files changed, 542 insertions, 1388 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 084a08944a8..db170626d26 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -26,7 +26,10 @@ using namespace Slice;
using namespace IceUtil;
using namespace IceUtilInternal;
-static string
+namespace
+{
+
+string
getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
{
string deprecateMetadata, deprecateSymbol;
@@ -38,7 +41,7 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
return deprecateSymbol;
}
-static void
+void
writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const SyntaxTreeBasePtr& valueType,
const string& value, int useWstring, const StringList& metaData)
{
@@ -126,7 +129,32 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt
}
}
-static void
+void
+writeMarshalUnmarshalDataMember(IceUtilInternal::Output& C, const DataMemberPtr& p, bool marshal)
+{
+ writeMarshalUnmarshalCode(C, p->type(), p->optional(), p->tag(), fixKwd(p->name()), marshal, p->getMetaData());
+}
+
+void
+writeMarshalUnmarshalDataMembers(IceUtilInternal::Output& C,
+ const DataMemberList& dataMembers,
+ const DataMemberList& optionalDataMembers,
+ bool marshal)
+{
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ if(!(*q)->optional())
+ {
+ writeMarshalUnmarshalDataMember(C, *q, marshal);
+ }
+ }
+ for(DataMemberList::const_iterator q = optionalDataMembers.begin(); q != optionalDataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalDataMember(C, *q, marshal);
+ }
+}
+
+void
writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& members, int useWstring)
{
bool first = true;
@@ -152,6 +180,8 @@ writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& me
}
}
+}
+
Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension,
const vector<string>& extraHeaders, const string& include,
const vector<string>& includePaths, const string& dllExport, const string& dir,
@@ -310,6 +340,7 @@ Slice::Gen::generate(const UnitPtr& p)
H << "\n#include <Ice/ObjectF.h>";
H << "\n#include <Ice/Exception.h>";
H << "\n#include <Ice/LocalObject.h>";
+ H << "\n#include <Ice/StreamTraits.h>";
if(p->usesProxies())
{
@@ -341,7 +372,9 @@ Slice::Gen::generate(const UnitPtr& p)
{
H << "\n#include <Ice/FactoryTableInit.h>";
}
+
H << "\n#include <IceUtil/ScopedArray.h>";
+ H << "\n#include <IceUtil/Optional.h>";
if(p->usesNonLocals())
{
@@ -370,6 +403,12 @@ Slice::Gen::generate(const UnitPtr& p)
}
}
+ if(p->hasContentsWithMetaData("preserve-slice"))
+ {
+ H << "\n#include <Ice/SlicedDataF.h>";
+ C << "\n#include <Ice/SlicedData.h>";
+ }
+
if(_checksum)
{
C << "\n#include <Ice/SliceChecksums.h>";
@@ -430,12 +469,12 @@ Slice::Gen::generate(const UnitPtr& p)
ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport);
p->visit(&objectDeclVisitor, false);
- HandleVisitor handleVisitor(H, C, _dllExport, _stream);
- p->visit(&handleVisitor, false);
-
TypesVisitor typesVisitor(H, C, _dllExport, _stream);
p->visit(&typesVisitor, false);
+ StreamVisitor streamVistor(H, C);
+ p->visit(&streamVistor, false);
+
AsyncVisitor asyncVisitor(H, C, _dllExport);
p->visit(&asyncVisitor, false);
@@ -466,12 +505,6 @@ Slice::Gen::generate(const UnitPtr& p)
ObjectVisitor objectVisitor(H, C, _dllExport, _stream);
p->visit(&objectVisitor, false);
- if(_stream)
- {
- StreamVisitor streamVistor(H, C);
- p->visit(&streamVistor, false);
- }
-
//
// We need to delay generating the template after the proxy
// definition, because __completed calls the begin_ method in the
@@ -611,6 +644,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
ExceptionPtr base = p->base();
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
+ bool hasDefaultValues = p->hasDefaultValues();
DataMemberList::const_iterator q;
vector<string> params;
@@ -626,7 +660,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
+ string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring);
allTypes.push_back(typeName);
allParamDecls.push_back(typeName + " __ice_" + fixKwd((*q)->name()));
}
@@ -664,7 +698,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H << "const char*" << "int";
}
H << epar;
- if(!p->isLocal() && !p->hasDefaultValues())
+ if(!p->isLocal() && !hasDefaultValues)
{
H << " {}";
}
@@ -704,7 +738,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
C << sb;
C << eb;
}
- else if(p->hasDefaultValues())
+ else if(hasDefaultValues)
{
C << sp << nl << scoped.substr(2) << "::" << name << "() :";
C.inc();
@@ -820,151 +854,157 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
string name = fixKwd(p->name());
string scope = fixKwd(p->scope());
string scoped = fixKwd(p->scoped());
- DataMemberList dataMembers = p->dataMembers();
- DataMemberList::const_iterator q;
-
string factoryName;
if(!p->isLocal())
{
ExceptionPtr base = p->base();
+ bool basePreserved = p->inheritsMetaData("preserve-slice");
+ bool preserved = basePreserved || p->hasMetaData("preserve-slice");
H << sp << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
- H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
+ H << nl << "virtual void __writeImpl(::IceInternal::BasicStream*) const;";
+ H << nl << "virtual void __read(::IceInternal::BasicStream*);";
+ H << nl << "virtual void __readImpl(::IceInternal::BasicStream*);";
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
H << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
- H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
-
+ H << nl << "virtual void __read(const ::Ice::InputStreamPtr&);";
+ if(_stream)
+ {
+ H << nl << "virtual void __writeImpl(const ::Ice::OutputStreamPtr&) const;";
+ H << nl << "virtual void __readImpl(const ::Ice::InputStreamPtr&);";
+ }
+
C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
- C << nl << "__os->write(::std::string(\"" << p->scoped() << "\"), false);";
- C << nl << "__os->startWriteSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ if(preserved)
+ {
+ C << nl << "__os->startWriteException(__slicedData);";
+ }
+ else
{
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
+ C << nl << "__os->startWriteException(0);";
}
+ C << nl << "__writeImpl(__os);";
+ C << nl << "__os->endWriteException();";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__writeImpl(::IceInternal::BasicStream* __os) const";
+ C << sb;
+ C << nl << "__os->startWriteSlice(\"" << p->scoped() << "\", " << (!base ? "true" : "false") << ");";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true);
C << nl << "__os->endWriteSlice();";
if(base)
{
- emitUpcall(base, "::__write(__os);");
+ emitUpcall(base, "::__writeImpl(__os);");
}
C << eb;
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
- C << sb;
- C << nl << "if(__rid)";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
- C << nl << "::std::string myId;";
- C << nl << "__is->read(myId, false);";
- C << eb;
- C << nl << "__is->startReadSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ C << nl << "__is->startReadException();";
+ C << nl << "__readImpl(__is);";
+ if(preserved)
{
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
+ C << nl << "__slicedData = __is->endReadException(true);";
}
+ else
+ {
+ C << nl << "__is->endReadException(false);";
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__readImpl(::IceInternal::BasicStream* __is)";
+ C << sb;
+ C << nl << "__is->startReadSlice();";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false);
C << nl << "__is->endReadSlice();";
if(base)
{
- emitUpcall(base, "::__read(__is, true);");
+ emitUpcall(base, "::__readImpl(__is);");
}
C << eb;
if(_stream)
{
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scoped.substr(2)
- << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const";
C << sb;
- C << nl << "__outS->write(::std::string(\"" << p->scoped() << "\"));";
- C << nl << "__outS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ if(preserved)
{
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData(),
- _useWstring);
+ C << nl << "__os->startException(__slicedData);";
}
- C << nl << "__outS->endSlice();";
- if(base)
+ else
{
- emitUpcall(base, "::__write(__outS);");
+ C << nl << "__os->startException(0);";
}
+ C << nl << "__writeImpl(__os);";
+ C << nl << "__os->endException();";
C << eb;
- C << sp << nl << "void" << nl << scoped.substr(2)
- << "::__read(const ::Ice::InputStreamPtr& __inS, bool __rid)";
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::__writeImpl(const ::Ice::OutputStreamPtr& __os) const";
C << sb;
- C << nl << "if(__rid)";
- C << sb;
- C << nl << "std::string s;";
- C << nl << "__inS->read(s);";
+ C << nl << "__os->startSlice(\"" << p->scoped() << "\", " << (!base ? "true" : "false") << ");";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true);
+ C << nl << "__os->endSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__writeImpl(__os);");
+ }
C << eb;
- C << nl << "__inS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)";
+ C << sb;
+ C << nl << "__is->startException();";
+ C << nl << "__readImpl(__is);";
+ if(preserved)
+ {
+ C << nl << "__slicedData = __is->endException(true);";
+ }
+ else
{
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData(),
- _useWstring);
+ C << nl << "__is->endException(false);";
}
- C << nl << "__inS->endSlice();";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::__readImpl(const ::Ice::InputStreamPtr& __is)";
+ C << sb;
+ C << nl << "__is->startSlice();";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false);
+ C << nl << "__is->endSlice();";
if(base)
{
- emitUpcall(base, "::__read(__inS, true);");
+ emitUpcall(base, "::__readImpl(__is);");
}
C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
else
{
//
// Emit placeholder functions to catch errors.
//
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr&) const";
+ 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 << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr&)";
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.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
- if(p->usesClasses())
+ if(preserved && !basePreserved)
{
- if(!base || (base && !base->usesClasses()))
- {
- H << nl << "virtual bool __usesClasses() const;";
-
- C << sp << nl << "bool";
- C << nl << scoped.substr(2) << "::__usesClasses() const";
- C << sb;
- C << nl << "return true;";
- C << eb;
- }
+ H.zeroIndent();
+ H << sp << nl << "protected:";
+ H.restoreIndent();
+ H << sp << nl << "::Ice::SlicedDataPtr __slicedData;";
}
factoryName = "__F" + p->flattenedScope() + p->name();
@@ -972,7 +1012,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << sp << nl << "struct " << factoryName << " : public ::IceInternal::UserExceptionFactory";
C << sb;
C << sp << nl << "virtual void";
- C << nl << "createAndThrow()";
+ C << nl << "createAndThrow(const ::std::string&)";
C << sb;
C << nl << "throw " << scoped << "();";
C << eb;
@@ -1097,7 +1137,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
vector<string> types;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
+ string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring);
types.push_back(typeName);
paramDecls.push_back(typeName + " __ice_" + (*q)->name());
}
@@ -1221,22 +1261,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if(_stream)
{
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << dllExport << "void ice_write(const ::Ice::OutputStreamPtr&) const;";
- H << nl << dllExport << "void ice_read(const ::Ice::InputStreamPtr&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
+ H << nl << dllExport << "void __write(const ::Ice::OutputStreamPtr&) const;";
+ H << nl << dllExport << "void __read(const ::Ice::InputStreamPtr&);";
}
C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
+ writeMarshalUnmarshalDataMember(C, *q, true);
}
C << eb;
@@ -1244,118 +1277,35 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
C << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
+ writeMarshalUnmarshalDataMember(C, *q, false);
}
C << eb;
if(_stream)
{
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scoped.substr(2)
- << "::ice_write(const ::Ice::OutputStreamPtr& __outS) const";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const";
C << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData(),
- _useWstring);
+ C << nl << "__os->write(" << fixKwd((*q)->name()) << ");";
}
C << eb;
- C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_read(const ::Ice::InputStreamPtr& __inS)";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)";
C << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData(),
- _useWstring);
+ C << nl << "__is->read(" << fixKwd((*q)->name()) << ");";
}
C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
}
H << eb << ';';
+
if(findMetaData(p->getMetaData()) == "class")
{
H << sp << nl << "typedef ::IceUtil::Handle< " << scoped << "> " << p->name() + "Ptr;";
-
- if(!p->isLocal() && _stream)
- {
- H << sp;
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << p->name() << "Ptr&);";
- H << nl << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << p->name()
- << "Ptr&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
-
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << fixKwd(p->scoped() + "Ptr") << "& __v)";
- C << sb;
- C << nl << "__v->ice_write(__outS);";
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << fixKwd(p->scoped() + "Ptr") << "& __v)";
- C << sb;
- C << nl << "__v->ice_read(__inS);";
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
- }
- else
- {
- if(!p->isLocal() && _stream)
- {
- H << sp;
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << name << "&);";
- H << nl << dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
-
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& __v)";
- C << sb;
- C << nl << "__v.ice_write(__outS);";
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& __v)";
- C << sb;
- C << nl << "__v.ice_read(__inS);";
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
}
_useWstring = resetUseWstring(_useWstringHist);
@@ -1366,7 +1316,8 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
string name = fixKwd(p->name());
TypePtr type = p->type();
- if(p->container() != 0 && (StructPtr::dynamicCast(p->container()) || ExceptionPtr::dynamicCast(p->container())) &&
+ if(p->container() != 0 &&
+ (StructPtr::dynamicCast(p->container()) || ExceptionPtr::dynamicCast(p->container())) &&
SequencePtr::dynamicCast(type))
{
SequencePtr s = SequencePtr::dynamicCast(type);
@@ -1385,8 +1336,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
}
}
- string s = typeToString(p->type(), p->getMetaData(), _useWstring);
- H << nl << s << ' ' << name << ';';
+ H << nl << typeToString(p->type(), p->optional(), p->getMetaData(), _useWstring) << ' ' << name << ';';
}
void
@@ -1411,231 +1361,6 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
H << nl << "typedef ::std::vector<" << (s[0] == ':' ? " " : "") << s << "> " << name << ';';
}
}
-
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if(!p->isLocal())
- {
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- if(protobuf || !seqType.empty())
- {
- string typeName = name;
- string scopedName = scoped;
- if(protobuf && !seqType.empty())
- {
- typeName = seqType;
- scopedName = seqType;
- }
- H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const "
- << typeName << "&);";
- H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, "
- << typeName << "&);";
-
- if(_stream)
- {
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << typeName << "&);";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << typeName
- << "&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
- }
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write" << name <<
- "(::IceInternal::BasicStream* __os, const " << scopedName << "& v)";
- C << sb;
- if(protobuf)
- {
- C << nl << "std::vector< ::Ice::Byte> data(v.ByteSize());";
- C << nl << "if(!v.IsInitialized())";
- C << sb;
- C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"type not fully initialized: \" + v.InitializationErrorString());";
- C << eb;
- C << nl << "if(!v.SerializeToArray(&data[0], data.size()))";
- C << sb;
- C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"SerializeToArray failed\");";
- C << eb;
- C << nl << "__os->write(&data[0], &data[0] + data.size());";
- }
- else
- {
- C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(v.size());";
- C << nl << "__os->writeSize(size);";
- C << nl << "for(" << name << "::const_iterator p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "(*p)", true);
- C << eb;
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read" << name
- << "(::IceInternal::BasicStream* __is, " << scopedName << "& v)";
- C << sb;
- if(protobuf)
- {
- C << nl << "::std::pair<const ::Ice::Byte*, const ::Ice::Byte*> data;";
- C << nl << "__is->read(data);";
- C << nl << "if(!v.ParseFromArray(data.first, data.second - data.first))";
- C << sb;
- C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"ParseFromArray failed\");";
- C << eb;
- }
- else
- {
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readAndCheckSeqSize(" << type->minWireSize() << ", sz);";
- C << nl << name << "(sz).swap(v);";
- C << nl << "for(" << name << "::iterator p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "(*p)", false);
- C << eb;
- }
- C << eb;
-
- if(_stream)
- {
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scopedName << "& v)";
- C << sb;
- if(protobuf)
- {
- C << nl << "std::vector< ::Ice::Byte> data(v.ByteSize());";
- C << nl << "if(!v.IsInitialized())";
- C << sb;
- C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"type not fully initialized: \" + v.InitializationErrorString());";
- C << eb;
- C << nl << "v.SerializeToArray(&data[0], data.size());";
-
- C << nl << "__outS->write(data);";
- }
- else
- {
- C << nl << "__outS->writeSize(::Ice::Int(v.size()));";
- C << nl << scopedName << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeStreamMarshalUnmarshalCode(C, type, "(*p)", true, "", StringList(), _useWstring);
- C << eb;
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scopedName << "& v)";
- C << sb;
- if(protobuf)
- {
- C << nl << "std::pair<const ::Ice::Byte*, const ::Ice::Byte*> data;";
- C << nl << "__inS->readByteSeq(data);";
- C << nl << "if(!v.ParseFromArray(data.first, data.second - data.first))";
- C << sb;
- C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"ParseFromArray failed\");";
- C << eb;
- }
- else
- {
- C << nl << "::Ice::Int sz = __inS->readAndCheckSeqSize(" << type->minWireSize() << ");";
- C << nl << scopedName << "(sz).swap(v);";
- C << nl << scopedName << "::iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeStreamMarshalUnmarshalCode(C, type, "(*p)", false, "", StringList(), _useWstring);
- C << eb;
- }
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
- }
- else if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
- {
- H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const " << s
- << "*, const " << s << "*);";
- H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, " << name << "&);";
-
- if(_stream)
- {
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << name << "&);";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name
- << "&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
- }
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write" << name
- << "(::IceInternal::BasicStream* __os, const " << s << "* begin, const " << s << "* end)";
- C << sb;
- C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(end - begin);";
- C << nl << "__os->writeSize(size);";
- C << nl << "for(int i = 0; i < size; ++i)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "begin[i]", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read" << name
- << "(::IceInternal::BasicStream* __is, " << scoped << "& v)";
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readAndCheckSeqSize(" << type->minWireSize() << ", sz);";
- C << nl << "v.resize(sz);";
- C << nl << "for(int i = 0; i < sz; ++i)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "v[i]", false);
- C << eb;
- C << eb;
-
- if(_stream)
- {
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& v)";
- C << sb;
- C << nl << "__outS->writeSize(::Ice::Int(v.size()));";
- C << nl << scoped << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeStreamMarshalUnmarshalCode(C, type, "(*p)", true, "", StringList(), _useWstring);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)";
- C << sb;
- C << nl << "::Ice::Int sz = __inS->readAndCheckSeqSize(" << type->minWireSize() << ");";
- C << nl << "v.resize(sz);";
- C << nl << "for(int i = 0; i < sz; ++i)";
- C << sb;
- writeStreamMarshalUnmarshalCode(C, type, "v[i]", false, "", StringList(), _useWstring);
- C << eb;
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
- }
- }
}
void
@@ -1667,92 +1392,6 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
}
string vs = typeToString(valueType, p->valueMetaData(), _useWstring);
H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';';
-
- if(!p->isLocal())
- {
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const " << name << "&);";
- H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, " << name << "&);";
-
- if(_stream)
- {
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const " << name
- << "&);";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
- }
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write" << name
- << "(::IceInternal::BasicStream* __os, const " << scoped << "& v)";
- C << sb;
- C << nl << "__os->writeSize(::Ice::Int(v.size()));";
- C << nl << scoped << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, keyType, "p->first", true);
- writeMarshalUnmarshalCode(C, valueType, "p->second", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read" << name
- << "(::IceInternal::BasicStream* __is, " << scoped << "& v)";
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readSize(sz);";
- C << nl << "while(sz--)";
- C << sb;
- C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
- const string pf = string("const_cast<") + ks + "&>(pair.first)";
- writeMarshalUnmarshalCode(C, keyType, pf, false);
- C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
- writeMarshalUnmarshalCode(C, valueType, "__i->second", false);
- C << eb;
- C << eb;
-
- if(_stream)
- {
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& v)";
- C << sb;
- C << nl << "__outS->writeSize(::Ice::Int(v.size()));";
- C << nl << scoped << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeStreamMarshalUnmarshalCode(C, keyType, "p->first", true, "", p->keyMetaData(), _useWstring);
- writeStreamMarshalUnmarshalCode(C, valueType, "p->second", true, "", p->valueMetaData(), _useWstring);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)";
- C << sb;
- C << nl << "::Ice::Int sz = __inS->readSize();";
- C << nl << "while(sz--)";
- C << sb;
- C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
- writeStreamMarshalUnmarshalCode(C, keyType, pf, false, "", p->keyMetaData(), _useWstring);
- C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
- writeStreamMarshalUnmarshalCode(C, valueType, "__i->second", false, "", p->valueMetaData(), _useWstring);
- C << eb;
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
- }
}
void
@@ -1772,89 +1411,6 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
}
}
H << eb << ';';
-
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- if(!p->isLocal())
- {
- size_t sz = enumerators.size();
- assert(sz <= 0x7fffffff); // 64-bit enums are not supported
-
- H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
-
- if(_stream)
- {
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr&, " << name << ");";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
- }
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
- << " v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "__os->write(static_cast< ::Ice::Byte>(v), " << sz << ");";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "__os->write(static_cast< ::Ice::Short>(v), " << sz << ");";
- }
- else
- {
- C << nl << "__os->write(static_cast< ::Ice::Int>(v), " << sz << ");";
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "::Ice::Byte val;";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "::Ice::Short val;";
- }
- else
- {
- C << nl << "::Ice::Int val;";
- }
- C << nl << "__is->read(val, " << sz << ");";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- C << eb;
-
- if(_stream)
- {
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, " << scoped << " v)";
- C << sb;
- C << nl << "__outS->write(v);";
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)";
- C << sb;
- C << nl << "__inS->read(v);";
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
- }
}
void
@@ -1870,18 +1426,8 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
void
Slice::Gen::TypesVisitor::emitUpcall(const ExceptionPtr& base, const string& call, bool isLocal)
{
- C.zeroIndent();
- C << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- C.restoreIndent();
- C << nl << (base ? fixKwd(base->name()) : string(isLocal ? "LocalException" : "UserException")) << call;
- C.zeroIndent();
- C << nl << "#else";
- C.restoreIndent();
C << nl << (base ? fixKwd(base->scoped()) : string(isLocal ? "::Ice::LocalException" : "::Ice::UserException"))
<< call;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
Slice::Gen::ProxyDeclVisitor::ProxyDeclVisitor(Output& h, Output& c, const string& dllExport) :
@@ -1941,6 +1487,8 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p)
string scoped = fixKwd(p->scoped());
H << sp << nl << "class " << name << ';';
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, ::IceInternal::ProxyHandle< ::IceProxy"
+ << scoped << ">&);";
H << nl << _dllExport << "::IceProxy::Ice::Object* upCast(::IceProxy" << scoped << "*);";
}
@@ -2050,6 +1598,23 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
<< "::IceProxy::Ice::Object* ::IceProxy" << scope << "upCast(::IceProxy" << scoped
<< "* p) { return p; }";
+ C << sp;
+ C << nl << "void" << nl << "::IceProxy" << scope << "__read(::IceInternal::BasicStream* __is, "
+ << "::IceInternal::ProxyHandle< ::IceProxy" << scoped << ">& v)";
+ C << sb;
+ C << nl << "::Ice::ObjectPrx proxy;";
+ C << nl << "__is->read(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;
}
@@ -2071,301 +1636,107 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p)
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_context(const ::Ice::Context& __context) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_context(__context).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_context(__context).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
//
// No facet!
//
- H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_adapterId(const std::string& __id) const";
+ H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_adapterId(const ::std::string& __id) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_adapterId(__id).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_adapterId(__id).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_endpoints(const ::Ice::EndpointSeq& __endpoints) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_endpoints(__endpoints).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_endpoints(__endpoints).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_locatorCacheTimeout(int __timeout) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_locatorCacheTimeout(__timeout).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_locatorCacheTimeout(__timeout).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionCached(bool __cached) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_connectionCached(__cached).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_connectionCached(__cached).get());";
- H.dec(); H << nl << "#endif"; H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_endpointSelection(::Ice::EndpointSelectionType __est) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_endpointSelection(__est).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_endpointSelection(__est).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_secure(bool __secure) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_secure(__secure).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_secure(__secure).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_preferSecure(bool __preferSecure) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_preferSecure(__preferSecure).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_preferSecure(__preferSecure).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_router(const ::Ice::RouterPrx& __router) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_router(__router).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_router(__router).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_locator(const ::Ice::LocatorPrx& __locator) const";
H << sb;
- H.dec(); H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_locator(__locator).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_locator(__locator).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_collocationOptimized(bool __co) const";
H << sb;
- H.dec(); H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_collocationOptimized(__co).get());";
- H.dec(); H << nl << "#else"; H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_collocationOptimized(__co).get());";
- H.dec(); H << nl << "#endif"; H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_twoway() const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_twoway().get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_twoway().get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_oneway() const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_oneway().get());";
- H.dec();
- H << nl << "#else"; H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_oneway().get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_batchOneway() const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_batchOneway().get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_batchOneway().get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_datagram() const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_datagram().get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_datagram().get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_batchDatagram() const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_batchDatagram().get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_batchDatagram().get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_compress(bool __compress) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_compress(__compress).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_compress(__compress).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_timeout(int __timeout) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_timeout(__timeout).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_timeout(__timeout).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
H << eb;
- H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionId(const std::string& __id) const";
+ H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionId(const ::std::string& __id) const";
H << sb;
- H.dec();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.inc();
- H << nl << "typedef ::IceProxy::Ice::Object _Base;";
- H << nl << "return dynamic_cast<" << name << "*>(_Base::ice_connectionId(__id).get());";
- H.dec();
- H << nl << "#else";
- H.inc();
H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_connectionId(__id).get());";
- H.dec();
- H << nl << "#endif";
- H.inc();
+ H << eb;
+
+ H << nl << nl << "::IceInternal::ProxyHandle<" << name
+ << "> ice_encodingVersion(const ::Ice::EncodingVersion& __v) const";
+ H << sb;
+ H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_encodingVersion(__v).get());";
H << eb;
H << nl << nl << _dllExport << "static const ::std::string& ice_staticId();";
@@ -2411,8 +1782,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string scope = fixKwd(p->scope());
TypePtr ret = p->returnType();
- string retS = returnTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIEnd);
- string retSEndAMI = returnTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd);
+ bool retIsOpt = p->returnIsOptional();
+ string retS = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIEnd);
+ string retSEndAMI = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd);
ContainerPtr container = p->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
@@ -2443,12 +1815,13 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string typeStringEndAMI;
if((*q)->isOutParam())
{
- typeString = outputTypeToString((*q)->type(), metaData, _useWstring | TypeContextAMIEnd);
- typeStringEndAMI = outputTypeToString((*q)->type(), metaData, _useWstring | TypeContextAMIPrivateEnd);
+ typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring | TypeContextAMIEnd);
+ typeStringEndAMI = outputTypeToString((*q)->type(), (*q)->optional(), metaData,
+ _useWstring | TypeContextAMIPrivateEnd);
}
else
{
- typeString = inputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
params.push_back(typeString);
@@ -2484,7 +1857,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
bool generatePrivateEnd = retS != retSEndAMI || outParamsDeclAMI != outParamsDeclEndAMI;
if(ret && generatePrivateEnd)
{
- string typeStringEndAMI = outputTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd);
+ string typeStringEndAMI = outputTypeToString(ret, p->returnIsOptional(), p->getMetaData(),
+ _useWstring | TypeContextAMIPrivateEnd);
outParamsDeclEndAMI.push_back(typeStringEndAMI + ' ' + "__ret");
}
@@ -2635,13 +2009,16 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << nl << "try";
C << sb;
C << nl << "__result->__prepare(" << flatName << ", " << operationModeToString(p->sendMode()) << ", __ctx);";
- C << nl << "::IceInternal::BasicStream* __os = __result->__getOs();";
- writeMarshalCode(C, inParams, 0, StringList(), TypeContextInParam);
- if(p->sendsClasses())
+ if(inParams.empty())
{
- C << nl << "__os->writePendingObjects();";
+ C << nl << "__result->__writeEmptyParams();";
+ }
+ else
+ {
+ C << nl << "::IceInternal::BasicStream* __os = __result->__startWriteParams(" << opFormatTypeToString(p) <<");";
+ writeMarshalCode(C, inParams, 0, TypeContextInParam);
+ C << nl << "__result->__endWriteParams();";
}
- C << nl << "__os->endWriteEncaps();";
C << nl << "__result->__send(true);";
C << eb;
C << nl << "catch(const ::Ice::LocalException& __ex)";
@@ -2664,7 +2041,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
// access violations errors with the test/Ice/slicing/objects test on VC9
// and Windows 64 bits when compiled with optimization (see bug 4400).
//
- writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring | TypeContextAMIEnd);
+ writeAllocateCode(C, ParamDeclList(), p, _useWstring | TypeContextAMIEnd);
C << nl << "if(!__result->__wait())";
C << sb;
@@ -2697,20 +2074,15 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());";
C << eb;
C << eb;
- C << nl << "::IceInternal::BasicStream* __is = __result->__getIs();";
if(ret || !outParams.empty())
{
- C << nl << "__is->startReadEncaps();";
- writeUnmarshalCode(C, outParams, ret, p->getMetaData(), _useWstring | TypeContextAMIEnd);
- if(p->returnsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << nl << "__is->endReadEncaps();";
+ C << nl << "::IceInternal::BasicStream* __is = __result->__startReadParams();";
+ writeUnmarshalCode(C, outParams, p, _useWstring | TypeContextAMIEnd);
+ C << nl << "__result->__endReadParams();";
}
else
{
- C << nl << "__is->skipEmptyEncaps();";
+ C << nl << "__result->__readEmptyParams();";
}
if(ret)
{
@@ -2762,20 +2134,15 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());";
C << eb;
C << eb;
- C << nl << "::IceInternal::BasicStream* __is = __result->__getIs();";
if(ret || !outParams.empty())
{
- C << nl << "__is->startReadEncaps();";
- writeUnmarshalCode(C, outParams, ret, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd);
- if(p->returnsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << nl << "__is->endReadEncaps();";
+ C << nl << "::IceInternal::BasicStream* __is = __result->__startReadParams();";
+ writeUnmarshalCode(C, outParams, p, _useWstring | TypeContextAMIPrivateEnd);
+ C << nl << "__result->__endReadParams();";
}
else
{
- C << nl << "__is->skipEmptyEncaps();";
+ C << nl << "__result->__readEmptyParams();";
}
C << eb;
}
@@ -3005,7 +2372,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p)
string name = fixKwd(p->name());
TypePtr ret = p->returnType();
- string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
vector<string> params;
@@ -3013,24 +2380,15 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
StringList metaData = (*q)->getMetaData();
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
string typeString;
if((*q)->isOutParam())
{
- typeString = outputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
else
{
- typeString = inputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
-#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring)
- : inputTypeToString((*q)->type(), metaData, _useWstring);
-#endif
-
params.push_back(typeString);
}
@@ -3145,7 +2503,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
string scoped = fixKwd(p->scoped());
TypePtr ret = p->returnType();
- string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
vector<string> params;
vector<string> paramsDecl;
@@ -3163,12 +2521,12 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
if(isOutParam)
{
outParams.push_back(*q);
- typeString = outputTypeToString(type, metaData, _useWstring);
+ typeString = outputTypeToString(type, (*q)->optional(), metaData, _useWstring);
}
else
{
inParams.push_back(*q);
- typeString = inputTypeToString(type, metaData, _useWstring);
+ typeString = inputTypeToString(type, (*q)->optional(), metaData, _useWstring);
}
params.push_back(typeString);
@@ -3185,16 +2543,17 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
C << sb;
C << nl << "::IceInternal::Outgoing __og(__handler.get(), " << flatName << ", "
<< operationModeToString(p->sendMode()) << ", __context);";
- if(!inParams.empty())
+ if(inParams.empty())
+ {
+ C << nl << "__og.writeEmptyParams();";
+ }
+ else
{
C << nl << "try";
C << sb;
- C << nl << "::IceInternal::BasicStream* __os = __og.os();";
- writeMarshalCode(C, inParams, 0, StringList(), TypeContextInParam);
- if(p->sendsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
+ C << nl<< "::IceInternal::BasicStream* __os = __og.startWriteParams(" << opFormatTypeToString(p) << ");";
+ writeMarshalCode(C, inParams, 0, TypeContextInParam);
+ C << nl << "__og.endWriteParams();";
C << eb;
C << nl << "catch(const ::Ice::LocalException& __ex)";
C << sb;
@@ -3208,10 +2567,10 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
// Declare the return __ret variable at the top-level scope to
// enable NRVO with GCC (see also bug #3619).
//
- writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring);
+ writeAllocateCode(C, ParamDeclList(), p, _useWstring);
if(!p->returnsData())
{
- C << nl << "if(!__og.is()->b.empty())";
+ C << nl << "if(__og.hasResponse())";
C << sb;
}
C << nl << "try";
@@ -3272,29 +2631,15 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
C << eb;
C << eb;
- for(ParamDeclList::const_iterator opi = outParams.begin(); opi != outParams.end(); ++opi)
- {
- StructPtr st = StructPtr::dynamicCast((*opi)->type());
- if(st && findMetaData(st->getMetaData()) == "class")
- {
- C << nl << fixKwd((*opi)->name()) << " = new " << fixKwd(st->scoped()) << ";";
- }
- }
-
if(ret || !outParams.empty())
{
- C << nl << "::IceInternal::BasicStream* __is = __og.is();";
- C << nl << "__is->startReadEncaps();";
- writeUnmarshalCode(C, outParams, ret, p->getMetaData());
- if(p->returnsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << nl << "__is->endReadEncaps();";
+ C << nl << "::IceInternal::BasicStream* __is = __og.startReadParams();";
+ writeUnmarshalCode(C, outParams, p);
+ C << nl << "__og.endReadParams();";
}
else
{
- C << nl << "__og.is()->skipEmptyEncaps();";
+ C << nl << "__og.readEmptyParams();";
}
if(ret)
@@ -3419,7 +2764,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
string scoped = fixKwd(p->scoped());
TypePtr ret = p->returnType();
- string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
vector<string> params;
vector<string> paramsDecl;
@@ -3433,23 +2778,15 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
string paramName = fixKwd((*q)->name());
StringList metaData = (*q)->getMetaData();
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
string typeString;
if((*q)->isOutParam())
{
- typeString = outputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
else
{
- typeString = inputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
-#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring)
- : inputTypeToString((*q)->type(), metaData, _useWstring);
-#endif
params.push_back(typeString);
paramsDecl.push_back(typeString + ' ' + paramName);
@@ -3498,7 +2835,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
C << sp << nl << "_DirectI" << spar;
if(ret)
{
- string resultRef = outputTypeToString(ret, p->getMetaData(), _useWstring);
+ string resultRef = outputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
C << resultRef + " __result";
}
C << directParamsDecl << "const ::Ice::Current& __current" << epar << " : ";
@@ -3575,7 +2912,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
C << nl;
if(ret)
{
- string resultRef= outputTypeToString(ret, p->getMetaData(), _useWstring);
+ string resultRef= outputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
C << nl << resultRef << " _result;";
}
@@ -3706,6 +3043,7 @@ Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p)
H << nl << _dllExport << "::Ice::Object* upCast(" << scoped << "*);";
H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << p->name() << "Ptr;";
H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << p->name() << "Prx;";
+ H << nl << _dllExport << "void __patch(" << p->name() << "Ptr&, ::Ice::ObjectPtr&);";
}
else
{
@@ -3772,7 +3110,8 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
-
+ bool basePreserved = p->inheritsMetaData("preserve-slice");
+ bool preserved = basePreserved || p->hasMetaData("preserve-slice");
H << sp << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
@@ -3808,7 +3147,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
bool hasBaseClass = !bases.empty() && !bases.front()->isInterface();
bool override = p->canBeCyclic() && (!hasBaseClass || !bases.front()->canBeCyclic());
- if(override)
+ if(!basePreserved && (override || preserved))
{
H << ", private IceInternal::GCShared";
}
@@ -3837,7 +3176,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
+ string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring);
allTypes.push_back(typeName);
allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
@@ -3846,7 +3185,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->hasDefaultValues())
{
- H << name << "() :";
+ H << sp << nl << name << "() :";
H.inc();
writeDataMemberInitializers(H, dataMembers, _useWstring);
H.dec();
@@ -4087,7 +3426,9 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << eb;
emitGCFunctions(p);
- } else {
+ }
+ else
+ {
C << sp << nl
<< (_dllExport.empty() ? "" : "ICE_DECLSPEC_EXPORT ")
<< "::Ice::LocalObject* " << scope.substr(2) << "upCast(" << scoped << "* p) { return p; }";
@@ -4101,16 +3442,17 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
string scoped = fixKwd(p->scoped());
string scope = fixKwd(p->scope());
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
+ bool basePreserved = p->inheritsMetaData("preserve-slice");
+ bool preserved = basePreserved || p->hasMetaData("preserve-slice");
if(!p->isLocal())
{
- ClassList bases = p->bases();
- ClassDefPtr base;
- if(!bases.empty() && !bases.front()->isInterface())
- {
- base = bases.front();
- }
-
OperationList allOps = p->allOperations();
if(!allOps.empty())
{
@@ -4185,7 +3527,6 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
<< "current.facet, current.operation);";
C << eb;
-
//
// Check if we need to generate ice_operationAttributes()
//
@@ -4255,116 +3596,146 @@ 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);";
-
-
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
+ H << nl << "virtual void __writeImpl(::IceInternal::BasicStream*) const;";
+ H << nl << "virtual void __read(::IceInternal::BasicStream*);";
+ H << nl << "virtual void __readImpl(::IceInternal::BasicStream*);";
+
H << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
- H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
-
+ H << nl << "virtual void __read(const ::Ice::InputStreamPtr&);";
+ if(_stream)
+ {
+ H << nl << "virtual void __writeImpl(const ::Ice::OutputStreamPtr&) const;";
+ H << nl << "virtual void __readImpl(const ::Ice::InputStreamPtr&);";
+ }
+
C << sp;
C << nl << "void" << nl << scoped.substr(2)
<< "::__write(::IceInternal::BasicStream* __os) const";
C << sb;
- C << nl << "__os->writeTypeId(ice_staticId());";
- C << nl << "__os->startWriteSlice();";
- DataMemberList dataMembers = p->dataMembers();
- DataMemberList::const_iterator q;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ if(preserved)
{
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
+ C << nl << "__os->startWriteObject(__slicedData);";
}
- C << nl << "__os->endWriteSlice();";
- emitUpcall(base, "::__write(__os);");
+ else
+ {
+ C << nl << "__os->startWriteObject(0);";
+ }
+ C << nl << "__writeImpl(__os);";
+ C << nl << "__os->endWriteObject();";
C << eb;
+
C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
+ C << nl << "void" << nl << scoped.substr(2)
+ << "::__writeImpl(::IceInternal::BasicStream* __os) const";
C << sb;
- C << nl << "if(__rid)";
+ C << nl << "__os->startWriteSlice(ice_staticId(), " << (!base ? "true" : "false") << ");";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true);
+ C << nl << "__os->endWriteSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__writeImpl(__os);");
+ }
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
C << sb;
- C << nl << "::std::string myId;";
- C << nl << "__is->readTypeId(myId);";
+ C << nl << "__is->startReadObject();";
+ C << nl << "__readImpl(__is);";
+ if(preserved)
+ {
+ C << nl << "__slicedData = __is->endReadObject(true);";
+ }
+ else
+ {
+ C << nl << "__is->endReadObject(false);";
+ }
C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__readImpl(::IceInternal::BasicStream* __is)";
+ C << sb;
C << nl << "__is->startReadSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false);
+ C << nl << "__is->endReadSlice();";
+ if(base)
{
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
+ emitUpcall(base, "::__readImpl(__is);");
}
- C << nl << "__is->endReadSlice();";
- emitUpcall(base, "::__read(__is, true);");
C << eb;
if(_stream)
{
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const";
C << sb;
- C << nl << "__outS->writeTypeId(ice_staticId());";
- C << nl << "__outS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ if(preserved)
{
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData(),
- _useWstring);
+ C << nl << "__os->startObject(__slicedData);";
}
- C << nl << "__outS->endSlice();";
- emitUpcall(base, "::__write(__outS);");
+ else
+ {
+ C << nl << "__os->startObject(0);";
+ }
+ C << nl << "__writeImpl(__os);";
+ C << nl << "__os->endObject();";
C << eb;
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __inS, bool __rid)";
+
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::__writeImpl(const ::Ice::OutputStreamPtr& __os) const";
C << sb;
- C << nl << "if(__rid)";
+ C << nl << "__os->startSlice(ice_staticId(), " << (!base ? "true" : "false") << ");";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true);
+ C << nl << "__os->endSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__writeImpl(__os);");
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)";
C << sb;
- C << nl << "__inS->readTypeId();";
+ C << nl << "__is->startObject();";
+ C << nl << "__readImpl(__is);";
+ if(preserved)
+ {
+ C << nl << "__slicedData = __is->endObject(true);";
+ }
+ else
+ {
+ C << nl << "__is->endObject(false);";
+ }
C << eb;
- C << nl << "__inS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__readImpl(const ::Ice::InputStreamPtr& __is)";
+ C << sb;
+ C << nl << "__is->startSlice();";
+ writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false);
+ C << nl << "__is->endSlice();";
+ if(base)
{
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData(),
- _useWstring);
+ emitUpcall(base, "::__readImpl(__is);");
}
- C << nl << "__inS->endSlice();";
- emitUpcall(base, "::__read(__inS, true);");
C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
else
{
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
//
// Emit placeholder functions to catch errors.
//
- C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr&) const";
+ 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 = \"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 << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr&)";
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.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
if(!p->isAbstract())
@@ -4421,7 +3792,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << nl << "const " << factoryName << "__Init " << factoryName << "__i;";
C << sp << nl << "}";
C << sp << nl << "#ifdef __APPLE__";
- std::string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
+ string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
C << nl << "extern \"C\" {";
C.inc();
C << nl << "void " << initfuncname << "();";
@@ -4432,51 +3803,15 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
}
}
- bool inProtected = false;
-
- if(!p->isAbstract())
- {
- //
- // We add a protected destructor to force heap instantiation of the class.
- //
- H.dec();
- H << sp << nl << "protected:";
- H.inc();
- H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
-
- if(!_doneStaticSymbol)
- {
- H << sp << nl << "friend class " << p->name() << "__staticInit;";
- }
-
- inProtected = true;
- }
-
//
// Emit data members. Access visibility may be specified by metadata.
//
+ bool inProtected = false;
DataMemberList dataMembers = p->dataMembers();
DataMemberList::const_iterator q;
bool prot = p->hasMetaData("protected");
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- TypePtr type = (*q)->type();
- if(SequencePtr::dynamicCast(type))
- {
- SequencePtr s = SequencePtr::dynamicCast(type);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(s->type());
- if(builtin && builtin->kind() == Builtin::KindByte)
- {
- StringList metaData = s->getMetaData();
- bool protobuf;
- findMetaData(s, metaData, protobuf);
- if(protobuf)
- {
- emitWarning((*q)->file(), (*q)->line(), "protobuf cannot be used as a class member in C++");
- }
- }
- }
-
if(prot || (*q)->hasMetaData("protected"))
{
if(!inProtected)
@@ -4498,9 +3833,39 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
}
}
- string name = fixKwd((*q)->name());
- string s = typeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
- H << sp << nl << s << ' ' << name << ';';
+ emitDataMember(*q);
+ }
+
+ if(!p->isAbstract())
+ {
+ //
+ // We add a protected destructor to force heap instantiation of the class.
+ //
+ if(!inProtected)
+ {
+ H.dec();
+ H << sp << nl << "protected:";
+ H.inc();
+ inProtected = true;
+ }
+ H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
+
+ if(!_doneStaticSymbol)
+ {
+ H << sp << nl << "friend class " << p->name() << "__staticInit;";
+ }
+ }
+
+ if(!p->isLocal() && preserved && !basePreserved)
+ {
+ if(!inProtected)
+ {
+ H.dec();
+ H << sp << nl << "protected:";
+ H.inc();
+ inProtected = true;
+ }
+ H << sp << nl << "::Ice::SlicedDataPtr __slicedData;";
}
H << eb << ';';
@@ -4543,14 +3908,12 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
C << sp << nl << "void "
<< (_dllExport.empty() ? "" : "ICE_DECLSPEC_EXPORT ");
- C << nl << scope.substr(2) << "__patch__" << p->name() << "Ptr(void* __addr, ::Ice::ObjectPtr& v)";
+ C << nl << scope.substr(2) << "__patch(" << p->name() << "Ptr& handle, ::Ice::ObjectPtr& v)";
C << sb;
- C << nl << scope << p->name() << "Ptr* p = static_cast< " << scope << p->name() << "Ptr*>(__addr);";
- C << nl << "assert(p);";
- C << nl << "*p = " << scope << p->name() << "Ptr::dynamicCast(v);";
- C << nl << "if(v && !*p)";
+ C << nl << "handle = " << scope << p->name() << "Ptr::dynamicCast(v);";
+ C << nl << "if(v && !handle)";
C << sb;
- C << nl << "IceInternal::Ex::throwUOE(" << scoped << "::ice_staticId(), v->ice_id());";
+ C << nl << "IceInternal::Ex::throwUOE(" << scoped << "::ice_staticId(), v);";
C << eb;
C << eb;
@@ -4589,7 +3952,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
string scope = fixKwd(p->scope());
TypePtr ret = p->returnType();
- string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
string params = "(";
string paramsDecl = "(";
@@ -4617,12 +3980,12 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
if(isOutParam)
{
outParams.push_back(*q);
- typeString = outputTypeToString(type, (*q)->getMetaData(), _useWstring);
+ typeString = outputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring);
}
else
{
inParams.push_back(*q);
- typeString = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
+ typeString = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring);
}
if(q != paramList.begin())
@@ -4725,26 +4088,17 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
if(!inParams.empty())
{
- C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
- C << nl << "__is->startReadEncaps();";
- writeAllocateCode(C, inParams, 0, StringList(), _useWstring | TypeContextInParam);
- writeUnmarshalCode(C, inParams, 0, StringList(), TypeContextInParam);
- if(p->sendsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << nl << "__is->endReadEncaps();";
+ C << nl << "::IceInternal::BasicStream* __is = __inS.startReadParams();";
+ writeAllocateCode(C, inParams, 0, _useWstring | TypeContextInParam);
+ writeUnmarshalCode(C, inParams, 0, TypeContextInParam);
+ C << nl << "__inS.endReadParams();";
}
else
{
- C << nl << "__inS.is()->skipEmptyEncaps();";
+ C << nl << "__inS.readEmptyParams();";
}
- if(ret || !outParams.empty() || !throws.empty())
- {
- C << nl << "::IceInternal::BasicStream* __os = __inS.os();";
- }
- writeAllocateCode(C, outParams, 0, StringList(), _useWstring);
+ writeAllocateCode(C, outParams, 0, _useWstring);
if(!throws.empty())
{
C << nl << "try";
@@ -4756,11 +4110,18 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
C << retS << " __ret = ";
}
C << fixKwd(name) << args << ';';
- writeMarshalCode(C, outParams, ret, p->getMetaData());
- if(p->returnsClasses())
+ if(ret || !outParams.empty())
+ {
+ C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams("
+ << opFormatTypeToString(p) << ");";
+ writeMarshalCode(C, outParams, p);
+ C << nl << "__inS.__endWriteParams(true);";
+ }
+ else
{
- C << nl << "__os->writePendingObjects();";
+ C << nl << "__inS.__writeEmptyParams();";
}
+ C << nl << "return ::Ice::DispatchOK;";
if(!throws.empty())
{
C << eb;
@@ -4769,13 +4130,11 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
{
C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
C << sb;
- C << nl << "__os->write(__ex);";
- C << nl << "return ::Ice::DispatchUserException;";
+ C << nl << "__inS.__writeUserException(__ex, " << opFormatTypeToString(p) << ");";
C << eb;
}
+ C << nl << "return ::Ice::DispatchUserException;";
}
-
- C << nl << "return ::Ice::DispatchOK;";
}
else
{
@@ -4783,19 +4142,14 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
if(!inParams.empty())
{
- C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
- C << nl << "__is->startReadEncaps();";
- writeAllocateCode(C, inParams, 0, StringList(), _useWstring | TypeContextInParam);
- writeUnmarshalCode(C, inParams, 0, StringList(), TypeContextInParam);
- if(p->sendsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << nl << "__is->endReadEncaps();";
+ C << nl << "::IceInternal::BasicStream* __is = __inS.startReadParams();";
+ writeAllocateCode(C, inParams, 0, _useWstring | TypeContextInParam);
+ writeUnmarshalCode(C, inParams, 0, TypeContextInParam);
+ C << nl << "__inS.endReadParams();";
}
else
{
- C << nl << "__inS.is()->skipEmptyEncaps();";
+ C << nl << "__inS.readEmptyParams();";
}
C << nl << classScopedAMD << '_' << name << "Ptr __cb = new IceAsync" << classScopedAMD << '_' << name
@@ -4831,11 +4185,12 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
string typeString;
if((*r)->isOutParam())
{
- typeString = outputTypeToString((*r)->type(), metaData, _useWstring | TypeContextAMIEnd);
+ typeString = outputTypeToString((*r)->type(), (*r)->optional(), metaData,
+ _useWstring | TypeContextAMIEnd);
}
else
{
- typeString = inputTypeToString((*r)->type(), metaData, _useWstring);
+ typeString = inputTypeToString((*r)->type(), (*r)->optional(), metaData, _useWstring);
}
if(!(*r)->isOutParam())
@@ -4868,10 +4223,39 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
}
void
+Slice::Gen::ObjectVisitor::emitDataMember(const DataMemberPtr& p)
+{
+ TypePtr type = p->type();
+ if(SequencePtr::dynamicCast(type))
+ {
+ SequencePtr s = SequencePtr::dynamicCast(type);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(s->type());
+ if(builtin && builtin->kind() == Builtin::KindByte)
+ {
+ StringList metaData = s->getMetaData();
+ bool protobuf;
+ findMetaData(s, metaData, protobuf);
+ if(protobuf)
+ {
+ emitWarning(p->file(), p->line(), "protobuf cannot be used as a class member in C++");
+ }
+ }
+ }
+
+ string name = fixKwd(p->name());
+ H << sp << nl << typeToString(p->type(), p->optional(), p->getMetaData(), _useWstring) << ' ' << name << ';';
+}
+
+void
Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
{
string scoped = fixKwd(p->scoped());
ClassList bases = p->bases();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
DataMemberList dataMembers = p->dataMembers();
//
@@ -4881,11 +4265,16 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
// We override __incRef(), __decRef(), and __addObject() only once, in the basemost potentially
// cyclic class in an inheritance hierarchy.
//
- bool hasBaseClass = !bases.empty() && !bases.front()->isInterface();
bool canBeCyclic = p->canBeCyclic();
- bool override = canBeCyclic && (!hasBaseClass || !bases.front()->canBeCyclic());
+ bool override = canBeCyclic && (!base || !base->canBeCyclic());
+ bool basePreserved = p->inheritsMetaData("preserve-slice");
+ bool preserved = basePreserved || p->hasMetaData("preserve-slice");
- if(override)
+ //
+ // We also override __addObject and __usesGC if this is the initial preserved
+ // class in the hierarchy.
+ //
+ if(!basePreserved && (override || preserved))
{
H << nl << "virtual void __addObject(::IceInternal::GCCountMap&);";
@@ -4902,9 +4291,9 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
C << eb;
C << eb;
- H << nl << "virtual bool __usesClasses();";
+ H << nl << "virtual bool __usesGC();";
- C << sp << nl << "bool" << nl << scoped.substr(2) << "::__usesClasses()";
+ C << sp << nl << "bool" << nl << scoped.substr(2) << "::__usesGC()";
C << sb;
C << nl << "return true;";
C << eb;
@@ -4914,23 +4303,35 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
// __gcReachable() and __gcClear() are overridden by the basemost class that
// can be cyclic, plus all classes derived from that class.
//
- if(canBeCyclic)
+ // We also override these methods for the initial preserved class in a
+ // hierarchy, regardless of whether the class itself is cyclic.
+ //
+ if(canBeCyclic || (preserved && !basePreserved))
{
H << nl << "virtual void __gcReachable(::IceInternal::GCCountMap&) const;";
C << sp << nl << "void" << nl << scoped.substr(2) << "::__gcReachable(::IceInternal::GCCountMap& _c) const";
C << sb;
- bool hasCyclicBase = hasBaseClass && bases.front()->canBeCyclic();
- if(hasCyclicBase)
+ bool hasCyclicBase = base && base->canBeCyclic();
+ if(hasCyclicBase || basePreserved)
{
emitUpcall(bases.front(), "::__gcReachable(_c);");
}
+
+ if(preserved && !basePreserved)
+ {
+ C << nl << "if(__slicedData)";
+ C << sb;
+ C << nl << "__slicedData->__addObject(_c);";
+ C << eb;
+ }
+
for(DataMemberList::const_iterator i = dataMembers.begin(); i != dataMembers.end(); ++i)
{
if((*i)->type()->usesClasses())
{
- emitGCInsertCode((*i)->type(), fixKwd((*i)->name()), "", 0);
+ emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0);
}
}
C << eb;
@@ -4939,15 +4340,34 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
C << sp << nl << "void" << nl << scoped.substr(2) << "::__gcClear()";
C << sb;
- if(hasCyclicBase)
+
+ if(hasCyclicBase || basePreserved)
{
emitUpcall(bases.front(), "::__gcClear();");
}
+
+ //
+ // Clear the reference to the SlicedData object (if any).
+ //
+ // Note that this member is treated differently than regular class data
+ // members. The SlicedData class inherits from GCShared and therefore its
+ // instances are always registered with the GC. As a result, we must never
+ // assign 0 to the __slicedData member to clear the reference.
+ //
+ if(preserved && !basePreserved)
+ {
+ C << nl << "if(__slicedData)";
+ C << sb;
+ C << nl << "__slicedData->__decRefUnsafe();";
+ C << nl << "__slicedData.__clearHandleUnsafe();";
+ C << eb;
+ }
+
for(DataMemberList::const_iterator j = dataMembers.begin(); j != dataMembers.end(); ++j)
{
if((*j)->type()->usesClasses())
{
- emitGCClearCode((*j)->type(), fixKwd((*j)->name()), "", 0);
+ emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0);
}
}
C << eb;
@@ -4957,8 +4377,8 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
void
Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& prefix, const string& name, int level)
{
- if((BuiltinPtr::dynamicCast(p) && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(p))
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
+ if((builtin && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p))
{
C << nl << "if(" << prefix << name << ')';
C << sb;
@@ -5021,8 +4441,8 @@ Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& pref
void
Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefix, const string& name, int level)
{
- if((BuiltinPtr::dynamicCast(p) && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(p))
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
+ if((builtin && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p))
{
C << nl << "if(" << prefix << name << ")";
C << sb;
@@ -5030,7 +4450,7 @@ Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefi
if(decl)
{
string scope = fixKwd(decl->scope());
- C << nl << "if(" << scope << "upCast(" << prefix << name << ".get())->__usesClasses())";
+ C << nl << "if(" << scope << "upCast(" << prefix << name << ".get())->__usesGC())";
C << sb;
C << nl << scope << "upCast(" << prefix << name << ".get())->__decRefUnsafe();";
C << nl << prefix << name << ".__clearHandleUnsafe();";
@@ -5038,7 +4458,7 @@ Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefi
}
else
{
- C << nl << "if(" << prefix << name << "->__usesClasses())";
+ C << nl << "if(" << prefix << name << "->__usesGC())";
C << sb;
C << nl << prefix << name << "->__decRefUnsafe();";
C << nl << prefix << name << ".__clearHandleUnsafe();";
@@ -5127,18 +4547,8 @@ Slice::Gen::ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p, boo
}
upcall += ")";
- H.zeroIndent();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug";
- H.restoreIndent();
- H << nl << fixKwd(p->name()) << upcall;
- H.zeroIndent();
- H << nl << "#else";
- H.restoreIndent();
H << nl << fixKwd(p->scoped()) << upcall;
- H.zeroIndent();
- H << nl << "#endif";
H << nl;
- H.restoreIndent();
return true;
}
@@ -5155,7 +4565,7 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p)
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
+ string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring);
allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
@@ -5205,17 +4615,7 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p)
void
Slice::Gen::ObjectVisitor::emitUpcall(const ClassDefPtr& base, const string& call)
{
- C.zeroIndent();
- C << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- C.restoreIndent();
- C << nl << (base ? fixKwd(base->name()) : string("Object")) << call;
- C.zeroIndent();
- C << nl << "#else";
- C.restoreIndent();
C << nl << (base ? fixKwd(base->scoped()) : string("::Ice::Object")) << call;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
}
Slice::Gen::AsyncCallbackVisitor::AsyncCallbackVisitor(Output& h, Output& c, const string& dllExport) :
@@ -5337,8 +4737,9 @@ bool
usePrivateEnd(const OperationPtr& p)
{
TypePtr ret = p->returnType();
- string retSEnd = returnTypeToString(ret, p->getMetaData(), TypeContextAMIEnd);
- string retSPrivateEnd = returnTypeToString(ret, p->getMetaData(), TypeContextAMIPrivateEnd);
+ bool retIsOpt = p->returnIsOptional();
+ string retSEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIEnd);
+ string retSPrivateEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIPrivateEnd);
ParamDeclList outParams;
vector<string> outDeclsEnd;
@@ -5349,8 +4750,10 @@ usePrivateEnd(const OperationPtr& p)
{
if((*q)->isOutParam())
{
- outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->getMetaData(), TypeContextAMIEnd));
- outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->getMetaData(), TypeContextAMIPrivateEnd));
+ outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ TypeContextAMIEnd));
+ outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ TypeContextAMIPrivateEnd));
}
}
@@ -5381,7 +4784,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
string delTmplName = (withCookie ? "Callback_" : "CallbackNC_") + clName + "_" + p->name();
TypePtr ret = p->returnType();
- string retS = inputTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
string retEndArg = getEndArg(ret, p->getMetaData(), "__ret");
ParamDeclList outParams;
@@ -5398,7 +4801,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
outParams.push_back(*q);
outArgs.push_back(fixKwd((*q)->name()));
outEndArgs.push_back(getEndArg((*q)->type(), (*q)->getMetaData(), outArgs.back()));
- outDecls.push_back(inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring));
+ outDecls.push_back(inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring));
}
}
@@ -5487,8 +4890,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
H << sb;
H << nl << clScope << clName << "Prx __proxy = " << clScope << clName
<< "Prx::uncheckedCast(__result->getProxy());";
- writeAllocateCode(H, outParams, ret, p->getMetaData(),
- _useWstring | TypeContextInParam | TypeContextAMICallPrivateEnd);
+ writeAllocateCode(H, outParams, p, _useWstring | TypeContextInParam | TypeContextAMICallPrivateEnd);
H << nl << "try";
H << sb;
H << nl;
@@ -5509,42 +4911,16 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
}
H << "__result" << epar << ';';
}
- writeEndCode(H, outParams, ret, p->getMetaData());
+ writeEndCode(H, outParams, p);
H << eb;
H << nl << "catch(::Ice::Exception& ex)";
H << sb;
- H.zeroIndent();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.restoreIndent();
- H << nl << "__exception(__result, ex);";
- H.zeroIndent();
- H << nl << "#else";
- H.restoreIndent();
+
H << nl << "" << baseD << "::__exception(__result, ex);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
H << nl << "return;";
H << eb;
H << nl << "if(response)";
H << sb;
- H.zeroIndent();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.restoreIndent();
- H << nl << "(callback.get()->*response)" << spar;
- if(ret)
- {
- H << "__ret";
- }
- H << outArgs;
- if(withCookie)
- {
- H << "CT::dynamicCast(__result->getCookie())";
- }
- H << epar << ';';
- H.zeroIndent();
- H << nl << "#else";
- H.restoreIndent();
H << nl << "(" << baseD << "::callback.get()->*response)" << spar;
if(ret)
{
@@ -5556,9 +4932,6 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
H << "CT::dynamicCast(__result->getCookie())";
}
H << epar << ';';
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
H << eb;
H << eb;
@@ -5641,150 +5014,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
}
}
-Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, const string& dllExport, bool stream) :
- H(h), C(c), _dllExport(dllExport), _stream(stream)
-{
-}
-
-bool
-Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p)
-{
- if(!p->hasClassDecls())
- {
- return false;
- }
-
- string name = fixKwd(p->name());
-
- H << sp;
- H << nl << "namespace " << name << nl << '{';
-
- return true;
-}
-
-void
-Slice::Gen::HandleVisitor::visitModuleEnd(const ModulePtr& p)
-{
- H << sp;
- H << nl << '}';
-}
-
-void
-Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p)
-{
- string name = p->name();
- string scoped = fixKwd(p->scoped());
-
- if(!p->isLocal())
- {
- H << sp;
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);";
- H << nl << _dllExport << "void __patch__" << name << "Ptr(void*, ::Ice::ObjectPtr&);";
- if(_stream)
- {
- H << sp;
- H.zeroIndent();
- H << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- H << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- H.restoreIndent();
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << name << "Prx(const ::Ice::OutputStreamPtr&, const " << name
- << "Prx&);";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << name << "Prx(const ::Ice::InputStreamPtr&, " << name
- << "Prx&);";
-
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << name << "(const ::Ice::OutputStreamPtr&, const "
- << name << "Ptr&);";
- H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << name << "(const ::Ice::InputStreamPtr&, " << name << "Ptr&);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
- }
- }
-}
-
-bool
-Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
-{
- if(!p->isLocal())
- {
- string name = p->name();
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- string factory;
- string type;
- if(!p->isAbstract())
- {
- type = scoped + "::ice_staticId()";
- factory = scoped + "::ice_factory()";
- }
- else
- {
- type = "\"\"";
- factory = "0";
- }
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, "
- << scope << name << "Prx& v)";
- C << sb;
- C << nl << "::Ice::ObjectPrx proxy;";
- C << nl << "__is->read(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;
-
- if(_stream)
- {
- C << sp;
- C.zeroIndent();
- C << nl << "// COMPILERFIX: Stream API is not supported with VC++ 6";
- C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
- C.restoreIndent();
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << name
- << "Prx(const ::Ice::OutputStreamPtr& __outS, const " << scope << name << "Prx& v)";
- C << sb;
- C << nl << "__outS->write(v);";
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "ice_read" << name
- << "Prx(const ::Ice::InputStreamPtr& __inS, " << scope << name << "Prx& v)";
- C << sb;
- C << nl << "__inS->read(v);";
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << name
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scope << name << "Ptr& v)";
- C << sb;
- C << nl << "__outS->writeObject(v);";
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "ice_read" << name << "(const ::Ice::InputStreamPtr& __inS, "
- << scope << name << "Ptr& __v)";
- C << sb;
- C << nl << "__inS->read(__v);";
- C << eb;
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
- }
- }
-
- return true;
-}
-
-Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c,
- const string& dllExport) :
+Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c, const string& dllExport) :
H(h), C(c), _dllExport(dllExport), _useWstring(false)
{
}
@@ -6021,7 +5251,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
string opName = op->name();
TypePtr ret = op->returnType();
- string retS = returnTypeToString(ret, op->getMetaData(), _useWstring);
+ string retS = returnTypeToString(ret, op->returnIsOptional(), op->getMetaData(), _useWstring);
if(!p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd")))
{
@@ -6034,7 +5264,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(!(*q)->isOutParam())
{
- H << ',' << nl << inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring);
+ H << ',' << nl << inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ _useWstring);
}
}
H << ',' << nl << "const Ice::Current&";
@@ -6051,8 +5282,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(!(*q)->isOutParam())
{
- C << ',' << nl << inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring) << ' '
- << fixKwd((*q)->name());
+ C << ',' << nl << inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ _useWstring) << ' ' << fixKwd((*q)->name());
}
}
C << ',' << nl << "const Ice::Current& current";
@@ -6114,23 +5345,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
H << ',' << nl;
}
StringList metaData = (*q)->getMetaData();
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
string typeString;
if((*q)->isOutParam())
{
- typeString = outputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
else
{
- typeString = inputTypeToString((*q)->type(), metaData, _useWstring);
+ typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
-#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring)
- : inputTypeToString((*q)->type(), metaData, _useWstring);
-#endif
H << typeString;
}
if(!p->isLocal())
@@ -6157,23 +5380,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
C << ',' << nl;
}
StringList metaData = (*q)->getMetaData();
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
string typeString;
if((*q)->isOutParam())
{
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
else
{
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring);
}
-#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring)
- : inputTypeToString((*q)->type(), metaData, _useWstring);
-#endif
C << typeString << ' ' << fixKwd((*q)->name());
}
if(!p->isLocal())
@@ -6282,12 +5497,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
paramsDeclInvoke.push_back("const " + proxyName + "& __prx");
TypePtr ret = p->returnType();
- string retS = inputTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
if(ret)
{
params.push_back(retS);
- paramsAMD.push_back(inputTypeToString(ret, p->getMetaData(), _useWstring));
+ paramsAMD.push_back(inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring));
paramsDecl.push_back(retS + " __ret");
args.push_back("__ret");
}
@@ -6299,12 +5514,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
{
string paramName = fixKwd((*q)->name());
TypePtr type = (*q)->type();
- string typeString = inputTypeToString(type, (*q)->getMetaData(), _useWstring);
+ string typeString = inputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring);
if((*q)->isOutParam())
{
params.push_back(typeString);
- paramsAMD.push_back(inputTypeToString(type, (*q)->getMetaData(), _useWstring));
+ paramsAMD.push_back(inputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring));
paramsDecl.push_back(typeString + ' ' + paramName);
args.push_back(paramName);
@@ -6342,17 +5557,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
H << eb;
H << nl << "void __sent(bool sentSynchronously)";
H << sb;
- H.zeroIndent();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H.restoreIndent();
- H << nl << "AMICallbackBase::__sent(sentSynchronously);";
- H.zeroIndent();
- H << nl << "#else";
- H.restoreIndent();
H << nl << "::Ice::AMICallbackBase::__sent(sentSynchronously);";
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
H << eb;
H << eb << ';';
H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMI << '_' << name << "> " << classNameAMI
@@ -6475,7 +5680,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
#endif
TypePtr ret = p->returnType();
- string retS = inputTypeToString(ret, p->getMetaData(), _useWstring);
+ string retS = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring);
if(ret)
{
@@ -6494,7 +5699,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
{
string paramName = fixKwd((*q)->name());
TypePtr type = (*q)->type();
- string typeString = inputTypeToString(type, (*q)->getMetaData(), _useWstring);
+ string typeString = inputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring);
if(ret || !outParams.empty())
{
@@ -6550,16 +5755,9 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
{
C << nl << "try";
C << sb;
- C << nl << "::IceInternal::BasicStream* __os = this->__getOs();";
- writeMarshalCode(C, outParams, 0, StringList(), TypeContextInParam);
- if(ret)
- {
- writeMarshalUnmarshalCode(C, ret, "__ret", true, "", true, p->getMetaData(), TypeContextInParam);
- }
- if(p->returnsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
+ C << nl << "::IceInternal::BasicStream* __os = __startWriteParams(" << opFormatTypeToString(p) << ");";
+ writeMarshalCode(C, outParams, p, TypeContextInParam);
+ C << nl << "__endWriteParams(true);";
C << eb;
C << nl << "catch(const ::Ice::Exception& __ex)";
C << sb;
@@ -6567,7 +5765,11 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
C << nl << "return;";
C << eb;
}
- C << nl << "__response(true);";
+ else
+ {
+ C << nl << "__writeEmptyParams();";
+ }
+ C << nl << "__response();";
C << eb;
C << eb;
@@ -6589,24 +5791,14 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
C << sb;
C << nl <<"if(__validateResponse(false))";
C << sb;
- C << nl << "__getOs()->write(*__ex);";
- C << nl << "__response(false);";
+ C << nl << "__writeUserException(*__ex, " << opFormatTypeToString(p) << ");";
+ C << nl << "__response();";
C << eb;
C << eb;
}
C << nl << "else";
C << sb;
- C.zeroIndent();
- C << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- C.restoreIndent();
- C << nl << "IncomingAsync::ice_exception(ex);";
- C.zeroIndent();
- C << nl << "#else";
- C.restoreIndent();
C << nl << "::IceInternal::IncomingAsync::ice_exception(ex);";
- C.zeroIndent();
- C << nl << "#endif";
- C.restoreIndent();
C << eb;
C << eb;
}
@@ -6634,10 +5826,6 @@ Slice::Gen::StreamVisitor::visitModuleStart(const ModulePtr& m)
// Only emit this for the top-level module.
//
H << sp;
- H.zeroIndent();
- H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX
- H << nl << "#else";
- H.restoreIndent();
H << nl << "namespace Ice" << nl << '{';
}
@@ -6653,9 +5841,6 @@ Slice::Gen::StreamVisitor::visitModuleEnd(const ModulePtr& m)
// Only emit this for the top-level module.
//
H << nl << '}';
- H.zeroIndent();
- H << nl << "#endif";
- H.restoreIndent();
}
}
@@ -6700,6 +5885,15 @@ Slice::Gen::StreamVisitor::visitStructStart(const StructPtr& p)
H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeStruct;";
}
H << nl << "static const int minWireSize = " << p->minWireSize() << ";";
+ H << nl << "static const bool isVariableLength = " << p->isVariableLength() << ";";
+ if(p->isVariableLength())
+ {
+ H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeFSize;";
+ }
+ else
+ {
+ H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeVSize;";
+ }
H << eb << ";" << nl;
}
return false;
@@ -6712,22 +5906,11 @@ Slice::Gen::StreamVisitor::visitEnum(const EnumPtr& p)
H << nl << "template<>";
H << nl << "struct StreamTrait< " << scoped << ">";
H << sb;
- H << nl << "static const ::Ice::StreamTraitType type = ";
- size_t sz = p->getEnumerators().size();
- if(sz <= 127)
- {
- H << "::Ice::StreamTraitTypeByteEnum;";
- }
- else if(sz <= 32767)
- {
- H << "::Ice::StreamTraitTypeShortEnum;";
- }
- else
- {
- H << "::Ice::StreamTraitTypeIntEnum;";
- }
- H << nl << "static const int enumLimit = " << sz << ";";
+ H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeEnum;";
+ H << nl << "static const int enumLimit = " << p->getEnumerators().size() << ";";
H << nl << "static const int minWireSize = " << p->minWireSize() << ";";
+ H << nl << "static const bool isVariableLength = true;";
+ H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeSize;";
H << eb << ";" << nl;
}
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index f30a220b445..941b2a90e12 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -254,6 +254,7 @@ private:
private:
+ void emitDataMember(const DataMemberPtr&);
void emitGCFunctions(const ClassDefPtr&);
void emitGCInsertCode(const TypePtr&, const std::string&, const std::string&, int);
void emitGCClearCode(const TypePtr&, const std::string&, const std::string&, int);
@@ -319,26 +320,6 @@ private:
std::list<int> _useWstringHist;
};
- class HandleVisitor : private ::IceUtil::noncopyable, public ParserVisitor
- {
- public:
-
- HandleVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool);
-
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
-
- private:
-
- ::IceUtilInternal::Output& H;
- ::IceUtilInternal::Output& C;
-
- std::string _dllExport;
- bool _stream;
- };
-
class ImplVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
diff --git a/cpp/src/slice2cpp/Makefile.mak b/cpp/src/slice2cpp/Makefile.mak
index 128e4f135a2..f6a4b8cf365 100644
--- a/cpp/src/slice2cpp/Makefile.mak
+++ b/cpp/src/slice2cpp/Makefile.mak
@@ -26,11 +26,7 @@ CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
PDBFLAGS = /pdb:$(NAME:.exe=.pdb)
!endif
-!if "$(BCPLUSPLUS)" == "yes"
-RES_FILE = ,, Slice2Cpp.res
-!else
RES_FILE = Slice2Cpp.res
-!endif
$(NAME): $(OBJS) Slice2Cpp.res
$(LINK) $(LD_EXEFLAGS) $(PDBFLAGS) $(OBJS) $(SETARGV) $(PREOUT)$@ $(PRELIBS)slice$(LIBSUFFIX).lib \
@@ -45,13 +41,7 @@ clean::
install:: all
copy $(NAME) "$(install_bindir)"
-
-!if "$(BCPLUSPLUS)" == "yes" && "$(OPTIMIZE)" != "yes"
-
-install:: all
- copy $(NAME:.exe=.tds) "$(install_bindir)"
-
-!elseif "$(GENERATE_PDB)" == "yes"
+!if "$(GENERATE_PDB)" == "yes"
install:: all
copy $(NAME:.exe=.pdb) "$(install_bindir)"