diff options
author | Michi Henning <michi@zeroc.com> | 2007-11-26 12:04:19 +1000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-11-26 12:04:19 +1000 |
commit | 36045f37b39ab655bea41947d5a8145c5a514328 (patch) | |
tree | 3b6e8436f6f9d6f1ba390a6ff73053549829f40d /cpp/src/slice2java/Gen.cpp | |
parent | Fixed VC6 build failures (diff) | |
download | ice-36045f37b39ab655bea41947d5a8145c5a514328.tar.bz2 ice-36045f37b39ab655bea41947d5a8145c5a514328.tar.xz ice-36045f37b39ab655bea41947d5a8145c5a514328.zip |
Bug 2474.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 02d2686e84b..dd285b1db1c 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -2863,7 +2863,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp << nl << "public static " << name << nl << "convert(int val)"; out << sb; - out << nl << "assert val < " << sz << ';'; + out << nl << "assert val >= 0 && val < " << sz << ';'; out << nl << "return __values[val];"; out << eb; @@ -2924,20 +2924,16 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sb; if(sz <= 0x7f) { - out << nl << "int __v = __is.readByte();"; + out << nl << "int __v = __is.readByte(" << sz << ");"; } else if(sz <= 0x7fff) { - out << nl << "int __v = __is.readShort();"; + out << nl << "int __v = __is.readShort(" << sz << ");"; } else { - out << nl << "int __v = __is.readInt();"; + out << nl << "int __v = __is.readInt(" << sz << ");"; } - out << nl << "if(__v < 0 || __v >= " << sz << ')'; - out << sb; - out << nl << "throw new Ice.MarshalException();"; - out << eb; out << nl << "return " << name << ".convert(__v);"; out << eb; @@ -2975,7 +2971,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) } out << nl << "if(__v < 0 || __v >= " << sz << ')'; out << sb; - out << nl << "throw new Ice.MarshalException();"; + out << nl << "throw new Ice.MarshalException(\"enumerator out of range\");"; out << eb; out << nl << "return " << name << ".convert(__v);"; out << eb; |