From: Tomas V. <tom...@gm...> - 2010-11-30 09:49:20
|
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 -- Quand on veut un mouton, c'est la preuve qu'on existe |
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 |
From: Panayotis K. <pan...@pa...> - 2010-11-30 18:38:21
|
On Nov 30, 2010, at 8:18 PM, Arno Puder wrote: > > 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. You can also take advantage of the "plugin" mechanism. To see a demo of this convenient way, have a look at the directory demo/iphome/plugins/Zip |
From: Tomas V. <tom...@gm...> - 2010-12-02 13:20:14
|
Hi, Arno: Yes, that's what I thought. So right now I'm trying to do a demo using only Java and cross compiling it to Obj-C code. I'm also trying to implement missing classes (now UITextViewDelegate) by first writing the stub in Java, cc:ing it to Obj-C and filling in the methods. Personally I found the C backend code much harder to understand but I haven't done a lot of C or Obj-C coding. How exactly is supposed to be used? Panayotis: Thank you, that is a perfect example. I'm currently trying to implement everything in Java but I think I will try something similar to the Zip plugin after to evaluate the options. If I implement classes on my own I would of course like to contribute and upload them. What worries me is that as I haven't done any Obj-C before, I'm currently reading about it and how it works so I'm not completely lost. When I'm implementing a new class I'm also looking at other similar classes that are implemented. But I can't be 100% sure that it's correct, how should I proceed then? Best regards, Tomas Vestelind On 30 November 2010 19:37, Panayotis Katsaloulis <pan...@pa...>wrote: > > On Nov 30, 2010, at 8:18 PM, Arno Puder wrote: > > > > > 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. > > You can also take advantage of the "plugin" mechanism. > To see a demo of this convenient way, have a look at the directory > demo/iphome/plugins/Zip > > > > > ------------------------------------------------------------------------------ > 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 > -- Quand on veut un mouton, c'est la preuve qu'on existe |