diff options
author | Michi Henning <michi@zeroc.com> | 2004-11-10 05:57:36 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-11-10 05:57:36 +0000 |
commit | 90f85666d9730f4bbb791ef9c5bedb2e99e8425d (patch) | |
tree | 6ceeafac0aea7111f1740943e213b665f2b302f0 /cpp | |
parent | HP fix (diff) | |
download | ice-90f85666d9730f4bbb791ef9c5bedb2e99e8425d.tar.bz2 ice-90f85666d9730f4bbb791ef9c5bedb2e99e8425d.tar.xz ice-90f85666d9730f4bbb791ef9c5bedb2e99e8425d.zip |
Streaming API for VB.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Slice/VbUtil.h | 4 | ||||
-rwxr-xr-x | cpp/src/Slice/VbUtil.cpp | 211 | ||||
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 28 | ||||
-rwxr-xr-x | cpp/src/slice2vb/Gen.cpp | 480 | ||||
-rw-r--r-- | cpp/src/slice2vb/Gen.h | 15 | ||||
-rw-r--r-- | cpp/src/slice2vb/Main.cpp | 13 |
6 files changed, 638 insertions, 113 deletions
diff --git a/cpp/include/Slice/VbUtil.h b/cpp/include/Slice/VbUtil.h index f516ab34c5a..b59bf5ab344 100644 --- a/cpp/include/Slice/VbUtil.h +++ b/cpp/include/Slice/VbUtil.h @@ -39,9 +39,9 @@ protected: // // Generate code to marshal or unmarshal a type // - void writeMarshalUnmarshalCode(::IceUtil::Output&, const TypePtr&, const std::string&, bool, + void writeMarshalUnmarshalCode(::IceUtil::Output&, const TypePtr&, const std::string&, bool, bool, bool, const std::string& = ""); - void writeSequenceMarshalUnmarshalCode(::IceUtil::Output&, const SequencePtr&, const std::string&, bool); + void writeSequenceMarshalUnmarshalCode(::IceUtil::Output&, const SequencePtr&, const std::string&, bool, bool); private: diff --git a/cpp/src/Slice/VbUtil.cpp b/cpp/src/Slice/VbUtil.cpp index 21bbea296e9..dd9a688a35f 100755 --- a/cpp/src/Slice/VbUtil.cpp +++ b/cpp/src/Slice/VbUtil.cpp @@ -227,10 +227,20 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out, const TypePtr& type, const string& param, bool marshal, + bool streamingAPI, bool isOutParam, const string& patchParams) { - string stream = marshal ? "__os" : "__is"; + string stream; + + if(marshal) + { + stream = streamingAPI ? "__out" : "__os"; + } + else + { + stream = streamingAPI ? "__in" : "__is"; + } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) @@ -345,11 +355,26 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out, { out << nl << "Dim " << param << "_PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType(Ice.Object)"; - out << nl << stream << ".readObject(" << param << "_PP)"; + if(streamingAPI) + { + out << nl << stream << ".readObject(CType(" << param << "_PP, Ice.ReadObjectCallback))"; + } + else + { + out << nl << stream << ".readObject(" << param << "_PP)"; + } } else { - out << nl << stream << ".readObject(New __Patcher(" << patchParams << "))"; + if(streamingAPI) + { + out << nl << stream << ".readObject(CType(New __Patcher(" << patchParams + << ", Ice.ReadObjectCallback)))"; + } + else + { + out << nl << stream << ".readObject(New __Patcher(" << patchParams << "))"; + } } } break; @@ -382,11 +407,21 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out, string helperName = fixId((contained ? contained->scoped() : typeToString(type)) + "Helper"); if(marshal) { - out << nl << helperName << ".__write(" << stream << ", " << param << ')'; + out << nl << helperName << '.'; + if(!streamingAPI) + { + out << "__"; + } + out << "write(" << stream << ", " << param << ')'; } else { - out << nl << param << " = " << helperName << ".__read(" << stream << ')'; + out << nl << param << " = " << helperName << '.'; + if(!streamingAPI) + { + out << "__"; + } + out << "read(" << stream << ')'; } return; } @@ -405,11 +440,26 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out, out << nl << "Dim " << param << "_PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType(" << typeToString(type) << "))"; - out << nl << stream << ".readObject(" << param << "_PP)"; + if(streamingAPI) + { + out << nl << stream << ".readObject(CType(" << param << "_PP, Ice.ReadObjectCallback))"; + } + else + { + out << nl << stream << ".readObject(" << param << "_PP)"; + } } else { - out << nl << stream << ".readObject(New __Patcher(" << patchParams << "))"; + if(streamingAPI) + { + out << nl << stream << ".readObject(New __Patcher(CType(" << patchParams + << ", Ice.ReadObjectCallback)))"; + } + else + { + out << nl << stream << ".readObject(New __Patcher(" << patchParams << "))"; + } } } return; @@ -466,7 +516,7 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - writeSequenceMarshalUnmarshalCode(out, seq, param, marshal); + writeSequenceMarshalUnmarshalCode(out, seq, param, marshal, streamingAPI); return; } @@ -486,9 +536,18 @@ void Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, const SequencePtr& seq, const string& param, - bool marshal) + bool marshal, + bool streamingAPI) { - string stream = marshal ? "__os" : "__is"; + string stream; + if(marshal) + { + stream = streamingAPI ? "__out" : "__os"; + } + else + { + stream = streamingAPI ? "__in" : "__is"; + } TypePtr type = seq->type(); string typeS = typeToString(type); @@ -527,7 +586,11 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << nl << "For __block As Integer = 0 To 0"; out.inc(); out << nl << "Dim __lenx As Integer = " << stream << ".readSize()"; - out << nl << stream << ".startSeq(__len, " << static_cast<unsigned>(builtin->minWireSize()) << ")"; + if(!streamingAPI) + { + out << nl << stream << ".startSeq(__len, " << static_cast<unsigned>(builtin->minWireSize()) + << ")"; + } out << nl << param << " = New "; if(builtin->kind() == Builtin::KindObject) { @@ -541,8 +604,16 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } out << nl << "For __ix As Integer = 0 To __lenx - 1"; out.inc(); - out << nl << stream << ".readObject(New IceInternal.SequencePatcher(" - << param << ", GetType(Ice.Object), __ix))"; + if(streamingAPI) + { + out << nl << stream << ".readObject(CType(New IceInternal.SequencePatcher(" + << param << ", GetType(Ice.Object), __ix), Ice.ReadObjectCallback))"; + } + else + { + out << nl << stream << ".readObject(New IceInternal.SequencePatcher(" + << param << ", GetType(Ice.Object), __ix))"; + } out.dec(); out << nl << "Next"; } @@ -562,9 +633,12 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out.dec(); out << nl << "Next"; } - out << nl << stream << ".checkSeq()"; - out << nl << stream << ".endElement()"; - out << nl << stream << ".endSeq(__lenx)"; + if(!streamingAPI) + { + out << nl << stream << ".checkSeq()"; + out << nl << stream << ".endElement()"; + out << nl << stream << ".endSeq(__lenx)"; + } out.dec(); out << nl << "Next"; } @@ -608,17 +682,28 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out.inc(); if(marshal) { + out << nl << "If " << param << " Is Nothing"; + out.inc(); + out << nl << stream << ".writeSize(0)"; + out.dec(); + out << nl << "Else"; + out.inc(); out << nl << stream << ".writeSize(" << param << '.' << limitID << ")"; out << nl << "For __ix As Integer = 0 To " << param << '.' << limitID << " - 1"; out.inc(); out << nl << stream << ".writeObject(" << param << "(__ix))"; out.dec(); out << nl << "Next"; + out.dec(); + out << nl << "End If"; } else { out << nl << "Dim szx As Integer = " << stream << ".readSize()"; - out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ')'; + if(!streamingAPI) + { + out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ')'; + } out << nl << param << " = New "; if(isArray) { @@ -632,12 +717,25 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out.inc(); out << nl << "Dim spx As IceInternal.SequencePatcher = New IceInternal.SequencePatcher(" << param << ", " << "GetType(" << typeS << "), ix)"; - out << nl << stream << ".readObject(spx)"; - out << nl << stream << ".checkSeq()"; - out << nl << stream << ".endElement()"; + if(streamingAPI) + { + out << nl << stream << ".readObject(CType(spx, Ice.ReadObjectCallback))"; + } + else + { + out << nl << stream << ".readObject(spx)"; + } + if(!streamingAPI) + { + out << nl << stream << ".checkSeq()"; + out << nl << stream << ".endElement()"; + } out.dec(); out << nl << "Next"; - out << nl << stream << ".endSeq(szx)"; + if(!streamingAPI) + { + out << nl << stream << ".endSeq(szx)"; + } } out.dec(); out << nl << "Next"; @@ -651,17 +749,28 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out.inc(); if(marshal) { + out << nl << "If " << param << " Is Nothing"; + out.inc(); + out << nl << stream << ".writeSize(0)"; + out.dec(); + out << nl << "Else"; + out.inc(); out << nl << stream << ".writeSize(" << param << '.' << limitID << ")"; out << nl << "For __ix As Integer = 0 To " << param << '.' << limitID << " - 1"; out.inc(); out << nl << param << "(__ix).__write(" << stream << ")"; out.dec(); out << nl << "Next"; + out.dec(); + out << nl << "End If"; } else { out << nl << "Dim szx As Integer = " << stream << ".readSize()"; - out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ')'; + if(!streamingAPI) + { + out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ')'; + } out << nl << param << " = New "; if(isArray) { @@ -674,14 +783,17 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << nl << "For __ix As Integer = 0 To " << param << '.' << limitID << " - 1"; out.inc(); out << nl << param << "(__ix).__read(" << stream << ")"; - if(st->isVariableLength()) + if(st->isVariableLength() && !streamingAPI) { out << nl << stream << ".checkSeq()"; out << nl << stream << ".endElement()"; } out.dec(); out << nl << "Next"; - out << nl << stream << ".endSeq(szx)"; + if(!streamingAPI) + { + out << nl << stream << ".endSeq(szx)"; + } } out.dec(); out << nl << "Next"; @@ -696,17 +808,28 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out.inc(); if(marshal) { + out << nl << "If " << param << " Is Nothing"; + out.inc(); + out << nl << stream << ".writeSize(0)"; + out.dec(); + out << nl << "Else"; + out.inc(); out << nl << stream << ".writeSize(" << param << '.'<< limitID << ')'; out << nl << "For __ix As Integer = 0 To " << param << '.' << limitID << " - 1"; out.inc(); out << nl << stream << ".writeByte(CType(" << param << "(__ix), Byte))"; out.dec(); out << nl << "Next"; + out.dec(); + out << nl << "End If"; } else { out << nl << "Dim szx As Integer = " << stream << ".readSize()"; - out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ')'; + if(!streamingAPI) + { + out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ')'; + } out << nl << param << " = New "; if(isArray) { @@ -728,7 +851,10 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } out.dec(); out << nl << "Next"; - out << nl << stream << ".endSeq(szx)"; + if(!streamingAPI) + { + out << nl << stream << ".endSeq(szx)"; + } } out.dec(); out << nl << "Next"; @@ -745,23 +871,40 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, helperName = fixId(ContainedPtr::dynamicCast(type)->scoped() + "Helper"); } + string func; + if(!streamingAPI && ProxyPtr::dynamicCast(type)) + { + func = "__"; + } if(marshal) { - string func = ProxyPtr::dynamicCast(type) ? "__write" : "write"; + func += "write"; + out << nl << "If " << param << " Is Nothing"; + out.inc(); + out << nl << stream << ".writeSize(0)"; + out.dec(); + out << nl << "Else"; + out.inc(); out << nl << stream << ".writeSize(" << param << '.' << limitID << ")"; out << nl << "For __ix As Integer = 0 To " << param << '.' << limitID << " - 1"; out.inc(); out << nl << helperName << '.' << func << '(' << stream << ", " << param << "(__ix))"; out.dec(); out << nl << "Next"; + out.dec(); + out << nl << "End If"; } else { + func += "read"; out << nl << "For __block As Integer = 0 To 0"; out.inc(); string func = ProxyPtr::dynamicCast(type) ? "__read" : "read"; out << nl << "Dim szx As Integer = " << stream << ".readSize()"; - out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ")"; + if(!streamingAPI) + { + out << nl << stream << ".startSeq(szx, " << static_cast<unsigned>(type->minWireSize()) << ")"; + } out << nl << param << " = New "; if(isArray) { @@ -783,15 +926,21 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } if(type->isVariableLength()) { - if(!SequencePtr::dynamicCast(type)) + if(!SequencePtr::dynamicCast(type) && !streamingAPI) { out << nl << stream << ".checkSeq()"; } - out << nl << stream << ".endElement()"; + if(!streamingAPI) + { + out << nl << stream << ".endElement()"; + } } out.dec(); out << nl << "Next"; - out << nl << stream << ".endSeq(szx)"; + if(!streamingAPI) + { + out << nl << stream << ".endSeq(szx)"; + } out.dec(); out << nl << "Next"; } diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index a95d3b3a607..3da9fe1feef 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -1207,7 +1207,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) { _out << "new "; } - _out << "class __Patcher : IceInternal.Patcher, Ice.ReadObjectCallback"; + _out << "class __Patcher : IceInternal.Patcher"; _out << sb; _out << sp << nl << "internal __Patcher(Ice.ObjectImpl instance"; if(allClassMembers.size() > 1) @@ -1255,11 +1255,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) } _out << eb; - _out << sp << nl << "public override void invoke(Ice.Object v)"; - _out << sb; - _out << nl << "patch(v);"; - _out << eb; - _out << sp << nl << "private " << name << " _instance;"; if(allClassMembers.size() > 1) { @@ -1850,7 +1845,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { _out << "new "; } - _out << "class __Patcher : IceInternal.Patcher, Ice.ReadObjectCallback"; + _out << "class __Patcher : IceInternal.Patcher"; _out << sb; _out << sp << nl << "internal __Patcher(Ice.Exception instance"; if(allClassMembers.size() > 1) @@ -2194,10 +2189,6 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) if(classMembers.size() != 0) { _out << sp << nl << "public sealed class __Patcher : IceInternal.Patcher"; - if(_stream) - { - _out << ", Ice.ReadObjectCallback"; - } _out << sb; _out << sp << nl << "internal __Patcher(" << name; if(patchStruct) @@ -2250,14 +2241,6 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } _out << eb; - if(_stream) - { - _out << sp << nl << "public override void invoke(Ice.Object v)"; - _out << sb; - _out << nl << "patch(v);"; - _out << eb; - } - _out << sp << nl << "private " << name; if(patchStruct) { @@ -3335,7 +3318,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) bool hasClassValue = (builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(value); if(hasClassValue) { - _out << sp << nl << "public sealed class __Patcher : IceInternal.Patcher, Ice.ReadObjectCallback"; + _out << sp << nl << "public sealed class __Patcher : IceInternal.Patcher"; _out << sb; _out << sp << nl << "internal __Patcher(" << name << " m, " << keyS << " key)"; _out << sb; @@ -3349,11 +3332,6 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << nl << "_m[_key] = (" << valueS << ")v;"; _out << eb; - _out << sp << nl << "public override void invoke(Ice.Object __v)"; - _out << sb; - _out << nl << "patch(__v);"; - _out << eb; - _out << sp << nl << "private " << name << " _m;"; _out << nl << "private " << keyS << " _key;"; _out << eb; diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp index f3df8044636..53c35bbed14 100755 --- a/cpp/src/slice2vb/Gen.cpp +++ b/cpp/src/slice2vb/Gen.cpp @@ -366,7 +366,7 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p) { _out << nl << "Dim " << param << " As " << typeS; } - writeMarshalUnmarshalCode(_out, q->first, param, false, true); + writeMarshalUnmarshalCode(_out, q->first, param, false, false, true); } if(op->sendsClasses()) { @@ -411,7 +411,7 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p) if(isClass) { - _out << "CType(" + fixId(q->second) + ", " + typeToString(q->first) + "_PP.value)"; + _out << "CType(" + fixId(q->second) + "_PP.value, " + typeToString(q->first) + ")"; } else { @@ -429,11 +429,11 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p) // for(q = outParams.begin(); q != outParams.end(); ++q) { - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, true, ""); + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, ""); } if(ret) { - writeMarshalUnmarshalCode(_out, ret, "__ret", true, true, ""); + writeMarshalUnmarshalCode(_out, ret, "__ret", true, false, true, ""); } if(op->returnsClasses()) { @@ -494,7 +494,7 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p) { _out << nl << "Dim " << fixId(q->second) << " As " << typeToString(q->first); } - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, true); + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true); } if(op->sendsClasses()) { @@ -814,9 +814,10 @@ Slice::VbVisitor::getArgsAsyncCB(const OperationPtr& op) } Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir, - bool impl, bool implTie) + bool impl, bool implTie, bool stream) : _base(base), - _includePaths(includePaths) + _includePaths(includePaths), + _stream(stream) { string file = base + ".vb"; string fileImpl = base + "I.vb"; @@ -915,7 +916,7 @@ Slice::Gen::generate(const UnitPtr& p) VbGenerator::validateMetaData(p); - TypesVisitor typesVisitor(_out); + TypesVisitor typesVisitor(_out, _stream); p->visit(&typesVisitor, false); ProxyVisitor proxyVisitor(_out); @@ -924,7 +925,7 @@ Slice::Gen::generate(const UnitPtr& p) OpsVisitor opsVisitor(_out); p->visit(&opsVisitor, false); - HelperVisitor helperVisitor(_out); + HelperVisitor helperVisitor(_out, _stream); p->visit(&helperVisitor, false); DelegateVisitor delegateVisitor(_out); @@ -1035,8 +1036,9 @@ Slice::Gen::OpsVisitor::OpsVisitor(IceUtil::Output& out) { } -Slice::Gen::TypesVisitor::TypesVisitor(IceUtil::Output& out) - : VbVisitor(out) +Slice::Gen::TypesVisitor::TypesVisitor(IceUtil::Output& out, bool stream) + : VbVisitor(out), + _stream(stream) { } @@ -1065,6 +1067,47 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) string scoped = fixId(p->scoped()); ClassList bases = p->bases(); + if(!p->isLocal() && _stream) + { + _out << sp << nl << "Public NotInheritable Class " << p->name() << "Helper"; + _out.inc(); + + _out << sp << nl << "Public Sub New(ByVal __in As Ice.InputStream)"; + _out.inc(); + _out << nl << "_in = __in"; + _out << nl << "_pp = New IceInternal.ParamPatcher(GetType(" << scoped << "))"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Shared Sub write(ByVal __out As Ice.OutputStream, ByVal __v As " + << fixId(name) << ')'; + _out.inc(); + _out << nl << "__out.writeObject(__v)"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Sub read()"; + _out.inc(); + _out << nl << "_in.readObject(_pp)"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public ReadOnly Property value() As " << scoped; + _out.inc(); + _out << nl << "Get"; + _out.inc(); + _out << nl << "Return CType(_pp.value, " << scoped << ')'; + _out.dec(); + _out << nl << "End Get"; + _out.dec(); + _out << nl << "End Property"; + + _out << sp << nl << "Private _in As Ice.InputStream"; + _out << nl << "Private _pp As IceInternal.ParamPatcher"; + + _out.dec(); + _out << nl << "End Class"; + } if(p->isInterface()) { _out << sp << nl << "Public Interface " << name; @@ -1194,14 +1237,14 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) _out << sp << nl << "#Region \"Marshaling support\""; _out.restoreIndent(); - _out << sp << nl << "Public Overrides Sub __write(ByVal __os As IceInternal.BasicStream)"; + _out << sp << nl << "Public Overloads Overrides Sub __write(ByVal __os As IceInternal.BasicStream)"; _out.inc(); _out << nl << "__os.writeTypeId(ice_staticId())"; _out << nl << "__os.startWriteSlice()"; for(d = members.begin(); d != members.end(); ++d) { StringList metaData = (*d)->getMetaData(); - writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), true, false); + writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), true, false, false); } _out << nl << "__os.endWriteSlice()"; _out << nl << "MyBase.__write(__os)"; @@ -1271,7 +1314,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) _out << nl << "End Class"; } - _out << sp << nl << "Public Overrides Sub __read(ByVal __is As IceInternal.BasicStream, " + _out << sp << nl << "Public Overloads Overrides Sub __read(ByVal __is As IceInternal.BasicStream, " "ByVal __rid As Boolean)"; _out.inc(); _out << nl << "If __rid Then"; @@ -1297,13 +1340,89 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) } writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), - false, false, patchParams.str()); + false, false, false, patchParams.str()); } _out << nl << "__is.endReadSlice()"; _out << nl << "MyBase.__read(__is, true)"; _out.dec(); _out << nl << "End Sub"; + // + // Write streaming API. + // + if(_stream) + { + _out << sp << nl << "Public Overloads Overrides Sub __write(ByVal __out As Ice.OutputStream)"; + _out.inc(); + _out << nl << "__out.writeTypeId(ice_staticId())"; + _out << nl << "__out.startSlice()"; + for(d = members.begin(); d != members.end(); ++d) + { + StringList metaData = (*d)->getMetaData(); + writeMarshalUnmarshalCode(_out, (*d)->type(), + fixId((*d)->name(), DotNet::ICloneable, true), + true, true, false); + } + _out << nl << "__out.endSlice()"; + _out << nl << "MyBase.__write(__out)"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Overloads Overrides Sub __read" + << "(ByVal __in As Ice.InputStream, ByVal __rid As Boolean)"; + _out.inc(); + _out << nl << "If __rid Then"; + _out.inc(); + _out << nl << "Dim myId As String = __in.readTypeId()"; + _out.dec(); + _out << nl << "End If"; + _out << nl << "__in.startSlice()"; + for(d = members.begin(); d != members.end(); ++d) + { + StringList metaData = (*d)->getMetaData(); + ostringstream patchParams; + patchParams << "Me"; + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) + { + if(classMembers.size() > 1 || allClassMembers.size() > 1) + { + patchParams << ", " << classMemberCount++; + } + } + writeMarshalUnmarshalCode(_out, (*d)->type(), + fixId((*d)->name(), DotNet::ICloneable, true), + false, true, false, patchParams.str()); + } + _out << nl << "__in.endSlice()"; + _out << nl << "MyBase.__read(__in, True)"; + _out.dec(); + _out << nl << "End Sub"; + } + else + { + // + // Emit placeholder functions to catch errors. + // + string scoped = p->scoped(); + _out << sp << nl << "Public Overloads Overrides Sub __write(ByVal __out As Ice.OutputStream)"; + _out.inc(); + _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException"; + _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\""; + _out << nl << "Throw ex"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Overloads Overrides Sub __read" + << "(ByVal __in As Ice.InputStream, ByVal __rid As Boolean)"; + _out.inc(); + _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException"; + _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\""; + _out << nl << "Throw ex"; + _out.dec(); + _out << nl << "End Sub"; + } + _out.zeroIndent(); _out << sp << nl << "#End Region"; // Marshalling support _out.restoreIndent(); @@ -1896,7 +2015,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) ExceptionPtr base = p->base(); - _out << sp << nl << "Public Overrides Sub __write(ByVal __os As IceInternal.BasicStream)"; + _out << sp << nl << "Public Overloads Overrides Sub __write(ByVal __os As IceInternal.BasicStream)"; _out.inc(); _out << nl << "__os.writeString(\"" << scoped << "\")"; _out << nl << "__os.startWriteSlice()"; @@ -1904,7 +2023,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::ApplicationException), - true, false); + true, false, false); } _out << nl << "__os.endWriteSlice()"; if(base) @@ -1976,7 +2095,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out.dec(); _out << nl << "End Class"; } - _out << sp << nl << "Public Overrides Sub __read(ByVal __is As IceInternal.BasicStream, " + _out << sp << nl << "Public Overloads Overrides Sub __read(ByVal __is As IceInternal.BasicStream, " "ByVal __rid As Boolean)"; _out.inc(); _out << nl << "If __rid Then"; @@ -2001,7 +2120,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) } writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::ApplicationException), - false, false, patchParams.str()); + false, false, false, patchParams.str()); } _out << nl << "__is.endReadSlice()"; if(base) @@ -2011,6 +2130,84 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out.dec(); _out << nl << "End Sub"; + if(_stream) + { + _out << sp << nl << "Public Overloads Overrides Sub __write(ByVal __out As Ice.OutputStream)"; + _out.inc(); + _out << nl << "__out.writeString(\"" << scoped << "\")"; + _out << nl << "__out.startSlice()"; + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + writeMarshalUnmarshalCode(_out, (*q)->type(), + fixId((*q)->name(), DotNet::ApplicationException), + true, true, false); + } + _out << nl << "__out.endSlice()"; + if(base) + { + _out << nl << "MyBase.__write(__out)"; + } + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Overloads Overrides Sub __read(ByVal __in As Ice.InputStream, " + << "ByVal __rid As Boolean)"; + _out.inc(); + _out << nl << "If __rid Then"; + _out.inc(); + _out << nl << "Dim myId As String = __in.readString()"; + _out.dec(); + _out << nl << "End If"; + _out << nl << "__in.startSlice()"; + classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size()); + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + ostringstream patchParams; + patchParams << "Me"; + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type())) + { + if(classMembers.size() > 1 || allClassMembers.size() > 1) + { + patchParams << ", " << classMemberCount++; + } + } + writeMarshalUnmarshalCode(_out, (*q)->type(), + fixId((*q)->name(), DotNet::ApplicationException), + false, true, false, patchParams.str()); + } + _out << nl << "__in.endSlice()"; + if(base) + { + _out << nl << "MyBase.__read(__in, true)"; + } + _out.dec(); + _out << nl << "End Sub"; + } + else + { + // + // Emit placeholder functions to catch errors. + // + string scoped = p->scoped(); + _out << sp << nl << "Public Overloads Overrides Sub __write(ByVal __out As Ice.OutputStream)"; + _out.inc(); + _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException"; + _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\""; + _out << nl << "Throw ex"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Overloads Overrides Sub __read" + << "(ByVal __in As Ice.InputStream, ByVal __rid As Boolean)"; + _out.inc(); + _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException"; + _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\""; + _out << nl << "Throw ex"; + _out.dec(); + _out << nl << "End Sub"; + } + if(!base || base && !base->usesClasses()) { _out << sp << nl << "Public Overrides Function __usesClasses() As Boolean"; @@ -2034,6 +2231,29 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { string name = fixId(p->name()); + if(!p->isLocal() && _stream) + { + _out << sp << nl << "Public NotInheritable Class " << p->name() << "Helper"; + _out.inc(); + + _out << sp << nl << "Public Shared Sub write(ByVal __out As Ice.OutputStream, ByVal __v As " << name << ')'; + _out.inc(); + _out << nl << "__v.__write(__out)"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Shared Function read(ByVal __in As Ice.InputStream) As " << name; + _out.inc(); + _out << nl << "Dim __v As " << name << " = New " << name; + _out << nl << "__v.__read(__in)"; + _out << nl << "Return __v"; + _out.dec(); + _out << nl << "End Function"; + + _out.dec(); + _out << nl << "End Class"; + } + if(p->hasMetaData("vb:class")) { _out << sp << nl << "Public Class " << name << " Implements _System.ICloneable"; @@ -2227,7 +2447,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) { writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), isClass ? DotNet::ICloneable : 0), - true, false); + true, false, false); } _out.dec(); _out << nl << "End Sub"; @@ -2357,11 +2577,55 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), isClass ? DotNet::ICloneable : 0), - false, false, patchParams.str()); + false, false, false, patchParams.str()); } _out.dec(); _out << nl << "End Sub"; + if(_stream) + { + _out << sp << nl << "Public Sub __write(ByVal __out As Ice.OutputStream)"; + _out.inc(); + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + writeMarshalUnmarshalCode(_out, (*q)->type(), + fixId((*q)->name(), isClass ? DotNet::ICloneable : 0), + true, true, false); + } + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Sub __read(ByVal __in As Ice.InputStream)"; + _out.inc(); + if(patchStruct) + { + _out << nl << "If _pm Is Nothing"; + _out.inc(); + _out << nl << "_pm = New __PatchMembers"; + _out.dec(); + _out << nl << "End If"; + } + classMemberCount = 0; + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + ostringstream patchParams; + patchParams << (patchStruct ? "_pm" : "Me"); + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type())) + { + if(classMembers.size() > 1) + { + patchParams << ", " << classMemberCount++; + } + } + writeMarshalUnmarshalCode(_out, (*q)->type(), + fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ), + false, true, false, patchParams.str()); + } + _out.dec(); + _out << nl << "End Sub"; + } + _out.zeroIndent(); _out << sp << nl << "#End Region"; // Marshalling support _out.restoreIndent(); @@ -2684,6 +2948,7 @@ void Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) { string name = fixId(p->name()); + string scoped = fixId(p->scoped()); _out << sp << nl << "Public Enum " << name; _out.inc(); EnumeratorList enumerators = p->getEnumerators(); @@ -2693,6 +2958,29 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) } _out.dec(); _out << nl << "End Enum"; + + if(_stream) + { + _out << sp << nl << "Public NotInheritable Class " << name << "Helper"; + _out.inc(); + + _out << sp << nl << "Public Shared Sub write(ByVal __out As Ice.OutputStream, ByVal __v As " << scoped << ')'; + _out.inc(); + writeMarshalUnmarshalCode(_out, p, "__v", true, true, false); + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Shared Function read(ByVal __in As Ice.InputStream) As " << scoped; + _out.inc(); + _out << nl << "Dim __v As " << scoped; + writeMarshalUnmarshalCode(_out, p, "__v", false, true, false); + _out << nl << "Return __v"; + _out.dec(); + _out << nl << "End Function"; + + _out.dec(); + _out << nl << "End Class"; + } } void @@ -3063,8 +3351,9 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) _out << sp << nl << "End Interface"; } -Slice::Gen::HelperVisitor::HelperVisitor(IceUtil::Output& out) - : VbVisitor(out) +Slice::Gen::HelperVisitor::HelperVisitor(IceUtil::Output& out, bool stream) + : VbVisitor(out), + _stream(stream) { } @@ -3368,6 +3657,29 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out.dec(); _out << nl << "End Function"; + if(_stream) + { + _out << sp << nl << "Public Shared Sub write(ByVal __out As Ice.OutputStream, ByVal __v As " << name << "Prx)"; + _out.inc(); + _out << nl << "__out.writeProxy(__v)"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Shared Function read(ByVal __in As Ice.InputStream) As " << name << "Prx"; + _out.inc(); + _out << nl << "Dim proxy As Ice.ObjectPrx = __in.readProxy()"; + _out << nl << "If Not proxy Is Nothing"; + _out.inc(); + _out << nl << "Dim result As " << name << "PrxHelper = New " << name << "PrxHelper"; + _out << nl << "result.__copyFrom(proxy)"; + _out << nl << "Return result"; + _out.dec(); + _out << nl << "End If"; + _out << nl << "Return Nothing"; + _out.dec(); + _out << nl << "End Function"; + } + _out.zeroIndent(); _out << sp << nl << "#End Region"; // Marshaling support _out.restoreIndent(); @@ -3401,17 +3713,35 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) _out << sp << nl << "Public Shared Sub write(ByVal __os As IceInternal.BasicStream, ByVal __v As " << typeS << ')'; _out.inc(); - writeSequenceMarshalUnmarshalCode(_out, p, "__v", true); + writeSequenceMarshalUnmarshalCode(_out, p, "__v", true, false); _out.dec(); _out << nl << "End Sub"; _out << sp << nl << "Public Shared Function read(ByVal __is As IceInternal.BasicStream) As " << typeS; _out.inc(); _out << nl << "Dim __v As " << typeS; - writeSequenceMarshalUnmarshalCode(_out, p, "__v", false); + writeSequenceMarshalUnmarshalCode(_out, p, "__v", false, false); _out << nl << "Return __v"; _out.dec(); _out << nl << "End Function"; + + if(_stream) + { + _out << sp << nl << "Public Shared Sub write(ByVal __out As Ice.OutputStream, ByVal __v As " << typeS << ')'; + _out.inc(); + writeSequenceMarshalUnmarshalCode(_out, p, "__v", true, true); + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Shared Function read(ByVal __in As Ice.InputStream) As " << typeS; + _out.inc(); + _out << nl << "Dim __v As " << typeS; + writeSequenceMarshalUnmarshalCode(_out, p, "__v", false, true); + _out << nl << "Return __v"; + _out.dec(); + _out << nl << "End Function"; + } + _out.dec(); _out << sp << nl << "End Class"; } @@ -3450,9 +3780,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << nl << "For Each __e As _System.Collections.DictionaryEntry In __v"; _out.inc(); string keyArg = "CType(__e.Key, " + keyS + ")"; - writeMarshalUnmarshalCode(_out, key, keyArg, true, false); + writeMarshalUnmarshalCode(_out, key, keyArg, true, false, false); string valueArg = "__e.Value"; - writeMarshalUnmarshalCode(_out, value, valueArg, true, false); + writeMarshalUnmarshalCode(_out, value, valueArg, true, false, false); _out.dec(); _out << nl << "Next"; _out.dec(); @@ -3495,13 +3825,13 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << nl << "For __i As Integer = 0 To __sz - 1"; _out.inc(); _out << nl << "Dim __k As " << keyS; - writeMarshalUnmarshalCode(_out, key, "__k", false, false); + writeMarshalUnmarshalCode(_out, key, "__k", false, false, false); if(!hasClassValue) { _out << nl << "Dim __v As " << valueS; } - writeMarshalUnmarshalCode(_out, value, "__v", false, false, "__r, __k"); + writeMarshalUnmarshalCode(_out, value, "__v", false, false, false, "__r, __k"); if(!hasClassValue) { _out << nl << "__r(__k) = __v"; @@ -3513,6 +3843,52 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out.dec(); _out << nl << "End Function"; + if(_stream) + { + _out << nl << "Public Shared Sub write(ByVal __out As Ice.OutputStream, ByVal __v As " << name << ')'; + _out.inc(); + _out << nl << "If __v Is Nothing Then"; + _out.inc(); + _out << nl << "__out.writeSize(0)"; + _out.dec(); + _out << nl << "Else"; + _out.inc(); + _out << nl << "__out.writeSize(__v.Count)"; + _out << nl << "For Each __e As _System.Collections.DictionaryEntry In __v"; + _out.inc(); + writeMarshalUnmarshalCode(_out, key, keyArg, true, true, false); + writeMarshalUnmarshalCode(_out, value, valueArg, true, true, false); + _out.dec(); + _out << nl << "Next"; + _out.dec(); + _out << nl << "End If"; + _out.dec(); + _out << nl << "End Sub"; + + _out << sp << nl << "Public Shared Function read(ByVal __in As Ice.InputStream) As " << name; + _out.inc(); + _out << nl << "Dim __sz As Integer = __in.readSize()"; + _out << nl << "Dim __r As " << name << " = New " << name; + _out << nl << "For __i As Integer = 0 To __sz - 1"; + _out.inc(); + _out << nl << "Dim __k As " << keyS; + writeMarshalUnmarshalCode(_out, key, "__k", false, true, false); + if(!hasClassValue) + { + _out << nl << "Dim __v As " << valueS; + } + writeMarshalUnmarshalCode(_out, value, "__v", false, true, false, "__r, __k"); + if(!hasClassValue) + { + _out << nl << "__r(__k) = __v"; + } + _out.dec(); + _out << nl << "Next"; + _out << nl << "Return __r"; + _out.dec(); + _out << nl << "End Function"; + } + _out.dec(); _out << sp << nl << "End Class"; } @@ -3710,20 +4086,28 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) _out.inc(); if(!inParams.empty()) { + _out << nl << "Try"; + _out.inc(); _out << nl << "Dim __os As IceInternal.BasicStream = __out.ostr()"; + for(q = inParams.begin(); q != inParams.end(); ++q) + { + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false); + } + if(op->sendsClasses()) + { + _out << nl << "__os.writePendingObjects()"; + } + _out.dec(); + _out << nl << "Catch __ex As Ice.LocalException"; + _out.inc(); + _out << nl << "__out.abort(__ex)"; + _out.dec(); + _out << nl << "End Try"; } if(!outParams.empty() || ret || !throws.empty()) { _out << nl << "Dim __is As IceInternal.BasicStream = __out.istr()"; } - for(q = inParams.begin(); q != inParams.end(); ++q) - { - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false); - } - if(op->sendsClasses()) - { - _out << nl << "__os.writePendingObjects()"; - } _out << nl << "If Not __out.invoke() Then"; _out.inc(); if(!throws.empty()) @@ -3757,7 +4141,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) } for(q = outParams.begin(); q != outParams.end(); ++q) { - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, true, ""); + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true, ""); } if(ret) { @@ -3772,7 +4156,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) else { _out << nl << "Dim __ret As " << retS; - writeMarshalUnmarshalCode(_out, ret, "__ret", false, true, ""); + writeMarshalUnmarshalCode(_out, ret, "__ret", false, false, true, ""); } } if(op->returnsClasses()) @@ -4202,7 +4586,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) for(q = inParams.begin(); q != inParams.end(); ++q) { string typeS = typeToString(q->first); - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false); + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false); } if(p->sendsClasses()) { @@ -4254,11 +4638,11 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << nl << "End If"; for(q = outParams.begin(); q != outParams.end(); ++q) { - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, true); + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true); } if(ret) { - writeMarshalUnmarshalCode(_out, ret, "__ret", false, true); + writeMarshalUnmarshalCode(_out, ret, "__ret", false, false, true); } if(p->returnsClasses()) { @@ -4380,8 +4764,6 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << sp << nl << "Public Sub ice_response" << spar << paramsAMD << epar << " Implements " << classNameAMD << '_' << name << ".ice_response"; // TODO: should be containing class? _out.inc(); - _out << nl << "If Not _finished Then"; - _out.inc(); if(ret || !outParams.empty()) { _out << nl << "Try"; @@ -4390,12 +4772,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) for(q = outParams.begin(); q != outParams.end(); ++q) { string typeS = typeToString(q->first); - writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false); + writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false); } if(ret) { string retS = typeToString(ret); - writeMarshalUnmarshalCode(_out, ret, "__ret", true, false); + writeMarshalUnmarshalCode(_out, ret, "__ret", true, false, false); } if(p->returnsClasses()) { @@ -4410,15 +4792,11 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } _out << nl << "__response(true)"; _out.dec(); - _out << nl << "End If"; - _out.dec(); _out << nl << "End Sub"; _out << sp << nl << "Public Sub ice_exception(ByVal ex As _System.Exception)" << " Implements " << classNameAMD << '_' << name << ".ice_exception"; // TODO: should be containing class? _out.inc(); - _out << nl << "If Not _finished Then"; - _out.inc(); if(throws.empty()) { _out << nl << "__exception(ex)"; @@ -4446,8 +4824,6 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << nl << "End Try"; } _out.dec(); - _out << nl << "End If"; - _out.dec(); _out << nl << "End Sub"; _out.dec(); diff --git a/cpp/src/slice2vb/Gen.h b/cpp/src/slice2vb/Gen.h index bb77d16e72e..1277cc3e40e 100644 --- a/cpp/src/slice2vb/Gen.h +++ b/cpp/src/slice2vb/Gen.h @@ -45,6 +45,7 @@ public: const std::vector<std::string>&, const std::string&, bool, + bool, bool); ~Gen(); @@ -64,13 +65,15 @@ private: std::string _base; std::vector<std::string> _includePaths; + bool _stream; + void printHeader(); class TypesVisitor : public VbVisitor { public: - TypesVisitor(::IceUtil::Output&); + TypesVisitor(::IceUtil::Output&, bool); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); @@ -86,6 +89,10 @@ private: virtual void visitEnum(const EnumPtr&); virtual void visitConst(const ConstPtr&); virtual void visitDataMember(const DataMemberPtr&); + + private: + + bool _stream; }; class ProxyVisitor : public VbVisitor @@ -119,7 +126,7 @@ private: { public: - HelperVisitor(::IceUtil::Output&); + HelperVisitor(::IceUtil::Output&, bool); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); @@ -127,6 +134,10 @@ private: virtual void visitClassDefEnd(const ClassDefPtr&); virtual void visitSequence(const SequencePtr&); virtual void visitDictionary(const DictionaryPtr&); + + private: + + bool _stream; }; class DelegateVisitor : public VbVisitor diff --git a/cpp/src/slice2vb/Main.cpp b/cpp/src/slice2vb/Main.cpp index 73b27351c3e..9e99c2290a7 100644 --- a/cpp/src/slice2vb/Main.cpp +++ b/cpp/src/slice2vb/Main.cpp @@ -33,6 +33,7 @@ usage(const char* n) "-d, --debug Print debug messages.\n" "--ice Permit `Ice' prefix (for building Ice source code only)\n" "--checksum Generate checksums for Slice definitions.\n" + "--stream Generate marshaling support for public stream API.\n" ; // Note: --case-sensitive is intentionally not shown here! } @@ -51,6 +52,7 @@ main(int argc, char* argv[]) bool caseSensitive = false; bool depend = false; bool checksum = false; + bool stream = false; int idx = 1; while(idx < argc) @@ -186,6 +188,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--stream") == 0) + { + stream = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" @@ -246,7 +257,7 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie); + Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream); if(!gen) { p->destroy(); |