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/slice2cs | |
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/slice2cs')
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 969472d97db..63adc6076c2 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -4323,6 +4323,31 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } _out << eb; + if(isClass) + { + emitGeneratedCodeAttribute(); + _out << nl << "public static void write__(IceInternal.BasicStream os__, " << name << " v__)"; + _out << sb; + _out << nl << "if(v__ == null)"; + _out << sb; + _out << nl << "nullMarshalValue__.write__(os__);"; + _out << eb; + _out << nl << "else"; + _out << sb; + _out << nl << "v__.write__(os__);"; + _out << eb; + _out << eb; + + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public static " << name << " readNew__(IceInternal.BasicStream is__)"; + _out << sb; + _out << nl << name << " v__ = new " << name << "();"; + _out << nl << "v__.read__(is__);"; + _out << nl << "return v__;"; + _out << eb; + } + if(_stream) { _out << sp; @@ -4346,8 +4371,37 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) classMemberCount); } _out << eb; + + if(isClass) + { + emitGeneratedCodeAttribute(); + _out << nl << "public static void ice_write(Ice.OutputStream outS__, " << name << " v__)"; + _out << sb; + _out << nl << "if(v__ == null)"; + _out << sb; + _out << nl << "nullMarshalValue__.ice_write(outS__);"; + _out << eb; + _out << nl << "else"; + _out << sb; + _out << nl << "v__.ice_write(outS__);"; + _out << eb; + _out << eb; + + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public static " << name << " ice_readNew(Ice.InputStream inS__)"; + _out << sb; + _out << nl << name << " v__ = new " << name << "();"; + _out << nl << "v__.ice_read(inS__);"; + _out << nl << "return v__;"; + _out << eb; + } } + if(isClass) + { + _out << nl << nl << "private static readonly " << name << " nullMarshalValue__ = new " << name << "();"; + } _out << sp << nl << "#endregion"; // Marshalling support } |