Hm...

For me this d3 ordinal thing like implementing the () operator in c++. Is
it a function with members and methods or is it an object with the ability
to be called as a function?

Anyway if you and Roberto say it is not a bug then it's not a bug.

When I revisit my D3 bindings I will explore your proposals - but AFAIK
there is no easy solution that resembles the original javascript API.
Currently I prefer to copy paste among the inheritance pyramid (there are 2
or 3 subtypes) and have a create() method instead of ordinal() that
generates the object.

If there is no objection I will post another stumbling block I encountered
in my jsinterop journey.


On Sun, Jun 25, 2017 at 5:35 PM, Thomas Broyer <[email protected]> wrote:

>
>
> On Sunday, June 25, 2017 at 1:24:40 PM UTC+2, Vassilis Virvilis wrote:
>>
>> Ηι,
>>
>> thanks for answering
>>
>> d3.ordinal does not exist as you said. However d3.scale.ordinal exists
>> and that part works great.
>>
>
> But it is not a type, so you cannot use 'instanceof' on it.
>
>
>> in d3 ordinal is both a function ordinal() which returns an ordinal
>> instance and an object with more methods such as range() which is the crux
>> of my issue.
>>
>> The problem there is that
>>
>>    - public native <I, O> O range(I[] values);       *// this doesn't
>>    work*
>>    - // public native <I> Ordinal range(I[] values); *// this works*
>>
>> I would like to use the first definition because it allows reusing some
>> code between different scales. Otherwise I have to copy-paste the range()
>> method multiple times instead of put it in a base class.
>>
>
> In Java, generics are more or less syntactic sugar for using the erased
> type and casting values. So when using the first one, GWT will, when used
> with O==Ordinal, generate a cast from Object to Ordinal, which IIUC is
> what's causing the error, because your JsType is not a type that can be
> checked (a cast is translated in JS to a type-check using 'instanceof').
>
>
>> The problem is on the exceptions generated by the attempting casting.
>>
>> As you said this may not be a bug but not for the reason you mentioned.
>>
>> So the question remains: Should I report it as an issue?
>>
>
> I would say no. Your @JsType is wrong. You should either use an interface
> with @JsType(isNative=true, name="?", namespace=JsPackage.GLOBAL), or if
> you want to use fields use a class with @JsType(isNative=true,
> name="Object", namespace=JsPackage.GLOBAL)
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-web-toolkit-contributors/6206fb29-d3c1-
> 48de-ab04-0610cbb3c2bd%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/6206fb29-d3c1-48de-ab04-0610cbb3c2bd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> 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 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAKbOjExtFzAEo2fL66Z3gDrfzNA%3DnF90moVCvGg2BUjjDVqJfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to