aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper.cpp96
-rw-r--r--libshiboken/basewrapper.h27
-rw-r--r--libshiboken/basewrapper_p.h13
3 files changed, 4 insertions, 132 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 8ccf89a6b..5431c4149 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -29,8 +29,6 @@
#include <string>
#include <cstring>
#include <cstddef>
-#include <set>
-#include <sstream>
#include <algorithm>
#include "threadstatesaver.h"
@@ -214,7 +212,7 @@ void SbkDeallocWrapper(PyObject* pyObj)
if (sbkObj->d->hasOwnership && sbkObj->d->validCppObject) {
SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
if (sbkType->d->is_multicpp) {
- Shiboken::DeallocVisitor visitor(sbkObj);
+ Shiboken::DtorCallerVisitor visitor(sbkObj);
Shiboken::walkThroughClassHierarchy(pyObj->ob_type, &visitor);
} else {
void* cptr = sbkObj->d->cptr[0];
@@ -441,6 +439,8 @@ void DtorCallerVisitor::visit(SbkObjectType* node)
void DtorCallerVisitor::done()
{
+ Shiboken::Object::deallocData(m_pyObj, true);
+
std::list<std::pair<void*, SbkObjectType*> >::const_iterator it = m_ptrs.begin();
for (; it != m_ptrs.end(); ++it) {
Shiboken::ThreadStateSaver threadSaver;
@@ -449,12 +449,6 @@ void DtorCallerVisitor::done()
}
}
-void DeallocVisitor::done()
-{
- Shiboken::Object::deallocData(m_pyObj, true);
- DtorCallerVisitor::done();
-}
-
namespace Module { void init(); }
void init()
@@ -789,27 +783,6 @@ bool hasCppWrapper(SbkObject* pyObj)
return pyObj->d->containsCppWrapper;
}
-bool wasCreatedByPython(SbkObject* pyObj)
-{
- return pyObj->d->cppObjectCreated;
-}
-
-void callCppDestructors(SbkObject* pyObj)
-{
- SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
- if (sbkType->d->is_multicpp) {
- Shiboken::DtorCallerVisitor visitor(pyObj);
- Shiboken::walkThroughClassHierarchy(pyObj->ob_type, &visitor);
- } else {
- Shiboken::ThreadStateSaver threadSaver;
- threadSaver.save();
- sbkType->d->cpp_dtor(pyObj->d->cptr[0]);
- }
- delete[] pyObj->d->cptr;
- pyObj->d->cptr = 0;
- invalidate(pyObj);
-}
-
bool hasOwnership(SbkObject* pyObj)
{
return pyObj->d->hasOwnership;
@@ -931,16 +904,6 @@ void* cppPointer(SbkObject* pyObj, PyTypeObject* desiredType)
return 0;
}
-std::vector<void*> cppPointers(SbkObject* pyObj)
-{
- int n = getNumberOfCppBaseClasses(Py_TYPE(pyObj));
- std::vector<void*> ptrs(n);
- for (int i = 0; i < n; ++i)
- ptrs[i] = pyObj->d->cptr[i];
- return ptrs;
-}
-
-
bool setCppPointer(SbkObject* sbkObj, PyTypeObject* desiredType, void* cptr)
{
int idx = 0;
@@ -1296,59 +1259,6 @@ void clearReferences(SbkObject* self)
self->d->referredObjects = 0;
}
-std::string info(SbkObject* self)
-{
- std::ostringstream s;
- std::list<SbkObjectType*> bases = getCppBaseClasses(self->ob_type);
-
- s << "C++ address....... ";
- std::list<SbkObjectType*>::const_iterator it = bases.begin();
- for (int i = 0; it != bases.end(); ++it, ++i)
- s << ((PyTypeObject*)*it)->tp_name << "/" << self->d->cptr[i] << ' ';
- s << "\n";
-
- s << "hasOwnership...... " << bool(self->d->hasOwnership) << "\n"
- "containsCppWrapper " << self->d->containsCppWrapper << "\n"
- "validCppObject.... " << self->d->validCppObject << "\n"
- "wasCreatedByPython " << self->d->cppObjectCreated << "\n";
-
-
- if (self->d->parentInfo && self->d->parentInfo->parent) {
- s << "parent............ ";
- Shiboken::AutoDecRef parent(PyObject_Str((PyObject*)self->d->parentInfo->parent));
- s << PyString_AS_STRING(parent.object()) << "\n";
- }
-
- if (self->d->parentInfo && self->d->parentInfo->children.size()) {
- s << "children.......... ";
- ChildrenList& children = self->d->parentInfo->children;
- for (ChildrenList::const_iterator it = children.begin(); it != children.end(); ++it) {
- Shiboken::AutoDecRef child(PyObject_Str((PyObject*)*it));
- s << PyString_AS_STRING(child.object()) << ' ';
- }
- s << '\n';
- }
-
- if (self->d->referredObjects && self->d->referredObjects->size()) {
- Shiboken::RefCountMap& map = *self->d->referredObjects;
- s << "referred objects.. ";
- Shiboken::RefCountMap::const_iterator it = map.begin();
- for (; it != map.end(); ++it) {
- if (it != map.begin())
- s << " ";
- s << '"' << it->first << "\" => ";
- std::list<PyObject*>::const_iterator j = it->second.begin();
- for (; j != it->second.end(); ++j) {
- Shiboken::AutoDecRef obj(PyObject_Str(*j));
- s << PyString_AS_STRING(obj.object()) << ' ';
- }
- s << ' ';
- }
- s << '\n';
- }
- return s.str();
-}
-
} // namespace Object
} // namespace Shiboken
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 4ce27ee13..0ad4a9eed 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -27,7 +27,6 @@
#include "python25compat.h"
#include "bindingmanager.h"
#include <list>
-#include <vector>
#include <map>
#include <string>
@@ -212,15 +211,9 @@ LIBSHIBOKEN_API void setTypeUserData(SbkObjectType* self, void* userData,
namespace Object {
/**
- * Returns a string with information about the internal state of the instance object, useful for debug purposes.
- */
-LIBSHIBOKEN_API std::string info(SbkObject* self);
-
-/**
* Returns true if the object is an instance of a type created by the Shiboken generator.
*/
LIBSHIBOKEN_API bool checkType(PyObject* pyObj);
-
/**
* Returns true if this object type is an instance of an user defined type derived from an Shiboken type.
* \see Shiboken::ObjectType::isUserType
@@ -256,22 +249,9 @@ LIBSHIBOKEN_API void setHasCppWrapper(SbkObject* pyObj, bool value);
LIBSHIBOKEN_API bool hasCppWrapper(SbkObject* pyObj);
/**
- * Return true if the Python object was created by Python, false otherwise.
- * \note This function was added to libshiboken only to be used by shiboken.wasCreatedByPython()
- */
-LIBSHIBOKEN_API bool wasCreatedByPython(SbkObject* pyObj);
-
-/**
- * Call the C++ object destructor and invalidates the Python object.
- * \note This function was added to libshiboken only to be used by shiboken.delete()
- */
-LIBSHIBOKEN_API void callCppDestructors(SbkObject* pyObj);
-
-/**
* Return true if the Python is responsible for deleting the underlying C++ object.
*/
LIBSHIBOKEN_API bool hasOwnership(SbkObject* pyObj);
-
/**
* Sets python as responsible to delete the underlying C++ object.
* \note You this overload only when the PyObject can be a sequence and you want to
@@ -279,7 +259,6 @@ LIBSHIBOKEN_API bool hasOwnership(SbkObject* pyObj);
* \see getOwnership(SbkObject*)
*/
LIBSHIBOKEN_API void getOwnership(PyObject* pyObj);
-
/**
* Sets python as responsible to delete the underlying C++ object.
*/
@@ -308,12 +287,6 @@ LIBSHIBOKEN_API bool hasParentInfo(SbkObject* pyObj);
LIBSHIBOKEN_API void* cppPointer(SbkObject* pyObj, PyTypeObject* desiredType);
/**
- * Return a list with all C++ pointers held from a Python object.
- * \note This function was added to libshiboken only to be used by shiboken.getCppPointer()
- */
-LIBSHIBOKEN_API std::vector<void*> cppPointers(SbkObject* pyObj);
-
-/**
* Set the C++ pointer of type \p desiredType of a Python object.
*/
LIBSHIBOKEN_API bool setCppPointer(SbkObject* sbkObj, PyTypeObject* desiredType, void* cptr);
diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h
index a00e1ad69..e1fbf67c8 100644
--- a/libshiboken/basewrapper_p.h
+++ b/libshiboken/basewrapper_p.h
@@ -26,8 +26,6 @@
#include <Python.h>
#include <list>
#include <map>
-#include <set>
-#include <string>
struct SbkObject;
struct SbkObjectType;
@@ -192,26 +190,17 @@ private:
PyTypeObject* m_desiredType;
};
-/// Call the destructor of each C++ object held by a Python object
class DtorCallerVisitor : public HierarchyVisitor
{
public:
DtorCallerVisitor(SbkObject* pyObj) : m_pyObj(pyObj) {}
void visit(SbkObjectType* node);
void done();
-protected:
+private:
std::list<std::pair<void*, SbkObjectType*> > m_ptrs;
SbkObject* m_pyObj;
};
-/// Dealloc of each C++ object held by a Python object, this implies a call to the C++ object destructor
-class DeallocVisitor : public DtorCallerVisitor
-{
-public:
- DeallocVisitor(SbkObject* pyObj) : DtorCallerVisitor(pyObj) {}
- void done();
-};
-
/// \internal Internal function used to walk on classes inheritance trees.
/**
* Walk on class hierarchy using a DFS algorithm.