atom feed22 messages in net.java.dev.rococoa.usersRe: BOOL mapping issues
FromSent OnAttachments
Harald KuhrFeb 9, 2010 11:58 am 
Duncan McGregorFeb 9, 2010 12:04 pm 
Harald KuhrFeb 9, 2010 12:27 pm 
Harald KuhrFeb 9, 2010 12:37 pm.java
Duncan McGregorFeb 10, 2010 12:37 am 
Harald KuhrFeb 10, 2010 2:39 am.java
Harald KuhrFeb 17, 2010 7:25 am 
Duncan McGregorFeb 18, 2010 1:56 am 
Andrew ThompsonFeb 18, 2010 6:52 pm 
Harald KuhrFeb 19, 2010 6:49 am 
Harald KuhrFeb 19, 2010 7:23 am 
Harald KuhrFeb 19, 2010 10:37 am 
Harald KuhrFeb 19, 2010 12:13 pm 
Duncan McGregorFeb 19, 2010 2:04 pm 
Harald KuhrFeb 19, 2010 3:06 pm 
Andrew ThompsonFeb 20, 2010 8:02 am 
Harald KuhrFeb 20, 2010 1:12 pm 
Andrew ThompsonFeb 20, 2010 5:22 pm 
Duncan McGregorFeb 21, 2010 2:55 am 
Harald KuhrFeb 21, 2010 8:14 am 
Duncan McGregorFeb 21, 2010 8:40 am 
Duncan McGregorFeb 21, 2010 9:01 am 
Subject:Re: BOOL mapping issues
From:Duncan McGregor (dun@oneeyedmen.com)
Date:Feb 21, 2010 2:55:22 am
List:net.java.dev.rococoa.users

On 21 Feb 2010, at 01:22, Andrew Thompson wrote:

On Feb 20, 2010, at 4:12 PM, Harald Kuhr wrote:

Jokes aside.. Do you know if it's always safe to use the mapping I proposed? At
least both bool and BOOL seems to use 1 rather than -1.

I have no explicit knowledge that this is safe, but logically what you did seems
harmless and makes sense. I suppose ideally we should only apply the mapping where the param type is
actually BOOL and not just whenever the argument on the Java side is a boolean.

Aye, there's the rub. You see all we know about the param type (at the moment)
is that it is Java boolean.

This was the gist of my example passing it as Object - the mapping at the moment
is entirely JNA, and JNA assumes that the Java type maps to the correct native
type.

Now it seems to me that we have 3 options.

1 - Pick a mapping and stick to it. So Java boolean (actually Boolean by the
time we get to the invocation) always maps to int32 with 1 = YES, 0 = NO.

2 - Look up the method signature for the selector that we are about to invoke,
and use that to inform our mapping. This is slow, but could be cached, and would
allow us to finesse our current silly issues with having to use CGFloat etc as
classes.

3 - Map boolean -> BOOL and provide an annotation to specify exceptions.

I'm actually quite keen on 2, but one is obviously simplest. Does anyone have an
example of a Mac API where JNA's default mapping actually makes sense, because
if not maybe we should suggest the change there?

Duncan