rubydotnet-developer Mailing List for rubydotnet (Page 4)
Status: Alpha
Brought to you by:
thomas
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(26) |
Aug
(3) |
Sep
(41) |
Oct
(1) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(6) |
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(3) |
Jul
(3) |
Aug
(2) |
Sep
|
Oct
(3) |
Nov
|
Dec
|
From: Tim S. <ti...@ih...> - 2003-07-21 10:40:18
|
On Sun, Jul 20, 2003 at 06:26:42PM -0400, Richard Kilmer wrote: > Tim, > > I got it, downloaded it, and am going to look through it later tonight. > > Thank you so much for posting it. I changed the interface tonight to that you can do DotNet.System.Console.WriteLine("Hello C# World!") rather than console = DotNet::Class.new('System.Console') console.WriteLine("Hello C# World!") Likewise with assemblies you have loaded. I just need to change the implementation a bit (I did the naive thing and just created a tree of nodes corresponding to everything in mscorlib. Unfortunately, this uses 10 megs of memory, so I'll probably use delayed evaluation to only load what is requested.) |
From: Richard K. <ri...@in...> - 2003-07-20 22:26:40
|
Tim, I got it, downloaded it, and am going to look through it later tonight. Thank you so much for posting it. -rich On Sunday, July 20, 2003, at 06:21 PM, Tim Sutherland wrote: > Did the message I sent last night giving a URL to download my library > get > through? I can't see it on the mailing list archive. > > I accidently sent it to rub...@sf... rather than > lists.sf.net, it came through to me but I'm not sure if it worked > properly. > > -- > "The subspace W inherits the other 8 properties of V. And there aren't > even any property taxes." > -- J. MacKay, Mathematics 134b > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Rubydotnet-developer mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer > |
From: Tim S. <ti...@ih...> - 2003-07-20 22:21:20
|
Did the message I sent last night giving a URL to download my library get through? I can't see it on the mailing list archive. I accidently sent it to rub...@sf... rather than lists.sf.net, it came through to me but I'm not sure if it worked properly. -- "The subspace W inherits the other 8 properties of V. And there aren't even any property taxes." -- J. MacKay, Mathematics 134b |
From: Tim S. <ti...@ih...> - 2003-07-20 10:05:14
|
Here is a (pre-)release of my library. (Under a BSD/MIT-style license). It allows Ruby to call DotNet libraries and DotNet to call Ruby libraries. http://www.sdkacm.com/tim/rubydotnetproxy-0.1.zip md5sum: 824940d6c08a744c32b658a707e05007 This file includes (Windows) binaries plus source code and some documentation. |
From: Tim S. <ti...@ih...> - 2003-07-19 11:06:12
|
On Fri, Jul 18, 2003 at 12:38:20PM -0700, John R. Pierce wrote: > Okay -- so disregard my previous post about the live Ruby / DotNet demo > being so secret. I tightened up security by downgrading my aspnet_wp.exe > process to run in a very under-priviledged account. > > So, without futher delay, the web address you want to check out to play > with Ben Schroeder's and John Pierce's Ruby / DotNet bridge is as follows: > > http://john.pierce.name/webevaluator Hi John. Good to hear from you. I'll try to package my library up over the next day or two so that people can play with it. |
From: Richard K. <ri...@in...> - 2003-07-19 03:54:33
|
All, I did not quite know where to post this, and I hope this list is ok... I have been thinking a bit on how to allow a developer to annotate their class's methods with parameter types when used externally by statically typed languages (Java, C#, SOAP). I want to present a syntax, and at the bottom have the code to back it up. Given the following class: class Account def Account.open(first, last) end def close end def add(money) end def remove(money) end def transfer(money, account) end end And assuming you wanted to make that accessible for statically typed systems you would just do this: require 'extern' class Account extern :Account.open, :return[Account], :first[String], :last[String] def Account.open(first, last) end extern :close def close end extern :add, :money[Float] def add(money) end extern :remove, :money[Float] def remove(money) end extern :transfer, :money[Float], :account[Account] def transfer(money, account) end end So, for each method you want to externalize you just include the 'extern' call. Usage: extern <method symbol>, [ [<:return[Classname]>], <:param[Classname]>, ... ] To reflect on this metadata you do: Account.each_externalized_method do | method | puts method.to_s end Which outputs: Account Account.open(String first, String last) NilClass close() NilClass add(Float money) NilClass remove(Float money) NilClass transfer(Float money, Account account) You can, of course, inspect the method (ExternalMethodDefinition instance) instead of printing it out. So this creates a runtime structure to store type information about methods, which again is useful is you want to bridge .NET to Ruby at the level of having a CLR type subclass a Ruby class, or generate a CLR type that represents a Ruby class. Of course, since Ruby's classes are open, you can define this extern metadata on existing classes: class ThreadGroup extern :ThreadGroup.new, :return[ThreadGroup] extern :add, :return[ThreadGroup], :thread[Thread] extern :list, :return[Array] end So what do folks think about the syntax? -rich PS...here is the magic code that makes this syntax work: ________ BEGIN 'extern.rb' _________ class ExternalMethodDefinition attr_accessor :klass, :name, :return_type Parameter = Struct.new(:name, :type) @@definitions = Hash.new([]) def self.[](klass) @@definitions[klass] end def initialize(klass, name, *parameters) list = @@definitions[klass] unless list list = [] @@defintions[klass] = list end list << self @klass = klass @name = name.to_s @name.gsub!(/__/, '.') @parameters = [] parameters.each do |param| if param.name=="return" @return_type = param.type else @parameters << param end end @return_type = NilClass unless @return_type end def add_parameter(name, type) unless type.kind_of?(Class) raise "Parameter #{name}'s type on method '#{@name}' of class '#{@klass}' must be a Ruby class" end if name == :return @return_type = type else @parameters << Parameter.new(name.to_s, type) end end def each_parameter @parameters.each {|param| yield param} end def to_s params = (@parameters.collect {|param| param.type.to_s+' '+param.name}).join(', ') return "#{@return_type.to_s} #{@name}(#{params})" end end class Symbol def [](klass=nil) if klass ExternalMethodDefinition::Parameter.new(self.to_s, klass) else (self.to_s+"__[]").intern end end def method_missing(method, *args, &block) if (?A..?Z).member?(self.to_s[0]) return (self.to_s+"__"+method.to_s).intern end super end end class Module def extern(method, *parameters) ExternalMethodDefinition.new(self, method, *parameters) end def each_externalized_method ExternalMethodDefinition[self].each { |exdef| yield exdef } end end ------ END 'extern.rb' ------ |
From: John R. P. <jo...@pi...> - 2003-07-19 01:07:35
|
Both Ben and I have discussed this to some extent. We agree that scripting .NET is a killer app. We use the Ruby / .NET bridge quite a bit now at our place of employment. Even though it is a bit experimental, we have used it to build developer tools and perform fixes on live product object systems in .NET. We are a SQL Server shop, and if you haven't used SQL Server, they have a really cool product called Query Analyzer to build and test SQL scripts in. Well, we've been called our Ruby / .NET bridge the Object Analyzer equivalent. We can connect to remote .NET objects and query them, manipulate them, and work them around in a very live way! Very cool stuff and a life saver at times. That said, the technology we have is not without its issues. More development is needed and some things will be just plain impossible without improved support from the CLR for dynamic languages. For instance, the technology we have constructed right now is using TCP sockets to form the bridge. From one perspective, the TCP socket bridge is really, really flexible and clients for SmallTalk, Perl, and Python could be built. After all, what language doesn't have a sockets library? Currently I am working on a native C extension to Ruby that will improve performance, when performance is more important. I hope to have that finished in a week's time. Lastly, both Ben and I discussed the current code base we have. We are going to release the bridge as Open Source (all the way). We also agree that the bridge, while enormously important technology, is not where the money is to be had. It is in the killer apps. So, time permitting, our code is coming to the community. We absolutely want to see it get further development from others in this space. Regards, John Pierce Executive Director, Information Services Prologue Research International, Inc. On Fri, 18 Jul 2003 18:57:44 -0400, Richard Kilmer wrote: > > Well, I want to bring this list up to date on why I am involved in this. > > Last week at OSCON I was invited to attend a dinner hosted by > Microsoft's .NET/CLR/Webservices teams and coordinated by Tim O'Reilly. > Present were the who's who of language creators including Matz (Ruby), > Larry Wall (Perl), Guido Von Rossum (Python). Also, Miguel de Icaza > (Mono), Dan Sugalski (Perl 6) and scores of web services folk. On the > Microsoft side was the product managers for .NET and the CLR teams and > David Stutz (former SSCLI manager). The discussion was about > integrating Perl/Python/Ruby with .NET. Its well known that when you > run a dynamic language on .NET it looses its dynamic nature and the > discussion went back and forth on the issues involved. The next day I > spoke for a couple of hours with Peter Drayton, product manager of the > CLR. I expressed an interest in binding the Ruby (current) runtime > with .NET as a first step, but to do it open-source (as in completely > open) as opposed to the ActiveState Perl (closed source) binding. He > offered any assistance that was needed to do this (people/time...no > $$). So, I going to start the coordination of such an effort when > Thomas sent his (well timed) email to the RubyTalk list. My plan was > to apply myself and someone who works for me (in a part time capacity) > to build the bridge. > > So, that's the history. I really think that scripting .NET with Ruby > would be a killer application space for Ruby, and open up all kinds of > commercial uses of it. One of my goals is to keep the .NET bridge open > and documented. The value is less in the bridge than the applications > it enables (not that the bridge itself is not important...its vital). > I would be interested in other folks views on this, especially John and > Ben who have working code. > > Best, > > Rich Kilmer > 571.332.6896 (cell) > > > On Friday, July 18, 2003, at 04:25 PM, John R. Pierce wrote: > > > The list just got off the ground yesterday. Mostly introductory > > messages about > > folks plans for developing Ruby and .NET based technologies have been > > discussed. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Rubydotnet-developer mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer |
From: Richard K. <ri...@in...> - 2003-07-18 22:57:46
|
Well, I want to bring this list up to date on why I am involved in this. Last week at OSCON I was invited to attend a dinner hosted by Microsoft's .NET/CLR/Webservices teams and coordinated by Tim O'Reilly. Present were the who's who of language creators including Matz (Ruby), Larry Wall (Perl), Guido Von Rossum (Python). Also, Miguel de Icaza (Mono), Dan Sugalski (Perl 6) and scores of web services folk. On the Microsoft side was the product managers for .NET and the CLR teams and David Stutz (former SSCLI manager). The discussion was about integrating Perl/Python/Ruby with .NET. Its well known that when you run a dynamic language on .NET it looses its dynamic nature and the discussion went back and forth on the issues involved. The next day I spoke for a couple of hours with Peter Drayton, product manager of the CLR. I expressed an interest in binding the Ruby (current) runtime with .NET as a first step, but to do it open-source (as in completely open) as opposed to the ActiveState Perl (closed source) binding. He offered any assistance that was needed to do this (people/time...no $$). So, I going to start the coordination of such an effort when Thomas sent his (well timed) email to the RubyTalk list. My plan was to apply myself and someone who works for me (in a part time capacity) to build the bridge. So, that's the history. I really think that scripting .NET with Ruby would be a killer application space for Ruby, and open up all kinds of commercial uses of it. One of my goals is to keep the .NET bridge open and documented. The value is less in the bridge than the applications it enables (not that the bridge itself is not important...its vital). I would be interested in other folks views on this, especially John and Ben who have working code. Best, Rich Kilmer 571.332.6896 (cell) On Friday, July 18, 2003, at 04:25 PM, John R. Pierce wrote: > The list just got off the ground yesterday. Mostly introductory > messages about > folks plans for developing Ruby and .NET based technologies have been > discussed. |
From: John R. P. <jo...@pi...> - 2003-07-18 20:25:13
|
Hi Richard, The list just got off the ground yesterday. Mostly introductory messages about folks plans for developing Ruby and .NET based technologies have been discussed. Actually, this morning the archive was working and capturing messages, but now it appears to be erroring out. Who knows what is going on? Regards, John On Fri, 18 Jul 2003 15:50:28 -0400, Richard Kilmer wrote: > > Hey all...the list is not being archived yet...what did I miss? > > -rich > > On Friday, July 18, 2003, at 03:38 PM, John R. Pierce wrote: > > > Okay -- so disregard my previous post about the live Ruby / DotNet > > demo being so > > secret. I tightened up security by downgrading my aspnet_wp.exe > > process to run > > in a very under-priviledged account. > > > > So, without futher delay, the web address you want to check out to > > play with Ben > > Schroeder's and John Pierce's Ruby / DotNet bridge is as follows: > > > > http://john.pierce.name/webevaluator > > > > Go to the following page for a brief introduction to WebScripts. It > > will give > > you a feel for what is possible by leveraging the Ruby / DotNet bridge > > in an > > application like Asp.NET. > > > > http://john.pierce.name/webevaluator?home > > > > Regards, > > > > John > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: VM Ware > > With VMware you can run multiple operating systems on a single machine. > > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > > _______________________________________________ > > Rubydotnet-developer mailing list > > Rub...@li... > > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Rubydotnet-developer mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer |
From: Richard K. <ri...@in...> - 2003-07-18 19:50:28
|
Hey all...the list is not being archived yet...what did I miss? -rich On Friday, July 18, 2003, at 03:38 PM, John R. Pierce wrote: > Okay -- so disregard my previous post about the live Ruby / DotNet > demo being so > secret. I tightened up security by downgrading my aspnet_wp.exe > process to run > in a very under-priviledged account. > > So, without futher delay, the web address you want to check out to > play with Ben > Schroeder's and John Pierce's Ruby / DotNet bridge is as follows: > > http://john.pierce.name/webevaluator > > Go to the following page for a brief introduction to WebScripts. It > will give > you a feel for what is possible by leveraging the Ruby / DotNet bridge > in an > application like Asp.NET. > > http://john.pierce.name/webevaluator?home > > Regards, > > John > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Rubydotnet-developer mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer > |
From: John R. P. <jo...@pi...> - 2003-07-18 19:38:24
|
Okay -- so disregard my previous post about the live Ruby / DotNet demo being so secret. I tightened up security by downgrading my aspnet_wp.exe process to run in a very under-priviledged account. So, without futher delay, the web address you want to check out to play with Ben Schroeder's and John Pierce's Ruby / DotNet bridge is as follows: http://john.pierce.name/webevaluator Go to the following page for a brief introduction to WebScripts. It will give you a feel for what is possible by leveraging the Ruby / DotNet bridge in an application like Asp.NET. http://john.pierce.name/webevaluator?home Regards, John |
From: Ben S. <bsc...@pr...> - 2003-07-18 13:30:53
|
Hi all, I've talked with a couple of you by private mail, but I thought I'd = write a quick introduction to the list as well. As John Pierce = mentioned, he and I have been working on a bridge from Ruby to Dot-Net. = Here is a basic example to show how code written using our bridge looks = - it's the same one I've sent in email to a couple of you. It starts a = Dot-Net machine, creates and manipulates an ArrayList, and uses = Enumerable methods to get a reversed copy. require 'dotnet' dotNet =3D DotNet.startNew list =3D dotNet.ArrayList.new list.add('Hello') list.add('World') puts list.count # -> prints <<2>> reversed =3D list.collect do |each| each.reverse end puts reversed.inspect # -> prints <<["olleH", "dlroW"]>> We automatically convert Strings and Fixnums to Dot-Net Strings and = Int32s, and vice-versa. We do the same with nil and booleans, and plan = to do so for floats and integers of different lengths. I think this = makes for smoother code, although it has the disadvantage of not = allowing calls to methods of the corresponding Dot-Net classes. (Maybe = a way to escape the behavior would be useful.) To create a Dot-Net object, you ask a DotNet instance for the class and = then send "new" to it, like any other Ruby class. You do not have to = use namespaces to qualify the class (one of my favorite ideas of John's = for this program), but may use them if a reference would otherwise be = ambiguous. The bridge will select one of the classes if you do not use = namespaces - which can be confusing. dotNet.ArrayList.new # -> a new ArrayList dotNet.System.Windows.Forms.Label.new # -> would otherwise be ambiguous = with=20 # = System.Reflection.Emit.Label Static methods can also be called using the class object. dotNet.ArrayList.repeat('a', 5) # -> a list containing 'a', 'a', 'a', = 'a', 'a' The class object can be used as a Type object when you pass it as a = parameter, and you can call static methods or constructors on Types. listType =3D dotNet.Type.getType('System.Collections.ArrayList') listType.getType.fullName # -> 'System.RuntimeType' listType.new # -> an ArrayList You can use any Dot-Net libraries with the bridge, including Windows = Forms. Here's an example of event handling for a simple button. dotNet.loadLibrary('System.Windows.Forms') button =3D dotNet.Button.new button.click.add do |sender, args| puts "Button clicked!" end button.performClick # -> prints <<Button clicked!>> As you have probably noticed, we do have to qualify everything through a = DotNet instance. dotNet.ArrayList.new dotNet.Hashtable.new # instead of=20 ArrayList.new Hashtable.new This is very flexible - for example, you could write a test program that = controlled a client and server - but is a bit inconvenient for the = common case where you're just controlling one Dot-Net VM from Ruby. = We've talked about ways to solve this, which I think others have = mentioned as well, like enumerating available types from a single = Dot-Net and introducing them as constants. There are still a lot of loose ends, and things we'd like to do, but we = have successfully used the program to write some small utilities and to = script objects from our production programs. I am planning to put = together some sort of "release" soon with more notes, but would of = course be happy to discuss anything here as well in the meantime. I'll put in a plug too for John's bridge-running webserver - I think = it's pretty neat. Regards, Ben Schroeder |
From: John R. P. <jo...@pi...> - 2003-07-18 11:22:53
|
Hello all, My name is John Pierce. I thought I'd introduce myself as well. I am the friend of Ben's that has been working on the Ruby/.NET bridge with him. I am currently working on the native C extension to make the bridge more performant, but we intend to leave the TCP socket-oriented bridge in tact for flexibility reasons. As far as really cool stuff, I have a live functioning demo on the web of the Ruby/.NET bridge where you can experiment and learn both Ruby and ASP.NET. The only trouble is that I we haven't found a way to sandbox both Ruby and the .NET side of the online demo. So if I tell you where it is at and others find it, they could slay my home machine (which is behind a firewall). I would be willing to send anyone a URL via private email as long as you promise you don't post it publicly and don't hack my home machine. The really nifty thing about the online web demonstration is that you can actually program ASP.NET web pages in Ruby syntax. You can new pages, add buttons, click handlers, content, client-side JavaScript, etc.... This is all possible because the Ruby context in which your Ruby code runs is based in the ASP.NET application that is hosting it. Really crazy -- we have a few sample pages demonstrating what I am saying. You gotta see to believe. Regards, John On Fri, 18 Jul 2003 07:03:44 +0100, "Thomas Sondergaard" wrote: > > Hi Tim > > Thanks for getting in contact. So both you and Ben have something that mostly > works - Excellent. There is a number of other people who are interested in > working on getting ruby/.net integration to work. Would you be interested in > collaborating with us? I think, if you and Ben, are willing a good next step > would be to get your code out in the public, so more people can start > contributing. > > Cheers, > > Thomas > > ---------- Original Message ----------- > From: Tim Sutherland <ti...@ih...> > To: rub...@so... > Sent: Fri, 18 Jul 2003 10:47:23 +1200 > Subject: [Rubydotnet-developer] Introduction > > > A few days ago I posted a message to rubytalk mentioning a library I > > am working on for allowing Ruby and DotNet to call each others' methods > > > > (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/75198) > > > > Since then I've been contacted by Ben Schroeder who told me about the > > similar project he has been working on, and who told me about this list. > > > > Status of my library: It mostly works, need to do more testing / > > documentation. (Well, write *any* documentation!) Ben's project has > > a richer interface e.g. uses Enumerable methods whenever a DotNet > > object supports Count (or Length) and get_Item. There are other > > things I'd like to implement like a "dotnet_methods" methods. > > > > I'll try to make a release soon under a BSD-ish license. > > > > My interface (calling DotNet methods from Ruby) looks like: > > # It would be nicer if this was > > # DotNet::System::Collections::Hashtable. > > hash_class = DotNet::Class.new('System.Collections.Hashtable') > > > > h = hash_class.new # h is an instance of DotNet::Instance > > h['a'] = [1, 2, 'three'] > > > > p(h['a']) # -> "[1, 2, \"three\"]" > > p(h.Count) # -> 1 > > > > # DotNet.new can be used just for type conversions. > > five = DotNet.new(5) # five is an instance of DotNet::Instance > > p(five.to_rb == 5) # -> true > > > > Type conversions: Integers, strings, arrays, nil, true, false are > > automatically converted to DotNet types. Calling 'to_rb' on a > > DotNet::Instance instance converts it to the Ruby type, if the object > > was one of the previously listed types. > > > > All operators/indexers are implemented (I believe). For relational > > operators (==, eql?, <, <=, >=, > ) we force the returned value to > > be a Ruby boolean. (Theoretically a DotNet library could implement > > '<' as returning e.g. an integer.) <=> is implemented using "== and > > <". == is implemented using Equals not op_Equality since e.g. > > System.Int32 only defines the former. > > > > I also implement "hash" in terms of "GetHash". > > > > When calling DotNet methods, if the method name ends in '=', we chop > > off the '=' and treat it as a SetField|SetProperty. Otherwise we use > > InvokeMethod|GetField|GetProperty. (My library uses > > GetType#InvokeMember.) > > > > At the moment I don't have any way to use DotNet delegates from the Ruby > > side. > > > > DotNet exceptions are mapped to DotNet::Exception Ruby exceptions, where > > 'message' is the same as the DotNet 'Message', and the 'dotnet_exception' > > attr_reader provides the original DotNet exception. > > > > >From the DotNet (e.g. C#) side, I can do things like > > RbType a = RbType.Eval('[1, 2, 3]'); > > int size = a.Call("size").ToInteger(); > > > > There are (implicit operator) conversions for integers, strings, > > arrays, null, true, false. > > > > You can use a delegate to represent a Ruby block, although I haven't > > tested this. I've implemented most operators in the usual way, although > > I forgot to do indexers -> [] and []=. > > > > Ruby exceptions are mapped into DotNet RbException types. > > > > Implementation wise, the code for calling Ruby from DotNet and > > calling DotNet from Ruby are mostly separate. They each use > > reference counting, which has the known problems e.g. circular references. > > > > The code is implemented in C# and C (Ruby extension.) There are > > about 8 lines of Microsoft's Extended C++ to allow for initialisation. > > > > The code does not run on Mono yet (http://www.go-mono.com/) because > > of a couple of bugs in that implementation. I intend to support this > > on both Microsoft and Mono implementations of dotnet. > > > > I'd be interested in seeing what other people have developed so we > > can share ideas/code. > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: VM Ware > > With VMware you can run multiple operating systems on a single machine. > > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > > same time. Free trial click here: > > http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > > Rubydotnet-developer mailing list > > Rub...@li... > > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer > ------- End of Original Message ------- > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Rubydotnet-developer mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer |
From: Thomas S. <th...@th...> - 2003-07-18 06:03:59
|
Hi Tim Thanks for getting in contact. So both you and Ben have something that mostly works - Excellent. There is a number of other people who are interested in working on getting ruby/.net integration to work. Would you be interested in collaborating with us? I think, if you and Ben, are willing a good next step would be to get your code out in the public, so more people can start contributing. Cheers, Thomas ---------- Original Message ----------- From: Tim Sutherland <ti...@ih...> To: rub...@so... Sent: Fri, 18 Jul 2003 10:47:23 +1200 Subject: [Rubydotnet-developer] Introduction > A few days ago I posted a message to rubytalk mentioning a library I > am working on for allowing Ruby and DotNet to call each others' methods > > (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/75198) > > Since then I've been contacted by Ben Schroeder who told me about the > similar project he has been working on, and who told me about this list. > > Status of my library: It mostly works, need to do more testing / > documentation. (Well, write *any* documentation!) Ben's project has > a richer interface e.g. uses Enumerable methods whenever a DotNet > object supports Count (or Length) and get_Item. There are other > things I'd like to implement like a "dotnet_methods" methods. > > I'll try to make a release soon under a BSD-ish license. > > My interface (calling DotNet methods from Ruby) looks like: > # It would be nicer if this was > # DotNet::System::Collections::Hashtable. > hash_class = DotNet::Class.new('System.Collections.Hashtable') > > h = hash_class.new # h is an instance of DotNet::Instance > h['a'] = [1, 2, 'three'] > > p(h['a']) # -> "[1, 2, \"three\"]" > p(h.Count) # -> 1 > > # DotNet.new can be used just for type conversions. > five = DotNet.new(5) # five is an instance of DotNet::Instance > p(five.to_rb == 5) # -> true > > Type conversions: Integers, strings, arrays, nil, true, false are > automatically converted to DotNet types. Calling 'to_rb' on a > DotNet::Instance instance converts it to the Ruby type, if the object > was one of the previously listed types. > > All operators/indexers are implemented (I believe). For relational > operators (==, eql?, <, <=, >=, > ) we force the returned value to > be a Ruby boolean. (Theoretically a DotNet library could implement > '<' as returning e.g. an integer.) <=> is implemented using "== and > <". == is implemented using Equals not op_Equality since e.g. > System.Int32 only defines the former. > > I also implement "hash" in terms of "GetHash". > > When calling DotNet methods, if the method name ends in '=', we chop > off the '=' and treat it as a SetField|SetProperty. Otherwise we use > InvokeMethod|GetField|GetProperty. (My library uses > GetType#InvokeMember.) > > At the moment I don't have any way to use DotNet delegates from the Ruby > side. > > DotNet exceptions are mapped to DotNet::Exception Ruby exceptions, where > 'message' is the same as the DotNet 'Message', and the 'dotnet_exception' > attr_reader provides the original DotNet exception. > > >From the DotNet (e.g. C#) side, I can do things like > RbType a = RbType.Eval('[1, 2, 3]'); > int size = a.Call("size").ToInteger(); > > There are (implicit operator) conversions for integers, strings, > arrays, null, true, false. > > You can use a delegate to represent a Ruby block, although I haven't > tested this. I've implemented most operators in the usual way, although > I forgot to do indexers -> [] and []=. > > Ruby exceptions are mapped into DotNet RbException types. > > Implementation wise, the code for calling Ruby from DotNet and > calling DotNet from Ruby are mostly separate. They each use > reference counting, which has the known problems e.g. circular references. > > The code is implemented in C# and C (Ruby extension.) There are > about 8 lines of Microsoft's Extended C++ to allow for initialisation. > > The code does not run on Mono yet (http://www.go-mono.com/) because > of a couple of bugs in that implementation. I intend to support this > on both Microsoft and Mono implementations of dotnet. > > I'd be interested in seeing what other people have developed so we > can share ideas/code. > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: > http://www.vmware.com/wl/offer/345/0 _______________________________________________ > Rubydotnet-developer mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubydotnet-developer ------- End of Original Message ------- |
From: Tim S. <ti...@ih...> - 2003-07-17 22:47:34
|
A few days ago I posted a message to rubytalk mentioning a library I am working on for allowing Ruby and DotNet to call each others' methods (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/75198) Since then I've been contacted by Ben Schroeder who told me about the similar project he has been working on, and who told me about this list. Status of my library: It mostly works, need to do more testing / documentation. (Well, write *any* documentation!) Ben's project has a richer interface e.g. uses Enumerable methods whenever a DotNet object supports Count (or Length) and get_Item. There are other things I'd like to implement like a "dotnet_methods" methods. I'll try to make a release soon under a BSD-ish license. My interface (calling DotNet methods from Ruby) looks like: # It would be nicer if this was # DotNet::System::Collections::Hashtable. hash_class = DotNet::Class.new('System.Collections.Hashtable') h = hash_class.new # h is an instance of DotNet::Instance h['a'] = [1, 2, 'three'] p(h['a']) # -> "[1, 2, \"three\"]" p(h.Count) # -> 1 # DotNet.new can be used just for type conversions. five = DotNet.new(5) # five is an instance of DotNet::Instance p(five.to_rb == 5) # -> true Type conversions: Integers, strings, arrays, nil, true, false are automatically converted to DotNet types. Calling 'to_rb' on a DotNet::Instance instance converts it to the Ruby type, if the object was one of the previously listed types. All operators/indexers are implemented (I believe). For relational operators (==, eql?, <, <=, >=, > ) we force the returned value to be a Ruby boolean. (Theoretically a DotNet library could implement '<' as returning e.g. an integer.) <=> is implemented using "== and <". == is implemented using Equals not op_Equality since e.g. System.Int32 only defines the former. I also implement "hash" in terms of "GetHash". When calling DotNet methods, if the method name ends in '=', we chop off the '=' and treat it as a SetField|SetProperty. Otherwise we use InvokeMethod|GetField|GetProperty. (My library uses GetType#InvokeMember.) At the moment I don't have any way to use DotNet delegates from the Ruby side. DotNet exceptions are mapped to DotNet::Exception Ruby exceptions, where 'message' is the same as the DotNet 'Message', and the 'dotnet_exception' attr_reader provides the original DotNet exception. From the DotNet (e.g. C#) side, I can do things like RbType a = RbType.Eval('[1, 2, 3]'); int size = a.Call("size").ToInteger(); There are (implicit operator) conversions for integers, strings, arrays, null, true, false. You can use a delegate to represent a Ruby block, although I haven't tested this. I've implemented most operators in the usual way, although I forgot to do indexers -> [] and []=. Ruby exceptions are mapped into DotNet RbException types. Implementation wise, the code for calling Ruby from DotNet and calling DotNet from Ruby are mostly separate. They each use reference counting, which has the known problems e.g. circular references. The code is implemented in C# and C (Ruby extension.) There are about 8 lines of Microsoft's Extended C++ to allow for initialisation. The code does not run on Mono yet (http://www.go-mono.com/) because of a couple of bugs in that implementation. I intend to support this on both Microsoft and Mono implementations of dotnet. I'd be interested in seeing what other people have developed so we can share ideas/code. |
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 |