raydac/java-binary-block-parser

JBBPByteOrder may add nativeOrder and inheritOrder

wjtxyz opened this issue · 3 comments

JBBPOut use the Object's @bin annotation ByteOrder instead of inherit the ByteOrder from JBBPOut constructor when call JBBPOut.Bin(Object)

example:

`

   byte[] bins = JBBPOut.BeginBin(JBBPByteOrder.LITTLE_ENDIAN).Int(123).Bin(new CommandData(123)).End().toByteArray();
   //actually, bins=[123, 0, 0, 0, 0, 0, 0, 123], but i want bins=[123, 0, 0, 0, 123, 0, 0, 0]

 static class CommandData{
    @Bin(order = 1)
    int data;

    public CommandData(int data) {
        this.data = data;
    }
}

`

am I correct that you have @Bin annotated object where directly defined ByteOrder and you want override order provided in @Bin by order provided in JBBPOut?

am I correct that you have @Bin annotated object where directly defined ByteOrder and you want override order provided in @Bin by order provided in JBBPOut?

yes

I have added into 2.0.2-SNAPSHOT new method JBBPOut#BinForceByteOrder