Re: Java array handling in JSNI
Thomas
Thomas Broyer wrote:
>>
>> 1. Is what I've just said correct?
>>
>
> If I correctly understood what you said, then yes.
>
>
Good, thanks. I work on my own, so its nice to have confirmation of
things like this.
>> 2. If so, why doesn't the debug runtime system generate a warning when
>> encountering a 'float []' in hosted mode? Ok it crashes with an obscure
>> exception,
>> but that isn't very helpful.
>>
>
> Because you can pass a float[] to JSNI, just not use it as an array
> from the JSNI code (but you can pass it back to the Java world: the
> function returns it, and/or passes it as an argument to a Java method
> call)
>
>
Good point. I'll let the GWT team off the hook over that one then! :-)
>> If you need to initialize a float [] from a client side java program and
>> then pass that array to a native method, you have to do something like:
>>
>> float [] floats = myinstance.myMethod2CreateFloatArray();
>>
>> public static native JsArrayNumber createNew() /*-{ return new Array();
>>
>> }-*/;
>>
>
> There's JavaScriptObject.createArray().<JsArrayNumber>cast() for that.
>
Yes, I'd overlooked that. Thanks again.
> Have a look at my JsCollections module, it has utility methods that
> will copy the array in DevMode but just pass it as-is when compiled,
> so it has no overhead.
> http://code.google.com/p/gwt-in-the-air/
>
Will do. Sounds very useful.
Regards
Alan
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home