summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generator/cppgenerator.cpp66
-rw-r--r--libshiboken/basewrapper.cpp9
-rw-r--r--libshiboken/basewrapper_p.h2
3 files changed, 47 insertions, 30 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 284b20f8..b1f8d573 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2010,27 +2010,35 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
mc << ')';
} else {
if (func->ownerClass()) {
-#ifndef AVOID_PROTECTED_HACK
- if (func->isStatic())
- mc << func->ownerClass()->qualifiedCppName() << "::";
- else
- mc << CPP_SELF_VAR "->";
+#ifdef AVOID_PROTECTED_HACK
+ if (!func->isProtected()) {
+#endif
+ if (func->isStatic())
+ mc << func->ownerClass()->qualifiedCppName() << "::";
+ else {
+#ifdef AVOID_PROTECTED_HACK
+ if (!func->isVirtual() && func->ownerClass()->hasProtectedMembers())
+ mc << "((" << func->ownerClass()->qualifiedCppName() << "*)" << CPP_SELF_VAR << ")->";
+ else
+#endif
+ mc << CPP_SELF_VAR "->";
+ }
- if (!func->isAbstract() && func->isVirtual())
- mc << "::%CLASS_NAME::";
+ if (!func->isAbstract() && func->isVirtual())
+ mc << "::%CLASS_NAME::";
- mc << func->originalName();
-#else
- if (func->isStatic())
- mc << func->ownerClass()->qualifiedCppName() << "::";
- else {
- if (func->isProtected())
- mc << "((" << wrapperName(func->ownerClass()) << "*) ";
- mc << CPP_SELF_VAR << (func->isProtected() ? ")" : "") << "->";
+
+ mc << func->originalName();
+
+#ifdef AVOID_PROTECTED_HACK
+ } else {
+ if (!func->isStatic())
+ mc << "((" << wrapperName(func->ownerClass()) << "*) " << CPP_SELF_VAR << ")->";
+
+ if (!func->isAbstract())
+ mc << (func->isProtected() ? wrapperName(func->ownerClass()) : "::" + func->ownerClass()->qualifiedCppName()) << "::";
+ mc << func->originalName() << "_protected";
}
- if (!func->isAbstract() && func->isVirtual())
- mc << (func->isProtected() ? wrapperName(func->ownerClass()) : "::%CLASS_NAME::");
- mc << func->originalName() << (func->isProtected() ? "_protected" : "");
#endif
} else {
mc << func->originalName();
@@ -2038,13 +2046,19 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
mc << '(' << userArgs.join(", ") << ')';
if (!func->isAbstract() && func->isVirtual()) {
mc.flush();
- QString virtualCall(methodCall);
- QString normalCall(methodCall);
+#ifndef AVOID_PROTECTED_HACK
+ if (!func->isProtected())
+#endif
+ {
+ QString virtualCall(methodCall);
+ QString normalCall(methodCall);
+
+ virtualCall = virtualCall.replace("%CLASS_NAME", func->ownerClass()->qualifiedCppName());
+ normalCall = normalCall.replace("::%CLASS_NAME::", "");
+ methodCall = "";
- virtualCall = virtualCall.replace("%CLASS_NAME", func->ownerClass()->qualifiedCppName());
- normalCall = normalCall.replace("::%CLASS_NAME::", "");
- methodCall = "";
- mc << "(Shiboken::Wrapper::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
+ mc << "(Shiboken::Wrapper::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
+ }
}
}
}
@@ -3247,6 +3261,10 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (metaClass->hasProtectedDestructor())
dtorClassName = wrapperName(metaClass);
#endif
+ // call the real destructor
+ if (metaClass->typeEntry()->isValue())
+ dtorClassName = wrapperName(metaClass);
+
s << INDENT << "Shiboken::BaseType::setDestructorFunction(&" << cpythonTypeName(metaClass) << ", &Shiboken::callCppDestructor<" << dtorClassName << " >);" << endl;
}
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 39c18c3e..6fb69bf9 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -170,7 +170,7 @@ void SbkDeallocWrapper(PyObject* pyObj)
}
}
- Shiboken::Wrapper::deallocData(sbkObj);
+ Shiboken::Wrapper::deallocData(sbkObj, !sbkObj->d->containsCppWrapper);
}
void SbkDeallocWrapperWithPrivateDtor(PyObject* self)
@@ -179,8 +179,7 @@ void SbkDeallocWrapperWithPrivateDtor(PyObject* self)
if (sbkObj->weakreflist)
PyObject_ClearWeakRefs(self);
- Shiboken::BindingManager::instance().releaseWrapper(sbkObj);
- Shiboken::Wrapper::deallocData(sbkObj);
+ Shiboken::Wrapper::deallocData(sbkObj, true);
}
void SbkBaseTypeDealloc(PyObject* pyObj)
@@ -927,10 +926,10 @@ void setParent(PyObject* parent, PyObject* child)
Py_DECREF(child);
}
-void deallocData(SbkObject* self)
+void deallocData(SbkObject* self, bool cleanup)
{
// Make cleanup if this is not a wrapper otherwise this will be done on wrapper destructor
- if(!self->d->containsCppWrapper) {
+ if(cleanup) {
removeParent(self);
if (self->d->parentInfo)
diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h
index 702fdbd0..428159e0 100644
--- a/libshiboken/basewrapper_p.h
+++ b/libshiboken/basewrapper_p.h
@@ -229,7 +229,7 @@ void clearReferences(SbkObject* self);
/**
* Destroy internal data
**/
-void deallocData(SbkObject* self);
+void deallocData(SbkObject* self, bool doCleanup);
} // namespace Wrapper
} // namespace Shiboken