jdmansour / nim-smartgi

Generates smart wrappers for GLib modules using GObject-Introspection.
1 stars 0 forks source link

topoSort implementation is wrong #1

Open jdmansour opened 8 years ago

jdmansour commented 8 years ago

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.