On Thu, May 28, 2009 at 8:18 PM, Vitali Lovich <[email protected]> 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 this now -- in a JSNI method:
static void bar(int arg) { ... }
var f = @org.example.Foo::bar(I);
You can then pass/return it to Java/JSNI code as a JavaScriptObject, or
directly to external Javascript that looks for a function.
> Ideally, you would be also able to execute any Javascript function object
> from within Java code, although that does present some problems.
>
You have to have a JSNI method to do this now:
private static native JavaScriptObject callFunc(JavaScriptObject func, int
arg) /*-{
func(arg);
}-*/;
--
John A. Tamplin
Software Engineer (GWT), Google
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---