On Thursday, October 20, 2016 at 5:32:11 PM UTC+2, Kirill Prazdnikov wrote:
>
> Hello all, this is an important topic, (despite no one wants to answer 
> for almost 2 month)
>
> Im trying to declare JsArray with interop but there are some issues:
>
> [INFO]    Errors in client/jsinterop/core/JsArray.java
> [INFO]       [ERROR] Line 17: JSNI method 'JSObject JsArray.get(int)' is 
> not allowed in a native JsType.
> [INFO]       [ERROR] Line 23: JSNI method 'void JsArray.set(int, 
> JSObject)' is not allowed in a native JsType.
>
> If GWT does not provide us with JsIndexer why then it don't allow JSNI in 
> the native JsTypes ?
>

(Probably) because 'native' already has a defined meaning on native classes.

Pease see the source:
> https://gist.github.com/kirillp/bd35e67910d8216cba139ab9e0af855c
>
>
Can't you delegate to a helper class (with static methods) ?

@JsOverlay public T get(int index) {
  return ArrayHelper.get(this, index);
}

(this looks a lot like java.lang.reflect.Array btw ;-) )

You may also possibly cast your 'this' to an array? (just an untested idea)

@JsOverlay
@SuppressWarnings("unchecked")
public T get(int index) {
  return (T) (((Object[]) ((Object) this))[index]); // or something like 
that, possibly with intermediate local variables if needed (as they'll 
hopefully be optimized out in the compilation)
}

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to