[Rubydotnet-developer] rubydotnet project
Status: Alpha
Brought to you by:
thomas
From: Thomas S. <th...@th...> - 2003-07-17 13:53:54
|
I haven't researched any of this thoroughly yet, but here is my initial ideas on how to integrate ruby with the .net runtime, so code defined in .net assemblies can be used from ruby. My idea is to write a ruby extension module in C, that hosts the .net runtime. I have done enough research to discover that there is indeed a hosting interface to the .net runtime, but I have not yet determined what level of interaction with the runtime you can achieve using the C or COM interface. I have ventured a rough road map and time map for one developer. 1. Empty (dummy) rubydotnet module can build and be loaded without errors from ruby. (0.5 days) 2. ruby extension module hosts .net runtime (1 day) 3. .net classed can be referenced and instantiated from ruby 3.1 Accessing the runtime (tracer-bullit), accessing the code in .net assemblies and enumerating the Types defined there-in. (3 days) 3.2 Creating ruby shadow-class objects for classes and objects (2 days) 4. Support for .net delegates calling back to ruby using ruby code blocks (lambdas). (2 day) 5. .net classes and interfaces can be subclassed and methods overwritten/implemented in ruby will be appropriately invoked from .net 5.1 Dynamic code generation (using emit api and probably the C# compiler API in .net) of call forwarders, but without the actual calling into ruby (2 days) 5.2 Calling ruby from .net runtime (1 day, probably overestimated, seeing as delegates are already implemented) 6. Support for overriding overloaded methods and invoking overloaded methods (not estimated) 7. ?? My initial estimate sums up to about 12 days work - I must have overlooked a hell of a lot. I always write unit tests and the rubydotnet project will be very easy to write automated unit tests for, so the test coverage should be extensive. In my estimates I have included the time to write unit tests, but as I wrote, I think this should be very easy and not take much time. Here's a sample of what I expect the ruby code using the dotnet module to look like. It is, incidently, very similar to what Ben Schroeder already has working. >>>> BEGINNING OF SAMPLE require 'dotnet' reference 'mscorlib.dll' # Object.reference is added by dotnet module include System.Util.Collections # standard ruby, right? mylist = ArrayList.new mylist.Add(1) <<<< END OF SAMPLE I imagine that the "require 'dotnet'" call loads the extension module and initializes the .net runtime. I then suppose that the "reference 'mscorlib.dll'" loads that assembly into the runtime using the C/COM api of the .net runtime. It then enumerates the classes and interfaces defined in the assembly and creates ruby shadow modules (for namespaces) and ruby shadow classes (for classes and interfaces). These objects are then used to instantiate objects like usual. A .net object is wrapped in a ruby shadow object, that handles the calling into the .net runtime and any marshalling that may be necessary. I'm curious what you think. Best regards, Thomas |