From: Arno P. <ar...@pu...> - 2011-05-09 18:20:24
|
Troy, first of all, the reason for doing the C backend is to fully support the Java object model. With the Objective-C backend, this simple Java program cannot be cross-compiled: class Base { int x; } class Derived extends Base { int x; } This is just one of several problems when trying to use the Objective-C object model to represent Java's object model. The C backend also features a fully-fledged garbage collector which was impossible for various reasons with Objective-C. Now to your question: lets assume you have interface I: interface I { public void foo(); } Then write a Java class as follows: class I_impl implements I { public native void foo(); } Cross-compile I_impl with the C backend and provide the implementation of I_impl.foo() as a C function. If you want I_impl to be a wrapper of an Objective-C object, you can add a helper field in Java: class I_impl implements I { private Object wrappedObjectiveCObject; public native void foo(); } Field 'wrappedObjectiveCObject' can then be 'abused' in the C code to save a reference to an Objective-C object. I would also suggest you take a look at xmlvm/doc/slides. There are a few slides highlighting some more details of the C backend. Arno On 5/9/11 11:00 AM, Troy Gaines wrote: > Hello everyone, > > Here's an issue we're having with the new C-backend. Originally, we > started using the cross-compatible Objective C library, which has served > us well. We used this for cross-compiling part of the application. The > rest we wrote by hand, since the interface was scoped to be different > between the two platforms. We're now trying to move to the new C > back-end but the semantics are now different. > > An example is how the Java Interface is cross-compiled. With the > cross-compatible library, it would generate an Objective C protocol. On > our side, we would create an Objective C class implementing the > protocol. With the posix target, it generates a C structure. > > What is the recommended way of making this transition? Am I missing > something? > > And thanks for all the hard work with this project! > > > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > > > > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |