aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/helper.cpp
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-09-16 17:24:51 -0300
committerHugo Lima <hugo.lima@openbossa.org>2009-09-16 17:24:51 -0300
commit30272e14e2ea9f173bc31636998d1c7d9f5e18b3 (patch)
treebd69ca006ffc7c278ac4661c07e08d029dcc4dba /libshiboken/helper.cpp
parente4287151135ee3d5d9c05b9f7f421b253fece677 (diff)
Changed signature of PySequence_to_argc_argv.
Diffstat (limited to 'libshiboken/helper.cpp')
-rw-r--r--libshiboken/helper.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/libshiboken/helper.cpp b/libshiboken/helper.cpp
index ed5dab6d1..e1f23867d 100644
--- a/libshiboken/helper.cpp
+++ b/libshiboken/helper.cpp
@@ -37,31 +37,28 @@
namespace Shiboken
{
-int
-PySequence_to_argc_argv(_object* argList, char** argv[])
+bool
+PySequence_to_argc_argv(PyObject* argList, int* argc, char*** argv)
{
if (!PySequence_Check(argList))
- return -1;
+ return false;
+ // Check all items
+ int numArgs = PySequence_Size(argList);
+ for (int i = 0; i < numArgs; ++i)
+ if (!PyString_Check(PySequence_GetItem(argList, i)))
+ return false;
- int argc = (int) PySequence_Size(argList);
- (*argv) = new char*[argc];
- for (int i = 0; i < argc; ++i) {
+ *argc = (int) PySequence_Size(argList);
+ *argv = new char*[*argc];
+ for (int i = 0; i < *argc; ++i) {
PyObject* item = PySequence_GetItem(argList, i);
- if (!PyString_Check(item)) {
- argc = -1;
- for (int j = 0; j < i; ++j)
- delete (*argv)[j];
- Py_DECREF(item);
- return -1;
- }
- char *origArg = PyString_AS_STRING(item);
- int size = strlen(origArg);
+ char* string = PyString_AS_STRING(item);
+ int size = strlen(string);
(*argv)[i] = new char[size+1];
- (*argv)[i] = strcpy((*argv)[i], origArg);
+ (*argv)[i] = strcpy((*argv)[i], string);
Py_DECREF(item);
}
-
- return argc;
+ return true;
}
} // namespace Shiboken