Ruby/DL how to struct

i’m trying to write a binding for the ggi library using Ruby/DL, but i am
unclear on how to best deal with a couple of issues.

for instance given this from the header file:
typedef signed short sint16;
typedef struct { sint16 x, y; } ggi_coord;

how does one translate this to Ruby/DL? i put:
typealias “sint16”, "signed short"
Ggi_coord = struct [ “sint16 x”, “sint16 y” ]

but it dosen’t work, saying that sint16 is an unknown type.

and what about:
typedef struct { uint16 r,g,b,a; } ggi_color;
typedef struct { uint16 size; ggi_color *data; } ggi_clut;

i put:
Ggi_color = struct [ “uint16 r”, “uint16 g”, “uint16 b”, “uint16 a” ]
Ggi_clut = struct [ “uint16 size”, “Ggi_color data *” ]

which bombs on Ggi_color data *.

i’m not a c coder so i’m sort of pecking my way through this. any help is
greatly appreciated.

-transami

At Thu, 12 Dec 2002 06:47:52 +0900,

typealias “sint16”, “signed short”

“signed” is not handled by Ruby/DL, so use “short”.

Ggi_coord = struct [ “sint16 x”, “sint16 y” ]

“uint16” is not defined. You should define it by yourself as follows.

typealias “uint16”, “unsigned short”

In the above example, I assume that sizeof(short) is 2.

Ggi_clut = struct [ “uint16 size”, “Ggi_color data *” ]

Use “void *” for representing a pointer type as follows.

Ggi_clut = struct [ “uint16 size”, “void *data” ]

···


Takaaki Tateishi ttate@kt.jaist.ac.jp