diff options
author | Benoit Foucher <benoit@zeroc.com> | 2015-02-17 11:50:58 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2015-02-17 11:50:58 +0100 |
commit | 67e9afa30c73daa260343d4c3638610f4c70980a (patch) | |
tree | ca5ba63f90d97e18f51238f3818294e3a5e3d3a4 /cpp/src/Slice/CsUtil.cpp | |
parent | IceLocatorDiscovery Makefile fix (diff) | |
download | ice-67e9afa30c73daa260343d4c3638610f4c70980a.tar.bz2 ice-67e9afa30c73daa260343d4c3638610f4c70980a.tar.xz ice-67e9afa30c73daa260343d4c3638610f4c70980a.zip |
Fixed ICE-6269: tolerate null values for structs and enums
Diffstat (limited to 'cpp/src/Slice/CsUtil.cpp')
-rw-r--r-- | cpp/src/Slice/CsUtil.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 85b811292ee..be424b7b67b 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -629,48 +629,27 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, { if(marshal) { + const string write = streamingAPI ? "ice_write" : "write__"; if(!isValueType(st)) { - out << nl << "if(" << param << " == null)"; - out << sb; - string typeS = typeToString(st); - out << nl << typeS << " tmp__ = new " << typeS << "();"; - out << nl << "tmp__."; - out << (streamingAPI ? "ice_write" : "write__") << "(" << stream << ");"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << param << "." << (streamingAPI ? "ice_write" : "write__") << "(" << stream << ");"; - out << eb; + out << nl << typeToString(st) << "." << write << "(" << stream << ", " << param << ");"; } else { - if(streamingAPI) - { - out << nl << param << ".ice_write(" << stream << ");"; - } - else - { - out << nl << param << ".write__(" << stream << ");"; - } + out << nl << param << "." << write << "(" << stream << ");"; } } else { if(!isValueType(st)) { - out << nl << "if(" << param << " == null)"; - out << sb; - out << nl << param << " = new " << typeToString(type) << "();"; - out << eb; - } - if(streamingAPI) - { - out << nl << param << ".ice_read(" << stream << ");"; + const string read = streamingAPI ? "ice_readNew" : "readNew__"; + out << nl << param << " = " << typeToString(type) << "." << read << "(" << stream << ");"; } else { - out << nl << param << ".read__(" << stream << ");"; + const string read = streamingAPI ? "ice_read" : "read__"; + out << nl << param << "." << read << "(" << stream << ");"; } } return; |