Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3722 > unrolled thread

Re: Building extention with multiple classes

Started byJoel VanderWerf <joelvanderwerf@gmail.com>
First post2011-04-29 17:32 -0500
Last post2011-04-29 17:32 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.ruby

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Building extention with multiple classes Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-04-29 17:32 -0500

#3722 — Re: Building extention with multiple classes

FromJoel VanderWerf <joelvanderwerf@gmail.com>
Date2011-04-29 17:32 -0500
SubjectRe: Building extention with multiple classes
Message-ID<4DBB3C76.8020805@gmail.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).

[toc] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web