@@ -356,7 +356,7 @@ public void visitEnd() {
356356 }
357357
358358 @ Override
359- public void visitStructureStart (final int offsetInCompiledBlock , final JBBPNamedFieldInfo nullableNameFieldInfo , final JBBPIntegerValueEvaluator nullableArraySize ) {
359+ public void visitStructureStart (final int offsetInCompiledBlock , final JBBPByteOrder byteOrder , final JBBPNamedFieldInfo nullableNameFieldInfo , final JBBPIntegerValueEvaluator nullableArraySize ) {
360360 final String structName = (nullableNameFieldInfo == null ? makeAnonymousStructName () : prepFldName (nullableNameFieldInfo .getFieldName ())).toLowerCase (Locale .ENGLISH );
361361 final String structBaseTypeName = structName .toUpperCase (Locale .ENGLISH );
362362 final String arraySizeIn = nullableArraySize == null ? null : evaluatorToString (NAME_INPUT_STREAM , offsetInCompiledBlock , nullableArraySize , this .flagSet , true );
@@ -379,7 +379,7 @@ public void visitStructureStart(final int offsetInCompiledBlock, final JBBPNamed
379379 if (nullableArraySize == null ) {
380380 structType = structBaseTypeName ;
381381 if (this .builder .generateFields ) {
382- printField (nullableNameFieldInfo , false , getCurrentStruct ().getFields ().indent (), null , fieldModifier , structType , structName );
382+ printField (nullableNameFieldInfo , byteOrder , false , getCurrentStruct ().getFields ().indent (), null , fieldModifier , structType , structName );
383383 }
384384
385385 processSkipRemainingFlag ();
@@ -392,7 +392,7 @@ public void visitStructureStart(final int offsetInCompiledBlock, final JBBPNamed
392392 } else {
393393 structType = structBaseTypeName + " []" ;
394394 if (this .builder .generateFields ) {
395- printField (nullableNameFieldInfo , true , getCurrentStruct ().getFields ().indent (), null , fieldModifier , structType , structName );
395+ printField (nullableNameFieldInfo , byteOrder , true , getCurrentStruct ().getFields ().indent (), null , fieldModifier , structType , structName );
396396 }
397397 processSkipRemainingFlag ();
398398 processSkipRemainingFlagForWriting ("this." + structName );
@@ -477,7 +477,7 @@ public void visitStructureEnd(final int offsetInCompiledBlock, final JBBPNamedFi
477477 }
478478
479479 @ Override
480- public void visitValField (final int offsetInCompiledBlock , final JBBPNamedFieldInfo nameFieldInfo , final JBBPIntegerValueEvaluator expression ) {
480+ public void visitValField (final int offsetInCompiledBlock , final JBBPByteOrder byteOrder , final JBBPNamedFieldInfo nameFieldInfo , final JBBPIntegerValueEvaluator expression ) {
481481 final String fieldName = prepFldName (nameFieldInfo .getFieldName ());
482482 FieldType type = FieldType .VAL ;
483483
@@ -496,7 +496,7 @@ public void visitValField(final int offsetInCompiledBlock, final JBBPNamedFieldI
496496 getCurrentStruct ().getFields ().printf ("@Bin(name=\" %s\" )" , nameFieldInfo .getFieldName ());
497497 }
498498 }
499- printField (nameFieldInfo , false , getCurrentStruct ().getFields (), FieldType .VAL , fieldModifier , textFieldType , fieldName );
499+ printField (nameFieldInfo , byteOrder , false , getCurrentStruct ().getFields (), FieldType .VAL , fieldModifier , textFieldType , fieldName );
500500 }
501501
502502 final String valIn = evaluatorToString (NAME_INPUT_STREAM , offsetInCompiledBlock , expression , this .flagSet , false );
@@ -511,6 +511,7 @@ public void visitValField(final int offsetInCompiledBlock, final JBBPNamedFieldI
511511 }
512512
513513 private void printField (final JBBPNamedFieldInfo nullableFieldInfo ,
514+ final JBBPByteOrder byteOrder ,
514515 final boolean array ,
515516 final JavaSrcTextBuffer buffer ,
516517 final FieldType nullableFieldType ,
@@ -524,22 +525,23 @@ private void printField(final JBBPNamedFieldInfo nullableFieldInfo,
524525 || nullableFieldType .getBinType () == BinType .UNDEFINED
525526 || nullableFieldType .getBinTypeArray () == BinType .UNDEFINED ) {
526527 if (binName == null ) {
527- buffer .printf ("@Bin%n" );
528+ buffer .printf ("@Bin(outByteOrder=JBBPByteOrder.%s)%n" , byteOrder . name () );
528529 } else {
529- buffer .printf ("@Bin(name=\" %s\" )%n" , binName );
530+ buffer .printf ("@Bin(name=\" %s\" ,outByteOrder=JBBPByteOrder.%s )%n" , binName , byteOrder . name () );
530531 }
531532 } else {
532533 if (binName == null ) {
533- buffer .printf ("@Bin(type=BinType.%s)%n" , array ? nullableFieldType .getBinTypeArray () : nullableFieldType .getBinType ());
534+ buffer .printf ("@Bin(type=BinType.%s,outByteOrder=JBBPByteOrder.%s )%n" , array ? nullableFieldType .getBinTypeArray () : nullableFieldType .getBinType (), byteOrder . name ());
534535 } else {
535- buffer .printf ("@Bin(name=\" %s\" ,type=BinType.%s)%n" , binName , array ? nullableFieldType .getBinTypeArray () : nullableFieldType .getBinType ());
536+ buffer .printf ("@Bin(name=\" %s\" ,type=BinType.%s,outByteOrder=JBBPByteOrder.%s )%n" , binName , array ? nullableFieldType .getBinTypeArray () : nullableFieldType .getBinType (), byteOrder . name ());
536537 }
537538 }
538539 }
539540 buffer .printf ("%s %s %s;%n" , modifier , type , name );
540541 }
541542
542543 private void printBitField (final boolean array ,
544+ final JBBPByteOrder byteOrder ,
543545 final JBBPNamedFieldInfo nullableFieldInfo ,
544546 final String sizeOfFieldOut ,
545547 final JavaSrcTextBuffer buffer ,
@@ -549,14 +551,14 @@ private void printBitField(final boolean array,
549551 if (this .builder .addBinAnnotations ) {
550552 final String binName = nullableFieldInfo == null ? null : nullableFieldInfo .getFieldName ();
551553 if (binName == null ) {
552- buffer .printf ("@Bin(type=BinType.%s,outBitNumber=%s)%n" ,
554+ buffer .printf ("@Bin(type=BinType.%s,outBitNumber=%s,outByteOrder=JBBPByteOrder.%s )%n" ,
553555 (array ? BinType .BIT_ARRAY : BinType .BIT ).name (),
554- sizeOfFieldOut );
556+ sizeOfFieldOut , byteOrder . name () );
555557 } else {
556- buffer .printf ("@Bin(name=\" %s\" ,type=BinType.%s,outBitNumber=%s)%n" ,
558+ buffer .printf ("@Bin(name=\" %s\" ,type=BinType.%s,outBitNumber=%s,outByteOrder=JBBPByteOrder.%s )%n" ,
557559 binName ,
558560 (array ? BinType .BIT_ARRAY : BinType .BIT ).name (),
559- sizeOfFieldOut );
561+ sizeOfFieldOut , byteOrder . name () );
560562 }
561563 }
562564 buffer .printf ("%s %s %s;%n" , modifier , type , name );
@@ -606,6 +608,7 @@ public void visitPrimitiveField(
606608 if (this .builder .generateFields ) {
607609 printField (
608610 nullableNameFieldInfo ,
611+ byteOrder ,
609612 false ,
610613 getCurrentStruct ().getFields (),
611614 type ,
@@ -619,7 +622,7 @@ public void visitPrimitiveField(
619622 } else {
620623 textFieldType = type .asJavaArrayFieldType () + " []" ;
621624 if (this .builder .generateFields ) {
622- printField (nullableNameFieldInfo , true , getCurrentStruct ().getFields (), type , fieldModifier , textFieldType , fieldName );
625+ printField (nullableNameFieldInfo , byteOrder , true , getCurrentStruct ().getFields (), type , fieldModifier , textFieldType , fieldName );
623626 }
624627 getCurrentStruct ().getReadFunc ().printf ("this.%s = %s;%n" , fieldName , type .makeReaderForArray (NAME_INPUT_STREAM , arraySizeIn , byteOrder ));
625628 if (readWholeStreamAsArray ) {
@@ -667,7 +670,7 @@ private void registerMaker(final String rawFieldType, final String fieldName, fi
667670 }
668671
669672 @ Override
670- public void visitBitField (final int offsetInCompiledBlock , final JBBPNamedFieldInfo nullableNameFieldInfo , final JBBPIntegerValueEvaluator notNullFieldSize , final JBBPIntegerValueEvaluator nullableArraySize ) {
673+ public void visitBitField (final int offsetInCompiledBlock , final JBBPByteOrder byteOrder , final JBBPNamedFieldInfo nullableNameFieldInfo , final JBBPIntegerValueEvaluator notNullFieldSize , final JBBPIntegerValueEvaluator nullableArraySize ) {
671674 final String fieldName = nullableNameFieldInfo == null ? makeAnonymousFieldName () : prepFldName (nullableNameFieldInfo .getFieldName ());
672675
673676 registerNamedField (nullableNameFieldInfo , FieldType .BIT );
@@ -713,6 +716,7 @@ public void visitBitField(final int offsetInCompiledBlock, final JBBPNamedFieldI
713716 if (this .builder .generateFields ) {
714717 printBitField (
715718 nullableArraySize != null ,
719+ byteOrder ,
716720 nullableNameFieldInfo ,
717721 sizeOfFieldOut ,
718722 getCurrentStruct ().getFields ().indent (),
@@ -803,7 +807,14 @@ public void visitCustomField(final int offsetInCompiledBlock, final JBBPFieldTyp
803807 }
804808
805809 @ Override
806- public void visitVarField (final int offsetInCompiledBlock , final JBBPNamedFieldInfo nullableNameFieldInfo , final JBBPByteOrder byteOrder , final boolean readWholeStreamIntoArray , final JBBPIntegerValueEvaluator nullableArraySizeEvaluator , final JBBPIntegerValueEvaluator extraDataValueEvaluator ) {
810+ public void visitVarField (
811+ final int offsetInCompiledBlock ,
812+ final JBBPNamedFieldInfo nullableNameFieldInfo ,
813+ final JBBPByteOrder byteOrder ,
814+ final boolean readWholeStreamIntoArray ,
815+ final JBBPIntegerValueEvaluator nullableArraySizeEvaluator ,
816+ final JBBPIntegerValueEvaluator extraDataValueEvaluator
817+ ) {
807818 this .flagSet .set (this .flagSet .get () | FLAG_DETECTED_VAR_FIELDS );
808819
809820 registerNamedField (nullableNameFieldInfo , FieldType .VAR );
@@ -826,7 +837,7 @@ public void visitVarField(final int offsetInCompiledBlock, final JBBPNamedFieldI
826837 if (readWholeStreamIntoArray || nullableArraySizeEvaluator != null ) {
827838 fieldType = "JBBPAbstractArrayField<? extends JBBPAbstractField>" ;
828839 if (this .builder .generateFields ) {
829- printField (nullableNameFieldInfo , true , getCurrentStruct ().getFields (), FieldType .VAR , fieldModifier , fieldType , fieldName );
840+ printField (nullableNameFieldInfo , byteOrder , true , getCurrentStruct ().getFields (), FieldType .VAR , fieldModifier , fieldType , fieldName );
830841 }
831842
832843 this .getCurrentStruct ().getReadFunc ().printf ("%s = %s;%n" ,
@@ -853,7 +864,7 @@ public void visitVarField(final int offsetInCompiledBlock, final JBBPNamedFieldI
853864 } else {
854865 fieldType = "JBBPAbstractField" ;
855866 if (this .builder .generateFields ) {
856- printField (nullableNameFieldInfo , false , getCurrentStruct ().getFields (), FieldType .VAR , fieldModifier , fieldType , fieldName );
867+ printField (nullableNameFieldInfo , byteOrder , false , getCurrentStruct ().getFields (), FieldType .VAR , fieldModifier , fieldType , fieldName );
857868 }
858869
859870 this .getCurrentStruct ().getReadFunc ().printf ("%s = %s;%n" ,
0 commit comments