javacpp icon indicating copy to clipboard operation
javacpp copied to clipboard

How to parsing function pointer that has mutidimensional array parameter?

Open rodamin opened this issue 2 years ago • 4 comments

// in header file

int (* testFunc)(char[][256] value);
// in generated java file

public static class TestFunc_BytePointer extends FunctionPointer {
    static { Loader.load(); }
    public TestFunc_BytePointer (Pointer p) { super(p); }
    protected TestFunc_BytePointer () { allocate(); }
    private native void allocate();

    public native int call(@Cast("char*") BytePointer errorList);
}
// generated native jni file

struct JavaCPP_hidden JavaCPP_org_bytedeco_test_ClassName_00024TestFunc_1BytePointer{
JavaCPP_org_bytedeco_test_ClassName_00024TestFunc_1BytePointer() : ptr(NULL), obj(NULL) { }
    int operator()(char* arg0);
    int (*ptr)(char* arg0);
    jobject obj; static jmethodID mid;
};

=> compile error error C2440: '=': cannot convert from 'int (__cdecl *)(char [][256])' to 'int (__cdecl *)(char *)'

rodamin avatar Jun 17 '22 09:06 rodamin

The Parser is probably going to have a hard time with that. Try to output the definition using Info.javaText: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#mapping-a-declaration-to-custom-code

saudet avatar Jun 17 '22 09:06 saudet

@saudet How to select call method of Function Pointer?

I tried new Info ("ClassName::testFunc") but it doesn't work.

rodamin avatar Jun 17 '22 10:06 rodamin

It's probably picking it up as int (*)(char*).

saudet avatar Jun 17 '22 10:06 saudet

@saudet Oh, thank you! I'll give it a try!

rodamin avatar Jun 17 '22 10:06 rodamin