diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-09-15 14:52:50 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-09-15 15:02:05 -0300 |
commit | d753c1cf52dfda27fb251366ee754017e2f68a44 (patch) | |
tree | 0044940f8285c1303cdeae34494a4b21de4409c3 /PySide/QtCore/qpair_conversions.h | |
parent | 96bc2011c8762c117fb2d71d3feba4678690ac49 (diff) |
added conversion rules for QList and QPair containers
Diffstat (limited to 'PySide/QtCore/qpair_conversions.h')
-rw-r--r-- | PySide/QtCore/qpair_conversions.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/PySide/QtCore/qpair_conversions.h b/PySide/QtCore/qpair_conversions.h new file mode 100644 index 000000000..4d9f21351 --- /dev/null +++ b/PySide/QtCore/qpair_conversions.h @@ -0,0 +1,25 @@ +template <typename StdPair> +struct Converter_qpair +{ + static PyObject* toPython(StdPair holder) + { + typename StdPair::first_type first(holder.first); + typename StdPair::second_type second(holder.second); + PyObject* tuple = PyTuple_New(2); + PyTuple_SET_ITEM(tuple, 0, Converter<typename StdPair::first_type>::toPython(first)); + PyTuple_SET_ITEM(tuple, 1, Converter<typename StdPair::second_type>::toPython(second)); + return tuple; + } + static StdPair toCpp(PyObject* pyobj) + { + StdPair result; + PyObject* pyFirst = PySequence_GetItem(pyobj, 0); + PyObject* pySecond = PySequence_GetItem(pyobj, 1); + result.first = Converter<typename StdPair::first_type>::toCpp(pyFirst); + result.second = Converter<typename StdPair::second_type>::toCpp(pySecond); + return result; + } +}; + +template<typename FT, typename ST> +struct Converter<QPair<FT, ST> > : Converter_qpair<QPair<FT, ST> > {}; |