We make parent classes appear earlier than derived classes in the generated code. To do this, we perform a topological sort on the list of "objects" - placing each class after its dependencies.
The code for the sort (topoSort function in smartgi.nim) is wrong, and only sorts partially. To get the list properly sorted, I have to run it multiple times. It should be straightforward to replace it with a correct implementation.
Note I wonder why this sorting is necessary at all - you should be able to put multiple type declarations in one type block which depend on each other. However, without sorting I get an error message "inheritance only works with non-final objects" in the generated GObject2.nim. The compiler sees that something inherits from TObject, before it sees that TObject inherits from TRoot, which is inheritable.
We make parent classes appear earlier than derived classes in the generated code. To do this, we perform a topological sort on the list of "objects" - placing each class after its dependencies.
The code for the sort (topoSort function in smartgi.nim) is wrong, and only sorts partially. To get the list properly sorted, I have to run it multiple times. It should be straightforward to replace it with a correct implementation.
Note I wonder why this sorting is necessary at all - you should be able to put multiple type declarations in one
type
block which depend on each other. However, without sorting I get an error message "inheritance only works with non-final objects" in the generated GObject2.nim. The compiler sees that something inherits from TObject, before it sees that TObject inherits from TRoot, which isinheritable
.