[Vala] GValue as Generic Type container issue.



Hi,

I am a really newbie in Vala world and would like to get some suggestion
about the code below:

public class GenericTypeExample<G> : ArrayList<G> {
 private ArrayList<G?> arr_list;
private int index = -1;
 # Using Value? as Generic Type container, but it does not seem to me work.
public Value? list_item {
owned get {
#COMPILATION ERROR --> return arr_list.get (index); ### ERROR GValue boxing
of type 'G' is not suported
}
 set {
# RUNTIME ERROR --> index = arr_list.index_of ( (G?) value); ### Resulting
SIGSEGV
 }
}
 public GenericTypeExample (ArrayList<G?> arr_list) {
this.arr_list = arr_list;
 }
}

    static int main (string[] args) {

 var sl = new ArrayList<string?> ();
  sl.add ("First");
 sl.add ("Second");
   var gte = new GenericTypeExample<string?> (sl);
  gte.list_item = "Second";
 stdout.printf ("Current list item: %s", (string?) gte.list_item );
 }
}

Thx in advance.

Cheers,

ilap


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