summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Util.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2006-08-24 23:00:10 +0000
committerMark Spruiell <mes@zeroc.com>2006-08-24 23:00:10 +0000
commitc8d6203027334c6ca01aa75bb799b52c4924b102 (patch)
treeed4c7e774d7a4d20573b1de660041115f952bb96 /py/modules/IcePy/Util.cpp
parentbug 1316: auto_array (diff)
downloadice-c8d6203027334c6ca01aa75bb799b52c4924b102.tar.bz2
ice-c8d6203027334c6ca01aa75bb799b52c4924b102.tar.xz
ice-c8d6203027334c6ca01aa75bb799b52c4924b102.zip
bug 943: map sequence<byte> to string
Diffstat (limited to 'py/modules/IcePy/Util.cpp')
-rw-r--r--py/modules/IcePy/Util.cpp46
1 files changed, 34 insertions, 12 deletions
diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp
index ee5d4660970..6330f1ee95b 100644
--- a/py/modules/IcePy/Util.cpp
+++ b/py/modules/IcePy/Util.cpp
@@ -310,20 +310,19 @@ IcePy::listToStringSeq(PyObject* l, Ice::StringSeq& seq)
{
assert(PyList_Check(l));
- int sz = PyList_Size(l);
+ int sz = PyList_GET_SIZE(l);
for(int i = 0; i < sz; ++i)
{
- PyObject* item = PyList_GetItem(l, i);
- if(item == NULL)
- {
- return false;
- }
- char* str = PyString_AsString(item);
- if(str == NULL)
- {
- return false;
- }
- seq.push_back(str);
+ PyObject* item = PyList_GET_ITEM(l, i);
+ if(item == NULL)
+ {
+ return false;
+ }
+ if(!PyString_Check(item))
+ {
+ return false;
+ }
+ seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item)));
}
return true;
@@ -355,6 +354,29 @@ IcePy::stringSeqToList(const Ice::StringSeq& seq, PyObject* l)
}
bool
+IcePy::tupleToStringSeq(PyObject* t, Ice::StringSeq& seq)
+{
+ assert(PyTuple_Check(t));
+
+ int sz = PyTuple_GET_SIZE(t);
+ for(int i = 0; i < sz; ++i)
+ {
+ PyObject* item = PyTuple_GET_ITEM(t, i);
+ if(item == NULL)
+ {
+ return false;
+ }
+ if(!PyString_Check(item))
+ {
+ return false;
+ }
+ seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item)));
+ }
+
+ return true;
+}
+
+bool
IcePy::dictionaryToContext(PyObject* dict, Ice::Context& context)
{
assert(PyDict_Check(dict));