On 26 avr, 23:53, Vitali Lovich <[email protected]> wrote:
> Unfortunately, I have already implemented my own version. This means that
> regardless of which is better (or even if they are identical) I must
> criticize & reject yours out of hand.
>
> On a serious note, why do some of your methods have a GWT.isScript check?
In web mode, a Java array is compiled into a JavaScript Array, so you
can pass it to a JavaScript method that takes an Array (if you're
certain it doesn't violate the contract of a Java array, i.e. fixed
length, homogeneous regarding the types of the contained objects --
don't start to mix String, Number, Object, etc. into what is a Java
array in your GWT/Java code, or you'll likely face unexpected results/
failures later on). This is the case for Array.prototype.concat() for
instance.
In hosted mode however, Java arrays and JavaScript arrays are not
interchangeable, so you have to copy from one to the other (see also
JsCollections' JsArrays.fromArray/toArray, as I pointed in this
thread) or emulate the native method's behavior (that's what I chose
to do in the case of concat(T...items), because ECMAScript clearly
defines the behavior of Array.prototype.concat(), browsers correctly
implement this definition, and I doubt it'd be faster/better to copy
the items into a JsArray and then call the concat(JsArray<T> items)
overloaded method)
Of course, I could also have just omitted those Java-array-based
overloads and only expose JsArray-based methods (and you'd then have
to use JsCollections' JsArrays or similar "interop utilities".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---