aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2009-08-24 10:18:45 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2009-08-24 10:18:45 -0300
commitdc419f4a5767a0a64e4e9a2446668370528c1343 (patch)
tree4a081cf09b832a4344ebf8cea60aaec333b46c23
parent4fca5b868e8b3d982dfa2ceb95806b2a5b2bb639 (diff)
Replaced use of boost::python::wrapper to PySide::wrapper.
-rw-r--r--cppgenerator.cpp16
-rw-r--r--hppgenerator.cpp34
2 files changed, 29 insertions, 21 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index ae1f625a8..9a7fdf5ff 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -624,11 +624,13 @@ void CppGenerator::writeModifiedConstructorImpl ( QTextStream& s, const Abstract
void CppGenerator::writeConstructorImpl(QTextStream& s, const AbstractMetaFunction* func)
{
- s << functionSignature(func, getWrapperName(func->ownerClass()) + "::", "",
- (Option)(OriginalTypeDescription | SkipDefaultValues));
- s << " : ";
+ QString wrapperName = getWrapperName(func->ownerClass());
+ s << wrapperName << "::" << wrapperName << "(PyObject *py_self" << (func->arguments().size() ? ", " : "");
+ writeFunctionArguments(s, func, OriginalTypeDescription | SkipDefaultValues);
+ s << ")" << endl;
+ s << INDENT << " : ";
writeFunctionCall(s, func);
- s << " {" << endl;
+ s << ", wrapper(py_self)" << endl << "{" << endl;
writeCodeSnips(s, getCodeSnips(func), CodeSnip::Beginning, TypeSystem::All, func);
writeCodeSnips(s, getCodeSnips(func), CodeSnip::End, TypeSystem::All, func);
s << '}' << endl << endl;
@@ -644,7 +646,7 @@ void CppGenerator::writeVirtualMethodImplHead(QTextStream& s, const AbstractMeta
CodeSnip::Beginning, TypeSystem::NativeCode, func);
}
- s << INDENT << "python::object method = PySide::detail::get_override(this, \"" << func->implementingClass()->name();
+ s << INDENT << "python::object method = get_override(\"" << func->implementingClass()->name();
if (func->implementingClass()->typeEntry()->isObject() || func->implementingClass()->typeEntry()->isQObject())
s << '*';
@@ -682,9 +684,7 @@ void CppGenerator::writeVirtualMethodImplHead(QTextStream& s, const AbstractMeta
(func->type()->isObject() || func->type()->isQObject())) {
s << INDENT << "PySide::qptr<" << QString(typeName).replace("*", "") << " > __ptr(__result.ptr());" << endl
- << INDENT << "if (__ptr.is_wrapper()) {" << endl
- << INDENT << INDENT << "python::incref(__result.ptr());" << endl
- << INDENT << "}" << endl
+ << INDENT << "python::incref(__result.ptr());" << endl
<< INDENT << "__ptr.release_ownership();" << endl;
}
diff --git a/hppgenerator.cpp b/hppgenerator.cpp
index 4e7da1120..0fd5cab6a 100644
--- a/hppgenerator.cpp
+++ b/hppgenerator.cpp
@@ -38,8 +38,8 @@ QString HppGenerator::fileNameForClass(const AbstractMetaClass *cppClass) const
void HppGenerator::writeCopyCtor(QTextStream &s, const AbstractMetaClass *cppClass)
{
- s << INDENT << getWrapperName(cppClass) << "(const " << cppClass->qualifiedCppName() << "& self)"
- << " : " << cppClass->qualifiedCppName() << "(self)" << endl
+ s << INDENT << getWrapperName(cppClass) << "(PyObject *py_self, const " << cppClass->qualifiedCppName() << "& self)"
+ << " : " << cppClass->qualifiedCppName() << "(self), wrapper(py_self)" << endl
<< INDENT << "{" << endl
<< INDENT << "}" << endl;
}
@@ -67,11 +67,13 @@ void HppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *cppCla
if (!cppClass->isPolymorphic() || cppClass->hasPrivateDestructor() || cppClass->isNamespace())
s << "namespace " << wrapperName << " {" << endl << endl;
+ bool needWriteBackReference = false;
if (cppClass->isNamespace()) {
s << INDENT << "struct Namespace {};" << endl;
} else {
QString className;
bool create_wrapper = canCreateWrapperFor(cppClass);
+ bool is_wrapper = false;
// detect the held type
QString held_type = cppClass->typeEntry()->heldTypeValue();
if (held_type.isEmpty() && create_wrapper)
@@ -81,16 +83,17 @@ void HppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *cppCla
CodeSnip::Declaration, TypeSystem::NativeCode);
if (cppClass->isPolymorphic() && !cppClass->hasPrivateDestructor()) {
+ /*
if (!held_type.isEmpty()) {
s << "// held type forward decalration" << endl;
s << "template<typename T> class " << held_type << ';' << endl;
}
+ */
// Class
s << "class PYSIDE_LOCAL " << wrapperName;
if (create_wrapper) {
- s << " : public " << cppClass->qualifiedCppName() << ", public boost::python::wrapper<";
- s << cppClass->qualifiedCppName() << '>';
+ s << " : public " << cppClass->qualifiedCppName() << ", public PySide::wrapper";
}
s << endl;
s << "{" << endl;
@@ -101,22 +104,20 @@ void HppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *cppCla
if (cppClass->isPolymorphic() && !cppClass->hasPrivateDestructor()) {
s << endl << "private:" << endl;
-
- if (cppClass->hasPrivateDestructor())
- className = cppClass->qualifiedCppName();
- else
- className = wrapperName;
+ className = wrapperName;
+ is_wrapper = true;
} else {
className = cppClass->qualifiedCppName();
}
// print the huge boost::python::class_ typedef
- s << INDENT << "typedef boost::python::class_< " << className;
+ s << INDENT << "typedef boost::python::class_< " << cppClass->qualifiedCppName();
writeBaseClass(s, cppClass);
if (!held_type.isEmpty())
- s << ", PySide::" << held_type << " < " << className << ", PySide::qptr_base::avoid_cache > ";
+ s << ", PySide::" << held_type << " < " << className << ", qptr_base::no_check_cache | qptr_base::"
+ << ( is_wrapper ? "wrapper_pointer" : "no_wrapper_pointer") << "> ";
if (!isCopyable(cppClass))
s << ", boost::noncopyable";
@@ -143,7 +144,6 @@ void HppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *cppCla
writeCodeSnips(s, cppClass->typeEntry()->codeSnips(),
CodeSnip::End, TypeSystem::ShellDeclaration);
-
}
QString staticKeyword = cppClass->isNamespace() ? QLatin1String("") : QLatin1String("static ");
@@ -159,6 +159,7 @@ void HppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *cppCla
s << "};" << endl << endl;
+
s << "#endif // __" << wrapperName.toUpper() << "__" << endl << endl;
}
@@ -179,7 +180,14 @@ void HppGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction* fun
s << INDENT << "static " << signatureForDefaultVirtualMethod(func, "", "_default", Generator::SkipName) << ';' << endl;
}
- s << INDENT << functionSignature(func, "", "", Generator::OriginalTypeDescription | Generator::SkipName);
+ if (func->isConstructor()) {
+ s << INDENT << getWrapperName(func->ownerClass()) << "(PyObject *py_self" << (func->arguments().size() ? "," : "");
+ writeFunctionArguments(s, func, Generator::OriginalTypeDescription | Generator::SkipName);
+ s << ")";
+ } else {
+ s << INDENT << functionSignature(func, "", "", Generator::OriginalTypeDescription | Generator::SkipName);
+ }
+
if (func->isModifiedRemoved() && func->isAbstract())
writeDefaultImplementation(s, func);
else