# Fwd: Ruby FFI port

**URL:** <https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030>\
**Category:** IronRuby\
**Created:** [March 28, 2011, 1:46am UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030 "2011-03-28T01:46:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 28, 2011, 1:46am UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/1 "2011-03-28T01:46:27Z")

</div>

Well, I think I’ve made a little progress - hoping to attach a simple  
function soon.

I am concerned about one thing though - we need to be able to call  
function  
pointers, but I think that _Marshal.GetDelegateForFunctionPointer_ only  
supports the STD calling convention. Any thoughts on how we might  
support  
cdecl? Presently, it’s not a blocking concern - so I’ll cross that  
bridge  
when the time comes…

Wayne: Sorry - I meant to send that to the mailing list, as opposed to  
sending it directly to you.

-Charles

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [March 31, 2011, 12:02pm UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/2 "2011-03-31T12:02:44Z")

</div>

Well, with some really, \*really \*ugly hacking, I’ve managed to get this  
far  
(the first example from FFI wiki):

irb(main):011:0\> module Hello  
irb(main):012:1\> extend FFI::Library  
irb(main):013:1\> ffi\_lib FFI::Library::LIBC  
irb(main):014:1\> attach\_function ‘puts’, [:string], :int  
irb(main):015:1\> end  
_(Object doesn’t support #inspect)_  
=\>  
irb(main):016:0\> Hello.puts(“Hello, World”)  
Hello, World  
=\> 0

(dunno why that _“(Object doesn’t support #inspect)”_ shows up…)

Anywho, I think we might might have a significant portion of FFI  
implemented  
fairly soon. The codebase is still pretty unstable/crappy, but I’m  
hoping  
to get it ready for contributions soon.

-Charles

On Sun, Mar 27, 2011 at 6:28 PM, Charles S. \<

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [March 31, 2011, 12:06pm UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/3 "2011-03-31T12:06:26Z")

</div>

> I am concerned about one thing though - we need to be able to call function  
> pointers, but I think that _Marshal.GetDelegateForFunctionPointer_ only  
> supports the STD calling convention. Any thoughts on how we might support  
> cdecl? Presently, it’s not a blocking concern - so I’ll cross that bridge  
> when the time comes…

D’oh! I overlooked the  
UnmanagedFunctionPointerAttribute[http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.unmanagedfunctionpointerattribute.aspx](http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.unmanagedfunctionpointerattribute.aspx)  
.

-Charles

On Thu, Mar 31, 2011 at 4:41 AM, Charles S. \<

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [April 1, 2011, 2:21am UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/4 "2011-04-01T02:21:41Z")

</div>

Ryan,

I’m _absolutely_ interested, but, as much as it shames me to say, the  
[ALT.NET](http://ALT.NET) Seattle conference wasn’t on my radar until just now.

I’m down for next year though, especially if you plan to give an F#  
workshop.

-Charles

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [March 31, 2011, 3:51pm UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/5 "2011-03-31T15:51:18Z")

</div>

Are you coming to [ALT.NET](http://ALT.NET) Seattle? We have an OSS track this year to  
help people learn how to contribute to projects. Interested?

Ryan

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [April 4, 2011, 1:46pm UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/6 "2011-04-04T13:46:28Z")

</div>

All,

IronRuby FFI is coming along well. So far, I support most of the  
FFI::Function uses, including attaching to function pointers, library  
functions, and wrapping Procs.

Structs are at 50%, and callbacks need to be implemented.

I’ll need just another week or two to cut the first release.

-Charles

On Thu, Mar 31, 2011 at 5:00 AM, Charles S. \<

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [April 24, 2011, 2:21am UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/7 "2011-04-24T02:21:44Z")

</div>

That’s a possibility, but it might have to come further down the road.

-Charles

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [April 14, 2011, 10:29pm UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/8 "2011-04-14T22:29:45Z")

</div>

> I’ll need just another week or two to cut the first release.

Maybe it can merge with mainline ffi gem at some point?  
-r

---

<div class="post-metadata">

**Author:** ![valdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@valdar](https://www.ruby-forum.com/u/valdar)\
**Post date:** [June 4, 2011, 11:31am UTC](https://www.ruby-forum.com/t/fwd-ruby-ffi-port/205030/9 "2011-06-04T11:31:42Z")

</div>

I just wanted to check how the Ruby FFI library was coming along?
