After a few weeks focusing entirely on fixing JNAerator’s parsing of more complex “theoretical” C constructs, I decided to go back to testing the parsing of real-world headers.

I picked the OpenCL headers (cl.h, cl_platform.h and cl_gl.h), which is not a project targeted at by JNAerator (it does high performance calculations, so accessing it through the reflection-heavy JNA makes little sense for now) but is very interesting from a parsing point of view : abundance of defines & typedefs, very little, self-contained files, weird comments style, no argument name for functions…

Good news is that JNAerator is now able to parse these three headers more or less correctly, and hence should be a bit less useless :-D.

Bad news is that I still did not find time to settle a proper regression test environment for JNAerated artifacts (so far, I only test parsing, serialization of DOM & design constraints on DOM classes). More on this front soon, I hope !

Here are the main changes in this version 0.3 (build 207) :

  • Now generates Pointer where it fails to resolve a pointer type (say for instance “struct S*” where S is nowhere to be found)
  • Added command-line option -defaultLibrary
  • Fixed the -library command line option : now you won’t get windows include symbols unless you provide a -defaultLibrary
  • Parse function argument comments and refactor them as JavaDocs :

    // Enqueued Commands APIs
    extern CL_API_ENTRY cl_int CL_API_CALL
    clEnqueueReadBuffer(cl_command_queue /* command_queue */,
      cl_mem /* buffer */,
      cl_bool /* blocking_read */,
      size_t /* offset */,
      size_t /* cb */,
      void * /* ptr */,
      cl_uint /* num_events_in_wait_list */,
      const cl_event * /* event_wait_list */,
      cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
    

    now becomes :

    /**
     * Enqueued Commands APIs
     * Original signature : `cl_int clEnqueueReadBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void*, cl_uint, cl_event*, cl_event*)`
     * @param cl_command_queue1 command_queue
     * @param cl_mem1 buffer
     * @param cl_bool1 blocking_read
     * @param size_t1 offset
     * @param size_t2 cb
     * @param arg1 ptr
     * @param cl_uint1 num_events_in_wait_list
     * @param cl_eventPtr1 event_wait_list
     * @param cl_eventPtr2 event
     * <i>native declaration : /Users/ochafik/src/opencl/cl.h</i>
     */
    int clEnqueueReadBuffer(
      com.sun.jna.Pointer cl_command_queue1,
      com.sun.jna.Pointer cl_mem1,
      int cl_bool1,
      com.sun.jna.NativeLong size_t1,
      com.sun.jna.NativeLong size_t2,
      com.sun.jna.Pointer arg1,
      int cl_uint1,
      com.sun.jna.ptr.PointerByReference cl_eventPtr1,
      com.sun.jna.ptr.PointerByReference cl_eventPtr2
    );
    
  • Better arg name choice for functions with anonymous args : now based on type when it makes sense (instead of just “arg” stubs)
  • Fixed parsing of __const modifier

Launch JNAeratorStudio (Web Start) or visit JNAerator’s project on Google Code