aboutsummaryrefslogtreecommitdiff
path: root/devel/ice/files/patch-py-modules-IcePy-Types.cpp
blob: 160a9cc8a064f0d7014bc86ed11da97638ddc248 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
--- py/modules/IcePy/Types.cpp.orig	2013-03-11 15:19:47.000000000 +0000
+++ py/modules/IcePy/Types.cpp	2014-09-08 14:21:13.335195726 +0000
@@ -1232,11 +1232,15 @@ IcePy::StructInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMa
 {
     assert(PyObject_IsInstance(p, pythonType.get()) == 1); // validate() should have caught this.
 
+    int sizePos = -1;
     if(optional)
     {
         if(_variableLength)
         {
-            os->startSize();
+            // BUGFIX: #5481 startSize/endSize can't be nested
+            //os->startSize();
+            sizePos = os->pos();
+            os->write(Ice::Int(0));
         }
         else
         {
@@ -1266,7 +1270,9 @@ IcePy::StructInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMa
 
     if(optional && _variableLength)
     {
-        os->endSize();
+        assert(sizePos != -1);
+        //os->endSize();
+        os->rewrite(os->pos() - sizePos - 4, sizePos);
     }
 }
 
@@ -1402,11 +1408,15 @@ IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Object
 {
     PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType);
 
+    int sizePos = -1;
     if(optional)
     {
         if(elementType->variableLength())
         {
-            os->startSize();
+            // BUGFIX: #5481 startSize/endSize can't be nested
+            //os->startSize();
+            sizePos = os->pos();
+            os->write(Ice::Int(0));
         }
         else if(elementType->wireSize() > 1)
         {
@@ -1490,7 +1500,9 @@ IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Object
 
     if(optional && elementType->variableLength())
     {
-        os->endSize();
+        assert(sizePos != -1);
+        //os->endSize();
+        os->rewrite(os->pos() - sizePos - 4, sizePos);
     }
 }
 
@@ -2480,11 +2492,15 @@ IcePy::DictionaryInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Obje
 
     const Ice::Int sz = p == Py_None ? 0 : static_cast<Ice::Int>(PyDict_Size(p));
 
+    int sizePos = -1;
     if(optional)
     {
         if(_variableLength)
         {
-            os->startSize();
+            // BUGFIX: #5481 startSize/endSize can't be nested
+            //os->startSize();
+            sizePos = os->pos();
+            os->write(Ice::Int(0));
         }
         else
         {
@@ -2523,7 +2539,9 @@ IcePy::DictionaryInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Obje
 
     if(optional && _variableLength)
     {
-        os->endSize();
+        assert(sizePos != -1);
+        //os->endSize();
+        os->rewrite(os->pos() - sizePos - 4, sizePos);
     }
 }
 
@@ -2958,9 +2976,13 @@ IcePy::ProxyInfo::optionalFormat() const
 void
 IcePy::ProxyInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap*, bool optional, const Ice::StringSeq*)
 {
+    int sizePos = -1;
     if(optional)
     {
-        os->startSize();
+        // BUGFIX: #5481 startSize/endSize can't be nested
+        //os->startSize();
+        sizePos = os->pos();
+        os->write(Ice::Int(0));
     }
 
     if(p == Py_None)
@@ -2978,7 +3000,9 @@ IcePy::ProxyInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap
 
     if(optional)
     {
-        os->endSize();
+        assert(sizePos != -1);
+        //os->endSize();
+        os->rewrite(os->pos() - sizePos - 4, sizePos);
     }
 }