A few days ago, David Kocher posted complete Objective-C mappings for the Foundation & AppKit frameworks on Rococoa’s mailing-list that he built using JNAerator and a good amount of hand-tweaking.

This boosted my motivation to enhance JNAerator and I basically rewrote most of the Objective-C-specific code of JNAerator to remove the need for any hand-tweaking.

The goal is almost reached, in its current version JNAerator is able to parse all of the Foundation framework and spit out a bunch of classes that compile straight away.

Try this :

`A few days ago, David Kocher posted complete Objective-C mappings for the Foundation & AppKit frameworks on Rococoa’s mailing-list that he built using JNAerator and a good amount of hand-tweaking.

This boosted my motivation to enhance JNAerator and I basically rewrote most of the Objective-C-specific code of JNAerator to remove the need for any hand-tweaking.

The goal is almost reached, in its current version JNAerator is able to parse all of the Foundation framework and spit out a bunch of classes that compile straight away.

Try this :

`

And you’ll get compiled wrappers for all of the Foundation framework classes.

Now for sure there are tons of bugs to iron out and many missing features (the devil is in the detail), but that’s an important milestone.

Here are the main changes in this version :

  • fix of the compilation code for use with Javac (Eclipse compiler was ok) : using the -jar outputJarFile command-line option will compile of all generated files and write a JAR with both classes and sources (for javadoc extraction in Java IDEs).
  • Objective-C wrappers generation was completely rewritten :
    • Objective-C protocols end up in Java interfaces
    • Objective-C classes are represented by abstract Java classes. This is a new feature of Rococoa, thanks to David Kocher & Duncan McGregor for the sample code
    • for each initXXXWithYYY method in Objective-C classes, a static method createXXXWithYYY(…) is created in the generated Java class : it returns alloc().initXXXWithYYY(…).
    • the NSClass instance associated to an Objective-C class (as opposed to a protocol) is created lazily by a private static getter
    • all class methods of Objective-C classes are forwarded in the body of the generated class :

      @interface Test : NSObject
      +(NSObject*)classMethod;
      @end
      

      Becomes :

      public abstract class Test extends NSObject {
      public static NSObject classMethod() {
      return _getCLASS_(). classMethod();
      }
      public static Test alloc() {
      return _getCLASS_().alloc();
      }
      public abstract class _class_ extends NSClass {
      public abstract NSObject classMethod();
      public abstract Test alloc();
      }
      private static _class_ _CLASS_;
      private static _class_ _getCLASS_() {
      if (_CLASS_ == null)
          _CLASS_ = Rococoa.createClass("Test", _class_.class);
      return _CLASS_;
      }
      }
      
    • _id_ is converted to either NSObject or AProtocol, in two different versions of the methods :

      ```objc -(NSObject*)test:(id)arg;

</nscopying>```

    Becomes :
  
    ```java @java.lang.Deprecated public abstract NSObject test(NSObject arg); public abstract NSObject test(NSCopying arg); ``` 

[A few days ago, David Kocher posted complete Objective-C mappings for the Foundation & AppKit frameworks on Rococoa’s mailing-list that he built using JNAerator and a good amount of hand-tweaking.

This boosted my motivation to enhance JNAerator and I basically rewrote most of the Objective-C-specific code of JNAerator to remove the need for any hand-tweaking.

The goal is almost reached, in its current version JNAerator is able to parse all of the Foundation framework and spit out a bunch of classes that compile straight away.

Try this :

`A few days ago, David Kocher posted complete Objective-C mappings for the Foundation & AppKit frameworks on Rococoa’s mailing-list that he built using JNAerator and a good amount of hand-tweaking.

This boosted my motivation to enhance JNAerator and I basically rewrote most of the Objective-C-specific code of JNAerator to remove the need for any hand-tweaking.

The goal is almost reached, in its current version JNAerator is able to parse all of the Foundation framework and spit out a bunch of classes that compile straight away.

Try this :

`

And you’ll get compiled wrappers for all of the Foundation framework classes.

Now for sure there are tons of bugs to iron out and many missing features (the devil is in the detail), but that’s an important milestone.

Here are the main changes in this version :

  • fix of the compilation code for use with Javac (Eclipse compiler was ok) : using the -jar outputJarFile command-line option will compile of all generated files and write a JAR with both classes and sources (for javadoc extraction in Java IDEs).
  • Objective-C wrappers generation was completely rewritten :
    • Objective-C protocols end up in Java interfaces
    • Objective-C classes are represented by abstract Java classes. This is a new feature of Rococoa, thanks to David Kocher & Duncan McGregor for the sample code
    • for each initXXXWithYYY method in Objective-C classes, a static method createXXXWithYYY(…) is created in the generated Java class : it returns alloc().initXXXWithYYY(…).
    • the NSClass instance associated to an Objective-C class (as opposed to a protocol) is created lazily by a private static getter
    • all class methods of Objective-C classes are forwarded in the body of the generated class :

      @interface Test : NSObject
      +(NSObject*)classMethod;
      @end
      

      Becomes :

      public abstract class Test extends NSObject {
      public static NSObject classMethod() {
      return _getCLASS_(). classMethod();
      }
      public static Test alloc() {
      return _getCLASS_().alloc();
      }
      public abstract class _class_ extends NSClass {
      public abstract NSObject classMethod();
      public abstract Test alloc();
      }
      private static _class_ _CLASS_;
      private static _class_ _getCLASS_() {
      if (_CLASS_ == null)
          _CLASS_ = Rococoa.createClass("Test", _class_.class);
      return _CLASS_;
      }
      }
      
    • _id_ is converted to either NSObject or AProtocol, in two different versions of the methods :

      ```objc -(NSObject*)test:(id)arg;

</nscopying>```

    Becomes :
  
    ```java @java.lang.Deprecated public abstract NSObject test(NSObject arg); public abstract NSObject test(NSCopying arg); ``` 

](http://ochafik.free.fr/Java/JNAeratorStudio.jnlp)