[Ironruby-core] Code Review: RubyLibsAndYaml

Tomas Matousek Tomas.Matousek at microsoft.com
Sun May 18 00:47:13 EDT 2008

tfpt review /shelveset:RubyLibsAndYaml;REDMOND\tomat

Adjusts class-initializer generator to enable generating initializers for multiple libraries within a single assembly.
Also enables extending existing Ruby modules and classes that are defined in C# libraries (previously only CLR classes could have been extended). For example, the following class adds additional methods on Kernel module:

[RubyModule(Extends = typeof(Kernel))]
public static class MyKernelOps {
  public static void Foo() { ... }

The type specified in Extends parameter is the C# class defining the module/class.

Enables to group C# classes and modules into Ruby libraries (e.g. thread, socket, openssl, yaml, etc.). Each library is identified by a root namespace. All Ruby classes and modules of the assembly defined within the namespace are considered parts of the library. The shelveset updates namespaces in IronRuby.Libraries.dll to group classes by library:


The list of namespaces that define libraries within an assembly is passed to the generator:

ClassInitGenerator IronRuby.Libraries.dll /libraries:Ruby.Builtins;Ruby.StandardLibrary.Threading;Ruby.StandardLibrary.Sockets;Ruby.StandardLibrary.OpenSsl;Ruby.StandardLibrary.Digest;Ruby.StandardLibrary.Zlib /out:Initializers.Generated.cs

The mapping from Ruby library name to the assembly and namespace is established via .rb files:

load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.Threading'

load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.OpenSsl'


(Kernel#load_assembly now takes an optional second argument identifying the library to load by its root namespace).

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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: RubyLibsAndYaml.diff
Type: application/octet-stream
Size: 709321 bytes
Desc: RubyLibsAndYaml.diff
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080517/a511faf1/attachment-0001.obj>

More information about the Ironruby-core mailing list