diff options
author | Jose <jose@zeroc.com> | 2017-10-30 12:40:46 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-10-30 12:40:46 +0100 |
commit | 164a436b839b41076fbee2fa5663af39e6ff56fe (patch) | |
tree | 77eb45d3b765adf57ef2ed91620a4901f147c994 /cpp/src/slice2cs/Gen.cpp | |
parent | ICE-8457 - Ruby and Python string fixes (diff) | |
download | ice-164a436b839b41076fbee2fa5663af39e6ff56fe.tar.bz2 ice-164a436b839b41076fbee2fa5663af39e6ff56fe.tar.xz ice-164a436b839b41076fbee2fa5663af39e6ff56fe.zip |
Fix Overqualification in generated code
See ICE-7856
Diffstat (limited to 'cpp/src/slice2cs/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 564 |
1 files changed, 311 insertions, 253 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index b70aae7be01..a5356187564 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -165,7 +165,8 @@ Slice::CsVisitor::~CsVisitor() void Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const OperationPtr& op, bool marshal, - bool resultStruct, bool publicNames, const string& customStream) + const string& scope, bool resultStruct, bool publicNames, + const string& customStream) { ParamDeclList optionals; @@ -188,7 +189,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(type)) { ostringstream os; - os << '(' << typeToString(type) << " v) => {" << paramPrefix << param << " = v; }"; + os << '(' << typeToString(type, scope) << " v) => {" << paramPrefix << param << " = v; }"; param = os.str(); } else @@ -202,7 +203,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const } else { - writeMarshalUnmarshalCode(_out, type, param, marshal, customStream); + writeMarshalUnmarshalCode(_out, type, scope, param, marshal, customStream); } } @@ -215,7 +216,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(ret)) { ostringstream os; - os << '(' << typeToString(ret) << " v) => {" << paramPrefix << returnValueS << " = v; }"; + os << '(' << typeToString(ret, scope) << " v) => {" << paramPrefix << returnValueS << " = v; }"; param = os.str(); } else @@ -225,7 +226,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!op->returnIsOptional()) { - writeMarshalUnmarshalCode(_out, ret, param, marshal, customStream); + writeMarshalUnmarshalCode(_out, ret, scope, param, marshal, customStream); } } @@ -254,14 +255,14 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(ret)) { ostringstream os; - os << '(' << typeToString(ret) << " v) => {" << paramPrefix << returnValueS << " = v; }"; + os << '(' << typeToString(ret, scope) << " v) => {" << paramPrefix << returnValueS << " = v; }"; param = os.str(); } else { param = paramPrefix + returnValueS; } - writeOptionalMarshalUnmarshalCode(_out, ret, param, op->returnTag(), marshal, customStream); + writeOptionalMarshalUnmarshalCode(_out, ret, scope, param, op->returnTag(), marshal, customStream); checkReturnType = false; } @@ -270,7 +271,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(type)) { ostringstream os; - os << '(' << typeToString(type) << " v) => {" << paramPrefix << param << " = v; }"; + os << '(' << typeToString(type, scope) << " v) => {" << paramPrefix << param << " = v; }"; param = os.str(); } else @@ -278,7 +279,7 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const param = paramPrefix + param; } - writeOptionalMarshalUnmarshalCode(_out, type, param, (*pli)->tag(), marshal, customStream); + writeOptionalMarshalUnmarshalCode(_out, type, scope, param, (*pli)->tag(), marshal, customStream); } if(checkReturnType) @@ -287,24 +288,24 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const if(!marshal && isClassType(ret)) { ostringstream os; - os << '(' << typeToString(ret) << " v) => {" << paramPrefix << returnValueS << " = v; }"; + os << '(' << typeToString(ret, scope) << " v) => {" << paramPrefix << returnValueS << " = v; }"; param = os.str(); } else { param = paramPrefix + returnValueS; } - writeOptionalMarshalUnmarshalCode(_out, ret, param, op->returnTag(), marshal, customStream); + writeOptionalMarshalUnmarshalCode(_out, ret, scope, param, op->returnTag(), marshal, customStream); } } void -Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const string& name, bool forStruct) +Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const string& name, const string& scope, bool forStruct) { if(member->optional()) { assert(!forStruct); - writeOptionalMarshalUnmarshalCode(_out, member->type(), name, member->tag(), true, "ostr_"); + writeOptionalMarshalUnmarshalCode(_out, member->type(), scope, name, member->tag(), true, "ostr_"); } else { @@ -315,18 +316,18 @@ Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const stri memberName = "this." + memberName; } - writeMarshalUnmarshalCode(_out, member->type(), memberName, true, stream); + writeMarshalUnmarshalCode(_out, member->type(), scope, memberName, true, stream); } } void -Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const string& name, bool forStruct) +Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const string& name, const string& scope, bool forStruct) { string param = name; if(isClassType(member->type())) { ostringstream os; - os << '(' << typeToString(member->type()) << " v) => { this." << name << " = v; }"; + os << '(' << typeToString(member->type(), scope) << " v) => { this." << name << " = v; }"; param = os.str(); } else if(forStruct) @@ -337,17 +338,18 @@ Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const st if(member->optional()) { assert(!forStruct); - writeOptionalMarshalUnmarshalCode(_out, member->type(), param, member->tag(), false, "istr_"); + writeOptionalMarshalUnmarshalCode(_out, member->type(), scope, param, member->tag(), false, "istr_"); } else { - writeMarshalUnmarshalCode(_out, member->type(), param, false, forStruct ? "" : "istr_"); + writeMarshalUnmarshalCode(_out, member->type(), scope, param, false, forStruct ? "" : "istr_"); } } void Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p) { + const string scope = fixId(p->scope()); ClassList bases = p->bases(); if(!bases.empty() && !bases.front()->isInterface()) { @@ -369,7 +371,7 @@ Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p) { string retS; vector<string> params, args; - string name = getDispatchParams(*i, retS, params, args); + string name = getDispatchParams(*i, retS, params, args, scope); _out << sp << nl << "public abstract " << retS << " " << name << spar << params << epar << ';'; } @@ -382,6 +384,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { string name = fixId(p->name()); string scoped = p->scoped(); + string scope = fixId(p->scope()); ClassList allBases = p->allBases(); StringList ids; ClassList bases = p->bases(); @@ -427,7 +430,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override bool ice_isA(string s, Ice.Current current = null)"; + _out << nl << "public override bool ice_isA(string s, " << getAbsolute("Ice.Current", scope) << " current = null)"; _out << sb; _out << nl << "return _System.Array.BinarySearch(_ids, s, IceUtilInternal.StringUtil.OrdinalStringComparer) >= 0;"; _out << eb; @@ -437,7 +440,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override string[] ice_ids(Ice.Current current = null)"; + _out << nl << "public override string[] ice_ids(" << getAbsolute("Ice.Current", scope) << " current = null)"; _out << sb; _out << nl << "return _ids;"; _out << eb; @@ -447,7 +450,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override string ice_id(Ice.Current current = null)"; + _out << nl << "public override string ice_id(" << getAbsolute("Ice.Current", scope) << " current = null)"; _out << sb; _out << nl << "return _ids[" << scopedPos << "];"; _out << eb; @@ -485,16 +488,17 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public static _System.Threading.Tasks.Task<Ice.OutputStream>"; + _out << nl << "public static _System.Threading.Tasks.Task<" << getAbsolute("Ice.OutputStream", scope) << ">"; _out << nl << "iceD_" << opName << "(" << name << (p->isInterface() ? "" : "Disp_") << " obj, " - << "IceInternal.Incoming inS, Ice.Current current)"; + << "IceInternal.Incoming inS, " << getAbsolute("Ice.Current", scope) << " current)"; _out << sb; TypePtr ret = op->returnType(); ParamDeclList inParams = op->inParameters(); ParamDeclList outParams = op->outParameters(); - _out << nl << "Ice.ObjectImpl.iceCheckMode(" << sliceModeToIceMode(op->mode()) << ", current.mode);"; + _out << nl << getAbsolute("Ice.ObjectImpl", scope) << ".iceCheckMode(" << sliceModeToIceMode(op->mode()) + << ", current.mode);"; if(!inParams.empty()) { // @@ -504,12 +508,17 @@ 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(), (*pli)->optional()); + string typeS = typeToString((*pli)->type(), scope, (*pli)->optional()); const bool isClass = isClassType((*pli)->type()); if((*pli)->optional()) { - _out << nl << typeS << ' ' << param << (isClass ? " = Ice.Util.None" : "") << ';'; + _out << nl << typeS << ' ' << param; + if(isClass) + { + _out << " = " << getAbsolute("Ice.Util", scope) << ".None"; + } + _out << ';'; } else { @@ -525,7 +534,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } } } - writeMarshalUnmarshalParams(inParams, 0, false); + writeMarshalUnmarshalParams(inParams, 0, false, scope); if(op->sendsClasses(false)) { _out << nl << "istr.readPendingValues();"; @@ -557,7 +566,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } else if(amd) { - string retS = resultType(op); + string retS = resultType(op, scope); _out << nl << "return inS.setResultTask" << (retS.empty() ? "" : ('<' + retS + '>')); _out << "(obj." << opName << "Async" << spar << inArgs << "current" << epar; if(!retS.empty()) @@ -573,7 +582,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) _out << nl << "(ostr, ret) =>"; } _out << sb; - writeMarshalUnmarshalParams(outParams, op, true, true); + writeMarshalUnmarshalParams(outParams, op, true, scope, true); if(op->returnsClasses(false)) { _out << nl << "ostr.writePendingValues();"; @@ -588,7 +597,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) { for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli) { - string typeS = typeToString((*pli)->type(), (*pli)->optional()); + string typeS = typeToString((*pli)->type(), scope, (*pli)->optional()); _out << nl << typeS << ' ' << "iceP_" + (*pli)->name() << ";"; } @@ -613,7 +622,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) if(!outParams.empty() || ret) { _out << nl << "var ostr = inS.startWriteParams();"; - writeMarshalUnmarshalParams(outParams, op, true); + writeMarshalUnmarshalParams(outParams, op, true, scope); if(op->returnsClasses(false)) { _out << nl << "ostr.writePendingValues();"; @@ -659,13 +668,14 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) emitGeneratedCodeAttribute(); } _out << nl << "public override _System.Threading.Tasks.Task<Ice.OutputStream>"; - _out << nl << "iceDispatch(IceInternal.Incoming inS, Ice.Current current)"; + _out << nl << "iceDispatch(IceInternal.Incoming inS, " << getAbsolute("Ice.Current", scope) << " current)"; _out << sb; _out << nl << "int pos = _System.Array.BinarySearch(_all, current.operation, " << "IceUtilInternal.StringUtil.OrdinalStringComparer);"; _out << nl << "if(pos < 0)"; _out << sb; - _out << nl << "throw new Ice.OperationNotExistException(current.id, current.facet, current.operation);"; + _out << nl << "throw new " << getAbsolute("Ice.OperationNotExistException", scope) + << "(current.id, current.facet, current.operation);"; _out << eb; _out << sp << nl << "switch(pos)"; _out << sb; @@ -678,19 +688,19 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) _out << sb; if(opName == "ice_id") { - _out << nl << "return Ice.ObjectImpl.iceD_ice_id(this, inS, current);"; + _out << nl << "return " << getAbsolute("Ice.ObjectImpl", scope) << ".iceD_ice_id(this, inS, current);"; } else if(opName == "ice_ids") { - _out << nl << "return Ice.ObjectImpl.iceD_ice_ids(this, inS, current);"; + _out << nl << "return " << getAbsolute("Ice.ObjectImpl", scope) << ".iceD_ice_ids(this, inS, current);"; } else if(opName == "ice_isA") { - _out << nl << "return Ice.ObjectImpl.iceD_ice_isA(this, inS, current);"; + _out << nl << "return " << getAbsolute("Ice.ObjectImpl", scope) << ".iceD_ice_isA(this, inS, current);"; } else if(opName == "ice_ping") { - _out << nl << "return Ice.ObjectImpl.iceD_ice_ping(this, inS, current);"; + _out << nl << "return " << getAbsolute("Ice.ObjectImpl", scope) << ".iceD_ice_ping(this, inS, current);"; } else { @@ -710,7 +720,8 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } else { - _out << nl << "return " << fixId(cl->scoped() + "Disp_") << ".iceD_" << opName << "(this, inS, current);"; + _out << nl << "return " << getAbsolute(fixId(cl->scoped() + "Disp_"), scope) << ".iceD_" + << opName << "(this, inS, current);"; } break; } @@ -720,7 +731,8 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } _out << eb; _out << sp << nl << "_System.Diagnostics.Debug.Assert(false);"; - _out << nl << "throw new Ice.OperationNotExistException(current.id, current.facet, current.operation);"; + _out << nl << "throw new " << getAbsolute("Ice.OperationNotExistException", scope) + << "(current.id, current.facet, current.operation);"; _out << eb; } @@ -735,6 +747,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { string name = fixId(p->name()); string scoped = p->scoped(); + string scope = fixId(p->scope()); ClassList allBases = p->allBases(); StringList ids; ClassList bases = p->bases(); @@ -774,7 +787,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override Ice.SlicedData ice_getSlicedData()"; + _out << nl << "public override " << getAbsolute("Ice.SlicedData", scope) << " ice_getSlicedData()"; _out << sb; _out << nl << "return iceSlicedData_;"; _out << eb; @@ -784,7 +797,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void iceWrite(Ice.OutputStream ostr_)"; + _out << nl << "public override void iceWrite(" << getAbsolute("Ice.OutputStream", scope) << " ostr_)"; _out << sb; _out << nl << "ostr_.startValue(iceSlicedData_);"; _out << nl << "iceWriteImpl(ostr_);"; @@ -796,7 +809,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void iceRead(Ice.InputStream istr_)"; + _out << nl << "public override void iceRead(" << getAbsolute("Ice.InputStream", scope) << " istr_)"; _out << sb; _out << nl << "istr_.startValue();"; _out << nl << "iceReadImpl(istr_);"; @@ -809,19 +822,19 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "protected override void iceWriteImpl(Ice.OutputStream ostr_)"; + _out << nl << "protected override void iceWriteImpl(" << getAbsolute("Ice.OutputStream", scope) << " 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)); + writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), scope); } } for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) { - writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true)); + writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), scope); } _out << nl << "ostr_.endSlice();"; if(base) @@ -835,19 +848,19 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { emitGeneratedCodeAttribute(); } - _out << nl << "protected override void iceReadImpl(Ice.InputStream istr_)"; + _out << nl << "protected override void iceReadImpl(" << getAbsolute("Ice.InputStream", scope) << " 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)); + writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), scope); } } for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) { - writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true)); + writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), scope); } _out << nl << "istr_.endSlice();"; if(base) @@ -858,7 +871,7 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) if(preserved && !basePreserved) { - _out << sp << nl << "protected Ice.SlicedData iceSlicedData_;"; + _out << sp << nl << "protected " << getAbsolute("Ice.SlicedData", scope) << " iceSlicedData_;"; } _out << sp << nl << "#endregion"; // Marshalling support @@ -881,7 +894,7 @@ Slice::CsVisitor::getParamAttributes(const ParamDeclPtr& p) } vector<string> -Slice::CsVisitor::getParams(const OperationPtr& op) +Slice::CsVisitor::getParams(const OperationPtr& op, const string& scope) { vector<string> params; ParamDeclList paramList = op->parameters(); @@ -893,40 +906,38 @@ Slice::CsVisitor::getParams(const OperationPtr& op) { param += "out "; } - param += typeToString((*q)->type(), (*q)->optional(), cl->isLocal()) + " " + fixId((*q)->name()); + param += typeToString((*q)->type(), scope, (*q)->optional(), cl->isLocal()) + " " + fixId((*q)->name()); params.push_back(param); } return params; } vector<string> -Slice::CsVisitor::getInParams(const OperationPtr& op, bool internal) +Slice::CsVisitor::getInParams(const OperationPtr& op, const string& scope, bool internal) { vector<string> params; string name = fixId(op->name()); ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); // Get the class containing the op. - ParamDeclList paramList = op->inParameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { - params.push_back(getParamAttributes(*q) + typeToString((*q)->type(), (*q)->optional(), cl->isLocal()) + params.push_back(getParamAttributes(*q) + typeToString((*q)->type(), scope, (*q)->optional(), cl->isLocal()) + " " + (internal ? "iceP_" + (*q)->name() : fixId((*q)->name()))); } return params; } vector<string> -Slice::CsVisitor::getOutParams(const OperationPtr& op, bool returnParam, bool outKeyword) +Slice::CsVisitor::getOutParams(const OperationPtr& op, const string& scope, bool returnParam, bool outKeyword) { vector<string> params; - if(returnParam) { TypePtr ret = op->returnType(); if(ret) { - params.push_back(typeToString(ret, op->returnIsOptional()) + " ret"); + params.push_back(typeToString(ret, scope, op->returnIsOptional()) + " ret"); } } @@ -938,7 +949,7 @@ Slice::CsVisitor::getOutParams(const OperationPtr& op, bool returnParam, bool ou { s += "out "; } - s += typeToString((*q)->type(), (*q)->optional()) + ' ' + fixId((*q)->name()); + s += typeToString((*q)->type(), scope, (*q)->optional()) + ' ' + fixId((*q)->name()); params.push_back(s); } @@ -978,40 +989,40 @@ Slice::CsVisitor::getInArgs(const OperationPtr& op, bool internal) } string -Slice::CsVisitor::getDispatchParams(const OperationPtr& op, string& retS, vector<string>& params, vector<string>& args) +Slice::CsVisitor::getDispatchParams(const OperationPtr& op, string& retS, vector<string>& params, vector<string>& args, + const string& scope) { string name; - + ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); // Get the class containing the op. ParamDeclList paramDecls; - ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); if(cl->hasMetaData("amd") || op->hasMetaData("amd")) { name = op->name() + "Async"; - params = getInParams(op); + params = getInParams(op, scope); args = getInArgs(op); paramDecls = op->inParameters(); - retS = taskResultType(op, true); + retS = taskResultType(op, scope, true); } else if(op->hasMarshaledResult()) { name = fixId(op->name(), DotNet::ICloneable, true); - params = getInParams(op); + params = getInParams(op, scope); args = getInArgs(op); paramDecls = op->inParameters(); - retS = resultType(op, true); + retS = resultType(op, scope, true); } else { name = fixId(op->name(), DotNet::ICloneable, true); - params = getParams(op); + params = getParams(op, scope); args = getArgs(op); paramDecls = op->parameters(); - retS = typeToString(op->returnType(), op->returnIsOptional()); + retS = typeToString(op->returnType(), scope, op->returnIsOptional()); } string currentParamName = getEscapedParamName(op, "current"); - params.push_back("Ice.Current " + currentParamName + " = null"); + params.push_back(getAbsolute("Ice.Current", scope) + " " + currentParamName + " = null"); args.push_back(currentParamName); return name; } @@ -1063,7 +1074,7 @@ Slice::CsVisitor::emitPartialTypeAttributes() } string -Slice::CsVisitor::writeValue(const TypePtr& type) +Slice::CsVisitor::writeValue(const TypePtr& type, const string& scope) { assert(type); @@ -1106,13 +1117,20 @@ Slice::CsVisitor::writeValue(const TypePtr& type) EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - return fixId(en->scoped()) + "." + fixId((*en->enumerators().begin())->name()); + return typeToString(type, scope) + "." + fixId((*en->enumerators().begin())->name()); } StructPtr st = StructPtr::dynamicCast(type); if(st) { - return st->hasMetaData("cs:class") ? string("null") : "new " + fixId(st->scoped()) + "()"; + if(st->hasMetaData("cs:class")) + { + return "null"; + } + else + { + return "new " + typeToString(type, scope) + "()"; + } } return "null"; @@ -1176,7 +1194,8 @@ Slice::CsVisitor::requiresDataMemberInitializers(const DataMemberList& members) } void -Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, int baseTypes, bool propertyMapping) +Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, const string& scope, int baseTypes, + bool propertyMapping) { for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p) { @@ -1197,8 +1216,8 @@ Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, int } else if((*p)->optional()) { - _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString((*p)->type(), true) - << "();"; + _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " + << typeToString((*p)->type(), scope, true) << "();"; } else { @@ -1211,7 +1230,8 @@ Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, int StructPtr st = StructPtr::dynamicCast((*p)->type()); if(st) { - _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, false) << "();"; + _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, scope, false) + << "();"; } } } @@ -2174,6 +2194,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { string name = p->name(); string scoped = fixId(p->scoped()); + string scope = fixId(p->scope()); ClassList bases = p->bases(); bool hasBaseClass = !bases.empty() && !bases.front()->isInterface(); @@ -2186,8 +2207,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { emitComVisibleAttribute(); OperationPtr o = p->allOperations().front(); - _out << nl << "public delegate " << typeToString(o->returnType(), o->returnIsOptional()) << " "; - _out << fixId(name) << spar << getParams(o) << epar << ";"; + _out << nl << "public delegate " << typeToString(o->returnType(), scope, o->returnIsOptional()) << " "; + _out << fixId(name) << spar << getParams(o, scope) << epar << ";"; return false; } @@ -2198,12 +2219,12 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "public partial interface " << fixId(name); if(!p->isLocal()) { - baseNames.push_back("Ice.Object"); + baseNames.push_back(getAbsolute("Ice.Object", scope)); baseNames.push_back(name + "Operations_"); } for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) { - baseNames.push_back(fixId((*q)->scoped())); + baseNames.push_back(getAbsolute(fixId((*q)->scoped()), scope)); } } else @@ -2269,7 +2290,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { _out << ", "; } - _out << *q; + _out << getAbsolute(*q, scope); } } @@ -2305,6 +2326,7 @@ void Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) { string name = fixId(p->name()); + string scope = fixId(p->scope()); DataMemberList classMembers = p->classDataMembers(); DataMemberList allClassMembers = p->allClassDataMembers(); DataMemberList dataMembers = p->dataMembers(); @@ -2334,7 +2356,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p) _out << " : base()"; } _out << sb; - writeDataMemberInitializers(dataMembers, DotNet::ICloneable, propertyMapping); + writeDataMemberInitializers(dataMembers, scope, DotNet::ICloneable, propertyMapping); _out << eb; _out << sp; @@ -2344,7 +2366,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(), (*d)->optional(), p->isLocal(), (*d)->getMetaData()); + string memberType = typeToString((*d)->type(), scope, (*d)->optional(), p->isLocal(), (*d)->getMetaData()); paramDecl.push_back(memberType + " " + memberName); } _out << paramDecl << epar; @@ -2421,12 +2443,13 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); bool isLocal = cl->isLocal(); bool isInterface = cl->isInterface(); + string scope = fixId(cl->scope()); if(isLocal) { string name = fixId(p->name(), DotNet::ICloneable, true); TypePtr ret = p->returnType(); - string retS = typeToString(ret, p->returnIsOptional(), true); + string retS = typeToString(ret, scope, p->returnIsOptional(), true); _out << sp; if(isInterface) @@ -2444,11 +2467,11 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << retS << " " << name << spar << getParams(p) << epar << ";"; + _out << retS << " " << name << spar << getParams(p, scope) << epar << ";"; if(cl->hasMetaData("async-oneway") || p->hasMetaData("async-oneway")) { - vector<string> inParams = getInParams(p); + vector<string> inParams = getInParams(p, scope); ParamDeclList inParamDecls = p->inParameters(); // @@ -2462,7 +2485,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << taskResultType(p); + _out << taskResultType(p, scope); string progress = getEscapedParamName(p, "progress"); string cancel = getEscapedParamName(p, "cancel"); @@ -2483,8 +2506,8 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << "Ice.AsyncResult begin_" << name << spar << inParams - << "Ice.AsyncCallback " + getEscapedParamName(p, "callback") + " = null" + _out << getAbsolute("Ice.AsyncResult", scope) << " begin_" << name << spar << inParams + << getAbsolute("Ice.AsyncCallback", scope) + " " + getEscapedParamName(p, "callback") + " = null" << "object " + getEscapedParamName(p, "cookie") + " = null" << epar << ';'; _out << sp; @@ -2495,8 +2518,8 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) { _out << "public abstract "; } - _out << retS << " end_" << name << spar << getOutParams(p, false, true) - << "Ice.AsyncResult " + getEscapedParamName(p, "asyncResult") << epar << ';'; + _out << retS << " end_" << name << spar << getOutParams(p, scope, false, true) + << (getAbsolute("Ice.AsyncResult", scope) + " " + getEscapedParamName(p, "asyncResult")) << epar << ';'; } } } @@ -2513,6 +2536,7 @@ bool Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { string name = fixId(p->name()); + string scope = fixId(p->scope()); ExceptionPtr base = p->base(); _out << sp; @@ -2530,11 +2554,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) _out << nl << "public partial class " << name << " : "; if(base) { - _out << fixId(base->scoped()); + _out << getAbsolute(fixId(base->scoped()), scope); } else { - _out << (p->isLocal() ? "Ice.LocalException" : "Ice.UserException"); + _out << getAbsolute(p->isLocal() ? "Ice.LocalException" : "Ice.UserException", scope); } _out << sb; @@ -2550,7 +2574,7 @@ void Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { string name = fixId(p->name()); - + string scope = fixId(p->scope()); DataMemberList allDataMembers = p->allDataMembers(); DataMemberList dataMembers = p->dataMembers(); DataMemberList allClassMembers = p->allClassDataMembers(); @@ -2561,7 +2585,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(), (*q)->optional()); + string memberType = typeToString((*q)->type(), scope, (*q)->optional()); allParamDecl.push_back(memberType + " " + memberName); } @@ -2575,7 +2599,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(), (*q)->optional()); + string memberType = typeToString((*q)->type(), scope, (*q)->optional()); paramDecl.push_back(memberType + " " + memberName); } @@ -2605,7 +2629,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) emitGeneratedCodeAttribute(); _out << nl << "private void _initDM()"; _out << sb; - writeDataMemberInitializers(dataMembers, DotNet::Exception); + writeDataMemberInitializers(dataMembers, scope, DotNet::Exception); _out << eb; } @@ -2636,7 +2660,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(), name, (*q)->optional(), (*q)->tag(), false); + writeSerializeDeserializeCode(_out, (*q)->type(), scope, name, (*q)->optional(), (*q)->tag(), false); } _out << eb; @@ -2757,7 +2781,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(), name, (*q)->optional(), (*q)->tag(), true); + writeSerializeDeserializeCode(_out, (*q)->type(), scope, name, (*q)->optional(), (*q)->tag(), true); } _out << sp << nl << "base.GetObjectData(info, context);"; _out << eb; @@ -2797,14 +2821,14 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override Ice.SlicedData ice_getSlicedData()"; + _out << nl << "public override " << getAbsolute("Ice.SlicedData", scope) << " ice_getSlicedData()"; _out << sb; _out << nl << "return slicedData_;"; _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void iceWrite(Ice.OutputStream ostr_)"; + _out << nl << "public override void iceWrite(" << getAbsolute("Ice.OutputStream", scope) << " ostr_)"; _out << sb; _out << nl << "ostr_.startException(slicedData_);"; _out << nl << "iceWriteImpl(ostr_);"; @@ -2813,7 +2837,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void iceRead(Ice.InputStream istr_)"; + _out << nl << "public override void iceRead(" << getAbsolute("Ice.InputStream", scope) << " istr_)"; _out << sb; _out << nl << "istr_.startException();"; _out << nl << "iceReadImpl(istr_);"; @@ -2823,12 +2847,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "protected override void iceWriteImpl(Ice.OutputStream ostr_)"; + _out << nl << "protected override void iceWriteImpl(" << getAbsolute("Ice.OutputStream", scope) << " 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)); + writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), scope); } _out << nl << "ostr_.endSlice();"; if(base) @@ -2839,13 +2863,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "protected override void iceReadImpl(Ice.InputStream istr_)"; + _out << nl << "protected override void iceReadImpl(" << getAbsolute("Ice.InputStream", scope) << " 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)); + writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), scope); } _out << nl << "istr_.endSlice();"; if(base) @@ -2866,7 +2890,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(preserved && !basePreserved) { - _out << sp << nl << "protected Ice.SlicedData slicedData_;"; + _out << sp << nl << "protected " << getAbsolute("Ice.SlicedData", scope) << " slicedData_;"; } _out << sp << nl << "#endregion"; // Marshalling support @@ -2879,7 +2903,7 @@ bool Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { string name = fixId(p->name()); - + string scope = fixId(p->scope()); _out << sp; emitDeprecate(p, 0, _out, "type"); @@ -2917,7 +2941,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { _out << ", "; } - _out << *q; + _out << getAbsolute(*q, scope); } } @@ -2932,7 +2956,7 @@ void Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) { string name = fixId(p->name()); - + string scope = fixId(p->scope()); DataMemberList classMembers = p->classDataMembers(); DataMemberList dataMembers = p->dataMembers(); @@ -2956,7 +2980,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) emitGeneratedCodeAttribute(); _out << nl << "public " << name << "()"; _out << sb; - writeDataMemberInitializers(dataMembers, DotNet::ICloneable, propertyMapping); + writeDataMemberInitializers(dataMembers, scope, DotNet::ICloneable, propertyMapping); _out << eb; } @@ -2967,7 +2991,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(), false, p->isLocal()); + string memberType = typeToString((*q)->type(), scope, false, p->isLocal()); paramDecl.push_back(memberType + " " + memberName); } _out << paramDecl << epar; @@ -3076,27 +3100,28 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public void ice_writeMembers(Ice.OutputStream ostr)"; + _out << nl << "public void ice_writeMembers(" << getAbsolute("Ice.OutputStream", scope) << " ostr)"; _out << sb; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), true); + writeMarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), scope, true); } _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public void ice_readMembers(Ice.InputStream istr)"; + _out << nl << "public void ice_readMembers(" << getAbsolute("Ice.InputStream", scope) << " istr)"; _out << sb; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeUnmarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), true); + writeUnmarshalDataMember(*q, fixId(*q, isClass ? DotNet::ICloneable : 0), scope, true); } _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public static void ice_write(Ice.OutputStream ostr, " << name << " v)"; + _out << nl << "public static void ice_write(" << getAbsolute("Ice.OutputStream", scope) << " ostr, " << name + << " v)"; _out << sb; if(isClass) { @@ -3117,7 +3142,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public static " << name << " ice_read(Ice.InputStream istr)"; + _out << nl << "public static " << name << " ice_read(" << getAbsolute("Ice.InputStream", scope) << " istr)"; _out << sb; _out << nl << "var v = new " << name << "();"; _out << nl << "v.ice_readMembers(istr);"; @@ -3143,6 +3168,7 @@ void Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) { string name = fixId(p->name()); + string scope = fixId(p->scope()); string scoped = fixId(p->scoped()); EnumeratorList enumerators = p->enumerators(); const bool explicitValue = p->explicitValue(); @@ -3174,17 +3200,17 @@ 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(Ice.OutputStream ostr, " << name << " v)"; + _out << nl << "public static void write(" << getAbsolute("Ice.OutputStream", scope) << " ostr, " << name << " v)"; _out << sb; - writeMarshalUnmarshalCode(_out, p, "v", true); + writeMarshalUnmarshalCode(_out, p, scope, "v", true); _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public static " << name << " read(Ice.InputStream istr)"; + _out << nl << "public static " << name << " read(" << getAbsolute("Ice.InputStream", scope) << " istr)"; _out << sb; _out << nl << name << " v;"; - writeMarshalUnmarshalCode(_out, p, "v", false); + writeMarshalUnmarshalCode(_out, p, scope, "v", false); _out << nl << "return v;"; _out << eb; @@ -3201,7 +3227,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) emitGeneratedCodeAttribute(); _out << nl << "public abstract class " << name; _out << sb; - _out << sp << nl << "public const " << typeToString(p->type()) << " value = "; + _out << sp << nl << "public const " << typeToString(p->type(), "") << " value = "; writeConstantValue(p->type(), p->valueType(), p->value()); _out << ";"; _out << eb; @@ -3223,6 +3249,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) StructPtr st = StructPtr::dynamicCast(cont); ExceptionPtr ex = ExceptionPtr::dynamicCast(cont); ClassDefPtr cl = ClassDefPtr::dynamicCast(cont); + string scope = fixId(cont->scope()); if(st) { isLocal = st->isLocal(); @@ -3258,7 +3285,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) emitDeprecate(p, cont, _out, "member"); - string type = typeToString(p->type(), isOptional, isLocal, p->getMetaData()); + string type = typeToString(p->type(), scope, isOptional, isLocal, p->getMetaData()); string propertyName = fixId(p->name(), baseTypes, isClass); string dataMemberName; if(isProperty) @@ -3483,6 +3510,7 @@ void Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) { ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); + string scope = fixId(cl->scope()); if(cl->isLocal()) { return; @@ -3498,7 +3526,7 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) string retSName; if(ret) { - retS = typeToString(ret, p->returnIsOptional()); + retS = typeToString(ret, scope, p->returnIsOptional()); retSName = resultStructReturnValueName(outParams); } @@ -3516,7 +3544,7 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) } for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { - _out << (typeToString((*i)->type(), (*i)->optional()) + " " + fixId((*i)->name())); + _out << (typeToString((*i)->type(), scope, (*i)->optional()) + " " + fixId((*i)->name())); } _out << epar; @@ -3545,7 +3573,8 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { - _out << nl << "public " << typeToString((*i)->type(), (*i)->optional()) << " " << fixId((*i)->name()) << ";"; + _out << nl << "public " << typeToString((*i)->type(), scope, (*i)->optional()) << " " << fixId((*i)->name()) + << ";"; } _out << eb; } @@ -3556,17 +3585,18 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public struct " << name << " : Ice.MarshaledResult"; + _out << nl << "public struct " << name << " : " << getAbsolute("Ice.MarshaledResult", scope); _out << sb; // // One shot constructor // - _out << nl << "public " << name << spar << getOutParams(p, true, false) << "Ice.Current current" << epar; + _out << nl << "public " << name << spar << getOutParams(p, scope, true, false) + << getAbsolute("Ice.Current", scope) + " current" << epar; _out << sb; _out << nl << "_ostr = IceInternal.Incoming.createResponseOutputStream(current);"; _out << nl << "_ostr.startEncapsulation(current.encoding, " << opFormatTypeToString(p) << ");"; - writeMarshalUnmarshalParams(outParams, p, true, false, true, "_ostr"); + writeMarshalUnmarshalParams(outParams, p, true, scope, false, true, "_ostr"); if(p->returnsClasses(false)) { _out << nl << "_ostr.writePendingValues();"; @@ -3574,25 +3604,26 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p) _out << nl << "_ostr.endEncapsulation();"; _out << eb; _out << sp; - _out << nl << "public Ice.OutputStream getOutputStream(Ice.Current current)"; + _out << nl << "public " << getAbsolute("Ice.OutputStream", scope) << " getOutputStream(" + << getAbsolute("Ice.Current", scope) << " current)"; _out << sb; _out << nl << "if(_ostr == null)"; _out << sb; _out << nl << "return new " << name << spar; if(ret) { - _out << writeValue(ret); + _out << writeValue(ret, scope); } for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { - _out << writeValue((*i)->type()); + _out << writeValue((*i)->type(), scope); } _out << "current" << epar << ".getOutputStream(current);"; _out << eb; _out << nl << "return _ostr;"; _out << eb; _out << sp; - _out << nl << "private Ice.OutputStream _ostr;"; + _out << nl << "private " << getAbsolute("Ice.OutputStream", scope) << " _ostr;"; _out << eb; } } @@ -3630,6 +3661,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) } string name = p->name(); + string scope = fixId(p->scope()); ClassList bases = p->bases(); _out << sp; @@ -3643,13 +3675,13 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr def = *q; if(def->isInterface() || def->allOperations().size() > 0) { - baseInterfaces.push_back(fixId((*q)->scoped() + "Prx")); + baseInterfaces.push_back(getAbsolute(fixId((*q)->scoped() + "Prx"), scope)); } } if(baseInterfaces.empty()) { - baseInterfaces.push_back("Ice.ObjectPrx"); + baseInterfaces.push_back(getAbsolute("Ice.ObjectPrx", scope)); } for(vector<string>::const_iterator q = baseInterfaces.begin(); q != baseInterfaces.end();) @@ -3675,10 +3707,11 @@ void Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); + string scope = fixId(cl->scope()); string name = fixId(p->name(), DotNet::ICloneable, true); - vector<string> inParams = getInParams(p); + vector<string> inParams = getInParams(p, scope); ParamDeclList inParamDecls = p->inParameters(); - string retS = typeToString(p->returnType(), p->returnIsOptional()); + string retS = typeToString(p->returnType(), scope, p->returnIsOptional()); string deprecateReason = getDeprecateReason(p, cl, "operation"); { @@ -3693,8 +3726,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << retS << " " << name << spar << getParams(p) - << ("Ice.OptionalContext " + context + " = new Ice.OptionalContext()") << epar << ';'; + _out << nl << retS << " " << name << spar << getParams(p, scope) + << (getAbsolute("Ice.OptionalContext", scope) + " " + context + " = new " + + getAbsolute("Ice.OptionalContext", scope) + "()") << epar << ';'; } { @@ -3714,9 +3748,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << taskResultType(p); + _out << nl << taskResultType(p, scope); _out << " " << p->name() << "Async" << spar << inParams - << ("Ice.OptionalContext " + context + " = new Ice.OptionalContext()") + << (getAbsolute("Ice.OptionalContext", scope) + " " + context + " = new " + + getAbsolute("Ice.OptionalContext", scope) + "()") << ("_System.IProgress<bool> " + progress + " = null") << ("_System.Threading.CancellationToken " + cancel + " = new _System.Threading.CancellationToken()") << epar << ";"; @@ -3726,8 +3761,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) // // Write the async versions of the operation (using IAsyncResult API) // - string clScope = fixId(cl->scope()); - string delType = clScope + "Callback_" + cl->name() + "_" + p->name(); + string delType = "Callback_" + cl->name() + "_" + p->name(); string context = getEscapedParamName(p, "context"); string callback = getEscapedParamName(p, "callback"); @@ -3741,8 +3775,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << "Ice.AsyncResult<" << delType << "> begin_" << p->name() << spar << inParams - << ("Ice.OptionalContext " + context + " = new Ice.OptionalContext()") << epar << ';'; + _out << nl << getAbsolute("Ice.AsyncResult", scope) << "<" << delType << "> begin_" << p->name() << spar + << inParams + << (getAbsolute("Ice.OptionalContext", scope) + " " + context + " = new " + + getAbsolute("Ice.OptionalContext", scope) + "()") << epar << ';'; // // Type-unsafe begin_ methods. @@ -3755,8 +3791,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << "Ice.AsyncResult begin_" << p->name() << spar << inParams - << "Ice.AsyncCallback " + callback << "object " + cookie << epar << ';'; + _out << nl << getAbsolute("Ice.AsyncResult", scope) << " begin_" << p->name() << spar << inParams + << getAbsolute("Ice.AsyncCallback", scope) + " " + callback << "object " + cookie << epar << ';'; _out << sp; writeDocCommentAMI(p, InParam, deprecateReason, @@ -3767,8 +3803,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << "Ice.AsyncResult begin_" << p->name() << spar << inParams - << "Ice.OptionalContext " + context << "Ice.AsyncCallback " + callback << "object " + cookie << epar << ';'; + _out << nl << getAbsolute("Ice.AsyncResult", scope) << " begin_" << p->name() << spar << inParams + << getAbsolute("Ice.OptionalContext", scope) + " " + context + << getAbsolute("Ice.AsyncCallback", scope) + " " + callback + << "object " + cookie << epar << ';'; // // end_ method. @@ -3780,8 +3818,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]"; } - _out << nl << retS << " end_" << p->name() << spar << getOutParams(p, false, true) - << "Ice.AsyncResult " + asyncResult << epar << ';'; + _out << nl << retS << " end_" << p->name() << spar << getOutParams(p, scope, false, true) + << getAbsolute("Ice.AsyncResult", scope) + " " + asyncResult << epar << ';'; } } @@ -3828,8 +3866,9 @@ Slice::Gen::AsyncDelegateVisitor::visitOperation(const OperationPtr& p) return; } - vector<string> paramDeclAMI = getOutParams(p, false, false); - string retS = typeToString(p->returnType(), p->returnIsOptional()); + string scope = fixId(cl->scope()); + vector<string> paramDeclAMI = getOutParams(p, scope, false, false); + string retS = typeToString(p->returnType(), scope, p->returnIsOptional()); string delName = "Callback_" + cl->name() + "_" + p->name(); _out << sp; @@ -3877,6 +3916,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } string name = p->name(); + string scope = fixId(p->scope()); string scoped = fixId(p->scoped()); ClassList bases = p->bases(); string opIntfName = "Operations"; @@ -3904,7 +3944,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) } string s = (*q)->scoped(); s += "Operations"; - _out << fixId(s) << '_'; + _out << getAbsolute(fixId(s), scope) << '_'; } ++q; } @@ -3918,7 +3958,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); + string name = getDispatchParams(op, retS, params, args, scope); _out << sp; if(amd) { @@ -3973,13 +4013,15 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) } string name = p->name(); + string scope = fixId(p->scope()); ClassList bases = p->bases(); _out << sp; emitComVisibleAttribute(); emitGeneratedCodeAttribute(); _out << nl << "[_System.Serializable]"; - _out << nl << "public sealed class " << name << "PrxHelper : Ice.ObjectPrxHelperBase, " << name << "Prx"; + _out << nl << "public sealed class " << name << "PrxHelper : " << getAbsolute("Ice.ObjectPrxHelperBase", scope) + << ", " << name << "Prx"; _out << sb; _out << sp; @@ -4006,9 +4048,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, op->returnIsOptional()); + string retS = typeToString(ret, scope, op->returnIsOptional()); - vector<string> params = getParams(op); + vector<string> params = getParams(op, scope); vector<string> args = getArgs(op); vector<string> argsAMI = getInArgs(op); @@ -4037,7 +4079,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp; _out << nl << "public " << retS << " " << opName << spar << params - << ("Ice.OptionalContext " + context + " = new Ice.OptionalContext()") << epar; + << (getAbsolute("Ice.OptionalContext", scope) + " " + context + " = new " + + getAbsolute("Ice.OptionalContext", scope) + "()") << epar; _out << sb; _out << nl << "try"; _out << sb; @@ -4106,8 +4149,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) OperationPtr op = *r; ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - string clScope = fixId(cl->scope()); - vector<string> paramsAMI = getInParams(op); + vector<string> paramsAMI = getInParams(op, scope); vector<string> argsAMI = getInArgs(op); string opName = op->name(); @@ -4121,9 +4163,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr ret = op->returnType(); - string retS = typeToString(ret, op->returnIsOptional()); + string retS = typeToString(ret, scope, op->returnIsOptional()); - string returnTypeS = resultType(op); + string returnTypeS = resultType(op, scope); ExceptionList throws = op->throws(); throws.sort(); @@ -4151,7 +4193,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << "<" << returnTypeS << ">"; } _out << " " << opName << "Async" << spar << paramsAMI - << ("Ice.OptionalContext " + context + " = new Ice.OptionalContext()") + << (getAbsolute("Ice.OptionalContext", scope) + " " + context + " = new " + + getAbsolute("Ice.OptionalContext", scope) + "()") << ("_System.IProgress<bool> " + progress + " = null") << ("_System.Threading.CancellationToken " + cancel + " = new _System.Threading.CancellationToken()") << epar; @@ -4170,8 +4213,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { _out << "<" << returnTypeS << ">"; } - _out << " _iceI_" << opName << "Async" << spar << getInParams(op, true) - << "Ice.OptionalContext context" + _out << " _iceI_" << opName << "Async" << spar << getInParams(op, scope, true) + << getAbsolute("Ice.OptionalContext", scope) + " context" << "_System.IProgress<bool> progress" << "_System.Threading.CancellationToken cancel" << "bool synchronous" << epar; @@ -4205,7 +4248,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, true) + _out << "private void _iceI_" << op->name() << spar << getInParams(op, scope, true) << "_System.Collections.Generic.Dictionary<string, string> context" << "bool synchronous" << "IceInternal.OutgoingAsyncCompletionCallback completed" << epar; @@ -4230,9 +4273,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) if(!inParams.empty()) { _out << ","; - _out << nl << "write: (Ice.OutputStream ostr) =>"; + _out << nl << "write: (" << getAbsolute("Ice.OutputStream", scope) << " ostr) =>"; _out << sb; - writeMarshalUnmarshalParams(inParams, 0, true); + writeMarshalUnmarshalParams(inParams, 0, true, scope); if(op->sendsClasses(false)) { _out << nl << "ostr.writePendingValues();"; @@ -4243,7 +4286,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) if(!throws.empty()) { _out << ","; - _out << nl << "userException: (Ice.UserException ex) =>"; + _out << nl << "userException: (" << getAbsolute("Ice.UserException", scope) << " ex) =>"; _out << sb; _out << nl << "try"; _out << sb; @@ -4255,13 +4298,13 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i) { - _out << nl << "catch(" << fixId((*i)->scoped()) << ")"; + _out << nl << "catch(" << getAbsolute(fixId((*i)->scoped()), scope) << ")"; _out << sb; _out << nl << "throw;"; _out << eb; } - _out << nl << "catch(Ice.UserException)"; + _out << nl << "catch(" << getAbsolute("Ice.UserException", scope) << ")"; _out << sb; _out << eb; @@ -4271,7 +4314,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) if(ret || !outParams.empty()) { _out << ","; - _out << nl << "read: (Ice.InputStream istr) =>"; + _out << nl << "read: (" << getAbsolute("Ice.InputStream", scope) << " istr) =>"; _out << sb; if(outParams.empty()) { @@ -4290,7 +4333,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) } else if(isClassType(ret)) { - _out << " = Ice.Util.None"; + _out << " = " << getAbsolute("Ice.Util", scope) << ".None"; } _out << ";"; } @@ -4301,13 +4344,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) else { TypePtr t = outParams.front()->type(); - _out << nl << typeToString(t, (outParams.front()->optional())) << " iceP_" << outParams.front()->name(); + _out << nl << typeToString(t, scope, (outParams.front()->optional())) << " iceP_" + << outParams.front()->name(); if(!outParams.front()->optional()) { StructPtr st = StructPtr::dynamicCast(t); if(st && isValueType(st)) { - _out << " = " << "new " << typeToString(t) << "()"; + _out << " = " << "new " << typeToString(t, scope) << "()"; } else if(isClassType(t) || st) { @@ -4316,12 +4360,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) } else if(isClassType(t)) { - _out << " = Ice.Util.None"; + _out << " = " << getAbsolute("Ice.Util", scope) << ".None"; } _out << ";"; } - writeMarshalUnmarshalParams(outParams, op, false, true); + writeMarshalUnmarshalParams(outParams, op, false, scope, true); if(op->returnsClasses(false)) { _out << nl << "istr.readPendingValues();"; @@ -4353,47 +4397,49 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) OperationPtr op = *r; ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - string clScope = fixId(cl->scope()); - vector<string> paramsAMI = getInParams(op); + vector<string> paramsAMI = getInParams(op, scope); 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, op->returnIsOptional()); + string retS = typeToString(ret, scope, op->returnIsOptional()); - string returnTypeS = resultType(op); + string returnTypeS = resultType(op, scope); // // Write the begin_ methods. // - string delType = clScope + "Callback_" + cl->name() + "_" + op->name(); + string clScope = fixId(cl->scope()); + string delType = getAbsolute(clScope + "Callback_" + cl->name() + "_" + op->name(), scope); string context = getEscapedParamName(op, "context"); string callback = getEscapedParamName(op, "callback"); string cookie = getEscapedParamName(op, "cookie"); _out << sp; - _out << nl << "public Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI - << "Ice.OptionalContext " + context + " = new Ice.OptionalContext()" << epar; + _out << nl << "public " << getAbsolute("Ice.AsyncResult", scope) << "<" << delType << "> begin_" << opName + << spar << paramsAMI << (getAbsolute("Ice.OptionalContext", scope) + " " + context + " = new " + + getAbsolute("Ice.OptionalContext", scope) + "()") << epar; _out << sb; _out << nl << "return begin_" << opName << spar << argsAMI << context << "null" << "null" << "false" << epar << ';'; _out << eb; _out << sp; - _out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI - << "Ice.AsyncCallback " + callback << "object " + cookie << epar; + _out << nl << "public " << getAbsolute("Ice.AsyncResult", scope) << " begin_" << opName << spar << paramsAMI + << getAbsolute("Ice.AsyncCallback", scope) + " " + callback << "object " + cookie << epar; _out << sb; - _out << nl << "return begin_" << opName << spar << argsAMI << "new Ice.OptionalContext()" << callback - << cookie << "false" << epar << ';'; + _out << nl << "return begin_" << opName << spar << argsAMI + << "new " + getAbsolute("Ice.OptionalContext", scope) + "()" << callback << cookie << "false" << epar << ';'; _out << eb; _out << sp; - _out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI - << "Ice.OptionalContext " + context << "Ice.AsyncCallback " + callback - << "object " + cookie << epar; + _out << nl << "public " << getAbsolute("Ice.AsyncResult", scope) + " begin_" << opName << spar << paramsAMI + << getAbsolute("Ice.OptionalContext", scope) + " " + context + << getAbsolute("Ice.AsyncCallback", scope) + " " + callback + << "object " + cookie << epar; _out << sb; _out << nl << "return begin_" << opName << spar << argsAMI << context << callback << cookie << "false" << epar << ';'; @@ -4405,8 +4451,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, false, true) - << "Ice.AsyncResult " + asyncResult << epar; + _out << sp << nl << "public " << retS << " end_" << opName << spar << getOutParams(op, scope, false, true) + << getAbsolute("Ice.AsyncResult", scope) + " " + asyncResult << epar; _out << sb; _out << nl << "var resultI_ = IceInternal.AsyncResultI.check(" + asyncResult + ", this, " << flatName << ");"; @@ -4446,10 +4492,11 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // Write the common begin_ implementation. // _out << sp; - _out << nl << "private Ice.AsyncResult<" << delType << "> begin_" << opName << spar << getInParams(op, true) - << "_System.Collections.Generic.Dictionary<string, string> context" - << "Ice.AsyncCallback completedCallback" << "object cookie" << "bool synchronous" - << epar; + _out << nl << "private " << getAbsolute("Ice.AsyncResult", scope) << "<" << delType << "> begin_" << opName << spar + << getInParams(op, scope, true) + << "_System.Collections.Generic.Dictionary<string, string> context" + << getAbsolute("Ice.AsyncCallback", scope) + " completedCallback" << "object cookie" << "bool synchronous" + << epar; _out << sb; if(op->returnsData()) @@ -4494,14 +4541,15 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "this, " << flatName << ", cookie, completedCallback);"; _out.dec(); - _out << nl << "_iceI_" << op->name() << spar << getInArgs(op, true) << "context" << "synchronous" << "completed" << epar << ";"; + _out << nl << "_iceI_" << op->name() << spar << getInArgs(op, true) << "context" << "synchronous" << "completed" + << epar << ";"; _out << nl << "return completed;"; _out << eb; } _out << sp << nl << "#endregion"; // Asynchronous operations _out << sp << nl << "#region Checked and unchecked cast operations"; - _out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b)"; + _out << sp << nl << "public static " << name << "Prx checkedCast(" << getAbsolute("Ice.ObjectPrx", scope) << " b)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; @@ -4518,7 +4566,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << eb; _out << sp << nl << "public static " << name - << "Prx checkedCast(Ice.ObjectPrx b, _System.Collections.Generic.Dictionary<string, string> ctx)"; + << "Prx checkedCast(" << getAbsolute("Ice.ObjectPrx", scope) + << " b, _System.Collections.Generic.Dictionary<string, string> ctx)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; @@ -4534,13 +4583,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return r;"; _out << eb; - _out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b, string f)"; + _out << sp << nl << "public static " << name << "Prx checkedCast(" << getAbsolute("Ice.ObjectPrx", scope) + << " b, string f)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; _out << nl << "return null;"; _out << eb; - _out << nl << "Ice.ObjectPrx bb = b.ice_facet(f);"; + _out << nl << getAbsolute("Ice.ObjectPrx", scope) << " bb = b.ice_facet(f);"; _out << nl << "try"; _out << sb; _out << nl << "if(bb.ice_isA(ice_staticId()))"; @@ -4550,21 +4600,21 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return h;"; _out << eb; _out << eb; - _out << nl << "catch(Ice.FacetNotExistException)"; + _out << nl << "catch(" << getAbsolute("Ice.FacetNotExistException", scope) << ")"; _out << sb; _out << eb; _out << nl << "return null;"; _out << eb; _out << sp << nl << "public static " << name - << "Prx checkedCast(Ice.ObjectPrx b, string f, " + << "Prx checkedCast(" << getAbsolute("Ice.ObjectPrx", scope) << " b, string f, " << "_System.Collections.Generic.Dictionary<string, string> ctx)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; _out << nl << "return null;"; _out << eb; - _out << nl << "Ice.ObjectPrx bb = b.ice_facet(f);"; + _out << nl << getAbsolute("Ice.ObjectPrx", scope) << " bb = b.ice_facet(f);"; _out << nl << "try"; _out << sb; _out << nl << "if(bb.ice_isA(ice_staticId(), ctx))"; @@ -4574,13 +4624,13 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return h;"; _out << eb; _out << eb; - _out << nl << "catch(Ice.FacetNotExistException)"; + _out << nl << "catch(" << getAbsolute("Ice.FacetNotExistException", scope) << ")"; _out << sb; _out << eb; _out << nl << "return null;"; _out << eb; - _out << sp << nl << "public static " << name << "Prx uncheckedCast(Ice.ObjectPrx b)"; + _out << sp << nl << "public static " << name << "Prx uncheckedCast(" << getAbsolute("Ice.ObjectPrx", scope) << " b)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; @@ -4596,13 +4646,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return r;"; _out << eb; - _out << sp << nl << "public static " << name << "Prx uncheckedCast(Ice.ObjectPrx b, string f)"; + _out << sp << nl << "public static " << name << "Prx uncheckedCast(" << getAbsolute("Ice.ObjectPrx", scope) + << " b, string f)"; _out << sb; _out << nl << "if(b == null)"; _out << sb; _out << nl << "return null;"; _out << eb; - _out << nl << "Ice.ObjectPrx bb = b.ice_facet(f);"; + _out << nl << getAbsolute("Ice.ObjectPrx", scope) << " bb = b.ice_facet(f);"; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.iceCopyFrom(bb);"; _out << nl << "return h;"; @@ -4652,14 +4703,15 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp << nl << "#region Marshaling support"; - _out << sp << nl << "public static void write(Ice.OutputStream ostr, " << name << "Prx v)"; + _out << sp << nl << "public static void write(" << getAbsolute("Ice.OutputStream", scope) << " ostr, " << name + << "Prx v)"; _out << sb; _out << nl << "ostr.writeProxy(v);"; _out << eb; - _out << sp << nl << "public static " << name << "Prx read(Ice.InputStream istr)"; + _out << sp << nl << "public static " << name << "Prx read(" << getAbsolute("Ice.InputStream", scope) << " istr)"; _out << sb; - _out << nl << "Ice.ObjectPrx proxy = istr.readProxy();"; + _out << nl << getAbsolute("Ice.ObjectPrx", scope) << " proxy = istr.readProxy();"; _out << nl << "if(proxy != null)"; _out << sb; _out << nl << name << "PrxHelper result = new " << name << "PrxHelper();"; @@ -4691,22 +4743,23 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) return; } - string typeS = typeToString(p); - + string scope = fixId(p->scope()); + string typeS = typeToString(p, scope); _out << sp; emitGeneratedCodeAttribute(); _out << nl << "public sealed class " << p->name() << "Helper"; _out << sb; - _out << sp << nl << "public static void write(Ice.OutputStream ostr, " << typeS << " v)"; + _out << sp << nl << "public static void write(" << getAbsolute("Ice.OutputStream", scope) << " ostr, " << typeS + << " v)"; _out << sb; - writeSequenceMarshalUnmarshalCode(_out, p, "v", true, false); + writeSequenceMarshalUnmarshalCode(_out, p, scope, "v", true, false); _out << eb; - _out << sp << nl << "public static " << typeS << " read(Ice.InputStream istr)"; + _out << sp << nl << "public static " << typeS << " read(" << getAbsolute("Ice.InputStream", scope) << " istr)"; _out << sb; _out << nl << typeS << " v;"; - writeSequenceMarshalUnmarshalCode(_out, p, "v", false, false); + writeSequenceMarshalUnmarshalCode(_out, p, scope, "v", false, false); _out << nl << "return v;"; _out << eb; _out << eb; @@ -4771,8 +4824,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) genericType = meta.substr(prefix.size()); } - string keyS = typeToString(key); - string valueS = typeToString(value); + string scope = fixId(p->scope()); + string keyS = typeToString(key, scope); + string valueS = typeToString(value, scope); string name = "_System.Collections.Generic." + genericType + "<" + keyS + ", " + valueS + ">"; _out << sp; @@ -4782,7 +4836,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << sp << nl << "public static void write("; _out.useCurrentPosAsIndent(); - _out << "Ice.OutputStream ostr,"; + _out << getAbsolute("Ice.OutputStream", scope) << " ostr,"; _out << nl << name << " v)"; _out.restoreIndent(); _out << sb; @@ -4797,13 +4851,13 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) _out << "Generic.KeyValuePair<" << keyS << ", " << valueS << ">"; _out << " e in v)"; _out << sb; - writeMarshalUnmarshalCode(_out, key, "e.Key", true); - writeMarshalUnmarshalCode(_out, value, "e.Value", true); + writeMarshalUnmarshalCode(_out, key, scope, "e.Key", true); + writeMarshalUnmarshalCode(_out, value, scope, "e.Value", true); _out << eb; _out << eb; _out << eb; - _out << sp << nl << "public static " << name << " read(Ice.InputStream istr)"; + _out << sp << nl << "public static " << name << " read(" << getAbsolute("Ice.InputStream", scope) << " istr)"; _out << sb; _out << nl << "int sz = istr.readSize();"; _out << nl << name << " r = new " << name << "();"; @@ -4815,20 +4869,20 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) { if(isValueType(st)) { - _out << nl << "k = new " << typeToString(key) << "();"; + _out << nl << "k = new " << typeToString(key, scope) << "();"; } else { _out << nl << "k = null;"; } } - writeMarshalUnmarshalCode(_out, key, "k", false); + writeMarshalUnmarshalCode(_out, key, scope, "k", false); if(isClassType(value)) { ostringstream os; - os << '(' << typeToString(value) << " v) => { r[k] = v; }"; - writeMarshalUnmarshalCode(_out, value, os.str(), false); + os << '(' << typeToString(value, scope) << " v) => { r[k] = v; }"; + writeMarshalUnmarshalCode(_out, value, scope, os.str(), false); } else { @@ -4838,14 +4892,14 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) { if(isValueType(st)) { - _out << nl << "v = new " << typeToString(value) << "();"; + _out << nl << "v = new " << typeToString(value, scope) << "();"; } else { _out << nl << "v = null;"; } } - writeMarshalUnmarshalCode(_out, value, "v", false); + writeMarshalUnmarshalCode(_out, value, scope, "v", false); _out << nl << "r[k] = v;"; } _out << eb; @@ -4890,14 +4944,14 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); bool hasBaseClass = !bases.empty() && !bases.front()->isInterface(); - string baseClass = "Ice.ObjectImpl"; + string name = p->name(); + string scope = fixId(p->scope()); + string baseClass = getAbsolute("Ice.ObjectImpl", scope); if(hasBaseClass && !bases.front()->allOperations().empty()) { baseClass = fixId(bases.front()->scoped() + "Disp_"); } - string name = p->name(); - _out << sp; emitComVisibleAttribute(); emitGeneratedCodeAttribute(); @@ -4922,7 +4976,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) for(ClassList::const_iterator i = allBases.begin(); i != allBases.end(); ++i) { - _out << ", " << fixId((*i)->scoped()); + _out << ", " << getAbsolute(fixId((*i)->scoped()), scope); } } @@ -4938,7 +4992,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) { string retS; vector<string> params, args; - string name = getDispatchParams(*i, retS, params, args); + string name = getDispatchParams(*i, retS, params, args, scope); _out << sp << nl << "public abstract " << retS << " " << name << spar << params << epar << ';'; } @@ -4962,7 +5016,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp; emitComVisibleAttribute(); emitGeneratedCodeAttribute(); - _out << nl << "public class " << name << "Tie_ : " << name << "Disp_, Ice.TieBase"; + _out << nl << "public class " << name << "Tie_ : " << name << "Disp_, " << getAbsolute("Ice.TieBase", scope); _out << sb; @@ -5023,13 +5077,14 @@ Slice::Gen::DispatcherVisitor::visitClassDefEnd(const ClassDefPtr&) void Slice::Gen::DispatcherVisitor::writeTieOperations(const ClassDefPtr& p, NameSet* opNames) { + string scope = fixId(p->scope()); 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); + string opName = getDispatchParams(*r, retS, params, args, scope); if(opNames) { if(opNames->find(opName) != opNames->end()) @@ -5078,6 +5133,7 @@ void Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment, bool forTie) { ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); + string scope = fixId(cl->scope()); string opName = op->name(); TypePtr ret = op->returnType(); ParamDeclList params = op->parameters(); @@ -5107,8 +5163,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); - string resultType = CsGenerator::resultType(op, true); + vector<string> pDecl = getInParams(op, scope); + string resultType = CsGenerator::resultType(op, scope, true); _out << "public "; if(!forTie) @@ -5121,7 +5177,8 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { _out << "<" << resultType << ">"; } - _out << " " << opName << "Async" << spar << pDecl << "Ice.Current current = null" << epar; + _out << " " << opName << "Async" << spar << pDecl << getAbsolute("Ice.Current", scope) + " current = null" + << epar; if(comment) { @@ -5132,7 +5189,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment _out << sb; if(ret) { - _out << nl << typeToString(ret) << " ret = " << writeValue(ret) << ';'; + _out << nl << typeToString(ret, scope) << " ret = " << writeValue(ret, scope) << ';'; } for(ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i) { @@ -5140,7 +5197,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { string name = fixId((*i)->name()); TypePtr type = (*i)->type(); - _out << nl << typeToString(type) << ' ' << name << " = " << writeValue(type) << ';'; + _out << nl << typeToString(type, scope) << ' ' << name << " = " << writeValue(type, scope) << ';'; } } _out << nl << "return _System.Threading.Tasks.Task.FromResult"; @@ -5151,7 +5208,8 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment else { - bool returnStruct = (op->returnType() && !outParams.empty()) || outParams.size() > 1 || op->hasMarshaledResult(); + bool returnStruct = (op->returnType() && !outParams.empty()) || outParams.size() > 1 || + op->hasMarshaledResult(); if(returnStruct) { @@ -5188,10 +5246,10 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment else { string retS = op->hasMarshaledResult() ? - fixId(cl->scope() + resultStructName(cl->name(), op->name(), true)) : - typeToString(ret); + fixId(cl->scope() + resultStructName(cl->name(), op->name(), true)) : + typeToString(ret, scope); - vector<string> pDecls = op->hasMarshaledResult() ? getInParams(op) : getParams(op); + vector<string> pDecls = op->hasMarshaledResult() ? getInParams(op, scope) : getParams(op, scope); _out << "public "; if(!forTie && !cl->isLocal()) @@ -5201,7 +5259,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment _out << retS << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls; if(!cl->isLocal()) { - _out << "Ice.Current current = null"; + _out << getAbsolute("Ice.Current", scope) + " current = null"; } _out << epar; if(comment) @@ -5216,7 +5274,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment << "("; if(ret) { - _out << writeValue(ret); + _out << writeValue(ret, scope); } for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i) { @@ -5224,7 +5282,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { _out << ", "; } - _out << writeValue((*i)->type()); + _out << writeValue((*i)->type(), scope); } _out << ", current);"; } @@ -5234,12 +5292,12 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment { string name = fixId((*i)->name()); TypePtr type = (*i)->type(); - _out << nl << name << " = " << writeValue(type) << ';'; + _out << nl << name << " = " << writeValue(type, scope) << ';'; } if(ret) { - _out << nl << "return " << writeValue(ret) << ';'; + _out << nl << "return " << writeValue(ret, scope) << ';'; } } _out << eb; |