On Thursday, May 12, 2016 at 11:51:11 AM UTC+2, Vassilis Virvilis wrote:
>
> Thomas thanks,
>
> Wow I did this and it works. But it is crazy. Cr is for crazy. Kudos to 
> jsinterop guys though.
>
> @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "[]")
>
>
You should probably use "Array" rather than "[]"
 

> public interface CrJsArray<T> {
>
>     public void push(T value);
>
>     @JsProperty
>     public int getLength();
> }
>
>
> I tried your suggestion to cast and __also works__ (eclipse complains 
> about but with (JavaScriptObject) (Object) my_native_object) it works and 
> it is definitely better.
>

Also, for converting from a java.util.Collection to an array, how about 
simply using Collection#toArray? (and then passing the array to JS through 
JsInterop)
 

> Questions
> 1) Is JavaScriptObject scheduled for deprecation?
>

Yes, it'll be replaced with JsInterop.
 

> 2) Should a native type be able to extend JavascriptObject. Because right 
> now (2.8pre1) fails at run time. That would make casting a bit saner. 
> Should I report it somewhere?
>

This is probably on-purpose.
 

> I tried to look for the reference you gave but I didn't find it. Wrong 
> keywords maybe...
>

I found 
this: 
https://groups.google.com/d/topic/google-web-toolkit/nmBAOX4vcSo/discussion
Not exactly what I remembered, but touches similar points.
 

>
> On Thu, May 12, 2016 at 12:20 PM, Thomas Broyer <[email protected]> 
> wrote:
>
>> That question came up already in the forum or in GWT-Contrib (try to 
>> search the archive), and I seem to recall that Goktug said you could cast 
>> @JsType(isNative=true) objects to/from JavaScriptObject, so you could use 
>> JsArray (and JsonUtils.safeEval). I think you can also cast to/from an 
>> array of @JsType(isNative=true), so if you don't need to alter the size of 
>> the JS array you can then use the bracket operators on a Java array (and 
>> cast from/to a JavaScriptObject).
>> This is only out of memory, please double check from the forum archives.
>>
>>
>> On Thursday, May 12, 2016 at 10:47:51 AM UTC+2, Vassilis Virvilis wrote:
>>>
>>> Hi again,
>>>
>>> I am trying to convert a jre collection or build a jsArray with a 
>>> isNative=true type.
>>>
>>> Unfortunately this is not possible because JsArray requires 
>>> JavascriptObject which is invcompatible (complie time error) with native 
>>> classes.
>>>
>>> Any ideas?
>>>
>>> I looked on deep dive jsinterop from Ray Cromwell and it says that there 
>>> is not a clean way for jsinterop1 to align collections. Ok I get that - but 
>>> there must be a way even if not the nicest/cleanest one.
>>>
>>> Otherwise looks like I have to create my own @jsinteroped MyJsArray 
>>> which looks wrong.
>>>
>>> -- 
>>> Vassilis Virvilis
>>>
>> -- 
>> 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.
>>
>
>
>
> -- 
> Vassilis Virvilis
>

-- 
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