Ask, and ye shall recieve.
jruby 1.1.4 on JDK 1.6:

Java Code:
public interface ISayer {
	public void say(String foo);
	public void sayMultipleThings(String foo, String bar);
}

public class SayThings {
	public static void sayThings( ISayer sayer ) {
		sayer.say("Invoked from java");
		
		sayer.sayMultipleThings("Saying Multiple", "Things From Java");
	}
}

Ruby Code:
require 'java'

$CLASSPATH << '.'

class RubySayer
	include Java::ISayer
	
	def say(word)
		puts "FROM RUBY: #{word}"
	end
	
	def say_multiple_things(first, second)
		puts "FROM RUBY: #{first}, #{second}"
	end
end

rc = RubySayer.new

Java::SayThings.say_things( rc )

When Run:
FROM RUBY: Invoked from java
FROM RUBY: Saying Multiple, Things From Java
Aside: Every time I go near java, CLASSPATH and 'one-class-per-file' makes me want to go outside and hit something. IronRuby isn't even finished yet and already I'd much rather use it :-)

Jim Deville wrote:
I saw a presentation that (if I remember correctly) showed methods like doFoo becoming do_foo. So I think they mangle method names. I don't know if they do this for interface methods, which is closer to this problem.

JD

-----Original Message-----
From: Curt Hagenlocher <[EMAIL PROTECTED]>
Sent: September 09, 2008 9:44 AM
To: ironruby-core@rubyforge.org <ironruby-core@rubyforge.org>
Subject: Re: [Ironruby-core] Overriding CLS Virtuals


The Java convention is that method names start with lower-case characters, so I don't imagine that there's any special handling being performed.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Jim Deville
Sent: Tuesday, September 09, 2008 9:43 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Overriding CLS Virtuals

I know their naming convention is different, but lets see what JRuby does too.

JD


-----Original Message-----
From: Tomas Matousek <[EMAIL PROTECTED]>
Sent: September 09, 2008 8:55 AM
To: ironruby-core@rubyforge.org <ironruby-core@rubyforge.org>
Subject: Re: [Ironruby-core] Overriding CLS Virtuals


Let's revisit that later, I'm also not sure what the details were.

Tomas

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Curt Hagenlocher
Sent: Tuesday, September 09, 2008 4:40 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Overriding CLS Virtuals

When you override a virtual method you're pushing much more into CLR-world than when you're just calling some function on some method.  In the latter case, you shouldn't have to know that the function you're calling is actually defined outside of Ruby, while in the former, this is a fairly important piece of information.

In any event, I recall that both John and Tomas felt that we shouldn't -- but no longer remember all the details.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Jim Deville
Sent: Tuesday, September 09, 2008 1:01 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Overriding CLS Virtuals

Are we planning on supporting name mangling to give more Ruby-ish names? Like will we be able to do "def dispose" instead of "def Dispose"?

JD
________________________________________
From: [EMAIL PROTECTED] [[EMAIL PROTECTED]] On Behalf Of Brad Wilson [[EMAIL PROTECTED]]
Sent: Monday, September 08, 2008 9:39 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Overriding CLS Virtuals

It's not real unless you start singing "You are the wind beneath my wings". :)

On Mon, Sep 8, 2008 at 9:36 PM, Orion Edwards <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote:
You are my hero :-)

Curt Hagenlocher wrote:

I've committed some changes to IronRuby (in SVN revision 141) that let you implement CLS interfaces and override virtual methods on CLS base types.  Interfaces work like Ruby modules, so to make your class implement IDisposable you could say

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
  

--
Orion Edwards
Web Application Developer

T: +64 7 859 2120
F: +64 7 859 2320
E: [EMAIL PROTECTED]

Open2view.com
The Real Estate Website

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to