[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rb_struct_new

nornagon

5/31/2005 5:02:00 AM

Hi. I'm documenting a C extension, and I'm having a little bit of
trouble figuring out what rb_struct_new does. I would check the return
value of that particular function, but I am currently running windows
and the extension is linux-only.

Could anyone point me in the right direction?

Thanks.
--
- nornagon


2 Answers

Tim Hunter

5/31/2005 12:14:00 PM

0

nornagon wrote:
> Hi. I'm documenting a C extension, and I'm having a little bit of
> trouble figuring out what rb_struct_new does. I would check the return
> value of that particular function, but I am currently running windows
> and the extension is linux-only.
>
> Could anyone point me in the right direction?
>
> Thanks.

It's basically the same as the Ruby code "Struct.new". The first
argument is the name of the new class. Succeeding arguments are the
names of the structure fields. The last argument is NULL. It returns a
new Struct class.

Daniel Berger

5/31/2005 12:19:00 PM

0

nornagon wrote:
> Hi. I'm documenting a C extension, and I'm having a little bit of
> trouble figuring out what rb_struct_new does. I would check the return
> value of that particular function, but I am currently running windows
> and the extension is linux-only.
>
> Could anyone point me in the right direction?
>
> Thanks.
> --
> - nornagon

It creates a new struct, one that you've defined previously with
rb_struct_define(). So, something like this:

VALUE rbMyStruct = rb_struct_define("MyStruct","foo","bar",0);
VALUE rbVal = rb_struct_new(rbMyStruct, ...);

I'm not sure why you think this is a Linux only function. It works
perfectly fine on Windows.

Regards,

Dan