nativelibs4java / JNAerator

JNAerator: native bindings generator for JNA / BridJ / Node.js
http://jnaerator.googlecode.com
510 stars 109 forks source link

JNAerator fails on GnuTLS header for JNA runtime #61

Open ochafik opened 9 years ago

ochafik commented 9 years ago

From @rdicroce on March 17, 2014 21:44

I tried to run JNAerator on gnutls.h. After playing around with different command-line options, I've been unable to get the correct output.

I'm using the pre-built Win32 binary package from ftp://ftp.gnutls.org/gcrypt/gnutls/w32/. I have placed JNAerator in the include directory so it will find the related headers.

If I run this:

java -jar jnaerator-0.12-20140222.210027-44-shaded.jar -mode Directory -runtime JNA -f -beautifyNames -library gnutls -v gnutls/gnutls.h

JNAerator "succeeds" in that it outputs GnutlsLibrary.java, but this generated file only contains definitions of constants. It does not contain ANY functions defined in gnutls.h.

If I add the -parseChunks option, JNAerator fails with a NullPointerException:

Regular parsing took too long, now trying to parse sources slice by slice.
java.lang.NullPointerException
        at com.ochafik.lang.jnaerator.Result.getFakePointer(Result.java:215)
        at com.ochafik.lang.jnaerator.JNATypeConversion$1.visitSimpleTypeRef(JNA
TypeConversion.java:580)
        at com.ochafik.lang.jnaerator.parser.TypeRef$SimpleTypeRef.accept(TypeRe
f.java:146)
        at com.ochafik.lang.jnaerator.parser.Scanner.visit(Scanner.java:466)
        at com.ochafik.lang.jnaerator.parser.Scanner.visitDeclaration(Scanner.ja
va:117)
        at com.ochafik.lang.jnaerator.parser.Scanner.visitArg(Scanner.java:77)
        at com.ochafik.lang.jnaerator.parser.Arg.accept(Arg.java:115)
        at com.ochafik.lang.jnaerator.JNATypeConversion.resolveTypeDef(JNATypeCo
nversion.java:502)
        at com.ochafik.lang.jnaerator.JNATypeConversion.resolveTypeDef(JNATypeCo
nversion.java:477)
        at com.ochafik.lang.jnaerator.JNATypeConversion.convertTypeToJNA(JNAType
Conversion.java:63)
        at com.ochafik.lang.jnaerator.JNADeclarationsConverter.convertVariablesD
eclarationToJNA(JNADeclarationsConverter.java:598)
        at com.ochafik.lang.jnaerator.JNADeclarationsConverter.convertVariablesD
eclaration(JNADeclarationsConverter.java:671)
        at com.ochafik.lang.jnaerator.JNADeclarationsConverter.convertStruct(JNA
DeclarationsConverter.java:430)
        at com.ochafik.lang.jnaerator.DeclarationsConverter.outputConvertedStruc
t(DeclarationsConverter.java:630)
        at com.ochafik.lang.jnaerator.JNADeclarationsConverter.convertStruct(JNA
DeclarationsConverter.java:435)
        at com.ochafik.lang.jnaerator.DeclarationsConverter.outputConvertedStruc
t(DeclarationsConverter.java:630)
        at com.ochafik.lang.jnaerator.DeclarationsConverter.convertStructs(Decla
rationsConverter.java:683)
        at com.ochafik.lang.jnaerator.DeclarationsConverter.fillLibraryMapping(D
eclarationsConverter.java:904)
        at com.ochafik.lang.jnaerator.JNADeclarationsConverter.generateLibraryFi
les(JNADeclarationsConverter.java:1143)
        at com.ochafik.lang.jnaerator.JNAerator.generateLibraryFiles(JNAerator.j
ava:1474)
        at com.ochafik.lang.jnaerator.JNAerator.jnaerationCore(JNAerator.java:14
46)
        at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:999)
        at com.ochafik.lang.jnaerator.JNAerator$1.finished(JNAerator.java:767)
        at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(
JNAeratorCommandLineArgs.java:148)
        at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:224)
        at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:197)
java.lang.NullPointerException
        at com.ochafik.lang.jnaerator.JNAerator$1$2.setFinished(JNAerator.java:7
34)
        at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:1047)
        at com.ochafik.lang.jnaerator.JNAerator$1.finished(JNAerator.java:767)
        at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(
JNAeratorCommandLineArgs.java:148)
        at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:224)
        at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:197)
#
# ERROR: JNAeration failed !
#
#       java.lang.NullPointerException
#

Copied from original issue: ochafik/nativelibs4java#485

ochafik commented 9 years ago

From @rdicroce on March 18, 2014 14:42

Just tried this with version 0.11. Behavior without -parseChunks is the same as latest snapshot, but it appears to work correctly with -parseChunks.