[Java-gnome-developer] handlers as ints?
Brought to you by:
afcowie
From: R. A. R. D. <riv...@ya...> - 2003-11-16 07:53:39
|
Hello Checking the docs I have found that handlers are treated as java ints. As we know ints are fixed 32 bits in Java, I wonder what will happen in 64bits OSes? As I see it, two solutions are posible: 1. Have a handler table to make the conversion, 2. Change everything to long and recompile. None of this is a good solution. I think using a java.awt Peer like solution works better. Hiding the handler in an interface that can be implemented in every platform is a way to work around this problem without the need to change the library in every platform. Something like: public interface Handler {} public class GObject { public GObject(Handler handler) { ... } ... } In native code, every platform have to implement a pair of functions like the following: int javaToNative(JObject * handler); // receives a Handler instance JObject * nativeToJava(int handler); // returns a Handler instance probably inline functions that should be used whenever is necesary to access a handler. Then you can have a OS32bitHandler with a java int field inside, and a OS64bitHandler with a java long field inside, and the code in javaToNative and nativeToJava will conditionally use one of those implementations depending on the arch. What do you think? regards, Rivas. __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree |