[Ironruby-core] Initializing external Ruby libraries

Peter Bacon Darwin bacondarwin at googlemail.com
Wed Feb 13 20:00:39 EST 2008

I believe the library side of this mechanism is already in-place.


Take a look at the \trunk\src\IronRuby.Libraries\Initializer.Generated.cs
file which is automatically generated by the
\trunk\src\IronRuby.Libraries\GenerateInitializers.cmd.  The cmd file
reflects on the compiled library file, reading the RubyClass, RubyMethod,
etc. attributes and generates the initialize code you describe below.  You
can see this in action inside \trunk\src\ironruby\Runtime\Loader.cs :


What appears to be missing is the hosting side of things when you "require"
one of these assemblies.  There doesn't seem to be any point in the assembly
loading process that checks for a LibraryInitializer class and runs the
LoadModules method.


Is that what you meant?


From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Wayne Kelly
Sent: Wednesday,13 February 13, 2008 23:59
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Initializing external Ruby libraries


For Ruby libraries such as sockets, openssl etc (ie not built-in classes or
modules), I assume we will implement/port them using say C# to produce a
managed dll (eg socket.dll). Client programs will then require 'socket', and
IronRuby will load socket.dll rather than socket.so


I note IronRuby already has the ability to load managed dlls such as
mscorlib - but that appears to simply load the assembly and then presumably
uses .NET reflection to expose the .NET classes as Ruby classes. But for
managed dll such as socket.dll that has been specifically engineered as an
IronRuby extension dll, I image the loading process would be a little
different? CRuby, for example exposes an Init_Foo function which explicitly
calls define_class, define_method etc to explicitly register each of the
Ruby classes implemented by that library (equivalent to what IronRuby does
in LibrariesInitializer.LoadModules).


Will there be a similar convention used by IronRuby? Possibly in static
class constructors?


Cheers, Wayne.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20080214/690b6f5c/attachment.html 

More information about the Ironruby-core mailing list