Reputation: 13
I try to define a ValueHash
similar to the ValueList
example in the Vala tutorial:
[Compact]
public class ValueHash : HashTable<string, Value?> {
[CCode (has_construct_function = false)]
protected ValueHash ();
}
Compiling this with valac 0.22 yields an
error: unable to chain up to base constructor requiring arguments
protected ValueHash ();
Searching the net I figured a call to the bas() constructor is needed, but how?
Trying out (I know that null
is not a valid argument here):
protected ValueHash () { base(null, null); }
yields:
error: too few arguments to function ‘g_hash_table_new_full’
protected ValueHash () { base(null, null); }
OK, probably need one argument more?
protected ValueHash () { base(null, null, null); }
yields:
error: Too many arguments, method `GLib.HashTable<string,GLib.Value?>'
does not take 3 arguments
protected ValueHash () { base(null, null, null); }
I cannot figure out what's going on here. As gobject already defines a ValueArray
in the GLib namespace, a ValueHash
would come in handy there, but incidentally this looks to be defined in libsoup-2.4, but I don't want to introduce a dependency on libsoup in my
code.
Thanks for any hints.
Upvotes: 1
Views: 150
Reputation: 14597
I'm not sure if there is a way to chain up to the 2-parameter constructor (or if what you are seeing is really a bug) but I believe calling the 4-parameter version explicitly works in any case:
[Compact]
public class ValueHash : HashTable<string, Value?> {
[CCode (has_construct_function = false)]
protected ValueHash () {
base.full (str_hash, str_equal, null, null);
}
}
Upvotes: 2