bodensx / jnaerator

Automatically exported from code.google.com/p/jnaerator
0 stars 0 forks source link

@Name renaming for bridJ overloaded parameterless functions ignored #101

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am trying to use jnaerator for the QCam library (used to control QImaging 
cameras).

I'm using jnaerator to produce a bundled Jar file with the bridJ option:

java -jar jnaerator-0.12-SNAPSHOT-20130323-2.jar -v -convertBodies -jar 
QCam.jar -direct -library QCam -mode StandaloneJar  CHeaders/*.h libQCam.dylib

It produces this java file (redacted version shown):

@Library("QCam") 
@Runtime(CRuntime.class) 
public class QCamLibrary {

    /**
     * QCam_LoadDriver()
     *  Result:
     *    QCam_Err code<br>
     * Original signature : <code>QCam_Err QCam_LoadDriver()</code><br>
     * <i>native declaration : CHeaders/QCamApi.h:785</i>
     */
    @Convention(Convention.Style.StdCall) 
    public static IntValuedEnum<QCamLibrary.QCam_Err > QCam_LoadDriver() {
        return FlagSet.fromValue(QCam_LoadDriver$2(), QCamLibrary.QCam_Err.class);
    }
    @Convention(Convention.Style.StdCall) 
    @Name("QCam_LoadDriver") 
    protected native static int QCam_LoadDriver$2();
}

When using this with Eclipse with a test program to use this QCam.jar I get an 
unsatisfied link error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: 
qcam.QCamLibrary.QCam_LoadDriver$2()I
    at qcam.QCamLibrary.QCam_LoadDriver$2(Native Method)
    at qcam.QCamLibrary.QCam_LoadDriver(QCamLibrary.java:1010)
    at TestQCam.main(TestQCam.java:47)

The dynamic library is being loaded. All works well if I duplicate the 
QCamLibrary and change it to:

    @Convention(Convention.Style.StdCall) 
    public static IntValuedEnum<QCamLibrary2.QCam_Err > QCam_LoadDriverNew() {
        return FlagSet.fromValue(QCam_LoadDriver(), QCamLibrary2.QCam_Err.class);
    }
    @Convention(Convention.Style.StdCall) 
    protected native static int QCam_LoadDriver();

I presume the @Name annotation is being used because since QCam_LoadDriver 
takes no parameters there is no way to disambiguate the overloaded variant that 
returns the enum and the native version (returning int) based on function 
signature. However it looks as if the @Name annotation is not being honoured!

But how can I get around this problem? I want to just use the jnaerated 
QCam,jar version

Original issue reported on code.google.com by michael5...@gmail.com on 5 Jun 2013 at 7:22