Re: [Vala] enum in a subclass



Thank you Andre. Now all is clear.

BR, Vitaly Kirsanov
skype: vkirsan

2014-11-07 18:31 GMT+03:00 Andre Masella <andre masella name>:

1) You can't use `override` for methods in interfaces, only for overriding
base classes.

2) The contents of `foo` are not in scope for `bar`, only they inherited
members because they are now part of `bar`. So `Type` in `bar` is
`GLib.Type` not `foo.Type`.

public interface foo
{
    public enum Type
    {
        a, b
    }

    public abstract Type get_type();
}

public class bar : foo
{
     foo.Type t = foo.Type.a;
     public new foo.Type get_type() { return t; }
}

3) You *really* *really* *really* don't want to name this method
`get_type` and you also don't want to name anything `Type` as these are
used underneath by GLib. The “fixed” version above will generate the
following broken C:

GType foo_get_type (void) G_GNUC_CONST;
fooType foo_get_type (foo* self);




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