On 2014-01-13 10:58, Jacob Carlborg wrote:

I'm using this philosophy when I'm porting SWT to D. In prioritizing order:

1. The public API needs to be the same on all platforms and preferably
as the Java API.

2. The types and signatures should match the native ones. That means, if
the native signature uses a pointer, the D code should use a pointer as
well, even if the Java code uses int/long.

3. Try to stay as close to the original Java code as possible. This will
make it easier to port future versions.

Hmm, these might actually be the cases where it should be "int" on both
platforms and a cast is required since it's would otherwise be "long"
for 64bit.

You did find the other cases where I know for sure that the type should
vary on 32 and 64bit, that is when the code looks like this:

int /*long*/

I double checked these cases with the Java code:

32bit           64bit
int /*long*/    long /*int*/
(int)/*64*/     (int)/*64*/

The reason for (int)/*64*/ is usually because the native type would be 64bit but the Java requires it to be 32bit. By the second rule above, I would translate (int)/*64*/ to the native type.

--
/Jacob Carlborg

Reply via email to