java中结构体入参_JNA中自定义结构体如何传参?

1、先给出C的头文件里的结构体:

typedef struct DetectionZone

{

Zone zone;

DetectionZoneParam param;

} DetectionZone;

typedef struct DetectionZoneList

{

DetectionZone* zoneArray;

int zoneNum;

} DetectionZoneList;

2、我用JNAAeratorStudio工具生成了Java对应的结构体,如下:

public class DetectionZoneList extends Structure {

/** C type : DetectionZone* */

public DetectionZone.ByReference zoneArray;

public int zoneNum;

public DetectionZoneList() {

super();

}

protected List > getFieldOrder() {

return Arrays.asList("zoneArray", "zoneNum");

}

/** @param zoneArray C type : DetectionZone* */

public DetectionZoneList(DetectionZone.ByReference zoneArray, int zoneNum) {

super();

this.zoneArray = zoneArray;

this.zoneNum = zoneNum;

}

public DetectionZoneList(Pointer peer) {

super(peer);

}

protected ByReference newByReference() { return new ByReference(); }

protected ByValue newByValue() { return new ByValue(); }

protected DetectionZoneList newInstance() { return new DetectionZoneList(); }

public static DetectionZoneList[] newArray(int arrayLength) {

return Structure.newArray(DetectionZoneList.class, arrayLength);

}

public static class ByReference extends DetectionZoneList implements Structure.ByReference {

};

public static class ByValue extends DetectionZoneList implements Structure.ByValue {

};

};

3、下面是我的调用:

DetectionZoneList zoneProp = new DetectionZoneList();

zoneProp.zoneNum = 1;

zoneProp.zoneArray = new DetectionZone.ByReference();

4、问题:

这里我的zoneNum是1,调用没有问题,我的需求是传多个zone,zoneNum会大于1,请问如何传递该结构体?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值