Unknown type evolves from overriding functions in Javascript

12 views
Skip to first unread message

MonkeyMike

unread,
Nov 20, 2009, 1:58:52 PM11/20/09
to Google Web Toolkit
I have some JSNI that the GWT compiler doesn't like...

----------------------
public static native void declareCustomMoveable(String
customMoveableId, NativeCustomMoveableCallback callback) /*-{
dojo.declare( customMoveableId, dojox.gfx.Moveable, {
onFirstMove: function(mover){

callback.@gwtgfx.client.callback.CustomMoveableCallback::onFirstMove
();
},
onMoving: function(mover, shift){
callback.@gwtgfx.client.callback.CustomMoveableCallback::onMoving(
Lgwtgfx/client/definition/jsni/NativeTransformDefinition;
)(shift);
},
onMoved: function(mover, shift){
callback.@gwtgfx.client.callback.CustomMoveableCallback::onMoved(
Lgwtgfx/client/definition/jsni/NativeTransformDefinition;
)(shift);
}
});
}-*/;
----------------------

Note that I am using dojo's pattern for "subclassing"
dojox.gfx.Moveable, and overriding the methods onFirstMove, onMoving,
and onMoved. In each of these, there is a call to the relevant method
from NativeCustomMoveableCallback.java (which is a Java interface, by
the way). The GWT compiler is okay with the onFirstMove
implementation, but for both the onMoving and onMoved implementations,
I get the following error...

"Expected a valid parameter type signature in JSNI method reference"

Note that I have indicated that "shift" is an instance of a
NativeTransformDefinition, which is a subclass of JavaScriptObject in
my library. Isn't this valid? I thought that the GWT compiler
"trusts" the developer to indicate types of objects that come from
JavaScript, so long as the types are subclasses of JavaScriptObject.

So is it just that my syntax is somehow incorrect? I'm using GWT
1.7. If not, how can I refactor this to achieve a pattern which is
acceptable to the GWT compiler?

Thanks in advance! :)

MonkeyMike

unread,
Nov 20, 2009, 2:03:17 PM11/20/09
to Google Web Toolkit
Sorry for the strange formatting, by the way. I simply copy-and-
pasted my code.

On Nov 20, 10:58 am, MonkeyMike <mikebin...@gmail.com> wrote:
> I have some JSNI that the GWT compiler doesn't like...
>
> ----------------------
>         public static native void declareCustomMoveable(String
> customMoveableId, NativeCustomMoveableCallback callback) /*-{
>                 dojo.declare( customMoveableId, dojox.gfx.Moveable, {
>                         onFirstMove: function(mover){
>
> callba...@gwtgfx.client.callback.CustomMoveableCallback::onFirstMove
> ();
>                         },
>                         onMoving: function(mover, shift){
>                                 callba...@gwtgfx.client.callback.CustomMoveableCallback::onMoving(
>                                         Lgwtgfx/client/definition/jsni/NativeTransformDefinition;
>                                 )(shift);
>                         },
>                         onMoved: function(mover, shift){
>                                 callba...@gwtgfx.client.callback.CustomMoveableCallback::onMoved(

MonkeyMike

unread,
Nov 23, 2009, 9:02:30 PM11/23/09
to Google Web Toolkit
Still looking for an answer on this one... I am puzzled as to how to
do this!

By the way, I realized during some other debugging that this bit of
code is one of many places where I was forgetting to state the "$wnd"
namespace. So here is the latest version of the problematic code...

----------------------------
public static native void declareCustomMoveable(String
customMoveableId, NativeCustomMoveableCallback callback) /*-{
$wnd.dojo.declare( customMoveableId, $wnd.dojox.gfx.Moveable, {
onFirstMove: function(mover){
callback.@gwtgfx.client.callback.CustomMoveableCallback::onFirstMove
();
},
onMoving: function(mover, shift){
callback.@gwtgfx.client.callback.CustomMoveableCallback::onMoving(
Lgwtgfx/client/definition/jsni/NativeTransformDefinition;
)(shift);
},
onMoved: function(mover, shift){
callback.@gwtgfx.client.callback.CustomMoveableCallback::onMoved(
Lgwtgfx/client/definition/jsni/NativeTransformDefinition;
)(shift);
}
});
}-*/;
----------------------------

Looking forward to the solution!

Cheers,
Mike

MonkeyMike

unread,
Nov 23, 2009, 9:18:13 PM11/23/09
to Google Web Toolkit
Wow... okay, I think I figured it out! It turns out that, at least
with GWT 1.7.0, whitespace matters. The following code turned out to
be valid...

-----------------------
public static native void declareCustomMoveable(String
customMoveableId,
NativeCustomMoveableCallback callback) /*-{
$wnd.dojo.declare( customMoveableId, $wnd.dojox.gfx.Moveable, {
onFirstMove: function(mover){

callback.@gwtgfx.client.callback.CustomMoveableCallback::onFirstMove
();
},
onMoving: function(mover, shift){

callback.@gwtgfx.client.callback.jsni.NativeCustomMoveableCallback::onMoving
(Lgwtgfx/client/definition/jsni/NativeTransformDefinition;)(shift);
},
onMoved: function(mover, shift){

callback.@gwtgfx.client.callback.jsni.NativeCustomMoveableCallback::onMoved
(Lgwtgfx/client/definition/jsni/NativeTransformDefinition;)(shift);
}
});
}-*/;
-----------------------

Please ignore the change in class and package names in this code,
compared to the previous posts. I realize that there were other
errors there, but that's not what this is about. The GWT compiler
didn't like how I was putting the type declarations on their own
lines.

Sorry for the confusion... but I suppose this is still a useful
post, since I discovered how much whitespace matters here.

Cheers,
Mike


On Nov 23, 6:02 pm, MonkeyMike <mikebin...@gmail.com> wrote:
> Still looking for an answer on this one... I am puzzled as to how to
> do this!
>
> By the way, I realized during some other debugging that this bit of
> code is one of many places where I was forgetting to state the "$wnd"
> namespace.  So here is the latest version of the problematic code...
>
> ----------------------------
> public static native void declareCustomMoveable(String
> customMoveableId, NativeCustomMoveableCallback callback) /*-{
>         $wnd.dojo.declare( customMoveableId, $wnd.dojox.gfx.Moveable, {
>                 onFirstMove: function(mover){
Reply all
Reply to author
Forward
0 new messages