On Feb 2, 8:16 pm, Tom <tomson...@gmail.com> wrote: > Hi, > > I have some questions and proposals around the JsArray-classes because > they are handy when working with JSNI but I believe they could be > improved a bit. > > a) Why are not all native methods provided through the wrapper. > Missing methods are: > * concat > * pop > * reverse > * slice > * splice > * sort
See http://code.google.com/p/google-web-toolkit/issues/detail?id=2793 > b) It would be nice if one could use them in a for-loop but because an > interface can only be implemented by one native class it can't > implement Iterable directly but provide a method like iterable(). See http://code.google.com/p/google-web-toolkit/wiki/LightweightCollections and my JsCollections module: http://code.google.com/p/gwt-in-the-air/ http://code.google.com/p/gwt-in-the-air/source/browse/trunk/src/net/ltgt/gwt/jscollections/client/JsArrays.java My JsArrays::toArray/fromArray are very "low-level" but toArray() has the advantage that you can iterate over it and it generates more optimized code (for (var i=0,l=arr.length;i<l;i++) {...}) than an Iterator (involves a new class and creating a new instance of it each time you want to iterate). fromArray() is meant to be used when wrapping 'native' JS code, when you know the JsArray is immutable (or at least has a "fixed size", and/ or you've been give a "private" copy); in this case it can be considered safe to cast the JsArray to/from a Java array. The Java array is to be considered immutable (in DevMode it'll be a copy anyway) -- http://groups.google.com/group/Google-Web-Toolkit-Contributors