From: Arno P. <ar...@pu...> - 2009-10-30 19:41:13
|
this is a tricky issue. Objective-C initializes member variables to 'nil' by default (which, I believe, is represented by 0x0). However, in XMLVM we cannot map Java's null to Objective-C's nil, because nil is not accepted as an argument to some data structures (e.g., NSArray, NSDictionary, etc). That is why we map null to [NSNull null]. Now, very unfortunate, you cannot do something like this in Objective-C: @interface Foo { id ref = [NSNull null]; } @end This means, you have do some fancy code generation. This is a known issue in XMLVM. In the meantime, you can explicitly initialize Java members such as: public class Test { Object ref = null; ... Arno Panayotis Katsaloulis wrote: > On 30 Οκτ 2009, at 8:35 μ.μ., Markus Heberling wrote: > >> Hi, >> >> take this code convert it to objc and run it: >> >> public class Test{ >> Object thisIsNotInitialized; >> >> void test(){ >> if(thisIsNotInitialized==null) >> System.out.println("null"); >> } >> >> public static void main(String[] args){ >> new Test().test(); >> } >> } >> >> I would expect to get "null" printed to the console. But that >> doesn't happen. The generated if is something like thos: >> >> if (_op1.o != [NSNull null]) goto label0; >> >> So it checks for [NSNull null]. But _op1.o contains 0x0 and the >> check is false. So I would guess that the initialization code of the >> ObjC variables has to be changed so that they contain [NSNull null] >> and not 0x0 by default. >> >> Hope you get what I mean. > > > > If a selector returns nil, what is seen in Java? > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |