Re: [Vala] CCode array length field name
- From: Evan Nemerson <evan coeus-group com>
- To: pHilipp Zabel <philipp zabel gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] CCode array length field name
- Date: Mon, 30 Nov 2009 15:09:43 -0800
On Mon, 2009-11-30 at 23:45 +0100, pHilipp Zabel wrote:
On Mon, Nov 30, 2009 at 10:19 PM, Jan-Jaap van der Geer
<jjvdgeer inbox com> wrote:
On Sun, 2009-11-29 at 00:38 +0100, pHilipp Zabel wrote:
vapi binding:
public class SomeStruct {
[CCode (array_param_name?...)] // what should this be ?
[CCode (array_length_name = "dataLength", array_length_type = "size_t")]
Not sure if that should be size_t or gsize.
I have something related. I have the following struct in C:
typedef struct
{
int errnum;
char errmess[252];
} os_error;
Right now I have this vapified like this:
[CCode (cname == "os_error")]
public struct error
{
public unowned int errnum;
public unowned char[] errmess;
}
However, when accessing the error.errmess.length I get compilation
errors (in C,, not in Vala. error: 'os_error' has no member named
'errmess_length1'). I suppose this is due to a problem in the vapi, but
I am not really sure how to tell Vala the length is 252 bytes.
I tried prefixing the errmess member with:
[CCode (array_length_name = "252", array_length_type = "int")]
but that did not seem to make a difference.
Any ideas?
[CCode (array_length = false)] will make Vala turn errmess.length into
constant -1 instead of errmess_length1. I don't know of any way to
make that constant 252 instead.
IIRC this should do the trick:
[CCode (cname == "os_error")]
public struct error {
public unowned int errnum;
public unowned char errmess[252];
}
If errmess is null-terminated and utf-8 encoded, you could wrap it as
a weak string.
I agree, binding it as a string is likely the right way to go.
-Evan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]