summaryrefslogtreecommitdiffstats
path: root/libshiboken/typeresolver.h
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-27 17:11:03 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-28 13:48:07 -0300
commit016bc9ba8847411cb92ee25a03d50e62f4e9e952 (patch)
treeebc979ff75c3f3a7a683f6352bab7941b7463787 /libshiboken/typeresolver.h
parent4bc7a3822af0476ffc8a86ffac65775c46d6b4da (diff)
downloadshiboken-016bc9ba8847411cb92ee25a03d50e62f4e9e952.tar.gz
shiboken-016bc9ba8847411cb92ee25a03d50e62f4e9e952.tar.xz
shiboken-016bc9ba8847411cb92ee25a03d50e62f4e9e952.zip
Implemented support to conversion without memory allocation.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libshiboken/typeresolver.h')
-rw-r--r--libshiboken/typeresolver.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/libshiboken/typeresolver.h b/libshiboken/typeresolver.h
index 18593551..b11678e2 100644
--- a/libshiboken/typeresolver.h
+++ b/libshiboken/typeresolver.h
@@ -33,15 +33,20 @@ class SbkBaseWrapperType;
/* To C++ convertion functions. */
template <typename T>
-inline void* pythonToValueType(PyObject* pyobj)
+inline void* pythonToValueType(PyObject* pyobj, void** data, bool alloc)
{
- return Shiboken::CppObjectCopier<T>::copy(Shiboken::Converter<T>::toCpp(pyobj));
+ if (alloc)
+ *data = Shiboken::CppObjectCopier<T>::copy(Shiboken::Converter<T>::toCpp(pyobj));
+
+ *reinterpret_cast< T*>(*data) = Shiboken::Converter<T>::toCpp(pyobj);
+ return *data;
}
template <typename T>
-inline void* pythonToObjectType(PyObject* pyobj)
+inline void* pythonToObjectType(PyObject* pyobj, void** data, bool)
{
- return Shiboken::Converter<T*>::toCpp(pyobj);
+ *data = Shiboken::Converter<T*>::toCpp(pyobj);
+ return *data;
}
template <typename T>
@@ -73,9 +78,8 @@ public:
};
typedef PyObject* (*CppToPythonFunc)(void*);
- typedef void* (*PythonToCppFunc)(PyObject*);
+ typedef void* (*PythonToCppFunc)(PyObject*, void**, bool);
typedef void (*DeleteObjectFunc)(void*);
- typedef PyTypeObject* (*GetPyTypeFunc)();
~TypeResolver();
@@ -96,7 +100,7 @@ public:
const char* typeName() const;
PyObject* toPython(void* cppObj);
- void* toCpp(PyObject* pyObj);
+ void* toCpp(PyObject* pyObj, void** place, bool alloc=false);
void deleteObject(void* object);
PyTypeObject* pythonType();