Is Ruby has something equivalent to ctypes in Python?

S

Shin guey Wong

I would like to load dll and create complex c datatype structure for the
dll. This can be done with ctypes library in Python.
So, do ruby has similar library like ctypes?
 
C

Charles Oliver Nutter

Shin said:
I would like to load dll and create complex c datatype structure for the
dll. This can be done with ctypes library in Python.
So, do ruby has similar library like ctypes?

On Rubinius and JRuby, you can use FFI. I'm hoping someone can do an FFI
port for MRI so everyone can start using the same library.

Here's a couple articles on FFI. JRuby and Rubinius support roughly the
same API, though it's probably going to see one or two more changes
before we release it in JRuby 1.1.4.

http://pluskid.lifegoo.com/?p=370#ffi-doc

http://wiki.jruby.org/wiki/Calling_C_from_JRuby

There also exists the "dl" library on Ruby, but most people I've talked
to consider it to be a bit too buggy/leaky for use. I don't know if
that's true.

- Charlie
 
S

Shin guey Wong

Charles said:
On Rubinius and JRuby, you can use FFI. I'm hoping someone can do an FFI
port for MRI so everyone can start using the same library.

- Charlie

Is the FFI for Rubinius and JRuby compatible? It would be great is all 3
ruby implementation using the same library.
 
A

A P

[Note: parts of this message were removed to make it a legal post.]

Ruby/DLhttp://ttsky.net/ruby/ruby-dl.html

Doc is a bit scarce, I've had better luck reading source, but it generally
does the job.
 
C

Charles Oliver Nutter

Shin said:
Is the FFI for Rubinius and JRuby compatible? It would be great is all 3
ruby implementation using the same library.

It is compatible between JRuby and Rubinius, and will be in a production
release of JRuby this month (1.1.4). We're looking for help getting an
FFI for the C Ruby implementations as well so everyone can use the same
library.

- Charlie
 
E

Emmanuel Oga

Until a uniform solution is done, you can give a try to
http://www.dyncall.org/, it has ruby bindings.

Greets!

It is compatible between JRuby and Rubinius, and will be in a production
release of JRuby this month (1.1.4). We're looking for help getting an FFI
for the C Ruby implementations as well so everyone can use the same library.

- Charlie



--
Emmanuel Oga
ELC Technologies (TM)
1921 State Street
Santa Barbara, CA 93101
(e-mail address removed)

(866)863-7365 Tel
(866)893-1902 Fax

+44 (0) 20 7504 1346 Tel - London Office
+44 (0) 20 7504 1347 Fax - London Office

http://www.elctech.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top