From 22aa9ced0d6b167ee835b4b184511c5df3f79591 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Wed, 28 Aug 2013 12:18:22 -0400 Subject: 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 --- generator/generator.cpp | 5 +++++ generator/generator.h | 6 ++++++ generator/shiboken/cppgenerator.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'generator') 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) { -- cgit v1.2.3