diff options
author | Jose <jose@zeroc.com> | 2018-07-13 13:25:05 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-07-13 13:25:05 +0200 |
commit | c253fee0571dc880725ca03f388b3a89a6b60c34 (patch) | |
tree | d91de68e097b40a43b9ffbc5f0a85f6fc763af6e | |
parent | Add support to build with PHP 7.2 on Windows (diff) | |
download | ice-c253fee0571dc880725ca03f388b3a89a6b60c34.tar.bz2 ice-c253fee0571dc880725ca03f388b3a89a6b60c34.tar.xz ice-c253fee0571dc880725ca03f388b3a89a6b60c34.zip |
Fixes for cs:namespace metadata directive
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 54 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 21 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.h | 2 |
3 files changed, 44 insertions, 33 deletions
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index bdf939515e8..27e0c974d31 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -195,15 +195,15 @@ string Slice::CsGenerator::getUnqualified(const ContainedPtr& p, const string& package, const string& prefix, const string& suffix) { - string name = fixId(p->name()); + string name = fixId(prefix + p->name() + suffix); string contPkg = getPackage(p); if(contPkg == package || contPkg.empty()) { - return prefix + name + suffix; + return name; } else { - return "global::" + contPkg + "." + prefix + name + suffix; + return "global::" + contPkg + "." + name; } } @@ -383,11 +383,11 @@ Slice::CsGenerator::getStaticId(const TypePtr& type) { ContainedPtr cont = ContainedPtr::dynamicCast(cl->container()); assert(cont); - return fixId(cont->scoped(), DotNet::ICloneable) + "." + cl->name() + "Disp_.ice_staticId()"; + return getUnqualified(cont) + "." + cl->name() + "Disp_.ice_staticId()"; } else { - return fixId(cl->scoped(), DotNet::ICloneable) + ".ice_staticId()"; + return getUnqualified(cl) + ".ice_staticId()"; } } @@ -525,7 +525,7 @@ Slice::CsGenerator::typeToString(const TypePtr& type, const string& package, boo ContainedPtr contained = ContainedPtr::dynamicCast(type); if(contained) { - return getUnqualified(fixId(contained->scoped()), package); + return getUnqualified(contained, package); } return "???"; @@ -544,12 +544,12 @@ Slice::CsGenerator::resultStructName(const string& className, const string& opNa } string -Slice::CsGenerator::resultType(const OperationPtr& op, const string& scope, bool dispatch) +Slice::CsGenerator::resultType(const OperationPtr& op, const string& package, bool dispatch) { ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); // Get the class containing the op. if(dispatch && op->hasMarshaledResult()) { - return getUnqualified(fixId(cl->scope() + resultStructName(cl->name(), op->name(), true)), scope); + return getUnqualified(cl, package, "", resultStructName("", op->name(), true)); } string t; @@ -558,16 +558,16 @@ Slice::CsGenerator::resultType(const OperationPtr& op, const string& scope, bool { if(outParams.empty()) { - t = typeToString(op->returnType(), scope, op->returnIsOptional(), cl->isLocal()); + t = typeToString(op->returnType(), package, op->returnIsOptional(), cl->isLocal()); } else if(op->returnType() || outParams.size() > 1) { ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - t = getUnqualified(fixId(cl->scope()) + resultStructName(cl->name(), op->name()), scope); + t = getUnqualified(cl, package, "", resultStructName("", op->name())); } else { - t = typeToString(outParams.front()->type(), scope, outParams.front()->optional(), cl->isLocal()); + t = typeToString(outParams.front()->type(), package, outParams.front()->optional(), cl->isLocal()); } } @@ -650,7 +650,7 @@ Slice::CsGenerator::isValueType(const TypePtr& type) void Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, const TypePtr& type, - const string& scope, + const string& package, const string& param, bool marshal, const string& customStream) @@ -777,7 +777,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } case Builtin::KindObjectProxy: { - string typeS = typeToString(type, scope); + string typeS = typeToString(type, package); if(marshal) { out << nl << stream << ".writeProxy(" << param << ");"; @@ -803,8 +803,8 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, ClassDefPtr def = prx->_class()->definition(); if(def->isInterface() || def->allOperations().size() > 0) { - string typeS = typeToString(type, scope); - if (marshal) + string typeS = typeToString(type, package); + if(marshal) { out << nl << typeS << "Helper.write(" << stream << ", " << param << ");"; } @@ -848,7 +848,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, { if(!isValueType(st)) { - out << nl << typeToString(st, scope) << ".ice_write(" << stream << ", " << param << ");"; + out << nl << typeToString(st, package) << ".ice_write(" << stream << ", " << param << ");"; } else { @@ -859,7 +859,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, { if(!isValueType(st)) { - out << nl << param << " = " << typeToString(type, scope) << ".ice_read(" << stream << ");"; + out << nl << param << " = " << typeToString(type, package) << ".ice_read(" << stream << ");"; } else { @@ -878,7 +878,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } else { - out << nl << param << " = (" << typeToString(type, scope) << ')' << stream << ".readEnum(" << en->maxValue() + out << nl << param << " = (" << typeToString(type, package) << ')' << stream << ".readEnum(" << en->maxValue() << ");"; } return; @@ -887,22 +887,22 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - writeSequenceMarshalUnmarshalCode(out, seq, scope, param, marshal, true, stream); + writeSequenceMarshalUnmarshalCode(out, seq, package, param, marshal, true, stream); return; } assert(ConstructedPtr::dynamicCast(type)); - string typeS; + string helperName; DictionaryPtr d = DictionaryPtr::dynamicCast(type); if(d) { - typeS = fixId(d->scope()) + d->name(); + helperName = getUnqualified(d, package, "", "Helper"); } else { - typeS = typeToString(type, scope); + helperName = typeToString(type, package) + "Helper"; } - string helperName = getUnqualified(typeS + "Helper", scope); + if(marshal) { out << nl << helperName << ".write(" << stream << ", " << param << ");"; @@ -1303,7 +1303,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, assert(cont); if(useHelper) { - string helperName = getUnqualified(fixId(cont->scoped(), DotNet::ICloneable) + "." + seq->name() + "Helper", scope); + string helperName = getUnqualified(getPackage(seq) + "." + seq->name() + "Helper", scope); if(marshal) { out << nl << helperName << ".write(" << stream << ", " << param << ");"; @@ -1445,7 +1445,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { patcherName = "global::IceInternal.Patcher.listReadValue"; - out << "global::System.Collections.Generic." << genericType << "<Ice.Value>(" << param << "_lenx);"; + out << "global::System.Collections.Generic." << genericType << "<global::Ice.Value>(" << param << "_lenx);"; } out << nl << "for(int ix = 0; ix < " << param << "_lenx; ++ix)"; out << sb; @@ -1869,11 +1869,11 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, string helperName; if(ProxyPtr::dynamicCast(type)) { - helperName = getUnqualified(fixId(ProxyPtr::dynamicCast(type)->_class()->scoped() + "PrxHelper"), scope); + helperName = getUnqualified(ProxyPtr::dynamicCast(type)->_class(), scope, "", "PrxHelper"); } else { - helperName = getUnqualified(fixId(ContainedPtr::dynamicCast(type)->scoped() + "Helper"), scope); + helperName = getUnqualified(ContainedPtr::dynamicCast(type), scope, "", "Helper"); } string func; diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index e3fdca9b129..2c00b5fe5f8 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -736,7 +736,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p) } else { - _out << nl << "return " << getUnqualified(fixId(cl->scoped() + "Disp_"), package) + _out << nl << "return " << getUnqualified(cl, package, "", "Disp_") << ".iceD_" << opName << "(this, inS, current);"; } break; @@ -2196,6 +2196,17 @@ Slice::Gen::CompactIdVisitor::visitUnitEnd(const UnitPtr&) } bool +Slice::Gen::CompactIdVisitor::visitModuleStart(const ModulePtr& p) +{ + return true; +} + +void +Slice::Gen::CompactIdVisitor::visitModuleEnd(const ModulePtr& p) +{ +} + +bool Slice::Gen::CompactIdVisitor::visitClassDefStart(const ClassDefPtr& p) { if(p->compactId() >= 0) @@ -3756,7 +3767,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr def = *q; if(def->isInterface() || def->allOperations().size() > 0) { - baseInterfaces.push_back(getUnqualified(fixId((*q)->scoped() + "Prx"), package)); + baseInterfaces.push_back(getUnqualified(*q, package, "", "Prx")); } } @@ -4026,9 +4037,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) { first = false; } - string s = (*q)->scoped(); - s += "Operations"; - _out << getUnqualified(fixId(s), package) << '_'; + _out << getUnqualified(*q, package, "", "Operations_"); } ++q; } @@ -5037,7 +5046,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) string baseClass = getUnqualified("Ice.ObjectImpl", package); if(hasBaseClass && !bases.front()->allOperations().empty()) { - baseClass = fixId(bases.front()->scoped() + "Disp_"); + baseClass = getUnqualified(bases.front(), package, "", "Disp_"); } _out << sp; diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index 743a2f512f7..02f70c20549 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -124,6 +124,8 @@ private: virtual bool visitUnitStart(const UnitPtr&); virtual void visitUnitEnd(const UnitPtr&); + virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); }; |