diff options
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Slice/CsUtil.cpp | 24 | ||||
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 14 |
2 files changed, 31 insertions, 7 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index ae9ed24bc11..c5ef9a41d29 100755 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -26,6 +26,16 @@ using namespace std; using namespace Slice; using namespace IceUtil; +// +// TODO: Temporary work-around for Mono compiler bug: "global::" does not work for generic classes. +// + +static string +global() +{ + return "\n#if !__MonoCS__ \nglobal::\n#endif\n"; +} + static string lookupKwd(const string& name, int baseTypes, bool mangleCasts = false) { @@ -198,7 +208,7 @@ Slice::CsGenerator::typeToString(const TypePtr& type) } else { - return "global::" + type + "<" + typeToString(seq->type()) + ">"; + return global() + type + "<" + typeToString(seq->type()) + ">"; } } @@ -763,7 +773,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isCustom) { - out << "global::" << genericType << "<Ice.Object>();"; + out << global() << genericType << "<Ice.Object>();"; } else if(isGeneric) { @@ -878,7 +888,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else if(isCustom) { out << sb; - out << nl << param << " = new " << "global::" << genericType << "<" + out << nl << param << " = new " << global() << genericType << "<" << typeToString(type) << ">();"; out << nl << "int szx__ = " << stream << ".readSize();"; out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)"; @@ -959,7 +969,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isCustom) { - out << "global::" << genericType << "<" << typeS << ">()"; + out << global() << genericType << "<" << typeS << ">()"; } else if(isGeneric) { @@ -1097,7 +1107,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isCustom) { - out << "global::" << genericType << "<" << typeS << ">();"; + out << global() << genericType << "<" << typeS << ">();"; } else if(isGeneric) { @@ -1234,7 +1244,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isCustom) { - out << "global::" << genericType << "<" << typeS << ">();"; + out << global() << genericType << "<" << typeS << ">();"; } else if(isGeneric) { @@ -1349,7 +1359,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isCustom) { - out << "global::" << genericType << "<" << typeS << ">();"; + out << global() << genericType << "<" << typeS << ">();"; } else if(isGeneric) { diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 7e21ca58aac..107e5af57dc 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -1073,8 +1073,22 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in _out << nl << "// Generated from file `" << fileBase << ".ice'"; + // + // TODO: Remove the work-around for Mono once global:: works correctly with generics. + // + _out.zeroIndent(); + _out << sp << nl << "#if __MonoCS__"; + _out.restoreIndent(); + _out << sp << nl << "using _System = System;"; + _out << nl << "using _Microsoft = Microsoft;"; + _out.zeroIndent(); + _out << nl << "#else"; + _out.restoreIndent(); _out << sp << nl << "using _System = global::System;"; _out << nl << "using _Microsoft = global::Microsoft;"; + _out.zeroIndent(); + _out << nl << "#endif"; + _out.restoreIndent(); if(impl || implTie) { |