Re: [Vala] MySQL access from vala



On Thu, May 06, 2010 at 20:51:07 +0300, Ndubi Abenga wrote:
            Field[] fields = result.fetch_fields ();
[...]
           mysql_connection.c:179: error: too many arguments to function
‘mysql_fetch_fields’

The offending C code is this right here:

*179:*        fields = (_tmp2_ = mysql_fetch_fields (self->priv->result, *
&_tmp1_*), fields_length1 = _tmp1_, _fields_size_ = fields_length1, _tmp2_);

and deleting the &_tmp1_ leads to successful compilation. Is this a bug, or
is there something I'm missing?

That would be a bug in the bindings.

For normal array passing, Vala expects to receive the pointer as return value
and the length by reference. If that's not the case (I suppose it returns
NULL-terminated array, right?), the return value needs some attributes.

It will need
    [CCode (array_length = false)]
like you can see two lines below. If it's indeed NULL-terminated, it will
also need "array_null_terminated = true", so together
    [CCode (array_length = false, array_null_terminated = true)]
and I suppose the caller is not responsible for freeing the pointer, so
I guess it will also need
    unowned
(like two lines below).

Check the documentation, try out and share the results.

Regards,
Jan

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



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