[Vala] public class Foo : List<Bar>



hi

I was trying to test whether this is allowed...

  public class Foo : List<Bar> {

...and got this error...



// valac --pkg gtk+-3.0 classtest.vala

public class NodeList : List<Strung> {
  public NodeList () { }
}

public class Strung {
  private string val;
  public Strung (string v) { this.val = v; }
  public string value () { return this.val; }
}

public static int main (string[] args) {
    NodeList list = new NodeList ();
    list.append ((Strung) "1. entry");
    list.append ((Strung) "2. entry");
    list.append ((Strung) "3. entry");

    unowned List<Strung> element = list.nth (2);
stdout.printf ("list.nth (2) = \"%s\"\n", (string) element.data.value ());
    int pos = list.position (element);
    stdout.printf ("Position: list.position () = %d\n", pos);
    return 0;
}



bash$ valac --pkg gtk+-3.0 classtest.vala
classtest.vala.c: In function ‘node_list_new’:
classtest.vala.c:72:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  self = (NodeList*) g_list_new ();
         ^
classtest.vala.c: In function ‘main’:
classtest.vala.c:297:2: warning: ‘g_type_init’ is deprecated (declared at /usr/include/glib-2.0/gobject/gtype.h:669) [-Wdeprecated-declarations]
  g_type_init ();
  ^
/tmp/ccXKn8dn.o: In function `node_list_new':
classtest.vala.c:(.text+0xe): undefined reference to `g_list_new'
collect2: error: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)



... so i guess it isn't allowed?


-billy


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