aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/helper.h
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-01-07 15:45:48 -0200
committerLauro Neto <lauro.neto@openbossa.org>2010-01-08 18:21:50 -0300
commitcdb91dc7438da10abe071eb852dc0db00ad90695 (patch)
tree6b78f272adda88e2e694ebc9f4da05897a87d9ae /libshiboken/helper.h
parenteb980e2beb0a3a9c1fca4bc217a61a67a2996710 (diff)
Added Shiboken::makeTuple inline method to help with constructions of Python tuples
from C++ objects. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken/helper.h')
-rw-r--r--libshiboken/helper.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/libshiboken/helper.h b/libshiboken/helper.h
index c6ab2c98e..8c3e3a64d 100644
--- a/libshiboken/helper.h
+++ b/libshiboken/helper.h
@@ -37,10 +37,30 @@
#include <Python.h>
#include "shibokenmacros.h"
+#include "conversions.h"
namespace Shiboken
{
+template<typename A, typename B>
+inline PyObject* makeTuple(const A& a, const B& b)
+{
+ PyObject* tuple = PyTuple_New(2);
+ PyTuple_SET_ITEM(tuple, 0, Converter<A>::toPython(a));
+ PyTuple_SET_ITEM(tuple, 1, Converter<B>::toPython(b));
+ return tuple;
+}
+
+template<typename A, typename B, typename C>
+inline PyObject* makeTuple(const A& a, const B& b, const C& c)
+{
+ PyObject* tuple = PyTuple_New(3);
+ PyTuple_SET_ITEM(tuple, 0, Converter<A>::toPython(a));
+ PyTuple_SET_ITEM(tuple, 1, Converter<B>::toPython(b));
+ PyTuple_SET_ITEM(tuple, 2, Converter<C>::toPython(c));
+ return tuple;
+}
+
LIBSHIBOKEN_API bool PySequence_to_argc_argv(PyObject* argList, int* argc, char*** argv);
} // namespace Shiboken