summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-07-29 13:52:27 +0200
committerJose <jose@zeroc.com>2016-07-29 13:52:27 +0200
commit03dd763393e796e92c4f272794190c24769a32fa (patch)
tree4edc35dd4d9f9a03f9bd40650f78d3beb147e7b8 /cpp/src/slice2cs
parentFix indentation (replace tabs with whitespaces) (diff)
downloadice-03dd763393e796e92c4f272794190c24769a32fa.tar.bz2
ice-03dd763393e796e92c4f272794190c24769a32fa.tar.xz
ice-03dd763393e796e92c4f272794190c24769a32fa.zip
ICE-7118 - Add serialization support for C# proxies
Diffstat (limited to 'cpp/src/slice2cs')
-rw-r--r--cpp/src/slice2cs/CsUtil.cpp59
-rw-r--r--cpp/src/slice2cs/CsUtil.h1
-rw-r--r--cpp/src/slice2cs/Gen.cpp17
3 files changed, 32 insertions, 45 deletions
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp
index 4bf6501a767..916304bcecf 100644
--- a/cpp/src/slice2cs/CsUtil.cpp
+++ b/cpp/src/slice2cs/CsUtil.cpp
@@ -498,34 +498,6 @@ Slice::CsGenerator::isValueType(const TypePtr& type)
return false;
}
-bool
-Slice::CsGenerator::isSerializable(const TypePtr& type)
-{
- //
- // A proxy cannot be serialized because a communicator is required during deserialization.
- //
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- ProxyPtr proxy = ProxyPtr::dynamicCast(type);
- if((builtin && builtin->kind() == Builtin::KindObjectProxy) || proxy)
- {
- return false;
- }
-
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- return isSerializable(seq->type());
- }
-
- DictionaryPtr d = DictionaryPtr::dynamicCast(type);
- if(d)
- {
- return isSerializable(d->keyType()) && isSerializable(d->valueType());
- }
-
- return true;
-}
-
void
Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
const TypePtr& type,
@@ -2025,11 +1997,6 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out,
int tag,
bool serialize)
{
- if(!isSerializable(type))
- {
- return;
- }
-
if(optional)
{
const string typeName = typeToString(type, true);
@@ -2165,9 +2132,16 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out,
}
case Builtin::KindObjectProxy:
{
- //
- // Proxies cannot be serialized.
- //
+ if(serialize)
+ {
+ out << nl << "info__.AddValue(\"" << param << "\", " << param
+ << ", typeof(Ice.ObjectPrxHelperBase));";
+ }
+ else
+ {
+ out << nl << param << " = (Ice.ObjectPrx)info__.GetValue(\"" << param
+ << "\", typeof(Ice.ObjectPrxHelperBase));";
+ }
break;
}
}
@@ -2177,9 +2151,16 @@ Slice::CsGenerator::writeSerializeDeserializeCode(Output &out,
ProxyPtr prx = ProxyPtr::dynamicCast(type);
if(prx)
{
- //
- // Proxies cannot be serialized.
- //
+ const string typeName = typeToString(type, false);
+ if(serialize)
+ {
+ out << nl << "info__.AddValue(\"" << param << "\", " << param << ", typeof(" << typeName << "Helper));";
+ }
+ else
+ {
+ out << nl << param << " = (" << typeName << ")info__.GetValue(\"" << param << "\", typeof(" << typeName
+ << "Helper));";
+ }
return;
}
diff --git a/cpp/src/slice2cs/CsUtil.h b/cpp/src/slice2cs/CsUtil.h
index 7ba159e0922..60c175f4501 100644
--- a/cpp/src/slice2cs/CsUtil.h
+++ b/cpp/src/slice2cs/CsUtil.h
@@ -44,7 +44,6 @@ protected:
static std::string getStaticId(const TypePtr&);
static std::string typeToString(const TypePtr&, bool = false, bool = false);
static bool isValueType(const TypePtr&);
- static bool isSerializable(const TypePtr&);
//
// Generate code to marshal or unmarshal a type
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 8f309996ffd..ff0a0b275d6 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -3938,11 +3938,6 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
dataMemberName = propertyName;
}
- if(!isSerializable(p->type()))
- {
- _out << nl << "[_System.NonSerialized]";
- }
-
if(isProperty)
{
_out << nl << "private";
@@ -4573,9 +4568,21 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp;
emitComVisibleAttribute();
emitGeneratedCodeAttribute();
+ _out << nl << "[_System.Serializable]";
_out << nl << "public sealed class " << name << "PrxHelper : Ice.ObjectPrxHelperBase, " << name << "Prx";
_out << sb;
+ _out << sp;
+ _out << nl << "public " << name << "PrxHelper()";
+ _out << sb;
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "public " << name << "PrxHelper(_System.Runtime.Serialization.SerializationInfo info__, "
+ << "_System.Runtime.Serialization.StreamingContext context__) : base(info__, context__)";
+ _out << sb;
+ _out << eb;
+
OperationList ops = p->allOperations();
if(!ops.empty())