diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-11-10 14:07:23 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-11-10 14:07:23 -0500 |
commit | 4e06be13bf710ec95f5d207c59b90a0584b857b4 (patch) | |
tree | 5bff3948e1c2db2809ac03ef8f4aa8ba14d03c3f /cpp/src/slice2cs/CsUtil.cpp | |
parent | Visual Studio settings for C++/C# languages (diff) | |
download | ice-4e06be13bf710ec95f5d207c59b90a0584b857b4.tar.bz2 ice-4e06be13bf710ec95f5d207c59b90a0584b857b4.tar.xz ice-4e06be13bf710ec95f5d207c59b90a0584b857b4.zip |
Replaced all double-underscores in C#
Diffstat (limited to 'cpp/src/slice2cs/CsUtil.cpp')
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 358 |
1 files changed, 191 insertions, 167 deletions
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index 3487cde3fce..a9ac2f94042 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -145,7 +145,7 @@ Slice::CsGenerator::fixId(const ContainedPtr& cont, int baseTypes, bool mangleCa if(contained && contained->hasMetaData("clr:property") && (contained->containedType() == Contained::ContainedTypeClass || contained->containedType() == Contained::ContainedTypeStruct)) { - return cont->name() + "__prop"; + return "_" + cont->name(); } else { @@ -507,9 +507,14 @@ void Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, const TypePtr& type, const string& param, - bool marshal) + bool marshal, + const string& customStream) { - string stream = marshal ? "os__" : "is__"; + string stream = customStream; + if(stream.empty()) + { + stream = marshal ? "ostr" : "istr"; + } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) @@ -687,7 +692,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } else { - out << nl << param << ".write__(" << stream << ");"; + out << nl << param << ".iceWrite(" << stream << ");"; } } else @@ -698,7 +703,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, } else { - out << nl << param << ".read__(" << stream << ");"; + out << nl << param << ".iceRead(" << stream << ");"; } } return; @@ -722,7 +727,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - writeSequenceMarshalUnmarshalCode(out, seq, param, marshal, true); + writeSequenceMarshalUnmarshalCode(out, seq, param, marshal, true, stream); return; } @@ -752,9 +757,14 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, const TypePtr& type, const string& param, int tag, - bool marshal) + bool marshal, + const string& customStream) { - string stream = marshal ? "os__" : "is__"; + string stream = customStream; + if(stream.empty()) + { + stream = marshal ? "ostr" : "istr"; + } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) @@ -901,9 +911,9 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << nl << "if(" << param << ".HasValue && " << stream << ".writeOptional(" << tag << ", Ice.OptionalFormat.FSize))"; out << sb; - out << nl << "int pos__ = " << stream << ".startSize();"; - writeMarshalUnmarshalCode(out, type, param + ".Value", marshal); - out << nl << stream << ".endSize(pos__);"; + out << nl << "int pos = " << stream << ".startSize();"; + writeMarshalUnmarshalCode(out, type, param + ".Value", marshal, customStream); + out << nl << stream << ".endSize(pos);"; out << eb; } else @@ -911,10 +921,10 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << nl << "if(" << stream << ".readOptional(" << tag << ", Ice.OptionalFormat.FSize))"; out << sb; out << nl << stream << ".skip(4);"; - string tmp = "tmpVal__"; + string tmp = "tmpVal"; string typeS = typeToString(type); out << nl << typeS << ' ' << tmp << ';'; - writeMarshalUnmarshalCode(out, type, tmp, marshal); + writeMarshalUnmarshalCode(out, type, tmp, marshal, customStream); out << nl << param << " = new Ice.Optional<" << typeS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -949,16 +959,16 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << sb; if(st->isVariableLength()) { - out << nl << "int pos__ = " << stream << ".startSize();"; + out << nl << "int pos = " << stream << ".startSize();"; } else { out << nl << stream << ".writeSize(" << st->minWireSize() << ");"; } - writeMarshalUnmarshalCode(out, type, param + ".Value", marshal); + writeMarshalUnmarshalCode(out, type, param + ".Value", marshal, customStream); if(st->isVariableLength()) { - out << nl << stream << ".endSize(pos__);"; + out << nl << stream << ".endSize(pos);"; } out << eb; } @@ -975,7 +985,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << nl << stream << ".skipSize();"; } string typeS = typeToString(type); - string tmp = "tmpVal__"; + string tmp = "tmpVal"; if(isValueType(st)) { out << nl << typeS << ' ' << tmp << " = new " << typeS << "();"; @@ -984,7 +994,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, { out << nl << typeS << ' ' << tmp << " = null;"; } - writeMarshalUnmarshalCode(out, type, tmp, marshal); + writeMarshalUnmarshalCode(out, type, tmp, marshal, customStream); out << nl << param << " = new Ice.Optional<" << typeS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -1011,9 +1021,9 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << nl << "if(" << stream << ".readOptional(" << tag << ", Ice.OptionalFormat.Size))"; out << sb; string typeS = typeToString(type); - string tmp = "tmpVal__"; + string tmp = "tmpVal"; out << nl << typeS << ' ' << tmp << ';'; - writeMarshalUnmarshalCode(out, type, tmp, marshal); + writeMarshalUnmarshalCode(out, type, tmp, marshal, customStream); out << nl << param << " = new Ice.Optional<" << typeS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -1027,7 +1037,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - writeOptionalSequenceMarshalUnmarshalCode(out, seq, param, tag, marshal); + writeOptionalSequenceMarshalUnmarshalCode(out, seq, param, tag, marshal, stream); return; } @@ -1042,7 +1052,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << sb; if(keyType->isVariableLength() || valueType->isVariableLength()) { - out << nl << "int pos__ = " << stream << ".startSize();"; + out << nl << "int pos = " << stream << ".startSize();"; } else { @@ -1050,10 +1060,10 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, << (keyType->minWireSize() + valueType->minWireSize()) << " + (" << param << ".Value.Count > 254 ? 5 : 1));"; } - writeMarshalUnmarshalCode(out, type, param + ".Value", marshal); + writeMarshalUnmarshalCode(out, type, param + ".Value", marshal, customStream); if(keyType->isVariableLength() || valueType->isVariableLength()) { - out << nl << stream << ".endSize(pos__);"; + out << nl << stream << ".endSize(pos);"; } out << eb; } @@ -1070,9 +1080,9 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out, out << nl << stream << ".skipSize();"; } string typeS = typeToString(type); - string tmp = "tmpVal__"; + string tmp = "tmpVal"; out << nl << typeS << ' ' << tmp << " = new " << typeS << "();"; - writeMarshalUnmarshalCode(out, type, tmp, marshal); + writeMarshalUnmarshalCode(out, type, tmp, marshal, customStream); out << nl << param << " = new Ice.Optional<" << typeS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -1087,9 +1097,14 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, const SequencePtr& seq, const string& param, bool marshal, - bool useHelper) + bool useHelper, + const string& customStream) { - string stream = marshal ? "os__" : "is__"; + string stream = customStream; + if(stream.empty()) + { + stream = marshal ? "ostr" : "istr"; + } if(useHelper) { @@ -1175,30 +1190,30 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, // cannot contain Ice.Object. // out << nl << "Ice.ObjectPrx[] " << param << "_tmp = " << param << ".ToArray();"; - out << nl << "for(int ix__ = 0; ix__ < " << param << "_tmp.Length; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << "_tmp.Length; ++ix)"; out << sb; - out << nl << stream << ".writeProxy(" << param << "_tmp[ix__]);"; + out << nl << stream << ".writeProxy(" << param << "_tmp[ix]);"; out << eb; } else { out << nl << "_System.Collections.Generic.IEnumerator<" << typeS - << "> e__ = " << param << ".GetEnumerator();"; - out << nl << "while(e__.MoveNext())"; + << "> e = " << param << ".GetEnumerator();"; + out << nl << "while(e.MoveNext())"; out << sb; string func = (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue) ? "writeValue" : "writeProxy"; - out << nl << stream << '.' << func << "(e__.Current);"; + out << nl << stream << '.' << func << "(e.Current);"; out << eb; } } else { - out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << '.' << limitID << "; ++ix)"; out << sb; string func = (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue) ? "writeValue" : "writeProxy"; - out << nl << stream << '.' << func << '(' << param << "[ix__]);"; + out << nl << stream << '.' << func << '(' << param << "[ix]);"; out << eb; } out << eb; @@ -1231,7 +1246,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { out << typeToString(seq) << "(" << param << "_lenx);"; } - out << nl << "for(int ix__ = 0; ix__ < " << param << "_lenx; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << "_lenx; ++ix)"; out << sb; string patcherName; if(isCustom) @@ -1250,9 +1265,9 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { patcherName = "Sequence"; } - out << nl << "IceInternal." << patcherName << "Patcher<Ice.Value> p__ = new IceInternal." - << patcherName << "Patcher<Ice.Value>(\"::Ice::Object\", " << param << ", ix__);"; - out << nl << stream << ".readValue(p__.patch);"; + out << nl << "IceInternal." << patcherName << "Patcher<Ice.Value> p = new IceInternal." + << patcherName << "Patcher<Ice.Value>(\"::Ice::Object\", " << param << ", ix);"; + out << nl << stream << ".readValue(p.patch);"; } else { @@ -1273,17 +1288,17 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { out << typeToString(seq) << "(" << param << "_lenx);"; } - out << nl << "for(int ix__ = 0; ix__ < " << param << "_lenx; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << "_lenx; ++ix)"; out << sb; if(isArray) { - out << nl << param << "[ix__] = " << stream << ".readProxy();"; + out << nl << param << "[ix] = " << stream << ".readProxy();"; } else { - out << nl << "Ice.ObjectPrx val__ = new Ice.ObjectPrxHelperBase();"; - out << nl << "val__ = " << stream << ".readProxy();"; - out << nl << param << "." << addMethod << "(val__);"; + out << nl << "Ice.ObjectPrx val = new Ice.ObjectPrxHelperBase();"; + out << nl << "val = " << stream << ".readProxy();"; + out << nl << param << "." << addMethod << "(val);"; } } out << eb; @@ -1338,8 +1353,8 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << sb; out << nl << param << " = new " << "global::" << genericType << "<" << typeToString(type) << ">();"; - out << nl << "int szx__ = " << stream << ".readSize();"; - out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)"; + out << nl << "int szx = " << stream << ".readSize();"; + out << nl << "for(int ix = 0; ix < szx; ++ix)"; out << sb; out << nl << param << ".Add(" << stream << ".read" << func << "());"; out << eb; @@ -1376,17 +1391,17 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, // stack bottom-up here. // out << nl << "_System.Collections.Generic.IEnumerator<" << typeS - << "> e__ = " << param << ".GetEnumerator();"; - out << nl << "while(e__.MoveNext())"; + << "> e = " << param << ".GetEnumerator();"; + out << nl << "while(e.MoveNext())"; out << sb; - out << nl << stream << ".writeValue(e__.Current);"; + out << nl << stream << ".writeValue(e.Current);"; out << eb; } else { - out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << '.' << limitID << "; ++ix)"; out << sb; - out << nl << stream << ".writeValue(" << param << "[ix__]);"; + out << nl << stream << ".writeValue(" << param << "[ix]);"; out << eb; } out << eb; @@ -1394,12 +1409,12 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { out << sb; - out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize(" + out << nl << "int szx = " << stream << ".readAndCheckSeqSize(" << static_cast<unsigned>(type->minWireSize()) << ");"; out << nl << param << " = new "; if(isArray) { - out << toArrayAlloc(typeS + "[]", "szx__"); + out << toArrayAlloc(typeS + "[]", "szx"); } else if(isCustom) { @@ -1410,16 +1425,16 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << "_System.Collections.Generic." << genericType << "<" << typeS << ">("; if(!isLinkedList) { - out << "szx__"; + out << "szx"; } out << ")"; } else { - out << fixId(seq->scoped()) << "(szx__)"; + out << fixId(seq->scoped()) << "(szx)"; } out << ';'; - out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)"; + out << nl << "for(int ix = 0; ix < szx; ++ix)"; out << sb; string patcherName; @@ -1441,7 +1456,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } string scoped = ContainedPtr::dynamicCast(type)->scoped(); out << nl << "IceInternal." << patcherName << "Patcher<" << typeS << "> spx = new IceInternal." - << patcherName << "Patcher<" << typeS << ">(\"" << scoped << "\", " << param << ", ix__);"; + << patcherName << "Patcher<" << typeS << ">(\"" << scoped << "\", " << param << ", ix);"; out << nl << stream << ".readValue(spx.patch);"; out << eb; out << eb; @@ -1469,18 +1484,18 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, if(isStack) { out << nl << typeS << "[] " << param << "_tmp = " << param << ".ToArray();"; - out << nl << "for(int ix__ = 0; ix__ < " << param << "_tmp.Length; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << "_tmp.Length; ++ix)"; } else { out << nl << "_System.Collections.Generic.IEnumerator<" << typeS - << "> e__ = " << param << ".GetEnumerator();"; - out << nl << "while(e__.MoveNext())"; + << "> e = " << param << ".GetEnumerator();"; + out << nl << "while(e.MoveNext())"; } } else { - out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << '.' << limitID << "; ++ix)"; } out << sb; string call; @@ -1488,12 +1503,12 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { if(isValueType(type)) { - call = "e__.Current"; + call = "e.Current"; } else { - call = "(e__.Current == null ? new "; - call += typeS + "() : e__.Current)"; + call = "(e.Current == null ? new "; + call += typeS + "() : e.Current)"; } } else @@ -1514,20 +1529,20 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { call += "_tmp"; } - call += "[ix__] == null ? new " + typeS + "() : " + param; + call += "[ix] == null ? new " + typeS + "() : " + param; if(isStack) { call += "_tmp"; } } - call += "[ix__]"; + call += "[ix]"; if(!isValueType(type)) { call += ")"; } } call += "."; - call += "write__"; + call += "iceWrite"; call += "(" + stream + ");"; out << nl << call; out << eb; @@ -1536,11 +1551,11 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { out << sb; - out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize(" + out << nl << "int szx = " << stream << ".readAndCheckSeqSize(" << static_cast<unsigned>(type->minWireSize()) << ");"; if(isArray) { - out << nl << param << " = new " << toArrayAlloc(typeS + "[]", "szx__") << ";"; + out << nl << param << " = new " << toArrayAlloc(typeS + "[]", "szx") << ";"; } else if(isCustom) { @@ -1548,44 +1563,44 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isStack) { - out << nl << typeS << "[] " << param << "__tmp = new " << toArrayAlloc(typeS + "[]", "szx__") << ";"; + out << nl << typeS << "[] " << param << "_tmp = new " << toArrayAlloc(typeS + "[]", "szx") << ";"; } else if(isGeneric) { out << nl << param << " = new _System.Collections.Generic." << genericType << "<" << typeS << ">("; if(!isLinkedList) { - out << "szx__"; + out << "szx"; } out << ");"; } else { - out << nl << param << " = new " << fixId(seq->scoped()) << "(szx__);"; + out << nl << param << " = new " << fixId(seq->scoped()) << "(szx);"; } - out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)"; + out << nl << "for(int ix = 0; ix < szx; ++ix)"; out << sb; if(isArray || isStack) { - string v = isArray ? param : param + "__tmp"; + string v = isArray ? param : param + "_tmp"; if(!isValueType(st)) { - out << nl << v << "[ix__] = new " << typeS << "();"; + out << nl << v << "[ix] = new " << typeS << "();"; } - out << nl << v << "[ix__].read__(" << stream << ");"; + out << nl << v << "[ix].iceRead(" << stream << ");"; } else { - out << nl << typeS << " val__ = new " << typeS << "();"; - out << nl << "val__.read__(" << stream << ");"; - out << nl << param << "." << addMethod << "(val__);"; + out << nl << typeS << " val = new " << typeS << "();"; + out << nl << "val.iceRead(" << stream << ");"; + out << nl << param << "." << addMethod << "(val);"; } out << eb; if(isStack) { - out << nl << "_System.Array.Reverse(" << param << "__tmp);"; + out << nl << "_System.Array.Reverse(" << param << "_tmp);"; out << nl << param << " = new _System.Collections.Generic." << genericType << "<" << typeS << ">(" - << param << "__tmp);"; + << param << "_tmp);"; } out << eb; } @@ -1612,26 +1627,26 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, if(isStack) { out << nl << typeS << "[] " << param << "_tmp = " << param << ".ToArray();"; - out << nl << "for(int ix__ = 0; ix__ < " << param << "_tmp.Length; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << "_tmp.Length; ++ix)"; out << sb; - out << nl << stream << ".writeEnum((int)" << param << "_tmp[ix__], " << en->maxValue() << ");"; + out << nl << stream << ".writeEnum((int)" << param << "_tmp[ix], " << en->maxValue() << ");"; out << eb; } else { out << nl << "_System.Collections.Generic.IEnumerator<" << typeS - << "> e__ = " << param << ".GetEnumerator();"; - out << nl << "while(e__.MoveNext())"; + << "> e = " << param << ".GetEnumerator();"; + out << nl << "while(e.MoveNext())"; out << sb; - out << nl << stream << ".writeEnum((int)e__.Current, " << en->maxValue() << ");"; + out << nl << stream << ".writeEnum((int)e.Current, " << en->maxValue() << ");"; out << eb; } } else { - out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << '.' << limitID << "; ++ix)"; out << sb; - out << nl << stream << ".writeEnum((int)" << param << "[ix__], " << en->maxValue() << ");"; + out << nl << stream << ".writeEnum((int)" << param << "[ix], " << en->maxValue() << ");"; out << eb; } out << eb; @@ -1639,11 +1654,11 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { out << sb; - out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize(" << + out << nl << "int szx = " << stream << ".readAndCheckSeqSize(" << static_cast<unsigned>(type->minWireSize()) << ");"; if(isArray) { - out << nl << param << " = new " << toArrayAlloc(typeS + "[]", "szx__") << ";"; + out << nl << param << " = new " << toArrayAlloc(typeS + "[]", "szx") << ";"; } else if(isCustom) { @@ -1651,27 +1666,27 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isStack) { - out << nl << typeS << "[] " << param << "__tmp = new " << toArrayAlloc(typeS + "[]", "szx__") << ";"; + out << nl << typeS << "[] " << param << "_tmp = new " << toArrayAlloc(typeS + "[]", "szx") << ";"; } else if(isGeneric) { out << nl << param << " = new _System.Collections.Generic." << genericType << "<" << typeS << ">("; if(!isLinkedList) { - out << "szx__"; + out << "szx"; } out << ");"; } else { - out << nl << param << " = new " << fixId(seq->scoped()) << "(szx__);"; + out << nl << param << " = new " << fixId(seq->scoped()) << "(szx);"; } - out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)"; + out << nl << "for(int ix = 0; ix < szx; ++ix)"; out << sb; if(isArray || isStack) { - string v = isArray ? param : param + "__tmp"; - out << nl << v << "[ix__] = (" << typeS << ')' << stream << ".readEnum(" << en->maxValue() << ");"; + string v = isArray ? param : param + "_tmp"; + out << nl << v << "[ix] = (" << typeS << ')' << stream << ".readEnum(" << en->maxValue() << ");"; } else { @@ -1681,9 +1696,9 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << eb; if(isStack) { - out << nl << "_System.Array.Reverse(" << param << "__tmp);"; + out << nl << "_System.Array.Reverse(" << param << "_tmp);"; out << nl << param << " = new _System.Collections.Generic." << genericType << "<" << typeS << ">(" - << param << "__tmp);"; + << param << "_tmp);"; } out << eb; } @@ -1719,26 +1734,26 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, if(isStack) { out << nl << typeS << "[] " << param << "_tmp = " << param << ".ToArray();"; - out << nl << "for(int ix__ = 0; ix__ < " << param << "_tmp.Length; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << "_tmp.Length; ++ix)"; out << sb; - out << nl << helperName << '.' << func << '(' << stream << ", " << param << "_tmp[ix__]);"; + out << nl << helperName << '.' << func << '(' << stream << ", " << param << "_tmp[ix]);"; out << eb; } else { out << nl << "_System.Collections.Generic.IEnumerator<" << typeS - << "> e__ = " << param << ".GetEnumerator();"; - out << nl << "while(e__.MoveNext())"; + << "> e = " << param << ".GetEnumerator();"; + out << nl << "while(e.MoveNext())"; out << sb; - out << nl << helperName << '.' << func << '(' << stream << ", e__.Current);"; + out << nl << helperName << '.' << func << '(' << stream << ", e.Current);"; out << eb; } } else { - out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)"; + out << nl << "for(int ix = 0; ix < " << param << '.' << limitID << "; ++ix)"; out << sb; - out << nl << helperName << '.' << func << '(' << stream << ", " << param << "[ix__]);"; + out << nl << helperName << '.' << func << '(' << stream << ", " << param << "[ix]);"; out << eb; } out << eb; @@ -1747,11 +1762,11 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { func = "read"; out << sb; - out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize(" + out << nl << "int szx = " << stream << ".readAndCheckSeqSize(" << static_cast<unsigned>(type->minWireSize()) << ");"; if(isArray) { - out << nl << param << " = new " << toArrayAlloc(typeS + "[]", "szx__") << ";"; + out << nl << param << " = new " << toArrayAlloc(typeS + "[]", "szx") << ";"; } else if(isCustom) { @@ -1759,7 +1774,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else if(isStack) { - out << nl << typeS << "[] " << param << "__tmp = new " << toArrayAlloc(typeS + "[]", "szx__") << ";"; + out << nl << typeS << "[] " << param << "_tmp = new " << toArrayAlloc(typeS + "[]", "szx") << ";"; } else if(isGeneric) { @@ -1767,14 +1782,14 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else { - out << nl << param << " = new " << fixId(seq->scoped()) << "(szx__);"; + out << nl << param << " = new " << fixId(seq->scoped()) << "(szx);"; } - out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)"; + out << nl << "for(int ix = 0; ix < szx; ++ix)"; out << sb; if(isArray || isStack) { - string v = isArray ? param : param + "__tmp"; - out << nl << v << "[ix__] = " << helperName << '.' << func << '(' << stream << ");"; + string v = isArray ? param : param + "_tmp"; + out << nl << v << "[ix] = " << helperName << '.' << func << '(' << stream << ");"; } else { @@ -1783,9 +1798,9 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << eb; if(isStack) { - out << nl << "_System.Array.Reverse(" << param << "__tmp);"; + out << nl << "_System.Array.Reverse(" << param << "_tmp);"; out << nl << param << " = new _System.Collections.Generic." << genericType << "<" << typeS << ">(" - << param << "__tmp);"; + << param << "_tmp);"; } out << eb; } @@ -1798,9 +1813,14 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, const SequencePtr& seq, const string& param, int tag, - bool marshal) + bool marshal, + const string& customStream) { - string stream = marshal ? "os__" : "is__"; + string stream = customStream; + if(stream.empty()) + { + stream = marshal ? "ostr" : "istr"; + } const TypePtr type = seq->type(); const string typeS = typeToString(type); @@ -1863,9 +1883,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, { out << nl << stream << ".skipSize();"; } - string tmp = "tmpVal__"; + string tmp = "tmpVal"; out << nl << seqS << ' ' << tmp << ';'; - writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true); + writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true, stream); out << nl << param << " = new Ice.Optional<" << seqS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -1885,9 +1905,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, out << nl << "if(" << param << ".HasValue && " << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(seq) << "))"; out << sb; - out << nl << "int pos__ = " << stream << ".startSize();"; - writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, true); - out << nl << stream << ".endSize(pos__);"; + out << nl << "int pos = " << stream << ".startSize();"; + writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, true, stream); + out << nl << stream << ".endSize(pos);"; out << eb; } else @@ -1895,9 +1915,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(seq) << "))"; out << sb; out << nl << stream << ".skip(4);"; - string tmp = "tmpVal__"; + string tmp = "tmpVal"; out << nl << seqS << ' ' << tmp << ';'; - writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true); + writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true, stream); out << nl << param << " = new Ice.Optional<" << seqS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -1925,17 +1945,17 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, out << sb; if(st->isVariableLength()) { - out << nl << "int pos__ = " << stream << ".startSize();"; + out << nl << "int pos = " << stream << ".startSize();"; } else if(st->minWireSize() > 1) { out << nl << stream << ".writeSize(" << param << ".Value == null ? 1 : " << length << " * " << st->minWireSize() << " + (" << length << " > 254 ? 5 : 1));"; } - writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, true); + writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, true, stream); if(st->isVariableLength()) { - out << nl << stream << ".endSize(pos__);"; + out << nl << stream << ".endSize(pos);"; } out << eb; } @@ -1951,9 +1971,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, { out << nl << stream << ".skipSize();"; } - string tmp = "tmpVal__"; + string tmp = "tmpVal"; out << nl << seqS << ' ' << tmp << ';'; - writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true); + writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true, stream); out << nl << param << " = new Ice.Optional<" << seqS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -1972,9 +1992,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, out << nl << "if(" << param << ".HasValue && " << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(seq) << "))"; out << sb; - out << nl << "int pos__ = " << stream << ".startSize();"; - writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, true); - out << nl << stream << ".endSize(pos__);"; + out << nl << "int pos = " << stream << ".startSize();"; + writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, true, stream); + out << nl << stream << ".endSize(pos);"; out << eb; } else @@ -1982,9 +2002,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out, out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(seq) << "))"; out << sb; out << nl << stream << ".skip(4);"; - string tmp = "tmpVal__"; + string tmp = "tmpVal"; out << nl << seqS << ' ' << tmp << ';'; - writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true); + writeSequenceMarshalUnmarshalCode(out, seq, tmp, marshal, true, stream); out << nl << param << " = new Ice.Optional<" << seqS << ">(" << tmp << ");"; out << eb; out << nl << "else"; @@ -2002,16 +2022,20 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, int tag, bool serialize) { + // + // Could do it only when param == "info", but not as good for testing + // + string dataMember = "this." + param; if(optional) { const string typeName = typeToString(type, true); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } return; @@ -2026,11 +2050,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetByte(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetByte(\"" << param << "\");"; } break; } @@ -2038,11 +2062,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetBoolean(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetBoolean(\"" << param << "\");"; } break; } @@ -2050,11 +2074,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetInt16(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetInt16(\"" << param << "\");"; } break; } @@ -2062,11 +2086,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetInt32(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetInt32(\"" << param << "\");"; } break; } @@ -2074,11 +2098,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetInt64(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetInt64(\"" << param << "\");"; } break; } @@ -2086,11 +2110,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetSingle(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetSingle(\"" << param << "\");"; } break; } @@ -2098,11 +2122,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ");"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetDouble(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetDouble(\"" << param << "\");"; } break; } @@ -2110,12 +2134,12 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << " == null ? \"\" : " << param + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << " == null ? \"\" : " << dataMember << ");"; } else { - out << nl << param << " = " << "info__.GetString(\"" << param << "\");"; + out << nl << dataMember << " = " << "info.GetString(\"" << param << "\");"; } break; } @@ -2126,11 +2150,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } break; @@ -2139,12 +2163,12 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, { if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(Ice.ObjectPrxHelperBase));"; } else { - out << nl << param << " = (Ice.ObjectPrx)info__.GetValue(\"" << param + out << nl << dataMember << " = (Ice.ObjectPrx)info.GetValue(\"" << param << "\", typeof(Ice.ObjectPrxHelperBase));"; } break; @@ -2159,11 +2183,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "Helper));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "Helper));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "Helper));"; } return; @@ -2175,11 +2199,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } return; @@ -2191,11 +2215,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } return; @@ -2207,11 +2231,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } return; @@ -2223,11 +2247,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } return; @@ -2238,11 +2262,11 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out, const string typeName = typeToString(type, false); if(serialize) { - out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "));"; + out << nl << "info.AddValue(\"" << param << "\", " << dataMember << ", typeof(" << typeName << "));"; } else { - out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName + out << nl << dataMember << " = (" << typeName << ")info.GetValue(\"" << param << "\", typeof(" << typeName << "));"; } } |