John Lam (IRONRUBY) wrote:
Wayne Kelly:
The mapping from Ruby library name to the assembly and namespace is
established via .rb files:
thread.rb:
load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.Threading'
openssl.rb:
load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.OpenSsl'
The files are included in the solution and their build action is set
to "copy if new", which means they are copied to the output directory
during the build. ir.exe includes the directory it is located in into
the load paths list ($:), so the .rb files copied there are found by
the standard Ruby require/load mechanism.
So what if some legacy code requires 'thread.so' or 'opensll.so'? Can
we set it up so that it automatically loads the corresponding library?
I'm not sure what the best solution to this problem is here - we should
probably throw an exception if *.so/.dll does not refer to a .NET assembly.
It's unlikely that existing code will require thread.so rather than thread.rb.
Charlie - what does JRuby do in this case?
In Ruby, load path searching is partially determined by the extension.
If you try to require a file with no extension, it looks first for that
file with a .rb extension, then for that filename as a .so library (or
.dll, or whatever the library extension is). If you try to load a file
with no extension, it will only ever search for exactly that file with
no extension.
In JRuby, we just use the .so/.dll as a marker for searching for
extensions, skipping the search for .rb. And in the cases of
thread.rb/thread.so, we just have a very small thread.rb file that loads
our actual extension, thread.so. In fact, most of the code extensions we
have defined to be .so, .rb, or sometimes both so that any load will
find them.
- Charlie
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core