Re: Easily add a Java Listener

2009-08-31 Thread Luc Prefontaine
It could be handy to have this shortcut implemented as you suggest. Solving ambiguities may be done through an explicit proxy or with some meta data to point to the proper method match. Luc On Mon, 2009-08-31 at 19:34 -0700, Timothy Pratley wrote: > If I understand correctly it could be impleme

Re: Easily add a Java Listener

2009-08-31 Thread Timothy Pratley
If I understand correctly it could be implemented with the following change to Reflector.java: static Object boxArg(Class paramType, Object arg){ if(paramType.isInterface() && arg instanceof IFn) return makeAProxy( findMethodMatch( paramType, arg ), arg ); Which would then

Re: Easily add a Java Listener

2009-08-31 Thread Luc Prefontaine
Hi guys, Am I missing something here? We define SWING listeners with proxies and find that it's already short in terms of code lines: (.addMouseListener (proxy [MouseAdapter] [] (mouseClicked [event] (if (= 2 (.getClickCount event)) (display-details (.locationToInde

Re: Easily add a Java Listener

2009-08-31 Thread Christophe Grand
Rhino provides a similar facility https://developer.mozilla.org/en/Scripting_Java#JavaScript_Functions_as_Java_Interfaces but AFAIK it uses reflection. On Tue, Sep 1, 2009 at 12:03 AM, Kevin Downey wrote: > > I think this would necessitate an added layer of indirection and > reflection, which wou

Re: Easily add a Java Listener

2009-08-31 Thread Kevin Downey
I think this would necessitate an added layer of indirection and reflection, which would mean taking a performance hit. On Mon, Aug 31, 2009 at 2:54 PM, Stuart Sierra wrote: > > That's a clever trick.  How does the block know which interface method > was invoked? > -SS > > On Aug 31, 2:41 pm, rb

Re: Easily add a Java Listener

2009-08-31 Thread Stuart Sierra
That's a clever trick. How does the block know which interface method was invoked? -SS On Aug 31, 2:41 pm, rb wrote: > Hi, > > After using Jwt from Clojure, I did it with Jruby and discovered that > Jruby has what they call Closure Conversion (http://kenai.com/projects/ > jruby/pages/CallingJav

Easily add a Java Listener

2009-08-31 Thread rb
Hi, After using Jwt from Clojure, I did it with Jruby and discovered that Jruby has what they call Closure Conversion (http://kenai.com/projects/ jruby/pages/CallingJavaFromJRuby#Closure_conversion ) where a Ruby block or closure is converted to an appropriate Java interface. From the wiki: "When