Re: [Vala] converting void** to int[]*, or other ways to generically assign arrays



there are no gtype for value array, except for string (GStrv) ?!

2014-10-16 7:00 GMT+02:00 Andy Lees <andrewl oz gmail com>:

Hi,

In providing a general purpose configuration facility, I register the
address of configured variables in a void*. The description of a configured
item is:
    string key;
    Type type;
    void *loc;
    string? deflt;
    int size;
    ConfigFlags flags;
and an example configuration definition would be:
Conf.ConfItem ("Priority", typeof (int32), &conf.priority, "30", 0, 0)
or
Conf.ConfItem ("Channels", typeof (int32[]), &conf.channels, "", 0, 0)
and an assignment is like:
*((int32*)it.loc) = int.parse (val);
This works fine with single values, but I cannot seem to find a way to
assign arrays.  If I use something like:
void **ptr = it.loc;
*ptr = to_int32_arr (list);
The array pointer is assigned, but the length (and I assume a reference
count) is not.

A problem is that I cannot figure out how to declare a pointer to an array
- declarations like: int32[] *target; don't compile.  Similarly an
assignment like:
*((int32[]*)it.loc) = to_int32_arr (list);
Doesn't compile. ( syntax error, expected identifier).

Surely there is a way to do this sort of thing straightforwardly in vala?
Is there a way to declare a pointer to an array?

Any assistance is welcome.

Regards,

Andrew Lees
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



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