summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-09 18:16:38 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-10 15:36:29 -0200
commitcc58f2c2b7f80e8b749d3dd0577a9b18902e61bb (patch)
treefbd243630fa736ed11ae95ecc055b17d2f45cc2f
parent0949f2b49dcfd9516e4e3e4044a97070533799ad (diff)
downloadshiboken-cc58f2c2b7f80e8b749d3dd0577a9b18902e61bb.tar.gz
shiboken-cc58f2c2b7f80e8b749d3dd0577a9b18902e61bb.tar.xz
shiboken-cc58f2c2b7f80e8b749d3dd0577a9b18902e61bb.zip
Removed macros SbkBaseWrapper_instanceDict and SbkBaseWrapper_setInstanceDict
-rw-r--r--generator/cppgenerator.cpp4
-rw-r--r--libshiboken/basewrapper.cpp6
-rw-r--r--libshiboken/basewrapper.h3
-rw-r--r--libshiboken/bindingmanager.cpp43
-rw-r--r--libshiboken/bindingmanager.h8
-rw-r--r--libshiboken/conversions.h4
6 files changed, 33 insertions, 35 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 4f4498ac..068616cf 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3398,10 +3398,10 @@ void CppGenerator::writeGetattroFunction(QTextStream& s, const AbstractMetaClass
s << INDENT << "if (self) {" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "if (SbkBaseWrapper_instanceDict(self)) {" << endl;
+ s << INDENT << "if (reinterpret_cast<SbkObject*>(self)->ob_dict) {" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "PyObject* meth = PyDict_GetItem(SbkBaseWrapper_instanceDict(self), name);" << endl;
+ s << INDENT << "PyObject* meth = PyDict_GetItem(reinterpret_cast<SbkObject*>(self)->ob_dict, name);" << endl;
s << INDENT << "if (meth) {" << endl;
{
Indentation indent(INDENT);
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index a1813350..199387be 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -388,9 +388,9 @@ void deallocWrapperWithPrivateDtor(PyObject* self)
if (((SbkObject *)self)->weakreflist)
PyObject_ClearWeakRefs(self);
- BindingManager::instance().releaseWrapper(self);
+ BindingManager::instance().releaseWrapper(reinterpret_cast<SbkObject*>(self));
clearReferences(reinterpret_cast<SbkObject*>(self));
- Py_TYPE(reinterpret_cast<SbkObject*>(self))->tp_free(self);
+ self->ob_type->tp_free(self);
}
void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append)
@@ -471,7 +471,7 @@ void deallocWrapper(PyObject* pyObj)
if (sbkObj->weakreflist)
PyObject_ClearWeakRefs(pyObj);
- BindingManager::instance().releaseWrapper(pyObj);
+ BindingManager::instance().releaseWrapper(sbkObj);
if (sbkObj->d->hasOwnership) {
SbkBaseWrapperType* sbkType = reinterpret_cast<SbkBaseWrapperType*>(pyObj->ob_type);
if (sbkType->is_multicpp) {
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 51ee7f8d..1393e1a2 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -175,9 +175,6 @@ LIBSHIBOKEN_API bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctor
#define SbkBaseWrapper_Check(op) PyObject_TypeCheck(op, (PyTypeObject*)&Shiboken::SbkBaseWrapper_Type)
#define SbkBaseWrapper_CheckExact(op) ((op)->ob_type == &Shiboken::SbkBaseWrapper_Type)
-#define SbkBaseWrapper_instanceDict(pyobj) (((SbkObject*)pyobj)->ob_dict)
-#define SbkBaseWrapper_setInstanceDict(pyobj,d) (((SbkObject*)pyobj)->ob_dict = d)
-
LIBSHIBOKEN_API PyObject*
SbkBaseWrapper_New(SbkBaseWrapperType* instanceType,
void* cptr,
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp
index e2d32d83..e667f617 100644
--- a/libshiboken/bindingmanager.cpp
+++ b/libshiboken/bindingmanager.cpp
@@ -32,7 +32,7 @@
namespace Shiboken
{
-typedef google::dense_hash_map<const void*, PyObject*> WrapperMap;
+typedef google::dense_hash_map<const void*, SbkObject*> WrapperMap;
class Graph
{
@@ -111,7 +111,7 @@ struct BindingManager::BindingManagerPrivate {
BindingManagerPrivate() : destroying(false) {}
void releaseWrapper(void* cptr);
- void assignWrapper(PyObject* wrapper, const void* cptr);
+ void assignWrapper(SbkObject* wrapper, const void* cptr);
};
@@ -122,7 +122,7 @@ void BindingManager::BindingManagerPrivate::releaseWrapper(void* cptr)
wrapperMapper.erase(iter);
}
-void BindingManager::BindingManagerPrivate::assignWrapper(PyObject* wrapper, const void* cptr)
+void BindingManager::BindingManagerPrivate::assignWrapper(SbkObject* wrapper, const void* cptr)
{
assert(cptr);
WrapperMap::iterator iter = wrapperMapper.find(cptr);
@@ -162,29 +162,29 @@ bool BindingManager::hasWrapper(const void* cptr)
{
return m_d->wrapperMapper.count(cptr);
}
-void BindingManager::registerWrapper(SbkObject* pyobj, void* cptr)
+void BindingManager::registerWrapper(SbkObject* pyObj, void* cptr)
{
- SbkBaseWrapperType* instanceType = reinterpret_cast<SbkBaseWrapperType*>(pyobj->ob_type);
+ SbkBaseWrapperType* instanceType = reinterpret_cast<SbkBaseWrapperType*>(pyObj->ob_type);
if (instanceType->mi_init && !instanceType->mi_offsets)
instanceType->mi_offsets = instanceType->mi_init(cptr);
- m_d->assignWrapper(reinterpret_cast<PyObject*>(pyobj), cptr);
+ m_d->assignWrapper(pyObj, cptr);
if (instanceType->mi_offsets) {
int* offset = instanceType->mi_offsets;
while (*offset != -1) {
if (*offset > 0)
- m_d->assignWrapper(reinterpret_cast<PyObject*>(pyobj), reinterpret_cast<void*>((std::size_t) cptr + (*offset)));
+ m_d->assignWrapper(pyObj, reinterpret_cast<void*>((std::size_t) cptr + (*offset)));
offset++;
}
}
}
-void BindingManager::releaseWrapper(PyObject* wrapper)
+void BindingManager::releaseWrapper(SbkObject* sbkObj)
{
- SbkBaseWrapperType* sbkType = reinterpret_cast<SbkBaseWrapperType*>(wrapper->ob_type);
- int numBases = sbkType->is_multicpp ? getNumberOfCppBaseClasses(wrapper->ob_type) : 1;
+ SbkBaseWrapperType* sbkType = reinterpret_cast<SbkBaseWrapperType*>(sbkObj->ob_type);
+ int numBases = sbkType->is_multicpp ? getNumberOfCppBaseClasses(sbkObj->ob_type) : 1;
- void** cptrs = reinterpret_cast<SbkObject*>(wrapper)->d->cptr;
+ void** cptrs = reinterpret_cast<SbkObject*>(sbkObj)->d->cptr;
for (int i = 0; i < numBases; ++i) {
void* cptr = cptrs[i];
m_d->releaseWrapper(cptr);
@@ -199,7 +199,7 @@ void BindingManager::releaseWrapper(PyObject* wrapper)
}
}
-PyObject* BindingManager::retrieveWrapper(const void* cptr)
+SbkObject* BindingManager::retrieveWrapper(const void* cptr)
{
WrapperMap::iterator iter = m_d->wrapperMapper.find(cptr);
if (iter == m_d->wrapperMapper.end())
@@ -209,22 +209,23 @@ PyObject* BindingManager::retrieveWrapper(const void* cptr)
PyObject* BindingManager::getOverride(const void* cptr, const char* methodName)
{
- PyObject* wrapper = retrieveWrapper(cptr);
+ SbkObject* wrapper = retrieveWrapper(cptr);
if (!wrapper)
return 0;
- if (SbkBaseWrapper_instanceDict(wrapper)) {
- PyObject* method = PyDict_GetItemString(SbkBaseWrapper_instanceDict(wrapper), methodName);
+ if (wrapper->ob_dict) {
+ PyObject* method = PyDict_GetItemString(wrapper->ob_dict, methodName);
if (method) {
- Py_INCREF(method);
+ Py_INCREF((PyObject*)method);
return method;
}
}
PyObject* pyMethodName = PyString_FromString(methodName);
- PyObject* method = PyObject_GetAttr(wrapper, pyMethodName);
+ PyObject* method = PyObject_GetAttr((PyObject*)wrapper, pyMethodName);
- if (method && PyMethod_Check(method) && reinterpret_cast<PyMethodObject*>(method)->im_self == wrapper) {
+ if (method && PyMethod_Check(method)
+ && reinterpret_cast<PyMethodObject*>(method)->im_self == reinterpret_cast<PyObject*>(wrapper)) {
PyObject* defaultMethod;
PyObject* mro = wrapper->ob_type->tp_mro;
@@ -288,7 +289,7 @@ void BindingManager::invalidateWrapper(SbkObject* wrapper)
m_d->destroying = parentDestroying;
}
- releaseWrapper(reinterpret_cast<PyObject*>(wrapper));
+ releaseWrapper(wrapper);
}
void BindingManager::invalidateWrapper(const void* cptr)
@@ -343,9 +344,9 @@ SbkBaseWrapperType* BindingManager::resolveType(void* cptr, Shiboken::SbkBaseWra
return identifiedType ? identifiedType : type;
}
-std::set< PyObject* > BindingManager::getAllPyObjects()
+std::set<SbkObject*> BindingManager::getAllPyObjects()
{
- std::set<PyObject*> pyObjects;
+ std::set<SbkObject*> pyObjects;
const WrapperMap& wrappersMap = m_d->wrapperMapper;
WrapperMap::const_iterator it = wrappersMap.begin();
for (; it != wrappersMap.end(); ++it)
diff --git a/libshiboken/bindingmanager.h b/libshiboken/bindingmanager.h
index 31ed7981..910e6053 100644
--- a/libshiboken/bindingmanager.h
+++ b/libshiboken/bindingmanager.h
@@ -41,9 +41,9 @@ public:
bool hasWrapper(const void *cptr);
- void registerWrapper(SbkObject* pyobj, void* cptr);
- void releaseWrapper(PyObject* wrapper);
- PyObject* retrieveWrapper(const void* cptr);
+ void registerWrapper(SbkObject* pyObj, void* cptr);
+ void releaseWrapper(SbkObject* wrapper);
+ SbkObject* retrieveWrapper(const void* cptr);
PyObject* getOverride(const void* cptr, const char* methodName);
/// Invalidate the Python wrapper and removes the relations from C++ pointers to the Python wrapper.
@@ -63,7 +63,7 @@ public:
/// Called by wrapper destructor
void destroyWrapper(const void* cptr);
void destroyWrapper(SbkObject* wrapper);
- std::set<PyObject*> getAllPyObjects();
+ std::set<SbkObject*> getAllPyObjects();
private:
~BindingManager();
// disable copy
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index b077e2f2..e443dad1 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -139,7 +139,7 @@ struct Converter<T*>
{
if (!cppobj)
Py_RETURN_NONE;
- PyObject* pyobj = BindingManager::instance().retrieveWrapper(cppobj);
+ PyObject* pyobj = reinterpret_cast<PyObject*>(BindingManager::instance().retrieveWrapper(cppobj));
if (pyobj)
Py_INCREF(pyobj);
else
@@ -263,7 +263,7 @@ struct ObjectTypeConverter
{
if (!cppobj)
Py_RETURN_NONE;
- PyObject* pyobj = BindingManager::instance().retrieveWrapper(cppobj);
+ PyObject* pyobj = reinterpret_cast<PyObject*>(BindingManager::instance().retrieveWrapper(cppobj));
if (pyobj)
Py_INCREF(pyobj);
else