Bob,

I would like for you to review this patch.  It modifies Map's private copy
of JSIO to always coerce a 'boolean' type argument of a JSNI reference  to
false if it is == null.

If you think it is good, I can port it back to the JSIO main branch as well.

M
maps/src/com/google/gwt/maps/jsio/rebind/PrimitiveFragmentGenerator.java


On Fri, Sep 26, 2008 at 12:35 PM, Eric Ayers <[EMAIL PROTECTED]> wrote:

>
>
> On Fri, Sep 26, 2008 at 11:46 AM, John Tamplin <[EMAIL PROTECTED]> wrote:
>
>> On Fri, Sep 26, 2008 at 11:37 AM, Eric Ayers <[EMAIL PROTECTED]> wrote:
>>
>>> I am running into a problem in hosted mode that is kind of tricky to work
>>> around.
>>>
>>> gwt-google-apis issue 180:
>>>
>>>   http://code.google.com/p/gwt-google-apis/issues/detail?id=180
>>>
>>> Basically, I have a JS API that is calling back into a method defined in
>>> Java:
>>>
>>>      [EMAIL PROTECTED]
>>> ::fromPixelToLatLng(Lcom/google/gwt/maps/client/geom/Point;IZ)(
>>>           arg0 || null,
>>>           arg1,
>>>           arg2);
>>>
>>> were 'arg2' is a boolean value.
>>>
>>> Sometimes, the Maps API is passing 'undefined' as the 3rd argument.
>>> I could fix this by writing all my argument passing in the form of:
>>>
>>> (arg2 == null ? false : arg2)
>>>
>>> but this would just be a workaround for hosted mode - web mode wouldn't
>>> care about the difference.  Besides that, it would bloat up the code.  So, I
>>> propose that in JsGlue that we just assume a null or undefined value is
>>> "false" when passed into java.
>>>
>>> M      user/test/com/google/gwt/dev/jjs/test/HostedTest.java
>>> M      dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
>>>
>>
>> For this to be reasonable, you have to be certain that everywhere a
>> boolean can be used the behavior of a null is exactly the same -- otherwise
>> you will be masking web-mode problems.  One example where this would cause a
>> problem would be
>>
>> public native String getBool(boolean v) /*-{
>>   return "" + v;
>> }-*/;
>>
>> If a JS undefined or null were allowed to be passed into Java code as a
>> boolean, then the result of this function would be different in web mode vs.
>> hosted mode.
>>
>> I think anytime we are getting values from JS, it is safer to ensure they
>> match the declared type at that point.  If you do it often, write a small
>> function to do the mapping.
>>
>> Examples where we *have* relaxed the JS types that can be used are String
>> (vs primitive string) and null/undef equivalence (by changing the generated
>> code in the few cases that care).
>>
>> --
>> John A. Tamplin
>> Software Engineer (GWT), Google
>>
>
> Ok, I see that would make a difference.
> @BobV, Instead, to get this to work in the Maps API, I'm going to go into
> the JSIO generator and generate the function (or inline equivalent) to do
> the mapping.
> --
> Eric Z. Ayers - GWT Team - Atlanta, GA USA
> http://code.google.com/webtoolkit/
>



-- 
Eric Z. Ayers - GWT Team - Atlanta, GA USA
http://code.google.com/webtoolkit/

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Attachment: galgwt-maps-map-boolean-undef-to-false-r856.patch
Description: Binary data

Reply via email to