[Vala] name containing a space in array liberation function



Hello,
I'm using a binding I made for a library of ours.
This library uses a struct for manipulating various kind of addresses, which I have bound like (in the Sos namespace):

[CCode (cname = "struct sos_address", has_type_id = false,
        default_value = "{.aaddr = { .addr = { .sa_family = 0, .sa_data = {0}}}}")]
public struct Address {
        public AddressType type;
        [CCode (cname = "aaddr.addr")]
        public Posix.SockAddr addr;
        [CCode (cname = "aaddr.in")]
        public Posix.SockAddrIn in;
        ... other members ...
}

I use a function which creates an array of these addresses, bound as follows:

[CCode (lower_case_cprefix = "sos_server_")]
namespace Server {
        public int get_server_addresses(string? service,
                        [CCode (array_length_type = "uint32_t")]
                        out Address[] addresses);
        ...
}

When I try to compile the following program:

public static int main(string[] args){
        Sos.Address[] addrs;
        Sos.Server.get_server_addresses("mambo", out addrs);
        return Posix.EXIT_SUCCESS;
}

the following array liberation function is generated:

...
static void _vala_struct sos_address_array_free (struct sos_address* array, gint array_length) {
...

which doesn't compile because of the extra ' ' character between _vala_struct and sos_address_array_free.


By replacing the line:
string cname = "_vala_%s_array_free".printf (get_ccode_name (st));

with:
string cname = "_vala_%s_array_free".printf (get_ccode_name (st)).replace(" ", "_");


In append_struct_array_free() in codegen/valaccodearraymodule.vala (first line), I managed to get the correct (from a C point of view):

...
static void _vala_struct_sos_address_array_free (struct sos_address* array, gint array_length) {
...

I tested this patch in the version we use (0.20.1) and things seem to go well. The patch can't apply as is on the current HEAD, but can be rewritten easily.


Do you think this patch is the correct way of doing things ?
Could you consider it for inclusion, or provide another fix for the issue ?
Or am I doing things the wrong way in the first place, in my vala or vapi file ?

Thank you.


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