DLX / Ruby Dynamic Loader eXtreme

The Elegant Interface Between Ruby & C

Search

Latest news

Jul 9 For those of you who have been following this project, I am currently about 90% done in rewriting the complete codebase of Ruby/DLX in C (for the most part of it anyway). ...
more

Apr 21 Okay guys, Ruby/DLX 0.8.2 has been released. ...
more

Links:

Ruby/DLX FAQ (Frequently Asked Questions)

General Questions

What is Ruby/DLX ?
Ruby/DLX is a Ruby extension that allows you to load and use shared libraries from within Ruby. To use such libraries using Ruby/DLX you do not have to program an extension in C ever again! All you need to do this to specify the original prototypes of all functions and all data types that you wish to use in Ruby, everything else is done right for you.
Isn't Ruby/DLX the same as Ruby/DL ?
No. I originally came up with the idea of Ruby/DLX by using Ruby/DL (and later Ruby/DL2). For calling simple functions like:

void usleep(unsigned long usec);

Ruby/DL might suffice, but when you really want to use any shared library that is coming your way in a simple and quick fashion, you'll soon learn the limitations of Ruby/DL.

To put it simply: using lots of —possibly nested— data types, that are passed to or returned from functions, that may have many fields that you might want to access, callback functions etc.. etc.. is not going to be fun in Ruby/DL. It's just not well enough equipped for that job, but Ruby/DLX is! For an extensive comparison click here
Why did you choose version 3 of the GNU Public License ?
I see a very hostile world coming towards the free software community, a world in which the Copyright maffia and global companies do not only control Software, but, due to digital convergence, also control hardware and determine which software runs on that hardware. I want to prevent any such attempt of a big company to use the results of my efforts in such a DRM-locked scenario.

To quote Eben Moglen, counsel for the FSF, himself:

Another important area is trusted computing, "which means computers you cannot trust," Moglen said, adding that if the FSF uses its leverage correctly, it could affect what kinds of trust are recognized in the network.

But if we don't use our leverage correctly, we could wind up in a world where free software is injured very badly, where you can modify code but you cannot do anything with that modified code because the hardware will not run that code because it cannot be signed 'Microsoft or IBM,'

If that happens, free software will be excluded from hardware, and that is not an outcome we can tolerate. eweek, November 2004

Warnings & Errors

I keep getting errors like:

Fatal DLX error: definition of struct FooBar is using an incomplete type: Baz (./mylib/mysource.rb:11)

but I definately have a typealias that should handle this type:

typealias( "Baz*", "void*" );

What am I doing Wrong?
While you have a typealias that defines the type 'Baz*' to be a 'void*', you do not define the type 'Baz' itself. struct FooBar, however, uses type 'Baz' as a here-struct (i.e. a struct inside a struct, as opposed to a struct* inside a struct). This has implications on the way the memory for 'struct FooBar' should be laid out and -thus- you need to give a full specification of 'Baz' in order for the type closure to succeed.
I keep getting errors like:

dlx/DLXImport.rb:250:in `call': no implicit conversion from nil to integer (TypeError)

What am I doing Wrong?
You should check the prototype of the function you are calling (should be on the line direct below). It is likely that you are passing a ruby integer value to a function that expects a pointer.
If you really have the address of a pointer and want to pass it to the function you should consider wrapping it inside a DLXCPtr (DLXCPtr.wrap( addr )), however, if all you wanted to pass is a 0, then pass the function a nil instead.