Re: [Vala] Mapping unnamed nested structs from C lib to Vala



Am 14.07.2012 09:44, schrieb Luca Bruno:
On Sat, Jul 14, 2012 at 12:12 AM, foracc <foracc d00m info> wrote:

Hey there,

I got an unnamed struct nested in another struct in a C library. Like this:

         typedef struct {
                 int a;

                 struct {
                         int x;
                         int y;
                 } vals;
         } mystruct;

How would I map that to Vala? I tried this:

         [Compact]
         [CCode (cheader_filename="mylib.h", cname="mystruct")]
         public struct mystruct {
                 public int a;

                 [CCode (cname="vals.x")]
                 int x;
                 [CCode (cname="vals.y")]
                 int y;
         }

It works, but isn't faithful to the original C library, and will run into
problems if the outer struct has equally named fields as the nested struct.


Call them vals_x, vals_y.


That'd certainly work, but what if the C struct is an array? I.e.

        typedef struct {
                int a;

                struct {
                        int x;
                        int y;
                } vals[10];
        } mystruct;

Regards



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