diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-08-17 19:31:37 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-08-17 19:31:37 -0300 |
commit | e0c29962e6f334452f0c9db2caaf6ed18065de85 (patch) | |
tree | cee27801c196fbcacf6130ad64216af133b555dd /tests/samplebinding/pair_conversions.h |
The End Is the Beginning Is the End
Diffstat (limited to 'tests/samplebinding/pair_conversions.h')
-rw-r--r-- | tests/samplebinding/pair_conversions.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/samplebinding/pair_conversions.h b/tests/samplebinding/pair_conversions.h new file mode 100644 index 000000000..8adf2f6f3 --- /dev/null +++ b/tests/samplebinding/pair_conversions.h @@ -0,0 +1,25 @@ +template <typename StdPair> +struct Converter_std_pair +{ + static PyObject* toPython(ValueHolder<StdPair> holder) + { + ValueHolder<typename StdPair::first_type> first(holder.value.first); + ValueHolder<typename StdPair::second_type> second(holder.value.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 = PyTuple_GET_ITEM(pyobj, 0); + PyObject* pySecond = PyTuple_GET_ITEM(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<std::pair<FT, ST> > : Converter_std_pair<std::pair<FT, ST> > {}; |