# RubyInline

**URL:** <https://www.ruby-forum.com/t/rubyinline/74761>\
**Category:** Ruby\
**Created:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/rubyinline/74761 "2006-11-07T10:55:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@joey](https://www.ruby-forum.com/u/joey)\
**Post date:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/rubyinline/74761/1 "2006-11-07T10:55:23Z")

</div>

So, Im trying to move away from mkmf, and onto RubyInline.  
I can’t work out how to define alloc functions from Inline, I tried  
something like:

class Y  
inline :C do |builder|  
builder.c \<\<-ENC  
void Init\_Y(){

```
  }
ENC

```

end  
end

but that makes Init\_Y a instance method, and I’m unsure of how to get  
the  
klass.

Has anyone done this before?

Thanks,  
Joey  
[http://www.eachmapinject.com](http://www.eachmapinject.com)

---

<div class="post-metadata">

**Author:** ![joey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@joey](https://www.ruby-forum.com/u/joey)\
**Post date:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/rubyinline/74761/2 "2006-11-07T11:04:34Z")

</div>

On Nov 2, 2006, at 9:15 AM, Joey wrote:

> So, Im trying to move away from mkmf, and onto RubyInline.  
> I can’t work out how to define alloc functions from Inline, I tried  
> something like:

[rearanged]

> but that makes Init\_Y a instance method, and I’m unsure of how to  
> get the  
> klass.
> 
> Has anyone done this before?
> 
> class Y  
> ^^^^^^^

this says you are in a class.

> inline :C do |builder|  
> builder.c \<\<-ENC  
> void Init\_Y(){
> 
> ```
> }
> 
> ```
> 
> ENC

Don’t do this, define initialize instead. If you need to add things  
to the Init method, use the hook for it (I forget what it is called).

> end  
> end

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
