Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3722
| From | Joel VanderWerf <joelvanderwerf@gmail.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Building extention with multiple classes |
| Date | 2011-04-29 17:32 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <4DBB3C76.8020805@gmail.com> (permalink) |
| References | <3ec123b0b692087d2e4c8472a3ba1eb9@ruby-forum.com> |
On 04/29/2011 02:39 PM, Richard Shinn wrote:
> Hello,
>
> I have been successful at building a ruby extension that contains one
> new class and now I would like to build multiple classes. I am wondering
> what is the best way to do this.
Take a look at the ext/ dir in ruby's source. For example, in socket.c:
void
Init_socket()
{
rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
This snippet defines two classes. Farther down you'll see the
rb_define_method() calls to associate the C functions that implement
methods, and also the C functions themselves. These functions can just
as well be defined in separate .c files in the same dir. They will get
found by extconf.rb (in the create_makefile call, IIRC).
Back to comp.lang.ruby | Previous | Next | Find similar | Unroll thread
Re: Building extention with multiple classes Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-04-29 17:32 -0500
csiph-web