A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bytedeco/javacpp/discussions/528 below:

Addressing arrays of structs within structs · bytedeco/javacpp · Discussion #528 · GitHub

Hi,
I got a C header file with following complex structure:

header file:
typedef struct iodbctpr {
    struct {
        long    acc_bipl[MAX_AXIS];
        long    acc_chg_time;
        /* ... */
    } data;
    struct {
        short   datano;
        short   type;
        union {
            char    cdata;
            short   idata;
            long    ldata;
            char    cdatas[MAX_AXIS];
            /* ... */
        } u;
    } prm[2];
} IODBCTPR;

Javacpp generates the following ...

Java code:
public class IODBCTPR extends Pointer {
    static { Loader.load(); }
    /** Default native constructor. */
    public IODBCTPR() { super((Pointer)null); allocate(); }
    /** Native array allocator. Access with {@link Pointer#position(long)}. */
    public IODBCTPR(long size) { super((Pointer)null); allocateArray(size); }
    /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
    public IODBCTPR(Pointer p) { super(p); }
    private native void allocate();
    private native void allocateArray(long size);
    @Override public IODBCTPR position(long position) {
        return (IODBCTPR)super.position(position);
    }
    @Override public IODBCTPR getPointer(long i) {
        return new IODBCTPR((Pointer)this).offsetAddress(i);
    }

        @Name("data.acc_bipl") public native long data_acc_bipl(int i); public native IODBCTPR data_acc_bipl(int i, long setter);
        @Name("data.acc_bipl") @MemberGetter public native CLongPointer data_acc_bipl();
        @Name("data.acc_chg_time") public native long data_acc_chg_time(); public native IODBCTPR data_acc_chg_time(long setter);
        /* ... */
        @Name({"prm", ".datano"}) public native short prm_datano(int i); public native IODBCTPR prm_datano(int i, short setter);
        @Name({"prm", ".type"}) public native short prm_type(int i); public native IODBCTPR prm_type(int i, short setter);
            @Name("prm.u.cdata") public native @Cast("char") byte prm_u_cdata(); public native IODBCTPR prm_u_cdata(byte setter);
            @Name("prm.u.idata") public native short prm_u_idata(); public native IODBCTPR prm_u_idata(short setter);
            @Name("prm.u.ldata") public native long prm_u_ldata(); public native IODBCTPR prm_u_ldata(long setter);
            @Name("prm.u.cdatas") public native @Cast("char") byte prm_u_cdatas(int i); public native IODBCTPR prm_u_cdatas(int i, byte setter);
            @Name("prm.u.cdatas") @MemberGetter public native @Cast("char*") BytePointer prm_u_cdatas();
        /* ... */
}

... and

jni....cpp code
static int JavaCPP_offsets[1][154] = {
        { sizeof(Fwlib32::IODBCTPR), offsetof(Fwlib32::IODBCTPR, data.jerk_acc_diff_lin), offsetof(Fwlib32::IODBCTPR, data.acc_chg_time), offsetof(Fwlib32::IODBCTPR, prm), offsetof(Fwlib32::IODBCTPR, prm.u.cdata), offsetof(Fwlib32::IODBCTPR, prm.u.idata), offsetof(Fwlib32::IODBCTPR, prm.u.ldata), offsetof(Fwlib32::IODBCTPR, prm.u.cdatas)}};

Since accessing the member prm requires an index like prm[0]

error: request for member ‘u’ in
‘((Fwlib32::IODBCTPR*)0)->Fwlib32::iodbctpr::prm’, which is of non-class type ‘Fwlib32::iodbctpr::<unnamed struct> [2]’`
* the generated Java code (see _jniOdbctpr.cpp.txt_) accesses only the first element of the array `prm`.

Is there any idea how to setup the parser to generate the correct code? (What entry in the InfoMap.map(InfoMap infoMap) can be added to solve the problem?)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4