Re: [Vala] An array of Delegations?

Try wrapping the delegates in an object and storing those in Gee or an
array.  The class accepting the delegates could use a private class so it's
not exposed.

delegate void UserCallback();

public class CallbackManager {
  private class DelegateWrapper {
    public UserCallback cb;

  private DelegateWrapper[] ar = new DelegateWrapper[0];

  public void add_callback(UserCallback cb) {
    DelegateWrapper wrapper = new DelegateWrapper();
    wrapper.cb = cb;
    ar += wrapper;

(This is just off the top of my head, I didn't compile this to verify.)

-- Jim

On Wed, Jun 1, 2011 at 4:20 PM, Joseph Montanez <jmontanez gorilla3d com>wrote:

I know this is a bit insane, but is there any plan or maybe even a
work around to having working list of delegations? I tried with both
gee and fixed arrays for delegations but I get the error of:

"Delegates with target are not supported as array element type"

Right now my only work around is have a number of nullable single
delegates in a class then keeping track of the last assigned index.

Joseph Montanez
Web Developer
Design, Develop, Deploy
vala-list mailing list
vala-list gnome org

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