aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2013-08-28 12:18:22 -0400
committerJohn Cummings <jcummings2@users.sf.net>2013-09-24 19:19:38 +0200
commit22aa9ced0d6b167ee835b4b184511c5df3f79591 (patch)
tree907354d65004a7c4434a5ae2b0b88deb6d530370 /generator
parent8287ee801965f2fbeea573e1eb652cc851920f86 (diff)
Write inititializations in topological order
Add methods to various places in the hierarchy so that the generator can access the topologically ordered class list (in addition to the unordered class list). Modify CppGenerator::finishGeneration to use this. This fixes a failure to correctly create Python wrapper classes due to subclass wrappers being initialized before their base class (with the result that the looked-up type object for the base class is null, causing the derived class to be created without referencing the base). Also change one of the test cases to test that we correctly wrap a typedef of a template class derived from a non-template base (which was failing before this change for the aforementioned reason). Change-Id: Ib4dc2626a41cb7bb905ff4a302c2613ea12d026b Reviewed-by: John Cummings <jcummings2@users.sf.net>
Diffstat (limited to 'generator')
-rw-r--r--generator/generator.cpp5
-rw-r--r--generator/generator.h6
-rw-r--r--generator/shiboken/cppgenerator.cpp2
3 files changed, 12 insertions, 1 deletions
diff --git a/generator/generator.cpp b/generator/generator.cpp
index 80399f71b..2d2456a10 100644
--- a/generator/generator.cpp
+++ b/generator/generator.cpp
@@ -153,6 +153,11 @@ AbstractMetaClassList Generator::classes() const
return m_d->apiextractor->classes();
}
+AbstractMetaClassList Generator::classesTopologicalSorted() const
+{
+ return m_d->apiextractor->classesTopologicalSorted();
+}
+
AbstractMetaFunctionList Generator::globalFunctions() const
{
return m_d->apiextractor->globalFunctions();
diff --git a/generator/generator.h b/generator/generator.h
index 3c357675c..8435ab6f7 100644
--- a/generator/generator.h
+++ b/generator/generator.h
@@ -95,6 +95,12 @@ public:
/// Returns the classes used to generate the binding code.
AbstractMetaClassList classes() const;
+ /// Returns the classes, topologically ordered, used to generate the binding code.
+ ///
+ /// The classes are ordered such that derived classes appear later in the list than
+ /// their parent classes.
+ AbstractMetaClassList classesTopologicalSorted() const;
+
/// Returns all global functions found by APIExtractor
AbstractMetaFunctionList globalFunctions() const;
diff --git a/generator/shiboken/cppgenerator.cpp b/generator/shiboken/cppgenerator.cpp
index a6ec5746d..04a087021 100644
--- a/generator/shiboken/cppgenerator.cpp
+++ b/generator/shiboken/cppgenerator.cpp
@@ -4590,7 +4590,7 @@ void CppGenerator::finishGeneration()
//this is a temporary solution before new type revison implementation
//We need move QMetaObject register before QObject
- AbstractMetaClassList lst = classes();
+ AbstractMetaClassList lst = classesTopologicalSorted();
AbstractMetaClass* klassQObject = lst.findClass("QObject");
AbstractMetaClass* klassQMetaObject = lst.findClass("QMetaObject");
if (klassQObject && klassQMetaObject) {