On Fri, May 29, 2009 at 10:42 AM, Vitali Lovich <vlov...@gmail.com> 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, maintain it, & it's IDE friendly, meaning no typos & syntax
> checking (which is a major strength of GWT).
>

That's not legal Java, so it would defeat your purpose of getting IDE
support/etc.  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 classes and method/field names) -- even that seems to
be a long way away however.

For JSNI syntax checking, you can use the Google Eclipse plugin which
supports a number of JSNI features.


> You have to have a JSNI method to do this now:
>>
>> private static native JavaScriptObject callFunc(JavaScriptObject func, int
>> arg) /*-{
>>    func(arg);
>> }-*/;
>
> Yes - hence the feature request.  I know it's non-trivial given that GWT
> follows Java convention & wraps varargs in an array which could cause
> problems for the JS.  Just trying to get some feedback on whether or not
> it's a good idea.
>

The only thing I think would be feasible here would be to add some sort of
call method on JavaScriptObject that would treat it as a torn-off function.
However, since you can't have polymorphic dispatch on JSOs, that would
reserve whatever name was chosen from all subclasses, so it would have to be
something unlikely to collide.

-- 
John A. Tamplin
Software Engineer (GWT), Google

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to