summaryrefslogtreecommitdiffstats
path: root/libshiboken/sbkconverter.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-11-01 16:17:01 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-12-09 20:28:07 -0300
commitda38f960cef3e105e959cfd80a193e029d82d9aa (patch)
treeb995687b88514f297a28ad983446f08260b29833 /libshiboken/sbkconverter.cpp
parentd427000699fe74f7f0b1d1fdf1907a0d40f83ba8 (diff)
downloadshiboken-da38f960cef3e105e959cfd80a193e029d82d9aa.tar.gz
shiboken-da38f960cef3e105e959cfd80a193e029d82d9aa.tar.xz
shiboken-da38f960cef3e105e959cfd80a193e029d82d9aa.zip
Added some setting and converting functions to the new converter's API.
Diffstat (limited to 'libshiboken/sbkconverter.cpp')
-rw-r--r--libshiboken/sbkconverter.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/libshiboken/sbkconverter.cpp b/libshiboken/sbkconverter.cpp
index 32d43507..202ba264 100644
--- a/libshiboken/sbkconverter.cpp
+++ b/libshiboken/sbkconverter.cpp
@@ -125,6 +125,18 @@ void deleteConverter(SbkConverter* converter)
}
}
+void setCppPointerToPythonFunction(SbkConverter* converter, CppToPythonFunc pointerToPythonFunc)
+{
+ converter->pointerToPython = pointerToPythonFunc;
+}
+
+void setPythonToCppPointerFunctions(SbkConverter* converter,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc)
+{
+ converter->toCppPointerConversion = std::make_pair(toCppPointerCheckFunc, toCppPointerConvFunc);
+}
+
void addPythonToCppValueConversion(SbkConverter* converter,
PythonToCppFunc pythonToCppFunc,
IsConvertibleToCppFunc isConvertibleToCppFunc)
@@ -140,9 +152,15 @@ void addPythonToCppValueConversion(SbkObjectType* type,
PyObject* pointerToPython(SbkObjectType* type, const void* cppIn)
{
+ return pointerToPython(type->d->converter, cppIn);
+}
+
+PyObject* pointerToPython(SbkConverter* converter, const void* cppIn)
+{
+ assert(converter);
if (!cppIn)
Py_RETURN_NONE;
- return type->d->converter->pointerToPython(cppIn);
+ return converter->pointerToPython(cppIn);
}
PyObject* referenceToPython(SbkObjectType* type, const void* cppIn)
@@ -236,6 +254,14 @@ void pythonToCppPointer(SbkObjectType* type, PyObject* pyIn, void* cppOut)
*((void**)cppOut) = (pyIn == Py_None) ? 0 : cppPointer((PyTypeObject*)type, (SbkObject*)pyIn);
}
+void pythonToCppPointer(SbkConverter* converter, PyObject* pyIn, void* cppOut)
+{
+ assert(converter);
+ assert(pyIn);
+ assert(cppOut);
+ *((void**)cppOut) = (pyIn == Py_None) ? 0 : cppPointer((PyTypeObject*)converter->pythonType, (SbkObject*)pyIn);
+}
+
static void _pythonToCppCopy(SbkConverter* converter, PyObject* pyIn, void* cppOut)
{
assert(converter);
@@ -252,7 +278,7 @@ void pythonToCppCopy(SbkObjectType* type, PyObject* pyIn, void* cppOut)
_pythonToCppCopy(type->d->converter, pyIn, cppOut);
}
-void pythonToCpp(SbkConverter* converter, PyObject* pyIn, void* cppOut)
+void pythonToCppCopy(SbkConverter* converter, PyObject* pyIn, void* cppOut)
{
_pythonToCppCopy(converter, pyIn, cppOut);
}