Ruby/DL how to struct 
Author Message
 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



Mon, 30 May 2005 05:47:52 GMT  
 Ruby/DL how to struct
At Thu, 12 Dec 2002 06:47:52 +0900,

Quote:
>   typealias "sint16", "signed short"

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

Quote:
>   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.

Quote:
>  Ggi_clut = struct [ "uint16 size", "Ggi_color data *" ]

Use "void *" for representing a pointer type as follows.

  Ggi_clut = struct [ "uint16 size", "void *data" ]
--



Tue, 31 May 2005 02:18:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Ruby/DL with GTK gtk_signal_connect

2. Array of structs in Ruby

3. Problem with Struct in Ruby 1.8.0

4. Ruby-swig for C struct plus methods

5. C-API: Setting a Ruby-Object in a wrapped C struct

6. Nested structs and struct.pack

7. struct module + array module = ? ( reading C structs )

8. pthread trouble with ruby-opengl on FreeBSD (was: Re: [announcement] Ruby 3D Ruby)

9. Ruby books (Ruby NG FAQ, Ruby FAQ, home page)

10. {QUAD}DL and system performance

11. cannot DL ur modified TPL

12. EasyResizeAndSplit ver 1.06 - new DL!!!

 

 
Powered by phpBB® Forum Software