GNOME Bugzilla – Bug 578603
Abilility to subclass compact class with methods only, report error otherwise
Last modified: 2009-07-28 17:33:40 UTC
Compiling the following code // valac sample.vala --pkg gtk+-2.0 --pkg cairo using GLib, Cairo; public class Sample.TestContext : Cairo.Context { } public class Sample.App { public static void main(string[] args) { } } results in following error /home/jaap/sample.c:25: error: field ‘parent_instance’ has incomplete type error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) This used to work fine some releases ago
Any help I would highly appreciate
Cairo is not using GObject, the cairo context is an opaque struct in C. This makes it impossible to support proper subclassing (without writing a library on top of cairo to wrap the native cairo types). The Vala compiler should report an error, though.
OK weird thing is that my code worked fine about a year ago
If the subclass only adds new methods but no fields, it's certainly possible to implement. We could support that for compact classes if that is sufficient.
For me in this case it would be sufficient. I just add some methods to cairo context to make drawing of other objects easier
commit fea12020d4f6086fea271f0f1a7832d96fd86169 Author: Jürg Billeter <j@bitron.ch> Date: Tue Jul 28 18:50:25 2009 +0200 Add limited support for derived compact classes Fixes bug 578603.