Re: [Vala] Virtual methods in interfaces



Hello,

                   في ج، 28-01-2011 عند 18:30 +1030 ، كتب James Moschou:
But see this is just a workaround. What I want is for the subclass to
inherit the interface and the interface implementation from the base
class, and override certain aspects. But what you have to do instead
is reimplement the interface, and override everything again. The two
are the same thing in these examples because they are so trivial. But
consider:
You almost got me with this one, but still I think I'm right :-p

You just found a bug in valac, but let's see your output. For the
subclass you got :

subclass - virtual
interface - other virtual
Segmentation fault
here I get this instead (using the tip of switch-to-gir branch, which is
based on 0.11.3):


subclass - virtual
class - other virtual
Segmentation fault

So the second one is correct (i.e. has probably been fixed meanwhile).
However, the third one still fails (the abstract interface method
implemented as non-virtual method). Using gdb, I found out that it is an
infinite recursion problem and commenting out the line :

iface->abstract_function = (void (*)(Interface*)) interface_abstract_function;

in the generated code makes it work as expected (i.e. I get "class -
abstract"). So you just have found a bug (rather 2, but one is already
fixed).

It might be a good idea to test all combinations of
abstract/virtual/implemented as virtual/normally implemented, etc. with
latest vala and report exactly what works and what doesn't.

HTH,
Abderrahim




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]