nativelibs4java / BridJ

BridJ: blazing fast Java / C / C++ interop
https://code.google.com/archive/p/bridj/
Other
297 stars 77 forks source link

Set values for a fixed size array #51

Closed ivangfr closed 9 years ago

ivangfr commented 9 years ago

Hi,

I have a C struct like:

typedef struct type_MyStruct {
    int iMeasure;
    int position[3];
} MyStruct;

When I generate the java class I get something like:

public class MyStruct extends StructObject {
    ...

    @Field(0)
    public int iMeasure() {
        ...
    }

    @Field(0)
    public MyStruct iMeasure(int iMeasure) {
        ...
    }

    @Array({3}) 
    @Field(1) 
    public Pointer<Integer> position() {
        ...
    }

    ...
}

As you can see I don't have a method set for position like:

    @Field(1) 
    public MyStruct position(Pointer<Integer> position) {
        ...
    }

So, how can I set values for this array of 3 positions? For example:

MyStruct myStruct = new MyStruct();
myStruct.iMeasure(10);

???
myStruct.position()

Thanks

ochafik commented 9 years ago

Hi @ivangfr,

Thanks for using BridJ! You can set items of position with myStruct.position().set(index, value).

Cheers