diff options
Diffstat (limited to 'cpp/src/Slice/CsUtil.cpp')
-rw-r--r-- | cpp/src/Slice/CsUtil.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 1ec3bff4a56..e3841b72e9e 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -651,24 +651,26 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - size_t sz = en->getEnumerators().size(); if(marshal) { if(streamingAPI) { - out << nl << "if((int)" << param << " < 0 || (int)" << param << " >= " << sz << ")"; + out << nl << "if((int)" << param << " < " << en->minValue() + << " || (int)" << param << " > " << en->maxValue() << ")"; out << sb; out << nl << "throw new Ice.MarshalException(\"enumerator out of range\");"; out << eb; } - out << nl << stream << ".writeEnum((int)" << param << ", " << sz << ");"; + out << nl << stream << ".writeEnum((int)" << param << ", " << en->maxValue() << ");"; } else { - out << nl << param << " = (" << fixId(en->scoped()) << ')' << stream << ".readEnum(" << sz << ");"; + out << nl << param << " = (" << fixId(en->scoped()) << ')' << stream << ".readEnum(" << en->maxValue() + << ");"; if(streamingAPI) { - out << nl << "if((int)" << param << " < 0 || (int)" << param << " >= " << sz << ")"; + out << nl << "if((int)" << param << " < " << en->minValue() << " || (int)" << param << " > " + << en->maxValue() << ")"; out << sb; out << nl << "throw new Ice.MarshalException(\"enumerator out of range\");"; out << eb; |