aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-23 14:51:56 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-24 15:31:08 -0300
commitffa52e72c2b8cc5d7a6086d4a5a270eac91de8b9 (patch)
treea6e27226226e2291fc40b8ddd602b9b3683a722e
parente243cc91579f8df5e51518a5cfae75cc995d39ec (diff)
Added ShibokenGenerator::shouldGenerateCppWrapper(metaClass) method.
-rw-r--r--cppgenerator.cpp2
-rw-r--r--headergenerator.cpp8
-rw-r--r--shibokengenerator.cpp7
-rw-r--r--shibokengenerator.h4
4 files changed, 13 insertions, 8 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 395fe1470..3449441d7 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -127,7 +127,7 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
s << endl;
}
- if (metaClass->isPolymorphic() && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) {
+ if (shouldGenerateCppWrapper(metaClass)) {
s << "// Native ---------------------------------------------------------" << endl;
s << endl;
diff --git a/headergenerator.cpp b/headergenerator.cpp
index 038e24eac..b31b92e61 100644
--- a/headergenerator.cpp
+++ b/headergenerator.cpp
@@ -59,8 +59,7 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
s << "#ifndef SBK_" << wrapperName.toUpper() << "_H" << endl;
s << "#define SBK_" << wrapperName.toUpper() << "_H" << endl<< endl;
- if (!metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) {
- s << "// The mother of all C++ binding hacks!" << endl;
+ if (shouldGenerateCppWrapper(metaClass)) {
s << "#define protected public" << endl << endl;
}
@@ -73,7 +72,7 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
writeCodeSnips(s, metaClass->typeEntry()->codeSnips(),
CodeSnip::Declaration, TypeSystem::NativeCode);
- if (metaClass->isPolymorphic() && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) {
+ if (shouldGenerateCppWrapper(metaClass)) {
// Class
s << "class " << wrapperName;
s << " : public " << metaClass->qualifiedCppName();
@@ -92,9 +91,6 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
if (metaClass->isQObject() && (metaClass->name() != "QObject"))
s << INDENT << "using QObject::parent;" << endl;
- writeCodeSnips(s, metaClass->typeEntry()->codeSnips(),
- CodeSnip::PrototypeInitialization, TypeSystem::NativeCode);
-
s << "};" << endl << endl;
}
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp
index 716097bfa..b40598579 100644
--- a/shibokengenerator.cpp
+++ b/shibokengenerator.cpp
@@ -180,9 +180,14 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType*
return result;
}
+bool ShibokenGenerator::shouldGenerateCppWrapper(const AbstractMetaClass* metaClass)
+{
+ return metaClass->isPolymorphic() && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor();
+}
+
QString ShibokenGenerator::wrapperName(const AbstractMetaClass* metaClass)
{
- if (metaClass->isPolymorphic()) {
+ if (shouldGenerateCppWrapper(metaClass)) {
QString result = metaClass->name();
if (metaClass->enclosingClass()) // is a inner class
result.replace("::", "_");
diff --git a/shibokengenerator.h b/shibokengenerator.h
index 5fe879722..78a5498c2 100644
--- a/shibokengenerator.h
+++ b/shibokengenerator.h
@@ -186,6 +186,10 @@ public:
void writeToCppConversion(QTextStream& s, const AbstractMetaType* type,
const AbstractMetaClass* context, QString argumentName);
+
+ /// Verifies if the class should have a C++ wrapper generated for it, instead of only a Python wrapper.
+ static bool shouldGenerateCppWrapper(const AbstractMetaClass* metaClass);
+
static QString wrapperName(const AbstractMetaClass* metaClass);
static QString pythonPrimitiveTypeName(QString cppTypeName);