Re: [Vala] bah! protected indeed! Re: structs unions and types



Sam Liddicott schrieb:
* Jared Moore wrote, On 23/06/08 13:27:
Hi Sam,

I'm having trouble understanding exactly what you are trying to access
where. Would you please be able to send a complete and minimal test
case, i.e. a standalone program which is as small as possible and
demonstrates the problem.
sorry; I'm confusing my larger design problem with smaller technical
problems and it makes it hard to see what the specific complaint is.

here is a small file; t.vala, compile it with:
  valac --pkg gtk+-2.0 t.vala

The problem is that Subclass cannot access protected member "widgets" of
the Superclass.

sam mojojojo:~/projects/vala/phoneui/src$ valac --pkg gtk+-2.0 t.vala
t.vala:13.5-13.16: error: Access to private member `window_widgets.blah'
denied
    widgets.blah=null;
    ^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)


The widgets member is declared in the .h file (therefore public-ish),
but vala still call's it private.


using Gtk;

protected struct window_widgets {
    Gtk.Object blah;
}

public class Superclass : Gtk.Object {
    protected window_widgets widgets;
}

public class Subclass : Superclass {
  construct {
    widgets.blah=null;
  }
}

You have to make the field blah of the struct public or at least
protected:

protected struct window_widgets {
    public Gtk.Object blah;
}

...


Regards,

Frederik



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