nativelibs4java / JNAerator

JNAerator: native bindings generator for JNA / BridJ / Node.js

Home Page:http://jnaerator.googlecode.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unnamed union processed but incorrectly referenced

kevemueller opened this issue · comments

First of all: amazing work!
I am running jnaerator-0.12 against the capstone library https://capstone-engine.github.io/download/3.0.4/capstone-3.0.4-win64.zip it produces a way better binding than the hand-tooled one of the author.
I ran into a strange show stopper.

typedef struct cs_detail {
  uint8_t regs_read[12];
  uint8_t regs_read_count; 
  uint8_t regs_write[20]; 
  uint8_t regs_write_count; 
  uint8_t groups[8]; 
  uint8_t groups_count; 
  union {
    cs_x86 x86; 
    cs_arm64 arm64;
    cs_arm arm; 
    cs_mips mips;   
    cs_ppc ppc; 
    cs_sparc sparc;
    cs_sysz sysz;   
    cs_xcore xcore;
  };
} cs_detail;

The unnamed union is processed fine, but the field1 accessor is referencing a completely different class than the one which is defined in the inner static class.

public class cs_detail extends StructObject {
  [...]
  public capstone.cs_arm_op.field1_union field1() {
    return this.io.getNativeObjectField(this, 6);
  }
  @Union 
  public static class field1_union extends StructObject {

At runtime the actual union is inaccessible.
Removing the erroneous capstone.cs_arm_op. yields a perfectly valid result.
I appreciate any feedback on how to resolve.

Cheers, and keep up the good work!