diff options
author | renato araujo oliveira <renato@renato-note.(none)> | 2009-11-03 17:10:08 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2009-11-03 20:25:04 -0200 |
commit | 030df87352ace61c7bad697ece1aa691215c20ea (patch) | |
tree | 7d421c184a7897c9334605bb05256669cdf750c4 | |
parent | 90df25280525d86d110f40906153197258b7bd1a (diff) |
Skip generation of unecessary wrapper classes.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r-- | cppgenerator.cpp | 4 | ||||
-rw-r--r-- | headergenerator.cpp | 8 | ||||
-rw-r--r-- | headergenerator.h | 1 | ||||
-rw-r--r-- | shibokengenerator.cpp | 15 |
4 files changed, 17 insertions, 11 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index 27576a346..8bde4de1e 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -138,7 +138,7 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl s << "using namespace Shiboken;" << endl << endl; - if (!metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) { + if (metaClass->isPolymorphic() && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) { s << "// Native ---------------------------------------------------------" << endl << endl; //inject code native beginner @@ -451,7 +451,7 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun s << INDENT << "if (!PyType_IsSubtype(type, &" << className << "))" << endl; s << INDENT << INDENT << "return 0;" << endl << endl; - if (overloadData.maxArgs() > 0) { + if (overloadData.maxArgs() > 0) { s << endl << INDENT << "int numArgs = "; writeArgumentsInitializer(s, overloadData); } diff --git a/headergenerator.cpp b/headergenerator.cpp index a8949a59a..ab5e563cf 100644 --- a/headergenerator.cpp +++ b/headergenerator.cpp @@ -56,8 +56,8 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met QString wrapperName = HeaderGenerator::wrapperName(metaClass); // Header - s << "#ifndef " << wrapperName.toUpper() << "_H" << endl; - s << "#define " << wrapperName.toUpper() << "_H" << endl<< endl; + 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; @@ -73,7 +73,7 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::Declaration, TypeSystem::NativeCode); - if (!metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) { + if (metaClass->isPolymorphic() && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) { /* * BOTOWTI (Beast of The Old World to be Investigated) // detect the held type @@ -112,7 +112,7 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met s << "};" << endl << endl; } - s << "#endif // " << wrapperName.toUpper() << "_H" << endl << endl; + s << "#endif // SBK_" << wrapperName.toUpper() << "_H" << endl << endl; } void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func) const diff --git a/headergenerator.h b/headergenerator.h index 1adf26dbc..2fdd779f2 100644 --- a/headergenerator.h +++ b/headergenerator.h @@ -35,6 +35,7 @@ protected: QString fileNameForClass(const AbstractMetaClass* metaClass) const; void generateClass(QTextStream& s, const AbstractMetaClass* metaClass); void finishGeneration(); + private: void writeCopyCtor(QTextStream &s, const AbstractMetaClass* metaClass) const; void writeFunction(QTextStream& s, const AbstractMetaFunction* func) const; diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index df714a595..adfeb1159 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -180,11 +180,16 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType* QString ShibokenGenerator::wrapperName(const AbstractMetaClass* metaClass) { - QString result = metaClass->name(); - if (metaClass->enclosingClass()) // is a inner class - result.replace("::", "_"); - result +="Wrapper"; - return result; + if (metaClass->isPolymorphic()) { + QString result = metaClass->name(); + if (metaClass->enclosingClass()) // is a inner class + result.replace("::", "_"); + + result +="Wrapper"; + return result; + } else { + return metaClass->qualifiedCppName(); + } } QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunction* func) |