diff options
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Slice/CsUtil.cpp | 68 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.h | 9 |
3 files changed, 65 insertions, 20 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 58d668e68a3..7a8713cc3e7 100755 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -216,13 +216,15 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, const TypePtr& type, const string& param, bool marshal, - bool seqElem) + bool isSeq, + bool isOutParam, + const string& patchParams) { string stream = marshal ? "__os" : "__is"; string startAssign; string endAssign; - if(seqElem) + if(isSeq) { startAssign = ".Add("; endAssign = ")"; @@ -334,7 +336,6 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } break; } -#if 0 case Builtin::KindObject: { if(marshal) @@ -343,25 +344,19 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } else { - if(holder) + if(isOutParam) { - out << nl << stream << ".readObject(" << param << ".getPatcher());"; + out << nl << "IceInternal.ParamPatcher " << param + << "_PP = new IceInternal.ParamPatcher(typeof(Ice.Object));"; + out << nl << stream << ".readObject(" << param << "_PP);"; } else { - if(patchParams.empty()) - { - out << nl << stream << ".readObject(new Patcher());"; - } - else - { - out << nl << stream << ".readObject(" << patchParams << ");"; - } + out << nl << stream << ".readObject(new __Patcher(" << patchParams << "));"; } } break; } -#endif case Builtin::KindObjectProxy: { string typeS = typeToString(type); @@ -408,7 +403,16 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } else { - out << nl << param << " = " << stream << ".readObject(new Patcher());"; + if(isOutParam) + { + out << nl << "IceInternal.ParamPatcher " << param + << "_PP = new IceInternal.ParamPatcher(typeof(" << typeToString(type) << "));"; + out << nl << stream << ".readObject(" << param << "_PP);"; + } + else + { + out << nl << stream << ".readObject(new __Patcher(" << patchParams << "));"; + } } return; } @@ -464,7 +468,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - writeSequenceMarshalUnmarshalCode(out, seq, param, marshal, seqElem); + writeSequenceMarshalUnmarshalCode(out, seq, param, marshal, isSeq); return; } @@ -486,13 +490,13 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, const SequencePtr& seq, const string& param, bool marshal, - bool seqElem) + bool isSeq) { string stream = marshal ? "__os" : "__is"; string startAssign; string endAssign; - if(seqElem) + if(isSeq) { startAssign = ".Add("; endAssign = ")"; @@ -537,7 +541,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << nl << "for(int __i = 0; __i < __len; ++__i)"; out << sb; out << nl << stream << ".readObject(new IceInternal.SequencePatcher(" - << param << ", typeof(Ice.Object), Ice.ObjectImpl.ice_staticId(), __i));"; + << param << ", typeof(Ice.Object), __i));"; out << eb; } else @@ -571,6 +575,32 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, return; } + ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); + if(cl) + { + if(marshal) + { + out << nl << stream << ".writeSize(" << param << ".Count);"; + out << nl << "for(int __i = 0; __i < " << param << ".Count; ++__i)"; + out << sb; + out << nl << stream << ".writeObject(" << param << "[__i]);"; + out << eb; + } + else + { + out << nl << "int sz = " << stream << ".readSize();"; + out << nl << param << " = new " << fixId(seq->scoped()) << "(sz);"; + out << nl << "for(int i = 0; i < sz; ++i)"; + out << sb; + out << nl << "IceInternal.SequencePatcher sp = new IceInternal.SequencePatcher(" + << param << ", " << "typeof(" << typeToString(type) << "), i);"; + out << nl << stream << ".readObject(sp);"; + out << eb; + } + return; + } + + EnumPtr en = EnumPtr::dynamicCast(type); if(en) { diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index cea0fdaadd2..a6bb64c30c4 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -2203,6 +2203,7 @@ Slice::ClassDef::createOperation(const string& name, _unit->error(msg); } + _hasOperations = true; OperationPtr op = new Operation(this, name, returnType, mode); _contents.push_back(op); return op; @@ -2521,6 +2522,12 @@ Slice::ClassDef::hasDataMembers() const return _hasDataMembers; } +bool +Slice::ClassDef::hasOperations() const +{ + return _hasOperations; +} + Contained::ContainedType Slice::ClassDef::containedType() const { @@ -2564,6 +2571,7 @@ Slice::ClassDef::ClassDef(const ContainerPtr& container, const string& name, boo SyntaxTreeBase(container->unit()), _interface(intf), _hasDataMembers(false), + _hasOperations(false), _bases(bases), _local(local) { diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index 3d54abd9946..310c922bea0 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -43,7 +43,7 @@ public: Gen(const std::string&, const std::string&, - const std::vector<std::string>&,
+ const std::vector<std::string>&, const std::string&); ~Gen(); @@ -67,6 +67,7 @@ private: TypesVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitOperation(const OperationPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); @@ -88,6 +89,7 @@ private: ProxyVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); virtual void visitOperation(const OperationPtr&); @@ -100,6 +102,7 @@ private: OpsVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); virtual void visitOperation(const OperationPtr&); @@ -112,6 +115,7 @@ private: HelperVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); virtual void visitSequence(const SequencePtr&); @@ -125,6 +129,7 @@ private: DelegateVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); }; @@ -136,6 +141,7 @@ private: DelegateMVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); }; @@ -147,6 +153,7 @@ private: DelegateDVisitor(::IceUtil::Output&); virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); }; |