Re: [Vala] Vala does not register string[] properties
- From: Abderrahim Kitouni <a kitouni gmail com>
- To: Julian Andres Klode <jak jak-linux org>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Vala does not register string[] properties
- Date: Thu, 25 Mar 2010 20:18:14 +0100
Hi,
2010/3/25 Julian Andres Klode <jak jak-linux org>:
Hi,
string[] properties are not installed via g_object_class_install_property (),
which makes it impossible for json-glib to deserialize objects with array
members.
I'm having the exact problem, with the exact use case [1], I was just
too lazy to post it :-)
In the json-glib test code, I read the following:
g_object_class_install_property (gobject_class,
PROP_MAH,
g_param_spec_boxed ("mah", "Mah", "Mah",
G_TYPE_STRV,
G_PARAM_READWRITE));
Whereas mah is:
gchar **mah;
Would it be possible for Vala to do the same, so I don't have to convert
arrays manually when working with json-glib?
It should be possible, but needs patching Vala. Making Vala register
the property is just something like :
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -717,7 +725,7 @@ internal class Vala.GObjectModule : GTypeModule {
return false;
}
- if (prop.property_type is ArrayType) {
+ if (prop.property_type is ArrayType &&
prop.property_type.get_type_id () == null) {
return false;
}
but the problem is in the *_[sg]et_property function : the property
setter/getter takes an extra "length" argument. Setting the property
should be trivial (I think we can just pass -1 as the array in a
GValue should null-terminated), but the getter may need some work.
(anyone familiar with vala's codegen?)
HTH,
Abderrahim
[1] I'm using json-glib to implement a vala parser for BuilDj
http://live.gnome.org/BuilDj
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]