Log in

No account? Create an account
More FFI - Testing 1,2,3... [entries|archive|friends|userinfo]

[ website | Netrunner Tracker ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Links:| Ruby Home RubyForge RAA comp.lang.ruby Ruby Documentation ]

More FFI [Dec. 14th, 2011|10:30 am]
[Tags|, ]
[mood |calmcalm]

Lately I've converted a few of my smaller Ruby libraries that were using C extensions to use the ffi gem. Specifically, sys-cpu, sys-uname and sys-uptime now all use FFI behind the scenes. They all now work with JRuby, too. Yay.

I'm still not enamored with FFI, though. It has added some features for automatic struct allocation which is good, but it still has most of the issues I complained about originally. In fact, another issue I didn't mention last time is that there's no way to automatically import simple macro definitions from header files. This again means manually inspecting header files if you want to use sensical constant names instead of raw numbers. To make matters worse, sometimes different platforms have the same macro with different values. To wit HW_MACHINE_ARCH is set to 11 on BSD, but 12 on other platforms. Fun.

And, converting those three gems to use FFI took much, much longer than it should have. It's still much easier for me to use C extensions. So, my more complex C extensions will not be converted any time soon, and probably only if I'm actually paid to do it.