From: Martin DeMello Date: 2009-06-16T03:11:25+09:00 Subject: Re: wrapping a C struct[] constant On Mon, Jun 15, 2009 at 7:13 PM, Jason Roelofs wrote: > > Could you give an example of how this would work? I'm having a hard time > picturing how such a thing would be possible to have done automagically. > There has to be something somewhere that defines how a Ruby class would map > to said C struct. Yes, I was simply looking for something like struct foo { int bar; char *baz; } cFoo = rb_define_class('cFoo') rb_map_struct(cFoo, foo) rb_accessor(cFoo, 'int', 'bar', bar) rb_accessor(cFoo, 'str', 'bar', bar) VALUE rb_function() { foo* a = some_function_call() return rb_deserialize_data(foo) } and from ruby foo = rb_function foo.bar foo.baz martin