Login  Register

Re: Problems getting started with gluten

Posted by Sven Gothel on Jan 23, 2012; 12:34am
URL: https://forum.jogamp.org/Problems-getting-started-with-gluten-tp3679814p3680663.html

On Sunday, January 22, 2012 11:29:35 PM Jennifer Milburn [via jogamp] wrote:

>
> Thanks Wade,
>    I had ant-antlr.jar on the class path (i.e. in the same directory) but I
> guess it was looking for antlr.jar. Your suggestion helped and I was able to
> generate the source code for one of the examples!  It appears that I can
> generate the JNI code for simple examples now.  I just tried generating the
> JNI code for the actual header file I need to work with and got a variety of
> errors.  However, it's clear that the gluegen is at least attempting to
> generate the JNI code.
>      I'm just trying to test the generation process on MacOS so I don't
> really expect this to work completely.  I'm going to generate different JNI
> classes for Windows and Linux using their respective header files (i.e.
> slightly different header for the two operating systems).  However, I am
> getting a large number of errors mostly related to ANTLR running into an
> unexpected token
> "extern" in the header.  
>
> ANTLR Parsing Error: line 122:4919: unexpected token: extern token
> name:"extern"
> line 122:4919: unexpected token: extern
> at com.jogamp.gluegen.cgram.GnuCParser.externalDef(GnuCParser.java:522)
> at com.jogamp.gluegen.cgram.GnuCParser.externalList(GnuCParser.java:258)
> at com.jogamp.gluegen.cgram.GnuCParser.translationUnit(GnuCParser.java:219)
> at com.jogamp.gluegen.GlueGen.run(GlueGen.java:131)
> at com.jogamp.gluegen.GlueGen.main(GlueGen.java:363)
> (note there are about 30 of these errors)
>
> I'm also getting the following error that is a little more serious.  Is this
> related to a limitation of JNI for this kind of method (i.e. a callback
> reference?)
>
> Exception in thread "main" java.lang.RuntimeException: Exception occurred
> while generating glue code.
> at com.jogamp.gluegen.GlueGen.run(GlueGen.java:304)
> at com.jogamp.gluegen.GlueGen.main(GlueGen.java:363)
> Caused by: java.lang.RuntimeException: Error while generating bindings for
> "int AT_RegisterFeatureCallback(AT_H Hndl, const AT_WC *  Feature, int
> (*EvCallback)(AT_H Hndl, const AT_WC *  Feature, void *  Context), void *
> Context);"
> at
> com.jogamp.gluegen.JavaEmitter.generateMethodBindingEmitters(JavaEmitter.java:726)
> at com.jogamp.gluegen.JavaEmitter.emitFunctions(JavaEmitter.java:419)
> at com.jogamp.gluegen.GlueGen.run(GlueGen.java:297)
> ... 1 more
> Caused by: java.lang.RuntimeException: Don't know how to convert
> pointer/array type "FeatureCallback"
> at com.jogamp.gluegen.JavaEmitter.typeToJavaType(JavaEmitter.java:1292)
> at com.jogamp.gluegen.JavaEmitter.bindFunction(JavaEmitter.java:1717)
> at
> com.jogamp.gluegen.JavaEmitter.generateMethodBindingEmitters(JavaEmitter.java:651)
> ... 3 more
>
> Any insight would be appreciated :)  I don't have any control over the
> header or the C interface.  I'm simply trying to create a java interface to
> the cameras drivers for Linux and Windows and the drivers are provided by
> the manufacturer.

Without seeing your c-header input files
I am not able to determine the source of the error,
ie whether they come from the input or GlueGen itself.

GlueGen itself includes test code and headers which are being parsed
and code generated for:
  src/junit/com/jogamp/gluegen/test/junit/generation/test1.h

The following class tests the generated signatures _and_ the proper data handling:
  src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java

Even though they are pretty simple, they demonstrate how it should work.

In JOGL for example, you can see more elaborated use of GlueGen
including dealing with API specific macros like GL_API .. etc.

Reading your error messages it is at least clear that not all macros are resolved,
eg. AT_H, AT_WC, Feature .. etc .. - but they all need to be resolved to have GlueGen
parse valid C headers.

One way is to include specific headers for the GlueGen processing
where you resolve them in a special way, or use the proper headers if this is possible.
You also could define types as opaque etc .. in the config files.

~Sven

> Sincerely,
> Jennifer Milburn
>
>