diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.h | 3 | ||||
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 45 | ||||
-rw-r--r-- | cpp/src/slice2cs/CsUtil.h | 5 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 742 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.h | 17 |
6 files changed, 453 insertions, 367 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index e1be83afdc4..ada7e2070f1 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -6679,7 +6679,7 @@ Slice::Unit::addTypeId(int compactId, const std::string& typeId) } std::string -Slice::Unit::getTypeId(int compactId) +Slice::Unit::getTypeId(int compactId) const { map<int, string>::const_iterator p = _typeIds.find(compactId); if(p != _typeIds.end()) @@ -6690,6 +6690,12 @@ Slice::Unit::getTypeId(int compactId) } bool +Slice::Unit::hasCompactTypeId() const +{ + return _typeIds.size() > 0; +} + +bool Slice::Unit::usesNonLocals() const { for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p) diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index 219c14ae151..81c01077a31 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -1092,7 +1092,8 @@ public: ContainedList findUsedBy(const ContainedPtr&) const; void addTypeId(int, const std::string&); - std::string getTypeId(int); + std::string getTypeId(int) const; + bool hasCompactTypeId() const; bool usesNonLocals() const; bool usesConsts() const; diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index 27e0c974d31..24e518b5a79 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -100,7 +100,7 @@ splitScopedName(const string& scoped) } string -Slice::CsGenerator::getPackagePrefix(const ContainedPtr& cont) +Slice::CsGenerator::getNamespacePrefix(const ContainedPtr& cont) { // // Traverse to the top-level module. @@ -124,41 +124,40 @@ Slice::CsGenerator::getPackagePrefix(const ContainedPtr& cont) assert(m); - // - // The cs:namespace metadata can be defined as global metadata or applied to a top-level module. - // We check for the metadata at the top-level module first and then fall back to the global scope. - // static const string prefix = "cs:namespace:"; string q; - if(!m->findMetaData(prefix, q)) + if(m->findMetaData(prefix, q)) { - UnitPtr unit = cont->unit(); - string file = cont->file(); - assert(!file.empty()); - - DefinitionContextPtr dc = unit->findDefinitionContext(file); - assert(dc); - q = dc->findMetaData(prefix); + q = q.substr(prefix.size()); } + return q; +} - if(!q.empty()) +string +Slice::CsGenerator::getCustomTypeIdNamespace(const UnitPtr& unit) +{ + DefinitionContextPtr dc = unit->findDefinitionContext(unit->topLevelFile()); + assert(dc); + + static const string typeIdNsPrefix = "cs:typeid-namespace:"; + string result = dc->findMetaData(typeIdNsPrefix); + if(!result.empty()) { - q = q.substr(prefix.size()); + result = result.substr(typeIdNsPrefix.size()); } - - return q; + return result; } string -Slice::CsGenerator::getPackage(const ContainedPtr& cont) +Slice::CsGenerator::getNamespace(const ContainedPtr& cont) { string scope = fixId(cont->scope()); if(scope.rfind(".") == scope.size() - 1) { scope = scope.substr(0, scope.size() - 1); } - string prefix = getPackagePrefix(cont); + string prefix = getNamespacePrefix(cont); if(!prefix.empty()) { if(!scope.empty()) @@ -196,7 +195,7 @@ Slice::CsGenerator::getUnqualified(const ContainedPtr& p, const string& package, const string& suffix) { string name = fixId(prefix + p->name() + suffix); - string contPkg = getPackage(p); + string contPkg = getNamespace(p); if(contPkg == package || contPkg.empty()) { return name; @@ -1303,7 +1302,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, assert(cont); if(useHelper) { - string helperName = getUnqualified(getPackage(seq) + "." + seq->name() + "Helper", scope); + string helperName = getUnqualified(getNamespace(seq) + "." + seq->name() + "Helper", scope); if(marshal) { out << nl << helperName << ".write(" << stream << ", " << param << ");"; @@ -2486,8 +2485,8 @@ Slice::CsGenerator::MetaDataVisitor::visitUnitStart(const UnitPtr& p) if(s.find(csPrefix) == 0) { static const string csAttributePrefix = csPrefix + "attribute:"; - static const string csNamespacePrefix = csPrefix + "namespace:"; - if(!(s.find(csNamespacePrefix) == 0 && s.size() > csNamespacePrefix.size()) && + static const string csTypeIdNsPrefix = csPrefix + "typeid-namespace:"; + if(!(s.find(csTypeIdNsPrefix) == 0 && s.size() > csTypeIdNsPrefix.size()) && !(s.find(csAttributePrefix) == 0 && s.size() > csAttributePrefix.size())) { dc->warning(InvalidMetaData, file, -1, "ignoring invalid global metadata `" + oldS + "'"); diff --git a/cpp/src/slice2cs/CsUtil.h b/cpp/src/slice2cs/CsUtil.h index 3c842d73f43..861ecedb9d8 100644 --- a/cpp/src/slice2cs/CsUtil.h +++ b/cpp/src/slice2cs/CsUtil.h @@ -35,7 +35,7 @@ public: // // Returns the namespace of a Contained entity. // - static std::string getPackage(const ContainedPtr&); + static std::string getNamespace(const ContainedPtr&); static std::string getUnqualified(const std::string&, const std::string&, bool builtin = false); static std::string getUnqualified(const ContainedPtr&, @@ -48,7 +48,8 @@ protected: // // Returns the namespace prefix of a Contained entity. // - static std::string getPackagePrefix(const ContainedPtr&); + static std::string getNamespacePrefix(const ContainedPtr&); + static std::string getCustomTypeIdNamespace(const UnitPtr&); static std::string resultStructName(const std::string&, const std::string&, bool = false); static std::string resultType(const OperationPtr&, const std::string&, bool = false); diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index a6b09ad2030..b5ee171ea53 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -36,24 +36,24 @@ namespace { string -sliceModeToIceMode(Operation::Mode opMode, string package) +sliceModeToIceMode(Operation::Mode opMode, string ns) { string mode; switch(opMode) { case Operation::Normal: { - mode = CsGenerator::getUnqualified("Ice.OperationMode.Normal", package); + mode = CsGenerator::getUnqualified("Ice.OperationMode.Normal", ns); break; } case Operation::Nonmutating: { - mode = CsGenerator::getUnqualified("Ice.OperationMode.Nonmutating", package); + mode = CsGenerator::getUnqualified("Ice.OperationMode.Nonmutating", ns); break; } case Operation::Idempotent: { - mode = CsGenerator::getUnqualified("Ice.OperationMode.Idempotent", package); + mode = CsGenerator::getUnqualified("Ice.OperationMode.Idempotent", ns); break; } default: @@ -66,21 +66,21 @@ sliceModeToIceMode(Operation::Mode opMode, string package) } string -opFormatTypeToString(const OperationPtr& op, string package) +opFormatTypeToString(const OperationPtr& op, string ns) { switch (op->format()) { case DefaultFormat: { - return CsGenerator::getUnqualified("Ice.FormatType.DefaultFormat", package); + return CsGenerator::getUnqualified("Ice.FormatType.DefaultFormat", ns); } case CompactFormat: { - return CsGenerator::getUnqualified("Ice.FormatType.CompactFormat", package); + return CsGenerator::getUnqualified("Ice.FormatType.CompactFormat", ns); } case SlicedFormat: { - return CsGenerator::getUnqualified("Ice.FormatType.SlicedFormat", package); + return CsGenerator::getUnqualified("Ice.FormatType.SlicedFormat", ns); } default: { @@ -172,7 +172,7 @@ Slice::CsVisitor::~CsVisitor() void Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const OperationPtr& op, bool marshal, - const string& package, bool resultStruct, bool publicNames, + const string& ns, bool resultStruct, bool publicNames, const string& customStream) { ParamDeclList optionals; @@ -196,7 +196,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(type)) { ostringstream os; - os << '(' << typeToString(type, package) << " v) => {" << paramPrefix << param << " = v; }"; + os << '(' << typeToString(type, ns) << " v) => {" << paramPrefix << param << " = v; }"; param = os.str(); } else @@ -210,7 +210,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const } else { - writeMarshalUnmarshalCode(_out, type, package, param, marshal, customStream); + writeMarshalUnmarshalCode(_out, type, ns, param, marshal, customStream); } } @@ -223,7 +223,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(ret)) { ostringstream os; - os << '(' << typeToString(ret, package) << " v) => {" << paramPrefix << returnValueS << " = v; }"; + os << '(' << typeToString(ret, ns) << " v) => {" << paramPrefix << returnValueS << " = v; }"; param = os.str(); } else @@ -233,7 +233,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!op->returnIsOptional()) { - writeMarshalUnmarshalCode(_out, ret, package, param, marshal, customStream); + writeMarshalUnmarshalCode(_out, ret, ns, param, marshal, customStream); } } @@ -262,14 +262,14 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(ret)) { ostringstream os; - os << '(' << typeToString(ret, package) << " v) => {" << paramPrefix << returnValueS << " = v; }"; + os << '(' << typeToString(ret, ns) << " v) => {" << paramPrefix << returnValueS << " = v; }"; param = os.str(); } else { param = paramPrefix + returnValueS; } - writeOptionalMarshalUnmarshalCode(_out, ret, package, param, op->returnTag(), marshal, customStream); + writeOptionalMarshalUnmarshalCode(_out, ret, ns, param, op->returnTag(), marshal, customStream); checkReturnType = false; } @@ -278,7 +278,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(type)) { ostringstream os; - os << '(' << typeToString(type, package) << " v) => {" << paramPrefix << param << " = v; }"; + os << '(' << typeToString(type, ns) << " v) => {" << paramPrefix << param << " = v; }"; param = os.str(); } else @@ -286,7 +286,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const param = paramPrefix + param; } - writeOptionalMarshalUnmarshalCode(_out, type, package, param, (*pli)->tag(), marshal, customStream); + writeOptionalMarshalUnmarshalCode(_out, type, ns, param, (*pli)->tag(), marshal, customStream); } if(checkReturnType) @@ -295,25 +295,25 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(ret)) { ostringstream os; - os << '(' << typeToString(ret, package) << " v) => {" << paramPrefix << returnValueS << " = v; }"; + os << '(' << typeToString(ret, ns) << " v) => {" << paramPrefix << returnValueS << " = v; }"; param = os.str(); } else { param = paramPrefix + returnValueS; } - writeOptionalMarshalUnmarshalCode(_out, ret, package, param, op->returnTag(), marshal, customStream); + writeOptionalMarshalUnmarshalCode(_out, ret, ns, param, op->returnTag(), marshal, customStream); } } void -Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const string& name, const string& package, +Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const string& name, const string& ns, bool forStruct) { if(member->optional()) { assert(!forStruct); - writeOptionalMarshalUnmarshalCode(_out, member->type(), package, name, member->tag(), true, "ostr_"); + writeOptionalMarshalUnmarshalCode(_out, member->type(), ns, name, member->tag(), true, "ostr_"); } else { @@ -324,19 +324,19 @@ Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const stri memberName = "this." + memberName; } - writeMarshalUnmarshalCode(_out, member->type(), package, memberName, true, stream); + writeMarshalUnmarshalCode(_out, member->type(), ns, memberName, true, stream); } } void -Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const string& name, const string& package, +Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const string& name, const string& ns, bool forStruct) { string param = name; if(isClassType(member->type())) { ostringstream os; - os << '(' << typeToString(member->type(), package) << " v) => { this." << name << " = v; }"; + os << '(' << typeToString(member->type(), ns) << " v) => { this." << name << " = v; }"; param = os.str(); } else if(forStruct) @@ -347,11 +347,11 @@ Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const st if(member->optional()) { assert(!forStruct); - writeOptionalMarshalUnmarshalCode(_out, member->type(), package, param, member->tag(), false, "istr_"); + writeOptionalMarshalUnmarshalCode(_out, member->type(), ns, param, member->tag(), false, "istr_"); } else { - writeMarshalUnmarshalCode(_out, member->type(), package, param, false, forStruct ? "" : "istr_"); + writeMarshalUnmarshalCode(_out, member->type(), ns, param, false, forStruct ? "" : "istr_"); } } @@ -379,8 +379,8 @@ Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p) { string retS; vector<string> params, args; - string package = getPackage(p); - string name = getDispatchParams(*i, retS, params, args, package); + string ns = getNamespace(p); + string name = getDispatchParams(*i, retS, params, args, ns); _out << sp << nl << "public abstract " << retS << " " << name << spar << params << epar << ';'; } @@ -393,7 +393,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { string name = fixId(p->name()); string scoped = p->scoped(); - string package = getPackage(p); + string ns = getNamespace(p); ClassList allBases = p->allBases(); StringList ids; ClassList bases = p->bases(); @@ -439,7 +439,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override bool ice_isA(string s, " << getUnqualified("Ice.Current", package) << " current = null)"; + _out << nl << "public override bool ice_isA(string s, " << getUnqualified("Ice.Current", ns) << " current = null)"; _out << sb; _out << nl << "return global::System.Array.BinarySearch(_ids, s, IceUtilInternal.StringUtil.OrdinalStringComparer) >= 0;"; _out << eb; @@ -449,7 +449,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override string[] ice_ids(" << getUnqualified("Ice.Current", package) << " current = null)"; + _out << nl << "public override string[] ice_ids(" << getUnqualified("Ice.Current", ns) << " current = null)"; _out << sb; _out << nl << "return _ids;"; _out << eb; @@ -459,7 +459,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override string ice_id(" << getUnqualified("Ice.Current", package) << " current = null)"; + _out << nl << "public override string ice_id(" << getUnqualified("Ice.Current", ns) << " current = null)"; _out << sb; _out << nl << "return _ids[" << scopedPos << "];"; _out << eb; @@ -497,16 +497,16 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public static global::System.Threading.Tasks.Task<" << getUnqualified("Ice.OutputStream", package) << ">"; + _out << nl << "public static global::System.Threading.Tasks.Task<" << getUnqualified("Ice.OutputStream", ns) << ">"; _out << nl << "iceD_" << opName << "(" << name << (p->isInterface() ? "" : "Disp_") << " obj, " - << "global::IceInternal.Incoming inS, " << getUnqualified("Ice.Current", package) << " current)"; + << "global::IceInternal.Incoming inS, " << getUnqualified("Ice.Current", ns) << " current)"; _out << sb; TypePtr ret = op->returnType(); ParamDeclList inParams = op->inParameters(); ParamDeclList outParams = op->outParameters(); - _out << nl << getUnqualified("Ice.ObjectImpl", package) << ".iceCheckMode(" << sliceModeToIceMode(op->mode(), package) + _out << nl << getUnqualified("Ice.ObjectImpl", ns) << ".iceCheckMode(" << sliceModeToIceMode(op->mode(), ns) << ", current.mode);"; if(!inParams.empty()) { @@ -517,7 +517,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) for(ParamDeclList::const_iterator pli = inParams.begin(); pli != inParams.end(); ++pli) { string param = "iceP_" + (*pli)->name(); - string typeS = typeToString((*pli)->type(), package, (*pli)->optional()); + string typeS = typeToString((*pli)->type(), ns, (*pli)->optional()); const bool isClass = isClassType((*pli)->type()); if((*pli)->optional()) @@ -525,7 +525,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) _out << nl << typeS << ' ' << param; if(isClass) { - _out << " = " << getUnqualified("Ice.Util", package) << ".None"; + _out << " = " << getUnqualified("Ice.Util", ns) << ".None"; } _out << ';'; } @@ -543,7 +543,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } } } - writeMarshalUnmarshalParams(inParams, 0, false, package); + writeMarshalUnmarshalParams(inParams, 0, false, ns); if(op->sendsClasses(false)) { _out << nl << "istr.readPendingValues();"; @@ -557,7 +557,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) if(op->format() != DefaultFormat) { - _out << nl << "inS.setFormat(" << opFormatTypeToString(op, package) << ");"; + _out << nl << "inS.setFormat(" << opFormatTypeToString(op, ns) << ");"; } vector<string> inArgs; @@ -575,7 +575,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } else if(amd) { - string retS = resultType(op, package); + string retS = resultType(op, ns); _out << nl << "return inS.setResultTask" << (retS.empty() ? "" : ('<' + retS + '>')); _out << "(obj." << opName << "Async" << spar << inArgs << "current" << epar; if(!retS.empty()) @@ -591,7 +591,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) _out << nl << "(ostr, ret) =>"; } _out << sb; - writeMarshalUnmarshalParams(outParams, op, true, package, true); + writeMarshalUnmarshalParams(outParams, op, true, ns, true); if(op->returnsClasses(false)) { _out << nl << "ostr.writePendingValues();"; @@ -606,7 +606,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli) { - string typeS = typeToString((*pli)->type(), package, (*pli)->optional()); + string typeS = typeToString((*pli)->type(), ns, (*pli)->optional()); _out << nl << typeS << ' ' << "iceP_" + (*pli)->name() << ";"; } @@ -631,7 +631,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) if(!outParams.empty() || ret) { _out << nl << "var ostr = inS.startWriteParams();"; - writeMarshalUnmarshalParams(outParams, op, true, package); + writeMarshalUnmarshalParams(outParams, op, true, ns); if(op->returnsClasses(false)) { _out << nl << "ostr.writePendingValues();"; @@ -677,15 +677,15 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) emitGeneratedCodeAttribute(); } _out << nl << "public override global::System.Threading.Tasks.Task<" - << getUnqualified("Ice.OutputStream", package) << ">"; + << getUnqualified("Ice.OutputStream", ns) << ">"; _out << nl << "iceDispatch(global::IceInternal.Incoming inS, " - << getUnqualified("Ice.Current", package) << " current)"; + << getUnqualified("Ice.Current", ns) << " current)"; _out << sb; _out << nl << "int pos = global::System.Array.BinarySearch(_all, current.operation, " << "global::IceUtilInternal.StringUtil.OrdinalStringComparer);"; _out << nl << "if(pos < 0)"; _out << sb; - _out << nl << "throw new " << getUnqualified("Ice.OperationNotExistException", package) + _out << nl << "throw new " << getUnqualified("Ice.OperationNotExistException", ns) << "(current.id, current.facet, current.operation);"; _out << eb; _out << sp << nl << "switch(pos)"; @@ -699,22 +699,22 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) _out << sb; if(opName == "ice_id") { - _out << nl << "return " << getUnqualified("Ice.ObjectImpl", package) + _out << nl << "return " << getUnqualified("Ice.ObjectImpl", ns) << ".iceD_ice_id(this, inS, current);"; } else if(opName == "ice_ids") { - _out << nl << "return " << getUnqualified("Ice.ObjectImpl", package) + _out << nl << "return " << getUnqualified("Ice.ObjectImpl", ns) << ".iceD_ice_ids(this, inS, current);"; } else if(opName == "ice_isA") { - _out << nl << "return " << getUnqualified("Ice.ObjectImpl", package) + _out << nl << "return " << getUnqualified("Ice.ObjectImpl", ns) << ".iceD_ice_isA(this, inS, current);"; } else if(opName == "ice_ping") { - _out << nl << "return " << getUnqualified("Ice.ObjectImpl", package) + _out << nl << "return " << getUnqualified("Ice.ObjectImpl", ns) << ".iceD_ice_ping(this, inS, current);"; } else @@ -735,7 +735,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } else { - _out << nl << "return " << getUnqualified(cl, package, "", "Disp_") + _out << nl << "return " << getUnqualified(cl, ns, "", "Disp_") << ".iceD_" << opName << "(this, inS, current);"; } break; @@ -746,7 +746,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } _out << eb; _out << sp << nl << "global::System.Diagnostics.Debug.Assert(false);"; - _out << nl << "throw new " << getUnqualified("Ice.OperationNotExistException", package) + _out << nl << "throw new " << getUnqualified("Ice.OperationNotExistException", ns) << "(current.id, current.facet, current.operation);"; _out << eb; } @@ -762,7 +762,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { string name = fixId(p->name()); string scoped = p->scoped(); - string package = getPackage(p); + string ns = getNamespace(p); ClassList allBases = p->allBases(); StringList ids; ClassList bases = p->bases(); @@ -802,7 +802,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override " << getUnqualified("Ice.SlicedData", package) << " ice_getSlicedData()"; + _out << nl << "public override " << getUnqualified("Ice.SlicedData", ns) << " ice_getSlicedData()"; _out << sb; _out << nl << "return iceSlicedData_;"; _out << eb; @@ -812,7 +812,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void iceWrite(" << getUnqualified("Ice.OutputStream", package) << " ostr_)"; + _out << nl << "public override void iceWrite(" << getUnqualified("Ice.OutputStream", ns) << " ostr_)"; _out << sb; _out << nl << "ostr_.startValue(iceSlicedData_);"; _out << nl << "iceWriteImpl(ostr_);"; @@ -824,7 +824,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void iceRead(" << getUnqualified("Ice.InputStream", package) << " istr_)"; + _out << nl << "public override void iceRead(" << getUnqualified("Ice.InputStream", ns) << " istr_)"; _out << sb; _out << nl << "istr_.startValue();"; _out << nl << "iceReadImpl(istr_);"; @@ -837,19 +837,19 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "protected override void iceWriteImpl(" << getUnqualified("Ice.OutputStream", package) << " ostr_)"; + _out << nl << "protected override void iceWriteImpl(" << getUnqualified("Ice.OutputStream", ns) << " ostr_)"; _out << sb; _out << nl << "ostr_.startSlice(ice_staticId(), " << p->compactId() << (!base ? ", true" : ", false") << ");"; for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) { if(!(*d)->optional()) { - writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), package); + writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), ns); } } for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) { - writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), package); + writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), ns); } _out << nl << "ostr_.endSlice();"; if(base) @@ -863,19 +863,19 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "protected override void iceReadImpl(" << getUnqualified("Ice.InputStream", package) << " istr_)"; + _out << nl << "protected override void iceReadImpl(" << getUnqualified("Ice.InputStream", ns) << " istr_)"; _out << sb; _out << nl << "istr_.startSlice();"; for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) { if(!(*d)->optional()) { - writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), package); + writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), ns); } } for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) { - writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), package); + writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), ns); } _out << nl << "istr_.endSlice();"; if(base) @@ -886,7 +886,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) if(preserved && !basePreserved) { - _out << sp << nl << "protected " << getUnqualified("Ice.SlicedData", package) << " iceSlicedData_;"; + _out << sp << nl << "protected " << getUnqualified("Ice.SlicedData", ns) << " iceSlicedData_;"; } _out << sp << nl << "#endregion"; // Marshalling support @@ -909,7 +909,7 @@ Slice::CsVisitor::getParamAttributes(const ParamDeclPtr& p) } vector<string> -Slice::CsVisitor::getParams(const OperationPtr& op, const string& package) +Slice::CsVisitor::getParams(const OperationPtr& op, const string& ns) { vector<string> params; ParamDeclList paramList = op->parameters(); @@ -921,14 +921,14 @@ Slice::CsVisitor::getParams(const OperationPtr& op, const string& package) { param += "out "; } - param += typeToString((*q)->type(), package, (*q)->optional(), cl->isLocal()) + " " + fixId((*q)->name()); + param += typeToString((*q)->type(), ns, (*q)->optional(), cl->isLocal()) + " " + fixId((*q)->name()); params.push_back(param); } return params; } vector<string> -Slice::CsVisitor::getInParams(const OperationPtr& op, const string& package, bool internal) +Slice::CsVisitor::getInParams(const OperationPtr& op, const string& ns, bool internal) { vector<string> params; @@ -937,14 +937,14 @@ Slice::CsVisitor::getInParams(const OperationPtr& op, const string& package, boo ParamDeclList paramList = op->inParameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { - params.push_back(getParamAttributes(*q) + typeToString((*q)->type(), package, (*q)->optional(), cl->isLocal()) + params.push_back(getParamAttributes(*q) + typeToString((*q)->type(), ns, (*q)->optional(), cl->isLocal()) + " " + (internal ? "iceP_" + (*q)->name() : fixId((*q)->name()))); } return params; } vector<string> -Slice::CsVisitor::getOutParams(const OperationPtr& op, const string& package, bool returnParam, bool outKeyword) +Slice::CsVisitor::getOutParams(const OperationPtr& op, const string& ns, bool returnParam, bool outKeyword) { vector<string> params; if(returnParam) @@ -952,7 +952,7 @@ Slice::CsVisitor::getOutParams(const OperationPtr& op, const string& package, bo TypePtr ret = op->returnType(); if(ret) { - params.push_back(typeToString(ret, package, op->returnIsOptional()) + " ret"); + params.push_back(typeToString(ret, ns, op->returnIsOptional()) + " ret"); } } @@ -964,7 +964,7 @@ Slice::CsVisitor::getOutParams(const OperationPtr& op, const string& package, bo { s += "out "; } - s += typeToString((*q)->type(), package, (*q)->optional()) + ' ' + fixId((*q)->name()); + s += typeToString((*q)->type(), ns, (*q)->optional()) + ' ' + fixId((*q)->name()); params.push_back(s); } @@ -1005,7 +1005,7 @@ Slice::CsVisitor::getInArgs(const OperationPtr& op, bool internal) string Slice::CsVisitor::getDispatchParams(const OperationPtr& op, string& retS, vector<string>& params, vector<string>& args, - const string& package) + const string& ns) { string name; ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); // Get the class containing the op. @@ -1014,30 +1014,30 @@ Slice::CsVisitor::getDispatchParams(const OperationPtr& op, string& retS, vector if(cl->hasMetaData("amd") || op->hasMetaData("amd")) { name = op->name() + "Async"; - params = getInParams(op, package); + params = getInParams(op, ns); args = getInArgs(op); paramDecls = op->inParameters(); - retS = taskResultType(op, package, true); + retS = taskResultType(op, ns, true); } else if(op->hasMarshaledResult()) { name = fixId(op->name(), DotNet::ICloneable, true); - params = getInParams(op, package); + params = getInParams(op, ns); args = getInArgs(op); paramDecls = op->inParameters(); - retS = resultType(op, package, true); + retS = resultType(op, ns, true); } else { name = fixId(op->name(), DotNet::ICloneable, true); - params = getParams(op, package); + params = getParams(op, ns); args = getArgs(op); paramDecls = op->parameters(); - retS = typeToString(op->returnType(), package, op->returnIsOptional()); + retS = typeToString(op->returnType(), ns, op->returnIsOptional()); } string currentParamName = getEscapedParamName(op, "current"); - params.push_back(getUnqualified("Ice.Current", package) + " " + currentParamName + " = null"); + params.push_back(getUnqualified("Ice.Current", ns) + " " + currentParamName + " = null"); args.push_back(currentParamName); return name; } @@ -1089,7 +1089,7 @@ Slice::CsVisitor::emitPartialTypeAttributes() } string -Slice::CsVisitor::writeValue(const TypePtr& type, const string& package) +Slice::CsVisitor::writeValue(const TypePtr& type, const string& ns) { assert(type); @@ -1132,7 +1132,7 @@ Slice::CsVisitor::writeValue(const TypePtr& type, const string& package) EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - return typeToString(type, package) + "." + fixId((*en->enumerators().begin())->name()); + return typeToString(type, ns) + "." + fixId((*en->enumerators().begin())->name()); } StructPtr st = StructPtr::dynamicCast(type); @@ -1144,7 +1144,7 @@ Slice::CsVisitor::writeValue(const TypePtr& type, const string& package) } else { - return "new " + typeToString(type, package) + "()"; + return "new " + typeToString(type, ns) + "()"; } } @@ -1209,7 +1209,7 @@ Slice::CsVisitor::requiresDataMemberInitializers(const DataMemberList& members) } void -Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, const string& package, int baseTypes, +Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, const string& ns, int baseTypes, bool propertyMapping) { for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p) @@ -1232,7 +1232,7 @@ Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, con else if((*p)->optional()) { _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " - << typeToString((*p)->type(), package, true) << "();"; + << typeToString((*p)->type(), ns, true) << "();"; } else { @@ -1245,7 +1245,7 @@ Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, con StructPtr st = StructPtr::dynamicCast((*p)->type()); if(st) { - _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, package, false) + _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, ns, false) << "();"; } } @@ -1907,43 +1907,30 @@ Slice::CsVisitor::writeDocCommentParam(const OperationPtr& p, ParamDir paramType } } -bool -Slice::CsVisitor::visitModuleStart(const ModulePtr& p) +void +Slice::CsVisitor::moduleStart(const ModulePtr& p) { if(!ContainedPtr::dynamicCast(p->container())) { - string package = getPackage(p); + string ns = getNamespacePrefix(p); string name = fixId(p->name()); - if(package != name) + if(!ns.empty()) { - vector<string> tokens; - IceUtilInternal::splitString(package, ".", tokens); - for(vector<string>::const_iterator p = tokens.begin(); p != tokens.end(); ++p) - { - _out << sp; - _out << nl << "namespace " << *p; - _out << sb; - } + _out << sp; + _out << nl << "namespace " << ns; + _out << sb; } } - return true; } void -Slice::CsVisitor::visitModuleEnd(const ModulePtr& p) +Slice::CsVisitor::moduleEnd(const ModulePtr& p) { if(!ContainedPtr::dynamicCast(p->container())) { - string package = getPackage(p); - string name = fixId(p->name()); - if(package != name) + if(!getNamespacePrefix(p).empty()) { - vector<string> tokens; - IceUtilInternal::splitString(package, ".", tokens); - for(vector<string>::const_iterator p = tokens.begin(); p != tokens.end(); ++p) - { - _out << eb; - } + _out << eb; } } } @@ -2032,6 +2019,9 @@ Slice::Gen::generate(const UnitPtr& p) TypesVisitor typesVisitor(_out); p->visit(&typesVisitor, false); + TypeIdVisitor typeIdVisitor(_out); + p->visit(&typeIdVisitor, false); + // // The async delegates are emitted before the proxy definition // because the proxy methods need to know the type. @@ -2181,28 +2171,33 @@ Slice::Gen::CompactIdVisitor::CompactIdVisitor(IceUtilInternal::Output& out) : } bool -Slice::Gen::CompactIdVisitor::visitUnitStart(const UnitPtr&) +Slice::Gen::CompactIdVisitor::visitUnitStart(const UnitPtr& p) { - _out << sp << nl << "namespace IceCompactId"; - _out << sb; - return true; -} + if(p->hasCompactTypeId()) + { + string typeIdNs = getCustomTypeIdNamespace(p); -void -Slice::Gen::CompactIdVisitor::visitUnitEnd(const UnitPtr&) -{ - _out << eb; -} + if(typeIdNs.empty()) + { + // TODO: replace by namespace Ice.TypeId, see issue #239 + // + _out << sp << nl << "namespace IceCompactId"; + } + else + { + _out << sp << nl << "namespace " << typeIdNs; + } -bool -Slice::Gen::CompactIdVisitor::visitModuleStart(const ModulePtr& p) -{ - return true; + _out << sb; + return true; + } + return false; } void -Slice::Gen::CompactIdVisitor::visitModuleEnd(const ModulePtr& p) +Slice::Gen::CompactIdVisitor::visitUnitEnd(const UnitPtr& p) { + _out << eb; } bool @@ -2212,6 +2207,9 @@ Slice::Gen::CompactIdVisitor::visitClassDefStart(const ClassDefPtr& p) { _out << sp; emitGeneratedCodeAttribute(); + + // TODO: rename to class Compact_Xxx, see issue #239 + // _out << nl << "public sealed class TypeId_" << p->compactId(); _out << sb; _out << nl << "public const string typeId = \"" << p->scoped() << "\";"; @@ -2220,6 +2218,76 @@ Slice::Gen::CompactIdVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } +Slice::Gen::TypeIdVisitor::TypeIdVisitor(IceUtilInternal::Output& out) : + CsVisitor(out) +{ +} + +bool +Slice::Gen::TypeIdVisitor::visitModuleStart(const ModulePtr& p) +{ + string ns = getNamespacePrefix(p); + + if(!ns.empty() && (p->hasValueDefs() || p->hasNonLocalExceptions())) + { + string name = fixId(p->name()); + if(!ContainedPtr::dynamicCast(p->container())) + { + // Top-level module + // + string typeIdNs = getCustomTypeIdNamespace(p->unit()); + if(typeIdNs.empty()) + { + typeIdNs = "Ice.TypeId"; + } + + name = typeIdNs + "." + name; + } + _out << sp << nl << "namespace " << name; + _out << sb; + return true; + } + return false; +} + +void +Slice::Gen::TypeIdVisitor::visitModuleEnd(const ModulePtr&) +{ + _out << eb; +} + +bool +Slice::Gen::TypeIdVisitor::visitClassDefStart(const ClassDefPtr& p) +{ + if(!p->isInterface() && !p->isLocal()) + { + generateHelperClass(p); + } + return false; +} + +bool +Slice::Gen::TypeIdVisitor::visitExceptionStart(const ExceptionPtr& p) +{ + if(!p->isLocal()) + { + generateHelperClass(p); + } + return false; +} + +void +Slice::Gen::TypeIdVisitor::generateHelperClass(const ContainedPtr& p) +{ + string name = fixId(p->name()); + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public sealed class " << name; + _out << sb; + _out << nl << "public global::" << getNamespace(p) << "." << name << " targetClass { get; }"; + _out << eb; +} + Slice::Gen::TypesVisitor::TypesVisitor(IceUtilInternal::Output& out) : CsVisitor(out) { @@ -2240,7 +2308,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); string name = fixId(p->name()); _out << sp; emitAttributes(p); @@ -2254,8 +2322,8 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -2263,7 +2331,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { string name = p->name(); string scoped = fixId(p->scoped()); - string package = getPackage(p); + string ns = getNamespace(p); ClassList bases = p->bases(); bool hasBaseClass = !bases.empty() && !bases.front()->isInterface(); @@ -2276,8 +2344,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { emitComVisibleAttribute(); OperationPtr o = p->allOperations().front(); - _out << nl << "public delegate " << typeToString(o->returnType(), package, o->returnIsOptional()) << " "; - _out << fixId(name) << spar << getParams(o, package) << epar << ";"; + _out << nl << "public delegate " << typeToString(o->returnType(), ns, o->returnIsOptional()) << " "; + _out << fixId(name) << spar << getParams(o, ns) << epar << ";"; return false; } @@ -2288,12 +2356,12 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "public partial interface " << fixId(name); if(!p->isLocal()) { - baseNames.push_back(getUnqualified("Ice.Object", package)); + baseNames.push_back(getUnqualified("Ice.Object", ns)); baseNames.push_back(name + "Operations_"); } for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) { - baseNames.push_back(getUnqualified(*q, package)); + baseNames.push_back(getUnqualified(*q, ns)); } } else @@ -2316,12 +2384,12 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!p->isLocal()) { - baseNames.push_back(getUnqualified("Ice.Value", package)); + baseNames.push_back(getUnqualified("Ice.Value", ns)); } } else { - baseNames.push_back(getUnqualified(bases.front(), package)); + baseNames.push_back(getUnqualified(bases.front(), ns)); bases.pop_front(); } @@ -2331,7 +2399,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { if((*q)->isAbstract()) { - baseNames.push_back(getUnqualified(*q, package)); + baseNames.push_back(getUnqualified(*q, ns)); } } } @@ -2395,7 +2463,7 @@ void Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) { string name = fixId(p->name()); - string package = getPackage(p); + string ns = getNamespace(p); DataMemberList classMembers = p->classDataMembers(); DataMemberList allClassMembers = p->allClassDataMembers(); DataMemberList dataMembers = p->dataMembers(); @@ -2437,7 +2505,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) _out << " : base()"; } _out << sb; - writeDataMemberInitializers(dataMembers, package, DotNet::ICloneable, propertyMapping); + writeDataMemberInitializers(dataMembers, ns, DotNet::ICloneable, propertyMapping); _out << nl << "ice_initialize();"; _out << eb; @@ -2448,7 +2516,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) for(DataMemberList::const_iterator d = allDataMembers.begin(); d != allDataMembers.end(); ++d) { string memberName = fixId((*d)->name(), DotNet::ICloneable); - string memberType = typeToString((*d)->type(), package, (*d)->optional(), p->isLocal(), (*d)->getMetaData()); + string memberType = typeToString((*d)->type(), ns, (*d)->optional(), p->isLocal(), (*d)->getMetaData()); paramDecl.push_back(memberType + " " + memberName); } _out << paramDecl << epar; @@ -2526,13 +2594,13 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); bool isLocal = cl->isLocal(); bool isInterface = cl->isInterface(); - string package = getPackage(cl); + string ns = getNamespace(cl); if(isLocal) { string name = fixId(p->name(), DotNet::ICloneable, true); TypePtr ret = p->returnType(); - string retS = typeToString(ret, package, p->returnIsOptional(), true); + string retS = typeToString(ret, ns, p->returnIsOptional(), true); _out << sp; if(isInterface) @@ -2550,11 +2618,11 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << retS << " " << name << spar << getParams(p, package) << epar << ";"; + _out << retS << " " << name << spar << getParams(p, ns) << epar << ";"; if(cl->hasMetaData("async-oneway") || p->hasMetaData("async-oneway")) { - vector<string> inParams = getInParams(p, package); + vector<string> inParams = getInParams(p, ns); ParamDeclList inParamDecls = p->inParameters(); // @@ -2568,7 +2636,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << taskResultType(p, package); + _out << taskResultType(p, ns); string progress = getEscapedParamName(p, "progress"); string cancel = getEscapedParamName(p, "cancel"); @@ -2589,8 +2657,8 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << getUnqualified("Ice.AsyncResult", package) << " begin_" << name << spar << inParams - << getUnqualified("Ice.AsyncCallback", package) + " " + getEscapedParamName(p, "callback") + " = null" + _out << getUnqualified("Ice.AsyncResult", ns) << " begin_" << name << spar << inParams + << getUnqualified("Ice.AsyncCallback", ns) + " " + getEscapedParamName(p, "callback") + " = null" << "object " + getEscapedParamName(p, "cookie") + " = null" << epar << ';'; _out << sp; @@ -2601,8 +2669,8 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << retS << " end_" << name << spar << getOutParams(p, package, false, true) - << (getUnqualified("Ice.AsyncResult", package) + " " + getEscapedParamName(p, "asyncResult")) << epar << ';'; + _out << retS << " end_" << name << spar << getOutParams(p, ns, false, true) + << (getUnqualified("Ice.AsyncResult", ns) + " " + getEscapedParamName(p, "asyncResult")) << epar << ';'; } } } @@ -2619,7 +2687,7 @@ bool Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { string name = fixId(p->name()); - string package = getPackage(p); + string ns = getNamespace(p); ExceptionPtr base = p->base(); _out << sp; @@ -2637,11 +2705,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) _out << nl << "public partial class " << name << " : "; if(base) { - _out << getUnqualified(base, package); + _out << getUnqualified(base, ns); } else { - _out << getUnqualified(p->isLocal() ? "Ice.LocalException" : "Ice.UserException", package); + _out << getUnqualified(p->isLocal() ? "Ice.LocalException" : "Ice.UserException", ns); } _out << sb; @@ -2657,7 +2725,7 @@ void Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { string name = fixId(p->name()); - string package = getPackage(p); + string ns = getNamespace(p); DataMemberList allDataMembers = p->allDataMembers(); DataMemberList dataMembers = p->dataMembers(); DataMemberList allClassMembers = p->allClassDataMembers(); @@ -2668,7 +2736,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) for(DataMemberList::const_iterator q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { string memberName = fixId((*q)->name()); - string memberType = typeToString((*q)->type(), package, (*q)->optional()); + string memberType = typeToString((*q)->type(), ns, (*q)->optional()); allParamDecl.push_back(memberType + " " + memberName); } @@ -2682,7 +2750,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { string memberName = fixId((*q)->name()); - string memberType = typeToString((*q)->type(), package, (*q)->optional()); + string memberType = typeToString((*q)->type(), ns, (*q)->optional()); paramDecl.push_back(memberType + " " + memberName); } @@ -2712,7 +2780,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) emitGeneratedCodeAttribute(); _out << nl << "private void _initDM()"; _out << sb; - writeDataMemberInitializers(dataMembers, package, DotNet::Exception); + writeDataMemberInitializers(dataMembers, ns, DotNet::Exception); _out << eb; } @@ -2743,7 +2811,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { string name = fixId((*q)->name(), DotNet::Exception, false); - writeSerializeDeserializeCode(_out, (*q)->type(), package, name, (*q)->optional(), (*q)->tag(), false); + writeSerializeDeserializeCode(_out, (*q)->type(), ns, name, (*q)->optional(), (*q)->tag(), false); } _out << eb; @@ -2864,7 +2932,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { string name = fixId((*q)->name(), DotNet::Exception, false); - writeSerializeDeserializeCode(_out, (*q)->type(), package, name, (*q)->optional(), (*q)->tag(), true); + writeSerializeDeserializeCode(_out, (*q)->type(), ns, name, (*q)->optional(), (*q)->tag(), true); } _out << sp << nl << "base.GetObjectData(info, context);"; _out << eb; @@ -2904,14 +2972,14 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override " << getUnqualified("Ice.SlicedData", package) << " ice_getSlicedData()"; + _out << nl << "public override " << getUnqualified("Ice.SlicedData", ns) << " ice_getSlicedData()"; _out << sb; _out << nl << "return slicedData_;"; _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void iceWrite(" << getUnqualified("Ice.OutputStream", package) << " ostr_)"; + _out << nl << "public override void iceWrite(" << getUnqualified("Ice.OutputStream", ns) << " ostr_)"; _out << sb; _out << nl << "ostr_.startException(slicedData_);"; _out << nl << "iceWriteImpl(ostr_);"; @@ -2920,7 +2988,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void iceRead(" << getUnqualified("Ice.InputStream", package) << " istr_)"; + _out << nl << "public override void iceRead(" << getUnqualified("Ice.InputStream", ns) << " istr_)"; _out << sb; _out << nl << "istr_.startException();"; _out << nl << "iceReadImpl(istr_);"; @@ -2930,12 +2998,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "protected override void iceWriteImpl(" << getUnqualified("Ice.OutputStream", package) << " ostr_)"; + _out << nl << "protected override void iceWriteImpl(" << getUnqualified("Ice.OutputStream", ns) << " ostr_)"; _out << sb; _out << nl << "ostr_.startSlice(\"" << scoped << "\", -1, " << (!base ? "true" : "false") << ");"; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), package); + writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), ns); } _out << nl << "ostr_.endSlice();"; if(base) @@ -2946,13 +3014,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "protected override void iceReadImpl(" << getUnqualified("Ice.InputStream", package) << " istr_)"; + _out << nl << "protected override void iceReadImpl(" << getUnqualified("Ice.InputStream", ns) << " istr_)"; _out << sb; _out << nl << "istr_.startSlice();"; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), package); + writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), ns); } _out << nl << "istr_.endSlice();"; if(base) @@ -2973,7 +3041,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(preserved && !basePreserved) { - _out << sp << nl << "protected " << getUnqualified("Ice.SlicedData", package) << " slicedData_;"; + _out << sp << nl << "protected " << getUnqualified("Ice.SlicedData", ns) << " slicedData_;"; } _out << sp << nl << "#endregion"; // Marshalling support @@ -2986,7 +3054,7 @@ bool Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { string name = fixId(p->name()); - string package = getPackage(p); + string ns = getNamespace(p); _out << sp; emitDeprecate(p, 0, _out, "type"); @@ -3024,7 +3092,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { _out << ", "; } - _out << getUnqualified(*q, package); + _out << getUnqualified(*q, ns); } } @@ -3040,7 +3108,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) { string name = fixId(p->name()); string scope = fixId(p->scope()); - string package = getPackage(p); + string ns = getNamespace(p); DataMemberList classMembers = p->classDataMembers(); DataMemberList dataMembers = p->dataMembers(); @@ -3064,7 +3132,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) emitGeneratedCodeAttribute(); _out << nl << "public " << name << "()"; _out << sb; - writeDataMemberInitializers(dataMembers, package, DotNet::ICloneable, propertyMapping); + writeDataMemberInitializers(dataMembers, ns, DotNet::ICloneable, propertyMapping); _out << nl << "ice_initialize();"; _out << eb; } @@ -3076,7 +3144,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0); - string memberType = typeToString((*q)->type(), package, false, p->isLocal()); + string memberType = typeToString((*q)->type(), ns, false, p->isLocal()); paramDecl.push_back(memberType + " " + memberName); } _out << paramDecl << epar; @@ -3186,27 +3254,27 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public void ice_writeMembers(" << getUnqualified("Ice.OutputStream", package) << " ostr)"; + _out << nl << "public void ice_writeMembers(" << getUnqualified("Ice.OutputStream", ns) << " ostr)"; _out << sb; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), package, true); + writeMarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), ns, true); } _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public void ice_readMembers(" << getUnqualified("Ice.InputStream", package) << " istr)"; + _out << nl << "public void ice_readMembers(" << getUnqualified("Ice.InputStream", ns) << " istr)"; _out << sb; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeUnmarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), package, true); + writeUnmarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), ns, true); } _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public static void ice_write(" << getUnqualified("Ice.OutputStream", package) << " ostr, " << name + _out << nl << "public static void ice_write(" << getUnqualified("Ice.OutputStream", ns) << " ostr, " << name << " v)"; _out << sb; if(isClass) @@ -3228,7 +3296,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public static " << name << " ice_read(" << getUnqualified("Ice.InputStream", package) << " istr)"; + _out << nl << "public static " << name << " ice_read(" << getUnqualified("Ice.InputStream", ns) << " istr)"; _out << sb; _out << nl << "var v = new " << name << "();"; _out << nl << "v.ice_readMembers(istr);"; @@ -3254,7 +3322,7 @@ void Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) { string name = fixId(p->name()); - string package = getPackage(p); + string ns = getNamespace(p); string scoped = fixId(p->scoped()); EnumeratorList enumerators = p->enumerators(); const bool explicitValue = p->explicitValue(); @@ -3286,18 +3354,18 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) _out << nl << "public sealed class " << p->name() << "Helper"; _out << sb; _out << sp; - _out << nl << "public static void write(" << getUnqualified("Ice.OutputStream", package) << " ostr, " << name + _out << nl << "public static void write(" << getUnqualified("Ice.OutputStream", ns) << " ostr, " << name << " v)"; _out << sb; - writeMarshalUnmarshalCode(_out, p, package, "v", true); + writeMarshalUnmarshalCode(_out, p, ns, "v", true); _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public static " << name << " read(" << getUnqualified("Ice.InputStream", package) << " istr)"; + _out << nl << "public static " << name << " read(" << getUnqualified("Ice.InputStream", ns) << " istr)"; _out << sb; _out << nl << name << " v;"; - writeMarshalUnmarshalCode(_out, p, package, "v", false); + writeMarshalUnmarshalCode(_out, p, ns, "v", false); _out << nl << "return v;"; _out << eb; @@ -3336,7 +3404,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) StructPtr st = StructPtr::dynamicCast(cont); ExceptionPtr ex = ExceptionPtr::dynamicCast(cont); ClassDefPtr cl = ClassDefPtr::dynamicCast(cont); - string package = getPackage(cont); + string ns = getNamespace(cont); if(st) { isLocal = st->isLocal(); @@ -3372,7 +3440,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) emitDeprecate(p, cont, _out, "member"); - string type = typeToString(p->type(), package, isOptional, isLocal, p->getMetaData()); + string type = typeToString(p->type(), ns, isOptional, isLocal, p->getMetaData()); string propertyName = fixId(p->name(), baseTypes, isClass); string dataMemberName; if(isProperty) @@ -3569,7 +3637,7 @@ Slice::Gen::ResultVisitor::visitModuleStart(const ModulePtr& p) { if(hasResultType(p)) { - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; return true; @@ -3580,8 +3648,8 @@ Slice::Gen::ResultVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::ResultVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -3599,7 +3667,7 @@ void Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) { ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); - string package = getPackage(cl); + string ns = getNamespace(cl); if(cl->isLocal()) { return; @@ -3615,7 +3683,7 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) string retSName; if(ret) { - retS = typeToString(ret, package, p->returnIsOptional()); + retS = typeToString(ret, ns, p->returnIsOptional()); retSName = resultStructReturnValueName(outParams); } @@ -3633,7 +3701,7 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) } for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { - _out << (typeToString((*i)->type(), package, (*i)->optional()) + " " + fixId((*i)->name())); + _out << (typeToString((*i)->type(), ns, (*i)->optional()) + " " + fixId((*i)->name())); } _out << epar; @@ -3662,7 +3730,7 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { - _out << nl << "public " << typeToString((*i)->type(), package, (*i)->optional()) << " " << fixId((*i)->name()) + _out << nl << "public " << typeToString((*i)->type(), ns, (*i)->optional()) << " " << fixId((*i)->name()) << ";"; } _out << eb; @@ -3674,18 +3742,18 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public struct " << name << " : " << getUnqualified("Ice.MarshaledResult", package); + _out << nl << "public struct " << name << " : " << getUnqualified("Ice.MarshaledResult", ns); _out << sb; // // One shot constructor // - _out << nl << "public " << name << spar << getOutParams(p, package, true, false) - << getUnqualified("Ice.Current", package) + " current" << epar; + _out << nl << "public " << name << spar << getOutParams(p, ns, true, false) + << getUnqualified("Ice.Current", ns) + " current" << epar; _out << sb; _out << nl << "_ostr = global::IceInternal.Incoming.createResponseOutputStream(current);"; - _out << nl << "_ostr.startEncapsulation(current.encoding, " << opFormatTypeToString(p, package) << ");"; - writeMarshalUnmarshalParams(outParams, p, true, package, false, true, "_ostr"); + _out << nl << "_ostr.startEncapsulation(current.encoding, " << opFormatTypeToString(p, ns) << ");"; + writeMarshalUnmarshalParams(outParams, p, true, ns, false, true, "_ostr"); if(p->returnsClasses(false)) { _out << nl << "_ostr.writePendingValues();"; @@ -3693,26 +3761,26 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) _out << nl << "_ostr.endEncapsulation();"; _out << eb; _out << sp; - _out << nl << "public " << getUnqualified("Ice.OutputStream", package) << " getOutputStream(" - << getUnqualified("Ice.Current", package) << " current)"; + _out << nl << "public " << getUnqualified("Ice.OutputStream", ns) << " getOutputStream(" + << getUnqualified("Ice.Current", ns) << " current)"; _out << sb; _out << nl << "if(_ostr == null)"; _out << sb; _out << nl << "return new " << name << spar; if(ret) { - _out << writeValue(ret, package); + _out << writeValue(ret, ns); } for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { - _out << writeValue((*i)->type(), package); + _out << writeValue((*i)->type(), ns); } _out << "current" << epar << ".getOutputStream(current);"; _out << eb; _out << nl << "return _ostr;"; _out << eb; _out << sp; - _out << nl << "private " << getUnqualified("Ice.OutputStream", package) << " _ostr;"; + _out << nl << "private " << getUnqualified("Ice.OutputStream", ns) << " _ostr;"; _out << eb; } } @@ -3730,7 +3798,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p) return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; return true; @@ -3739,8 +3807,8 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::ProxyVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -3752,7 +3820,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) } string name = p->name(); - string package = getPackage(p); + string ns = getNamespace(p); ClassList bases = p->bases(); _out << sp; @@ -3766,13 +3834,13 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr def = *q; if(def->isInterface() || def->allOperations().size() > 0) { - baseInterfaces.push_back(getUnqualified(*q, package, "", "Prx")); + baseInterfaces.push_back(getUnqualified(*q, ns, "", "Prx")); } } if(baseInterfaces.empty()) { - baseInterfaces.push_back(getUnqualified("Ice.ObjectPrx", package)); + baseInterfaces.push_back(getUnqualified("Ice.ObjectPrx", ns)); } for(vector<string>::const_iterator q = baseInterfaces.begin(); q != baseInterfaces.end();) @@ -3798,11 +3866,11 @@ void Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); - string package = getPackage(cl); + string ns = getNamespace(cl); string name = fixId(p->name(), DotNet::ICloneable, true); - vector<string> inParams = getInParams(p, package); + vector<string> inParams = getInParams(p, ns); ParamDeclList inParamDecls = p->inParameters(); - string retS = typeToString(p->returnType(), package, p->returnIsOptional()); + string retS = typeToString(p->returnType(), ns, p->returnIsOptional()); string deprecateReason = getDeprecateReason(p, cl, "operation"); { @@ -3817,9 +3885,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << retS << " " << name << spar << getParams(p, package) - << (getUnqualified("Ice.OptionalContext", package) + " " + context + " = new " + - getUnqualified("Ice.OptionalContext", package) + "()") << epar << ';'; + _out << nl << retS << " " << name << spar << getParams(p, ns) + << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " + + getUnqualified("Ice.OptionalContext", ns) + "()") << epar << ';'; } { @@ -3839,10 +3907,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << taskResultType(p, package); + _out << nl << taskResultType(p, ns); _out << " " << p->name() << "Async" << spar << inParams - << (getUnqualified("Ice.OptionalContext", package) + " " + context + " = new " + - getUnqualified("Ice.OptionalContext", package) + "()") + << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " + + getUnqualified("Ice.OptionalContext", ns) + "()") << ("global::System.IProgress<bool> " + progress + " = null") << ("global::System.Threading.CancellationToken " + cancel + " = new global::System.Threading.CancellationToken()") << epar << ";"; @@ -3866,10 +3934,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << getUnqualified("Ice.AsyncResult", package) << "<" << delType << "> begin_" << p->name() << spar + _out << nl << getUnqualified("Ice.AsyncResult", ns) << "<" << delType << "> begin_" << p->name() << spar << inParams - << (getUnqualified("Ice.OptionalContext", package) + " " + context + " = new " + - getUnqualified("Ice.OptionalContext", package) + "()") << epar << ';'; + << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " + + getUnqualified("Ice.OptionalContext", ns) + "()") << epar << ';'; // // Type-unsafe begin_ methods. @@ -3882,8 +3950,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << getUnqualified("Ice.AsyncResult", package) << " begin_" << p->name() << spar << inParams - << getUnqualified("Ice.AsyncCallback", package) + " " + callback << "object " + cookie << epar << ';'; + _out << nl << getUnqualified("Ice.AsyncResult", ns) << " begin_" << p->name() << spar << inParams + << getUnqualified("Ice.AsyncCallback", ns) + " " + callback << "object " + cookie << epar << ';'; _out << sp; writeDocCommentAMI(p, InParam, deprecateReason, @@ -3894,9 +3962,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << getUnqualified("Ice.AsyncResult", package) << " begin_" << p->name() << spar << inParams - << getUnqualified("Ice.OptionalContext", package) + " " + context - << getUnqualified("Ice.AsyncCallback", package) + " " + callback + _out << nl << getUnqualified("Ice.AsyncResult", ns) << " begin_" << p->name() << spar << inParams + << getUnqualified("Ice.OptionalContext", ns) + " " + context + << getUnqualified("Ice.AsyncCallback", ns) + " " + callback << "object " + cookie << epar << ';'; // @@ -3909,8 +3977,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << retS << " end_" << p->name() << spar << getOutParams(p, package, false, true) - << getUnqualified("Ice.AsyncResult", package) + " " + asyncResult << epar << ';'; + _out << nl << retS << " end_" << p->name() << spar << getOutParams(p, ns, false, true) + << getUnqualified("Ice.AsyncResult", ns) + " " + asyncResult << epar << ';'; } } @@ -3922,7 +3990,7 @@ Slice::Gen::AsyncDelegateVisitor::AsyncDelegateVisitor(IceUtilInternal::Output& bool Slice::Gen::AsyncDelegateVisitor::visitModuleStart(const ModulePtr& p) { - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; return true; @@ -3931,8 +3999,8 @@ Slice::Gen::AsyncDelegateVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::AsyncDelegateVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -3959,9 +4027,9 @@ Slice::Gen::AsyncDelegateVisitor::visitOperation(const OperationPtr& p) return; } - string package = getPackage(cl); - vector<string> paramDeclAMI = getOutParams(p, package, false, false); - string retS = typeToString(p->returnType(), package, p->returnIsOptional()); + string ns = getNamespace(cl); + vector<string> paramDeclAMI = getOutParams(p, ns, false, false); + string retS = typeToString(p->returnType(), ns, p->returnIsOptional()); string delName = "Callback_" + cl->name() + "_" + p->name(); _out << sp; @@ -3986,7 +4054,7 @@ Slice::Gen::OpsVisitor::visitModuleStart(const ModulePtr& p) { return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; return true; @@ -3995,8 +4063,8 @@ Slice::Gen::OpsVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::OpsVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -4010,7 +4078,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } string name = p->name(); - string package = getPackage(p); + string ns = getNamespace(p); string scoped = fixId(p->scoped()); ClassList bases = p->bases(); string opIntfName = "Operations"; @@ -4036,7 +4104,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) { first = false; } - _out << getUnqualified(*q, package, "", "Operations_"); + _out << getUnqualified(*q, ns, "", "Operations_"); } ++q; } @@ -4050,7 +4118,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd")); string retS; vector<string> params, args; - string name = getDispatchParams(op, retS, params, args, package); + string name = getDispatchParams(op, retS, params, args, ns); _out << sp; if(amd) { @@ -4085,7 +4153,7 @@ Slice::Gen::HelperVisitor::visitModuleStart(const ModulePtr& p) return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; return true; @@ -4094,8 +4162,8 @@ Slice::Gen::HelperVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::HelperVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -4107,14 +4175,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) } string name = p->name(); - string package = getPackage(p); + string ns = getNamespace(p); ClassList bases = p->bases(); _out << sp; emitComVisibleAttribute(); emitGeneratedCodeAttribute(); _out << nl << "[global::System.Serializable]"; - _out << nl << "public sealed class " << name << "PrxHelper : " << getUnqualified("Ice.ObjectPrxHelperBase", package) + _out << nl << "public sealed class " << name << "PrxHelper : " << getUnqualified("Ice.ObjectPrxHelperBase", ns) << ", " << name << "Prx"; _out << sb; @@ -4142,9 +4210,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); string opName = fixId(op->name(), DotNet::ICloneable, true); TypePtr ret = op->returnType(); - string retS = typeToString(ret, package, op->returnIsOptional()); + string retS = typeToString(ret, ns, op->returnIsOptional()); - vector<string> params = getParams(op, package); + vector<string> params = getParams(op, ns); vector<string> args = getArgs(op); vector<string> argsAMI = getInArgs(op); @@ -4173,8 +4241,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp; _out << nl << "public " << retS << " " << opName << spar << params - << (getUnqualified("Ice.OptionalContext", package) + " " + context + " = new " + - getUnqualified("Ice.OptionalContext", package) + "()") << epar; + << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " + + getUnqualified("Ice.OptionalContext", ns) + "()") << epar; _out << sb; _out << nl << "try"; _out << sb; @@ -4243,7 +4311,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) OperationPtr op = *r; ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - vector<string> paramsAMI = getInParams(op, package); + vector<string> paramsAMI = getInParams(op, ns); vector<string> argsAMI = getInArgs(op); string opName = op->name(); @@ -4257,9 +4325,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr ret = op->returnType(); - string retS = typeToString(ret, package, op->returnIsOptional()); + string retS = typeToString(ret, ns, op->returnIsOptional()); - string returnTypeS = resultType(op, package); + string returnTypeS = resultType(op, ns); ExceptionList throws = op->throws(); throws.sort(); @@ -4287,8 +4355,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << "<" << returnTypeS << ">"; } _out << " " << opName << "Async" << spar << paramsAMI - << (getUnqualified("Ice.OptionalContext", package) + " " + context + " = new " + - getUnqualified("Ice.OptionalContext", package) + "()") + << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " + + getUnqualified("Ice.OptionalContext", ns) + "()") << ("global::System.IProgress<bool> " + progress + " = null") << ("global::System.Threading.CancellationToken " + cancel + " = new global::System.Threading.CancellationToken()") << epar; @@ -4307,8 +4375,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { _out << "<" << returnTypeS << ">"; } - _out << " _iceI_" << opName << "Async" << spar << getInParams(op, package, true) - << getUnqualified("Ice.OptionalContext", package) + " context" + _out << " _iceI_" << opName << "Async" << spar << getInParams(op, ns, true) + << getUnqualified("Ice.OptionalContext", ns) + " context" << "global::System.IProgress<bool> progress" << "global::System.Threading.CancellationToken cancel" << "bool synchronous" << epar; @@ -4342,7 +4410,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // Write the common invoke method // _out << sp << nl; - _out << "private void _iceI_" << op->name() << spar << getInParams(op, package, true) + _out << "private void _iceI_" << op->name() << spar << getInParams(op, ns, true) << "global::System.Collections.Generic.Dictionary<string, string> context" << "bool synchronous" << "global::IceInternal.OutgoingAsyncCompletionCallback completed" << epar; @@ -4360,16 +4428,16 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "outAsync.invoke("; _out.inc(); _out << nl << flatName << ","; - _out << nl << sliceModeToIceMode(op->sendMode(), package) << ","; - _out << nl << opFormatTypeToString(op, package) << ","; + _out << nl << sliceModeToIceMode(op->sendMode(), ns) << ","; + _out << nl << opFormatTypeToString(op, ns) << ","; _out << nl << "context,"; _out << nl << "synchronous"; if(!inParams.empty()) { _out << ","; - _out << nl << "write: (" << getUnqualified("Ice.OutputStream", package) << " ostr) =>"; + _out << nl << "write: (" << getUnqualified("Ice.OutputStream", ns) << " ostr) =>"; _out << sb; - writeMarshalUnmarshalParams(inParams, 0, true, package); + writeMarshalUnmarshalParams(inParams, 0, true, ns); if(op->sendsClasses(false)) { _out << nl << "ostr.writePendingValues();"; @@ -4380,7 +4448,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) if(!throws.empty()) { _out << ","; - _out << nl << "userException: (" << getUnqualified("Ice.UserException", package) << " ex) =>"; + _out << nl << "userException: (" << getUnqualified("Ice.UserException", ns) << " ex) =>"; _out << sb; _out << nl << "try"; _out << sb; @@ -4392,13 +4460,13 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i) { - _out << nl << "catch(" << getUnqualified(*i, package) << ")"; + _out << nl << "catch(" << getUnqualified(*i, ns) << ")"; _out << sb; _out << nl << "throw;"; _out << eb; } - _out << nl << "catch(" << getUnqualified("Ice.UserException", package) << ")"; + _out << nl << "catch(" << getUnqualified("Ice.UserException", ns) << ")"; _out << sb; _out << eb; @@ -4408,7 +4476,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) if(ret || !outParams.empty()) { _out << ","; - _out << nl << "read: (" << getUnqualified("Ice.InputStream", package) << " istr) =>"; + _out << nl << "read: (" << getUnqualified("Ice.InputStream", ns) << " istr) =>"; _out << sb; if(outParams.empty()) { @@ -4427,7 +4495,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) } else if(isClassType(ret)) { - _out << " = " << getUnqualified("Ice.Util", package) << ".None"; + _out << " = " << getUnqualified("Ice.Util", ns) << ".None"; } _out << ";"; } @@ -4438,14 +4506,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) else { TypePtr t = outParams.front()->type(); - _out << nl << typeToString(t, package, (outParams.front()->optional())) << " iceP_" + _out << nl << typeToString(t, ns, (outParams.front()->optional())) << " iceP_" << outParams.front()->name(); if(!outParams.front()->optional()) { StructPtr st = StructPtr::dynamicCast(t); if(st && isValueType(st)) { - _out << " = " << "new " << typeToString(t, package) << "()"; + _out << " = " << "new " << typeToString(t, ns) << "()"; } else if(isClassType(t) || st) { @@ -4454,12 +4522,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) } else if(isClassType(t)) { - _out << " = " << getUnqualified("Ice.Util", package) << ".None"; + _out << " = " << getUnqualified("Ice.Util", ns) << ".None"; } _out << ";"; } - writeMarshalUnmarshalParams(outParams, op, false, package, true); + writeMarshalUnmarshalParams(outParams, op, false, ns, true); if(op->returnsClasses(false)) { _out << nl << "istr.readPendingValues();"; @@ -4491,48 +4559,48 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) OperationPtr op = *r; ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - vector<string> paramsAMI = getInParams(op, package); + vector<string> paramsAMI = getInParams(op, ns); vector<string> argsAMI = getInArgs(op); string opName = op->name(); ParamDeclList inParams = op->inParameters(); ParamDeclList outParams = op->outParameters(); TypePtr ret = op->returnType(); - string retS = typeToString(ret, package, op->returnIsOptional()); + string retS = typeToString(ret, ns, op->returnIsOptional()); - string returnTypeS = resultType(op, package); + string returnTypeS = resultType(op, ns); // // Write the begin_ methods. // - string clScope = getPackage(cl); - string delType = getUnqualified(clScope + ".Callback_" + cl->name() + "_" + op->name(), package); + string clScope = getNamespace(cl); + string delType = getUnqualified(clScope + ".Callback_" + cl->name() + "_" + op->name(), ns); string context = getEscapedParamName(op, "context"); string callback = getEscapedParamName(op, "callback"); string cookie = getEscapedParamName(op, "cookie"); _out << sp; - _out << nl << "public " << getUnqualified("Ice.AsyncResult", package) << "<" << delType << "> begin_" << opName - << spar << paramsAMI << (getUnqualified("Ice.OptionalContext", package) + " " + context + " = new " + - getUnqualified("Ice.OptionalContext", package) + "()") << epar; + _out << nl << "public " << getUnqualified("Ice.AsyncResult", ns) << "<" << delType << "> begin_" << opName + << spar << paramsAMI << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " + + getUnqualified("Ice.OptionalContext", ns) + "()") << epar; _out << sb; _out << nl << "return begin_" << opName << spar << argsAMI << context << "null" << "null" << "false" << epar << ';'; _out << eb; _out << sp; - _out << nl << "public " << getUnqualified("Ice.AsyncResult", package) << " begin_" << opName << spar << paramsAMI - << getUnqualified("Ice.AsyncCallback", package) + " " + callback << "object " + cookie << epar; + _out << nl << "public " << getUnqualified("Ice.AsyncResult", ns) << " begin_" << opName << spar << paramsAMI + << getUnqualified("Ice.AsyncCallback", ns) + " " + callback << "object " + cookie << epar; _out << sb; _out << nl << "return begin_" << opName << spar << argsAMI - << "new " + getUnqualified("Ice.OptionalContext", package) + "()" << callback << cookie << "false" << epar << ';'; + << "new " + getUnqualified("Ice.OptionalContext", ns) + "()" << callback << cookie << "false" << epar << ';'; _out << eb; _out << sp; - _out << nl << "public " << getUnqualified("Ice.AsyncResult", package) + " begin_" << opName << spar << paramsAMI - << getUnqualified("Ice.OptionalContext", package) + " " + context - << getUnqualified("Ice.AsyncCallback", package) + " " + callback + _out << nl << "public " << getUnqualified("Ice.AsyncResult", ns) + " begin_" << opName << spar << paramsAMI + << getUnqualified("Ice.OptionalContext", ns) + " " + context + << getUnqualified("Ice.AsyncCallback", ns) + " " + callback << "object " + cookie << epar; _out << sb; _out << nl << "return begin_" << opName << spar << argsAMI << context << callback @@ -4545,8 +4613,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) string flatName = "_" + opName + "_name"; string asyncResult = getEscapedParamName(op, "asyncResult"); - _out << sp << nl << "public " << retS << " end_" << opName << spar << getOutParams(op, package, false, true) - << getUnqualified("Ice.AsyncResult", package) + " " + asyncResult << epar; + _out << sp << nl << "public " << retS << " end_" << opName << spar << getOutParams(op, ns, false, true) + << getUnqualified("Ice.AsyncResult", ns) + " " + asyncResult << epar; _out << sb; _out << nl << "var resultI_ = global::IceInternal.AsyncResultI.check(" + asyncResult + ", this, " << flatName << ");"; @@ -4586,10 +4654,10 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // Write the common begin_ implementation. // _out << sp; - _out << nl << "private " << getUnqualified("Ice.AsyncResult", package) << "<" << delType << "> begin_" << opName << spar - << getInParams(op, package, true) + _out << nl << "private " << getUnqualified("Ice.AsyncResult", ns) << "<" << delType << "> begin_" << opName << spar + << getInParams(op, ns, true) << "global::System.Collections.Generic.Dictionary<string, string> context" - << getUnqualified("Ice.AsyncCallback", package) + " completedCallback" << "object cookie" << "bool synchronous" + << getUnqualified("Ice.AsyncCallback", ns) + " completedCallback" << "object cookie" << "bool synchronous" << epar; _out << sb; @@ -4643,7 +4711,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp << nl << "#endregion"; // Asynchronous operations _out << sp << nl << "#region Checked and unchecked cast operations"; - _out << sp << nl << "public static " << name << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", package) << " b)"; + _out << sp << nl << "public static " << name << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; @@ -4660,7 +4728,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << eb; _out << sp << nl << "public static " << name - << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", package) + << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b, global::System.Collections.Generic.Dictionary<string, string> ctx)"; _out << sb; _out << nl << "if(b == null)"; @@ -4677,14 +4745,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return r;"; _out << eb; - _out << sp << nl << "public static " << name << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", package) + _out << sp << nl << "public static " << name << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b, string f)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; _out << nl << "return null;"; _out << eb; - _out << nl << getUnqualified("Ice.ObjectPrx", package) << " bb = b.ice_facet(f);"; + _out << nl << getUnqualified("Ice.ObjectPrx", ns) << " bb = b.ice_facet(f);"; _out << nl << "try"; _out << sb; _out << nl << "if(bb.ice_isA(ice_staticId()))"; @@ -4694,21 +4762,21 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return h;"; _out << eb; _out << eb; - _out << nl << "catch(" << getUnqualified("Ice.FacetNotExistException", package) << ")"; + _out << nl << "catch(" << getUnqualified("Ice.FacetNotExistException", ns) << ")"; _out << sb; _out << eb; _out << nl << "return null;"; _out << eb; _out << sp << nl << "public static " << name - << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", package) << " b, string f, " + << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b, string f, " << "global::System.Collections.Generic.Dictionary<string, string> ctx)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; _out << nl << "return null;"; _out << eb; - _out << nl << getUnqualified("Ice.ObjectPrx", package) << " bb = b.ice_facet(f);"; + _out << nl << getUnqualified("Ice.ObjectPrx", ns) << " bb = b.ice_facet(f);"; _out << nl << "try"; _out << sb; _out << nl << "if(bb.ice_isA(ice_staticId(), ctx))"; @@ -4718,13 +4786,13 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return h;"; _out << eb; _out << eb; - _out << nl << "catch(" << getUnqualified("Ice.FacetNotExistException", package) << ")"; + _out << nl << "catch(" << getUnqualified("Ice.FacetNotExistException", ns) << ")"; _out << sb; _out << eb; _out << nl << "return null;"; _out << eb; - _out << sp << nl << "public static " << name << "Prx uncheckedCast(" << getUnqualified("Ice.ObjectPrx", package) << " b)"; + _out << sp << nl << "public static " << name << "Prx uncheckedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; @@ -4740,14 +4808,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return r;"; _out << eb; - _out << sp << nl << "public static " << name << "Prx uncheckedCast(" << getUnqualified("Ice.ObjectPrx", package) + _out << sp << nl << "public static " << name << "Prx uncheckedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b, string f)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; _out << nl << "return null;"; _out << eb; - _out << nl << getUnqualified("Ice.ObjectPrx", package) << " bb = b.ice_facet(f);"; + _out << nl << getUnqualified("Ice.ObjectPrx", ns) << " bb = b.ice_facet(f);"; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.iceCopyFrom(bb);"; _out << nl << "return h;"; @@ -4797,15 +4865,15 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp << nl << "#region Marshaling support"; - _out << sp << nl << "public static void write(" << getUnqualified("Ice.OutputStream", package) << " ostr, " << name + _out << sp << nl << "public static void write(" << getUnqualified("Ice.OutputStream", ns) << " ostr, " << name << "Prx v)"; _out << sb; _out << nl << "ostr.writeProxy(v);"; _out << eb; - _out << sp << nl << "public static " << name << "Prx read(" << getUnqualified("Ice.InputStream", package) << " istr)"; + _out << sp << nl << "public static " << name << "Prx read(" << getUnqualified("Ice.InputStream", ns) << " istr)"; _out << sb; - _out << nl << getUnqualified("Ice.ObjectPrx", package) << " proxy = istr.readProxy();"; + _out << nl << getUnqualified("Ice.ObjectPrx", ns) << " proxy = istr.readProxy();"; _out << nl << "if(proxy != null)"; _out << sb; _out << nl << name << "PrxHelper result = new " << name << "PrxHelper();"; @@ -4837,23 +4905,23 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) return; } - string package = getPackage(p); - string typeS = typeToString(p, package); + string ns = getNamespace(p); + string typeS = typeToString(p, ns); _out << sp; emitGeneratedCodeAttribute(); _out << nl << "public sealed class " << p->name() << "Helper"; _out << sb; - _out << sp << nl << "public static void write(" << getUnqualified("Ice.OutputStream", package) << " ostr, " << typeS + _out << sp << nl << "public static void write(" << getUnqualified("Ice.OutputStream", ns) << " ostr, " << typeS << " v)"; _out << sb; - writeSequenceMarshalUnmarshalCode(_out, p, package, "v", true, false); + writeSequenceMarshalUnmarshalCode(_out, p, ns, "v", true, false); _out << eb; - _out << sp << nl << "public static " << typeS << " read(" << getUnqualified("Ice.InputStream", package) << " istr)"; + _out << sp << nl << "public static " << typeS << " read(" << getUnqualified("Ice.InputStream", ns) << " istr)"; _out << sb; _out << nl << typeS << " v;"; - writeSequenceMarshalUnmarshalCode(_out, p, package, "v", false, false); + writeSequenceMarshalUnmarshalCode(_out, p, ns, "v", false, false); _out << nl << "return v;"; _out << eb; _out << eb; @@ -4918,9 +4986,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) genericType = meta.substr(prefix.size()); } - string package = getPackage(p); - string keyS = typeToString(key, package); - string valueS = typeToString(value, package); + string ns = getNamespace(p); + string keyS = typeToString(key, ns); + string valueS = typeToString(value, ns); string name = "global::System.Collections.Generic." + genericType + "<" + keyS + ", " + valueS + ">"; _out << sp; @@ -4930,7 +4998,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << sp << nl << "public static void write("; _out.useCurrentPosAsIndent(); - _out << getUnqualified("Ice.OutputStream", package) << " ostr,"; + _out << getUnqualified("Ice.OutputStream", ns) << " ostr,"; _out << nl << name << " v)"; _out.restoreIndent(); _out << sb; @@ -4945,13 +5013,13 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << "Generic.KeyValuePair<" << keyS << ", " << valueS << ">"; _out << " e in v)"; _out << sb; - writeMarshalUnmarshalCode(_out, key, package, "e.Key", true); - writeMarshalUnmarshalCode(_out, value, package, "e.Value", true); + writeMarshalUnmarshalCode(_out, key, ns, "e.Key", true); + writeMarshalUnmarshalCode(_out, value, ns, "e.Value", true); _out << eb; _out << eb; _out << eb; - _out << sp << nl << "public static " << name << " read(" << getUnqualified("Ice.InputStream", package) << " istr)"; + _out << sp << nl << "public static " << name << " read(" << getUnqualified("Ice.InputStream", ns) << " istr)"; _out << sb; _out << nl << "int sz = istr.readSize();"; _out << nl << name << " r = new " << name << "();"; @@ -4963,20 +5031,20 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) { if(isValueType(st)) { - _out << nl << "k = new " << typeToString(key, package) << "();"; + _out << nl << "k = new " << typeToString(key, ns) << "();"; } else { _out << nl << "k = null;"; } } - writeMarshalUnmarshalCode(_out, key, package, "k", false); + writeMarshalUnmarshalCode(_out, key, ns, "k", false); if(isClassType(value)) { ostringstream os; - os << '(' << typeToString(value, package) << " v) => { r[k] = v; }"; - writeMarshalUnmarshalCode(_out, value, package, os.str(), false); + os << '(' << typeToString(value, ns) << " v) => { r[k] = v; }"; + writeMarshalUnmarshalCode(_out, value, ns, os.str(), false); } else { @@ -4986,14 +5054,14 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) { if(isValueType(st)) { - _out << nl << "v = new " << typeToString(value, package) << "();"; + _out << nl << "v = new " << typeToString(value, ns) << "();"; } else { _out << nl << "v = null;"; } } - writeMarshalUnmarshalCode(_out, value, package, "v", false); + writeMarshalUnmarshalCode(_out, value, ns, "v", false); _out << nl << "r[k] = v;"; } _out << eb; @@ -5017,7 +5085,7 @@ Slice::Gen::DispatcherVisitor::visitModuleStart(const ModulePtr& p) return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; return true; @@ -5026,8 +5094,8 @@ Slice::Gen::DispatcherVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::DispatcherVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -5041,11 +5109,11 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); bool hasBaseClass = !bases.empty() && !bases.front()->isInterface(); string name = p->name(); - string package = getPackage(p); - string baseClass = getUnqualified("Ice.ObjectImpl", package); + string ns = getNamespace(p); + string baseClass = getUnqualified("Ice.ObjectImpl", ns); if(hasBaseClass && !bases.front()->allOperations().empty()) { - baseClass = getUnqualified(bases.front(), package, "", "Disp_"); + baseClass = getUnqualified(bases.front(), ns, "", "Disp_"); } _out << sp; @@ -5072,7 +5140,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) for(ClassList::const_iterator i = allBases.begin(); i != allBases.end(); ++i) { - _out << ", " << getUnqualified(*i, package); + _out << ", " << getUnqualified(*i, ns); } } @@ -5088,7 +5156,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) { string retS; vector<string> params, args; - string name = getDispatchParams(*i, retS, params, args, package); + string name = getDispatchParams(*i, retS, params, args, ns); _out << sp << nl << "public abstract " << retS << " " << name << spar << params << epar << ';'; } @@ -5112,7 +5180,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp; emitComVisibleAttribute(); emitGeneratedCodeAttribute(); - _out << nl << "public class " << name << "Tie_ : " << name << "Disp_, " << getUnqualified("Ice.TieBase", package); + _out << nl << "public class " << name << "Tie_ : " << name << "Disp_, " << getUnqualified("Ice.TieBase", ns); _out << sb; @@ -5173,14 +5241,14 @@ Slice::Gen::DispatcherVisitor::visitClassDefEnd(const ClassDefPtr&) void Slice::Gen::DispatcherVisitor::writeTieOperations(const ClassDefPtr& p, NameSet* opNames) { - string package = getPackage(p); + string ns = getNamespace(p); OperationList ops = p->operations(); for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r) { string retS; vector<string> params; vector<string> args; - string opName = getDispatchParams(*r, retS, params, args, package); + string opName = getDispatchParams(*r, retS, params, args, ns); if(opNames) { if(opNames->find(opName) != opNames->end()) @@ -5229,7 +5297,7 @@ void Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment, bool forTie) { ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - string package = getPackage(cl); + string ns = getNamespace(cl); string opName = op->name(); TypePtr ret = op->returnType(); ParamDeclList params = op->parameters(); @@ -5259,8 +5327,8 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment if(!cl->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd"))) { ParamDeclList::const_iterator i; - vector<string> pDecl = getInParams(op, package); - string resultType = CsGenerator::resultType(op, package, true); + vector<string> pDecl = getInParams(op, ns); + string resultType = CsGenerator::resultType(op, ns, true); _out << "public "; if(!forTie) @@ -5273,7 +5341,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { _out << "<" << resultType << ">"; } - _out << " " << opName << "Async" << spar << pDecl << getUnqualified("Ice.Current", package) + " current = null" + _out << " " << opName << "Async" << spar << pDecl << getUnqualified("Ice.Current", ns) + " current = null" << epar; if(comment) @@ -5285,7 +5353,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment _out << sb; if(ret) { - _out << nl << typeToString(ret, package) << " ret = " << writeValue(ret, package) << ';'; + _out << nl << typeToString(ret, ns) << " ret = " << writeValue(ret, ns) << ';'; } for(ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i) { @@ -5293,7 +5361,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { string name = fixId((*i)->name()); TypePtr type = (*i)->type(); - _out << nl << typeToString(type, package) << ' ' << name << " = " << writeValue(type, package) << ';'; + _out << nl << typeToString(type, ns) << ' ' << name << " = " << writeValue(type, ns) << ';'; } } _out << nl << "return global::System.Threading.Tasks.Task.FromResult"; @@ -5343,9 +5411,9 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { string retS = op->hasMarshaledResult() ? fixId(cl->scope() + resultStructName(cl->name(), op->name(), true)) : - typeToString(ret, package); + typeToString(ret, ns); - vector<string> pDecls = op->hasMarshaledResult() ? getInParams(op, package) : getParams(op, package); + vector<string> pDecls = op->hasMarshaledResult() ? getInParams(op, ns) : getParams(op, ns); _out << "public "; if(!forTie && !cl->isLocal()) @@ -5355,7 +5423,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment _out << retS << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls; if(!cl->isLocal()) { - _out << getUnqualified("Ice.Current", package) + " current = null"; + _out << getUnqualified("Ice.Current", ns) + " current = null"; } _out << epar; if(comment) @@ -5370,7 +5438,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment << "("; if(ret) { - _out << writeValue(ret, package); + _out << writeValue(ret, ns); } for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { @@ -5378,7 +5446,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { _out << ", "; } - _out << writeValue((*i)->type(), package); + _out << writeValue((*i)->type(), ns); } _out << ", current);"; } @@ -5388,12 +5456,12 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { string name = fixId((*i)->name()); TypePtr type = (*i)->type(); - _out << nl << name << " = " << writeValue(type, package) << ';'; + _out << nl << name << " = " << writeValue(type, ns) << ';'; } if(ret) { - _out << nl << "return " << writeValue(ret, package) << ';'; + _out << nl << "return " << writeValue(ret, ns) << ';'; } } _out << eb; @@ -5413,7 +5481,7 @@ Slice::Gen::ImplVisitor::visitModuleStart(const ModulePtr& p) return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; @@ -5423,8 +5491,8 @@ Slice::Gen::ImplVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::ImplVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool @@ -5483,7 +5551,7 @@ Slice::Gen::ImplTieVisitor::visitModuleStart(const ModulePtr& p) return false; } - CsVisitor::visitModuleStart(p); + moduleStart(p); _out << sp << nl << "namespace " << fixId(p->name()); _out << sb; @@ -5493,8 +5561,8 @@ Slice::Gen::ImplTieVisitor::visitModuleStart(const ModulePtr& p) void Slice::Gen::ImplTieVisitor::visitModuleEnd(const ModulePtr& p) { - CsVisitor::visitModuleEnd(p); _out << eb; + moduleEnd(p); } bool diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index 02f70c20549..2b8c168d1a6 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -74,8 +74,8 @@ protected: void writeDocCommentAMD(const OperationPtr&, const std::string&); void writeDocCommentParam(const OperationPtr&, ParamDir, bool); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); + void moduleStart(const ModulePtr&); + void moduleEnd(const ModulePtr&); ::IceUtilInternal::Output& _out; }; @@ -121,12 +121,23 @@ private: public: CompactIdVisitor(IceUtilInternal::Output&); - virtual bool visitUnitStart(const UnitPtr&); virtual void visitUnitEnd(const UnitPtr&); + virtual bool visitClassDefStart(const ClassDefPtr&); + }; + + class TypeIdVisitor : public CsVisitor + { + public: + + TypeIdVisitor(IceUtilInternal::Output&); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); + virtual bool visitExceptionStart(const ExceptionPtr&); + + private: + void generateHelperClass(const ContainedPtr&); }; class TypesVisitor : public CsVisitor |