From: Arno P. <ar...@pu...> - 2010-11-30 18:19:08
|
the preferred way is to do as much as possible in Java and then cross-compile to Objective-C. If you already have an Objective-C class that you want to expose in Java, you need to create a Java stub and then write some "glue" code in Objective-C that bridges the Java API to the Objective-C API. This is necessary because of the certain differences between the languages. E.g., we have to use name mangling when cross-compiling from Java to Objective-C and the "glue" code needs to do a mapping from the mangled version of a name to the original version. Here is an example taken from xmlvm/src/xmlvm2objc/compat-lib/objc/org_xmlvm_iphone_UIImage.m: + (org_xmlvm_iphone_UIImage*) imageWithContentsOfFile___java_lang_String :(java_lang_String*)path { return [[UIImage alloc] initWithContentsOfFile:path]; } The new C backend (once its done), can automate some of the boilerplate code that currently needs to be done manually in Objective-C. Here is the same example from the C backend: JAVA_OBJECT org_xmlvm_iphone_UIImage_imageWithContentsOfFile___java_lang_String(JAVA_OBJECT n1) { if (!__CLASS_org_xmlvm_iphone_UIImage.classInitialized) __INIT_org_xmlvm_iphone_UIImage(); //XMLVM_BEGIN_WRAPPER[org_xmlvm_iphone_UIImage_imageWithContentsOfFile___java_lang_String] NSString *nsStr = toNSString(n1); UIImage *named = [UIImage imageNamed:nsStr]; org_xmlvm_iphone_UIImage *toRet = __NEW_org_xmlvm_iphone_UIImage(); toRet->org_xmlvm_iphone_UIImage.ocImage = named; return toRet; //XMLVM_END_WRAPPER } Only the code between the //XMLVM_* comments was written by hand; the rest was generated by the C backend. Arno On 11/30/10 1:48 AM, Tomas Vestelind wrote: > Hi, > > I'm doing a proof-of-concept implementation with XMLVM for my master's > thesis. > > I have a mobile application which uses a in-house framework and my goal > is to make the program cross compile with XMLVM and do the framework > components either in Objective-C or in Java then cross compiling it to > Objective-C. So, I'm wondering how you do when you implement new classes > in Objective-C. I will need this for our classes and possibly for Cocoa > classes that are not implemented. > > From what I have understood you create stubs in Java and then use XMLVM > to generate Objective-C source files from these. Then you do the > implementation of each class manually. Is this correct? > > If this is the case and I would like to implement a new class in > Objective-C, would I do my skeleton in Java, generate the Objective-C > code and do the implementation in Objective-C? > > Best regards, > Tomas Vestelind > > ps. I think > https://sites.google.com/a/xmlvm.org/documentation/home should be on > www.xmlvm.org <http://www.xmlvm.org> > > -- > Quand on veut un mouton, c'est la preuve qu'on existe > > > > ------------------------------------------------------------------------------ > Increase Visibility of Your 3D Game App& Earn a Chance To Win $500! > Tap into the largest installed PC base& get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. > http://p.sf.net/sfu/intelisp-dev2dev > > > > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |