[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-30 Thread Ray Cromwell
There's a type safe trick to doing it for all methods that return a value, see: http://cromwellian.blogspot.com/2006_07_01_archive.html which is based on this: http://weblogs.java.net/blog/alexwinston/archive/2005/04/strongly_types_1.html With my GWT.create() relaxation proposal, you could wri

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-30 Thread Thomas Broyer
On 29 mai, 02:18, Vitali Lovich wrote: > It would be nice if there was a way to wrap Java methods with an opaque > Javascript function object so that you could pass them around in the native > code (obviously there are issues with compiler optimizations in this case). > Ideally, you would be al

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-29 Thread Vitali Lovich
On Fri, May 29, 2009 at 11:59 AM, John Tamplin wrote: > On Fri, May 29, 2009 at 11:31 AM, Vitali Lovich wrote: > >> The way you get a method reference in pure Java is via reflection, which >>> in general is not feasible though there have been some discussions of >>> allowing it when everything

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-29 Thread John Tamplin
On Fri, May 29, 2009 at 11:31 AM, Vitali Lovich wrote: > The way you get a method reference in pure Java is via reflection, which in >> general is not feasible though there have been some discussions of allowing >> it when everything can be evaluated at compile time (ie, all constants for >> clas

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-29 Thread Vitali Lovich
On Fri, May 29, 2009 at 11:16 AM, John Tamplin wrote: > On Fri, May 29, 2009 at 10:42 AM, Vitali Lovich wrote: > >> I was thinking more along the lines of JavascriptFunction foo = >> MyClass.bar.method or something like that. That way, you could do dynamic >> function invocation without ever ne

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-29 Thread John Tamplin
On Fri, May 29, 2009 at 10:42 AM, Vitali Lovich wrote: > I was thinking more along the lines of JavascriptFunction foo = > MyClass.bar.method or something like that. That way, you could do dynamic > function invocation without ever needing JSNI. It's also a lot easier to > write that code, main

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-29 Thread Vitali Lovich
On Fri, May 29, 2009 at 9:42 AM, John Tamplin wrote: > On Thu, May 28, 2009 at 8:18 PM, Vitali Lovich wrote: > >> It would be nice if there was a way to wrap Java methods with an opaque >> Javascript function object so that you could pass them around in the native >> code (obviously there are is

[gwt-contrib] Re: Feature idea - reference Java methods as Javascript functions

2009-05-29 Thread John Tamplin
On Thu, May 28, 2009 at 8:18 PM, Vitali Lovich wrote: > It would be nice if there was a way to wrap Java methods with an opaque > Javascript function object so that you could pass them around in the native > code (obviously there are issues with compiler optimizations in this case). > You can do

[gwt-contrib] Re: Feature idea

2009-04-27 Thread Ray Cromwell
One possibility is to use hidden method parameters. Let L = {the set of all method parameters which are referenced by GWT.isLiteral() in the body} For each parameter P in L, add a new parameter to the method, PiL (P is Literal). that is, in Vitali's example: void addParameter (HashMap h, int si

[gwt-contrib] Re: Feature idea

2009-04-27 Thread Bruce Johnson
It seems like the general functionality (i.e. GWT.isLiteral()) ought to be implemented at the same time as method cloning. That's what makes me excited about the whole thing. Otherwise, at least for me, it's hard to wrap my head around how you could usefully emit different code for the same method

[gwt-contrib] Re: Feature idea

2009-04-27 Thread Joel Webber
Cool, I had no idea GCC provided that information. I won't claim to be one of the compiler gurus, but this sounds pretty feasible to me, and to Ray's point, might be a useful way of loosening the GWT.create() magic a bit. @Lex, Scott: What do you think? Is this relatively easy and useful? On Mon,

[gwt-contrib] Re: Feature idea

2009-04-27 Thread Vitali Lovich
Yeah, probably from a compiler's perspective, the value check may be more complicated (the value may only be available after the AST stage depending on when optimization is done) It can possibly bloat the resultant code (since I believe you may have to build different implementations of each funct

[gwt-contrib] Re: Feature idea

2009-04-27 Thread Ray Cromwell
+1 I suggested a similar feature a few days ago privately, I called it GWT.isLiteral(), since the underlying check is if its an AST literal in the compiler, although in my example, you can't do value comparisons, just assertions on the literal. The value checks would be done via traditional opera