From ccdc433367d4c7b9df44b227cc93285e73beef9e Mon Sep 17 00:00:00 2001 From: olabusayoT <50379531+olabusayoT@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:24:31 -0500 Subject: [PATCH] fixup! fixup! fixup! Fix Bug with valueLength being overwritten after Trim - rename custom prefixedlength parsers to *BitLengthParsers to more accurately reflect what they're doing - rename custom prefixedlength unparsers to MinimumLengthUnparsers to more accurately reflect what they're doing - rename PrefixedLengthParserMixin2 to BitLengthFromBitLimitMixin to more accurately reflect what it is - got rid of HexBinaryLengthPrefixed since it is the same as HexBinaryEndOfBitLimit DAFFODIL-2658 --- .../codegen/c/DaffodilCCodeGenerator.scala | 5 ++-- .../grammar/ElementBaseGrammarMixin.scala | 23 ++++++++----------- .../grammar/primitives/PrimitivesBCD.scala | 16 ++++++------- .../primitives/PrimitivesBinaryBoolean.scala | 8 +++---- .../primitives/PrimitivesBinaryNumber.scala | 16 ++++++------- .../primitives/PrimitivesIBM4690Packed.scala | 16 ++++++------- .../primitives/PrimitivesLengthKind.scala | 11 --------- .../grammar/primitives/PrimitivesPacked.scala | 16 ++++++------- .../unparsers/runtime1/BCDUnparsers.scala | 4 ++-- .../runtime1/BinaryBooleanUnparsers.scala | 2 +- .../runtime1/BinaryNumberUnparsers.scala | 4 ++-- .../IBM4690PackedDecimalUnparsers.scala | 4 ++-- .../runtime1/PackedDecimalUnparsers.scala | 4 ++-- .../runtime1/SpecifiedLengthUnparsers.scala | 4 ++-- .../runtime1/processors/BCDParsers.scala | 8 +++---- .../IBM4690PackedDecimalParsers.scala | 8 +++---- .../processors/PackedDecimalParsers.scala | 8 +++---- .../parsers/BinaryBooleanParsers.scala | 4 ++-- .../parsers/BinaryNumberParsers.scala | 8 +++---- .../parsers/BinaryNumberTraits.scala | 2 +- .../parsers/HexBinaryLengthParsers.scala | 7 ------ 21 files changed, 78 insertions(+), 100 deletions(-) diff --git a/daffodil-codegen-c/src/main/scala/org/apache/daffodil/codegen/c/DaffodilCCodeGenerator.scala b/daffodil-codegen-c/src/main/scala/org/apache/daffodil/codegen/c/DaffodilCCodeGenerator.scala index 62922f56a8..35e7034ae2 100644 --- a/daffodil-codegen-c/src/main/scala/org/apache/daffodil/codegen/c/DaffodilCCodeGenerator.scala +++ b/daffodil-codegen-c/src/main/scala/org/apache/daffodil/codegen/c/DaffodilCCodeGenerator.scala @@ -49,7 +49,7 @@ import org.apache.daffodil.core.grammar.primitives.ChoiceCombinator import org.apache.daffodil.core.grammar.primitives.ElementCombinator import org.apache.daffodil.core.grammar.primitives.ElementParseAndUnspecifiedLength import org.apache.daffodil.core.grammar.primitives.ElementUnused -import org.apache.daffodil.core.grammar.primitives.HexBinaryLengthPrefixed +import org.apache.daffodil.core.grammar.primitives.HexBinaryEndOfBitLimit import org.apache.daffodil.core.grammar.primitives.HexBinarySpecifiedLength import org.apache.daffodil.core.grammar.primitives.OrderedSequence import org.apache.daffodil.core.grammar.primitives.RepOrderedExactlyNSequenceChild @@ -289,7 +289,8 @@ object DaffodilCCodeGenerator case g: ElementParseAndUnspecifiedLength => elementParseAndUnspecifiedLengthGenerateCode(g, cgState) case g: ElementUnused => noop(g) - case g: HexBinaryLengthPrefixed => hexBinaryLengthPrefixedGenerateCode(g.e, cgState) + case g: HexBinaryEndOfBitLimit if g.e.isPrefixed => + hexBinaryLengthPrefixedGenerateCode(g.e, cgState) case g: HexBinarySpecifiedLength => hexBinarySpecifiedLengthGenerateCode(g.e, cgState) case g: OrderedSequence => orderedSequenceGenerateCode(g, cgState) case g: Prod => prod(g, cgState) diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala index cb28440f66..58d19bdd0f 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala @@ -72,13 +72,7 @@ trait ElementBaseGrammarMixin } } - protected lazy val isPrefixed: Boolean = { - import LengthKind._ - lengthKind match { - case Prefixed => true - case _ => false - } - } + lazy val isPrefixed: Boolean = lengthKind == LengthKind.Prefixed protected lazy val isDelimitedPrefixedPattern: Boolean = { import LengthKind._ @@ -86,7 +80,7 @@ trait ElementBaseGrammarMixin case Delimited => true // don't test for hasDelimiters because it might not be our delimiter, but a surrounding group's separator, or it's terminator, etc. case Pattern => true - case Prefixed => isPrefixed + case Prefixed => true case _ => false } } @@ -661,7 +655,7 @@ trait ElementBaseGrammarMixin } private lazy val hexBinaryLengthPrefixed = prod("hexBinaryLengthPrefixed") { - new HexBinaryLengthPrefixed(this) + new HexBinaryEndOfBitLimit(this) } private lazy val hexBinaryValue = prod("hexBinaryValue") { @@ -1387,14 +1381,15 @@ trait ElementBaseGrammarMixin } case LengthKind.Implicit if isSimpleType && primType == PrimType.String => new SpecifiedLengthImplicitCharacters(this, body, this.maxLength.longValue) - - case LengthKind.Implicit if isSimpleType && primType == PrimType.HexBinary => - new SpecifiedLengthImplicit(this, body, this.maxLength.longValue * bitsMultiplier) case LengthKind.Implicit - if isSimpleType && impliedRepresentation == Representation.Binary => + if isSimpleType && + impliedRepresentation == Representation.Binary && + primType != PrimType.HexBinary => new SpecifiedLengthImplicit(this, body, implicitBinaryLengthInBits) - case LengthKind.Implicit if isComplexType => + case LengthKind.Implicit => body // for complex types, implicit means "roll up from the bottom" + // for simple types, the primitives have custom parsers that handle implicit length logic + // and don't use the limit provided by the SpecifiedLengthImplicit parser case LengthKind.EndOfParent if isComplexType => notYetImplemented("lengthKind='endOfParent' for complex type") case LengthKind.EndOfParent => diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBCD.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBCD.scala index 879b81d91b..154e221376 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBCD.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBCD.scala @@ -19,18 +19,18 @@ package org.apache.daffodil.core.grammar.primitives import org.apache.daffodil.core.dsom.ElementBase import org.apache.daffodil.core.grammar.Terminal +import org.apache.daffodil.runtime1.processors.parsers.BCDDecimalBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.BCDDecimalKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.BCDDecimalPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.BCDDecimalRuntimeLengthParser +import org.apache.daffodil.runtime1.processors.parsers.BCDIntegerBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.BCDIntegerKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.BCDIntegerPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.BCDIntegerRuntimeLengthParser import org.apache.daffodil.runtime1.processors.unparsers.Unparser import org.apache.daffodil.unparsers.runtime1.BCDDecimalKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.BCDDecimalPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.BCDDecimalMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.BCDDecimalRuntimeLengthUnparser import org.apache.daffodil.unparsers.runtime1.BCDIntegerKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.BCDIntegerPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.BCDIntegerMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.BCDIntegerRuntimeLengthUnparser class BCDIntegerRuntimeLength(val e: ElementBase) extends Terminal(e, true) { @@ -52,9 +52,9 @@ class BCDIntegerKnownLength(val e: ElementBase, lengthInBits: Long) extends Term class BCDIntegerPrefixedLength(val e: ElementBase) extends Terminal(e, true) { - override lazy val parser = new BCDIntegerPrefixedLengthParser(e.elementRuntimeData) + override lazy val parser = new BCDIntegerBitLimitLengthParser(e.elementRuntimeData) - override lazy val unparser: Unparser = new BCDIntegerPrefixedLengthUnparser( + override lazy val unparser: Unparser = new BCDIntegerMinimumLengthUnparser( e.elementRuntimeData ) } @@ -93,8 +93,8 @@ class BCDDecimalKnownLength(val e: ElementBase, lengthInBits: Long) extends Term class BCDDecimalPrefixedLength(val e: ElementBase) extends Terminal(e, true) { override lazy val parser = - new BCDDecimalPrefixedLengthParser(e.elementRuntimeData, e.binaryDecimalVirtualPoint) + new BCDDecimalBitLimitLengthParser(e.elementRuntimeData, e.binaryDecimalVirtualPoint) override lazy val unparser: Unparser = - new BCDDecimalPrefixedLengthUnparser(e.elementRuntimeData, e.binaryDecimalVirtualPoint) + new BCDDecimalMinimumLengthUnparser(e.elementRuntimeData, e.binaryDecimalVirtualPoint) } diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryBoolean.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryBoolean.scala index 1f4865ff59..b934a24fb5 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryBoolean.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryBoolean.scala @@ -19,10 +19,10 @@ package org.apache.daffodil.core.grammar.primitives import org.apache.daffodil.core.dsom.ElementBase import org.apache.daffodil.core.grammar.Terminal +import org.apache.daffodil.runtime1.processors.parsers.BinaryBooleanBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.BinaryBooleanParser -import org.apache.daffodil.runtime1.processors.parsers.BinaryBooleanPrefixedLengthParser import org.apache.daffodil.runtime1.processors.unparsers.Unparser -import org.apache.daffodil.unparsers.runtime1.BinaryBooleanPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.BinaryBooleanMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.BinaryBooleanUnparser class BinaryBoolean(val e: ElementBase) extends Terminal(e, true) { @@ -46,14 +46,14 @@ class BinaryBoolean(val e: ElementBase) extends Terminal(e, true) { } class BinaryBooleanPrefixedLength(val e: ElementBase) extends Terminal(e, true) { - override lazy val parser = new BinaryBooleanPrefixedLengthParser( + override lazy val parser = new BinaryBooleanBitLimitLengthParser( e.elementRuntimeData, e.binaryBooleanTrueRep, e.binaryBooleanFalseRep, e.lengthUnits ) - override lazy val unparser: Unparser = new BinaryBooleanPrefixedLengthUnparser( + override lazy val unparser: Unparser = new BinaryBooleanMinimumLengthUnparser( e.elementRuntimeData, e.binaryBooleanTrueRep, e.binaryBooleanFalseRep, diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryNumber.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryNumber.scala index 92204f409c..bf5e66e3ed 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryNumber.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesBinaryNumber.scala @@ -22,22 +22,22 @@ import org.apache.daffodil.core.grammar.Terminal import org.apache.daffodil.lib.exceptions.Assert import org.apache.daffodil.lib.util.MaybeInt import org.apache.daffodil.runtime1.dpath.NodeInfo +import org.apache.daffodil.runtime1.processors.parsers.BinaryDecimalBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.BinaryDecimalKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.BinaryDecimalPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.BinaryDecimalRuntimeLengthParser import org.apache.daffodil.runtime1.processors.parsers.BinaryDoubleParser import org.apache.daffodil.runtime1.processors.parsers.BinaryFloatParser +import org.apache.daffodil.runtime1.processors.parsers.BinaryIntegerBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.BinaryIntegerKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.BinaryIntegerPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.BinaryIntegerRuntimeLengthParser import org.apache.daffodil.runtime1.processors.unparsers.Unparser import org.apache.daffodil.unparsers.runtime1.BinaryDecimalKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.BinaryDecimalPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.BinaryDecimalMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.BinaryDecimalRuntimeLengthUnparser import org.apache.daffodil.unparsers.runtime1.BinaryDoubleUnparser import org.apache.daffodil.unparsers.runtime1.BinaryFloatUnparser import org.apache.daffodil.unparsers.runtime1.BinaryIntegerKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.BinaryIntegerPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.BinaryIntegerMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.BinaryIntegerRuntimeLengthUnparser class BinaryIntegerRuntimeLength(val e: ElementBase, signed: Boolean) @@ -77,7 +77,7 @@ class BinaryIntegerPrefixedLength(val e: ElementBase, signed: Boolean) private lazy val pladj = e.prefixedLengthAdjustmentInUnits override lazy val parser = - new BinaryIntegerPrefixedLengthParser(erd, signed) + new BinaryIntegerBitLimitLengthParser(erd, signed) override lazy val unparser: Unparser = { val maybeNBits = e.primType match { @@ -89,7 +89,7 @@ class BinaryIntegerPrefixedLength(val e: ElementBase, signed: Boolean) case _ => Assert.invariantFailed("Only integer base types should be used for this primitive") } - new BinaryIntegerPrefixedLengthUnparser(erd, maybeNBits, signed) + new BinaryIntegerMinimumLengthUnparser(erd, maybeNBits, signed) } } @@ -134,14 +134,14 @@ class BinaryDecimalKnownLength(val e: ElementBase, lengthInBits: Long) class BinaryDecimalPrefixedLength(val e: ElementBase) extends Terminal(e, true) { override lazy val parser = - new BinaryDecimalPrefixedLengthParser( + new BinaryDecimalBitLimitLengthParser( e.elementRuntimeData, e.decimalSigned, e.binaryDecimalVirtualPoint ) override lazy val unparser: Unparser = - new BinaryDecimalPrefixedLengthUnparser( + new BinaryDecimalMinimumLengthUnparser( e.elementRuntimeData, e.decimalSigned, e.binaryDecimalVirtualPoint diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesIBM4690Packed.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesIBM4690Packed.scala index 955a6c097c..f624c96fa1 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesIBM4690Packed.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesIBM4690Packed.scala @@ -19,18 +19,18 @@ package org.apache.daffodil.core.grammar.primitives import org.apache.daffodil.core.dsom.ElementBase import org.apache.daffodil.core.grammar.Terminal +import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedDecimalBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedDecimalKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedDecimalPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedDecimalRuntimeLengthParser +import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedIntegerBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedIntegerKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedIntegerPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedIntegerRuntimeLengthParser import org.apache.daffodil.runtime1.processors.unparsers.Unparser import org.apache.daffodil.unparsers.runtime1.IBM4690PackedDecimalKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.IBM4690PackedDecimalPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.IBM4690PackedDecimalMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.IBM4690PackedDecimalRuntimeLengthUnparser import org.apache.daffodil.unparsers.runtime1.IBM4690PackedIntegerKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.IBM4690PackedIntegerPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.IBM4690PackedIntegerMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.IBM4690PackedIntegerRuntimeLengthUnparser class IBM4690PackedIntegerRuntimeLength(val e: ElementBase, signed: Boolean) @@ -62,9 +62,9 @@ class IBM4690PackedIntegerKnownLength(val e: ElementBase, signed: Boolean, lengt class IBM4690PackedIntegerPrefixedLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) { override lazy val parser = - new IBM4690PackedIntegerPrefixedLengthParser(e.elementRuntimeData, signed) + new IBM4690PackedIntegerBitLimitLengthParser(e.elementRuntimeData, signed) - override lazy val unparser: Unparser = new IBM4690PackedIntegerPrefixedLengthUnparser( + override lazy val unparser: Unparser = new IBM4690PackedIntegerMinimumLengthUnparser( e.elementRuntimeData ) } @@ -102,12 +102,12 @@ class IBM4690PackedDecimalKnownLength(val e: ElementBase, lengthInBits: Long) } class IBM4690PackedDecimalPrefixedLength(val e: ElementBase) extends Terminal(e, true) { - override lazy val parser = new IBM4690PackedDecimalPrefixedLengthParser( + override lazy val parser = new IBM4690PackedDecimalBitLimitLengthParser( e.elementRuntimeData, e.binaryDecimalVirtualPoint ) - override lazy val unparser: Unparser = new IBM4690PackedDecimalPrefixedLengthUnparser( + override lazy val unparser: Unparser = new IBM4690PackedDecimalMinimumLengthUnparser( e.elementRuntimeData, e.binaryDecimalVirtualPoint ) diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesLengthKind.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesLengthKind.scala index 20107e94db..b187703668 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesLengthKind.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesLengthKind.scala @@ -34,7 +34,6 @@ import org.apache.daffodil.runtime1.processors.parsers.BCDIntegerDelimitedParser import org.apache.daffodil.runtime1.processors.parsers.BlobSpecifiedLengthParser import org.apache.daffodil.runtime1.processors.parsers.HexBinaryDelimitedParser import org.apache.daffodil.runtime1.processors.parsers.HexBinaryEndOfBitLimitParser -import org.apache.daffodil.runtime1.processors.parsers.HexBinaryLengthPrefixedParser import org.apache.daffodil.runtime1.processors.parsers.HexBinarySpecifiedLengthParser import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedDecimalDelimitedParser import org.apache.daffodil.runtime1.processors.parsers.IBM4690PackedIntegerDelimitedParser @@ -182,16 +181,6 @@ case class HexBinaryEndOfBitLimit(e: ElementBase) extends Terminal(e, true) { new HexBinaryMinLengthInBytesUnparser(e.minLength.longValue, e.elementRuntimeData) } -case class HexBinaryLengthPrefixed(e: ElementBase) extends Terminal(e, true) { - - override lazy val parser: DaffodilParser = new HexBinaryLengthPrefixedParser( - e.elementRuntimeData - ) - - override lazy val unparser: DaffodilUnparser = - new HexBinaryMinLengthInBytesUnparser(e.minLength.longValue, e.elementRuntimeData) -} - abstract class PackedIntegerDelimited( e: ElementBase, signed: Boolean, diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesPacked.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesPacked.scala index a99993cd86..b5c6b963b3 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesPacked.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesPacked.scala @@ -20,18 +20,18 @@ package org.apache.daffodil.core.grammar.primitives import org.apache.daffodil.core.dsom.ElementBase import org.apache.daffodil.core.grammar.Terminal import org.apache.daffodil.lib.util.PackedSignCodes +import org.apache.daffodil.runtime1.processors.parsers.PackedDecimalBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.PackedDecimalKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.PackedDecimalPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.PackedDecimalRuntimeLengthParser +import org.apache.daffodil.runtime1.processors.parsers.PackedIntegerBitLimitLengthParser import org.apache.daffodil.runtime1.processors.parsers.PackedIntegerKnownLengthParser -import org.apache.daffodil.runtime1.processors.parsers.PackedIntegerPrefixedLengthParser import org.apache.daffodil.runtime1.processors.parsers.PackedIntegerRuntimeLengthParser import org.apache.daffodil.runtime1.processors.unparsers.Unparser import org.apache.daffodil.unparsers.runtime1.PackedDecimalKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.PackedDecimalPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.PackedDecimalMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.PackedDecimalRuntimeLengthUnparser import org.apache.daffodil.unparsers.runtime1.PackedIntegerKnownLengthUnparser -import org.apache.daffodil.unparsers.runtime1.PackedIntegerPrefixedLengthUnparser +import org.apache.daffodil.unparsers.runtime1.PackedIntegerMinimumLengthUnparser import org.apache.daffodil.unparsers.runtime1.PackedIntegerRuntimeLengthUnparser class PackedIntegerRuntimeLength( @@ -83,10 +83,10 @@ class PackedIntegerPrefixedLength( ) extends Terminal(e, true) { override lazy val parser = - new PackedIntegerPrefixedLengthParser(e.elementRuntimeData, signed, packedSignCodes) + new PackedIntegerBitLimitLengthParser(e.elementRuntimeData, signed, packedSignCodes) override lazy val unparser: Unparser = - new PackedIntegerPrefixedLengthUnparser(e.elementRuntimeData, packedSignCodes) + new PackedIntegerMinimumLengthUnparser(e.elementRuntimeData, packedSignCodes) } class PackedDecimalRuntimeLength(val e: ElementBase, packedSignCodes: PackedSignCodes) @@ -132,13 +132,13 @@ class PackedDecimalKnownLength( class PackedDecimalPrefixedLength(val e: ElementBase, packedSignCodes: PackedSignCodes) extends Terminal(e, true) { - override lazy val parser = new PackedDecimalPrefixedLengthParser( + override lazy val parser = new PackedDecimalBitLimitLengthParser( e.elementRuntimeData, e.binaryDecimalVirtualPoint, packedSignCodes ) - override lazy val unparser: Unparser = new PackedDecimalPrefixedLengthUnparser( + override lazy val unparser: Unparser = new PackedDecimalMinimumLengthUnparser( e.elementRuntimeData, e.binaryDecimalVirtualPoint, packedSignCodes diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BCDUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BCDUnparsers.scala index 68d1ec207a..86c80ba430 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BCDUnparsers.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BCDUnparsers.scala @@ -56,7 +56,7 @@ final class BCDIntegerDelimitedUnparser(e: ElementRuntimeData) override def getBitLength(state: ParseOrUnparseState): Int = { 0 } } -final class BCDIntegerPrefixedLengthUnparser(e: ElementRuntimeData) +final class BCDIntegerMinimumLengthUnparser(e: ElementRuntimeData) extends BCDIntegerBaseUnparser(e) { override lazy val runtimeDependencies = Vector() @@ -100,7 +100,7 @@ final class BCDDecimalDelimitedUnparser(e: ElementRuntimeData, binaryDecimalVirt override def getBitLength(state: ParseOrUnparseState): Int = { 0 } } -final class BCDDecimalPrefixedLengthUnparser( +final class BCDDecimalMinimumLengthUnparser( e: ElementRuntimeData, binaryDecimalVirtualPoint: Int ) extends BCDDecimalBaseUnparser(e, binaryDecimalVirtualPoint) { diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryBooleanUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryBooleanUnparsers.scala index bb329e8904..59bb85d04c 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryBooleanUnparsers.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryBooleanUnparsers.scala @@ -128,7 +128,7 @@ class BinaryBooleanUnparser( } } -class BinaryBooleanPrefixedLengthUnparser( +class BinaryBooleanMinimumLengthUnparser( e: ElementRuntimeData, binaryBooleanTrueRep: MaybeULong, binaryBooleanFalseRep: ULong, diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryNumberUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryNumberUnparsers.scala index dea17446b2..6648cb7b90 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryNumberUnparsers.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/BinaryNumberUnparsers.scala @@ -116,7 +116,7 @@ class BinaryIntegerRuntimeLengthUnparser( override val runtimeDependencies = Vector(lengthEv) } -class BinaryIntegerPrefixedLengthUnparser( +class BinaryIntegerMinimumLengthUnparser( e: ElementRuntimeData, maybeNBits: MaybeInt, signed: Boolean @@ -196,7 +196,7 @@ class BinaryDecimalRuntimeLengthUnparser( override val runtimeDependencies = Vector(lengthEv) } -class BinaryDecimalPrefixedLengthUnparser( +class BinaryDecimalMinimumLengthUnparser( e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/IBM4690PackedDecimalUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/IBM4690PackedDecimalUnparsers.scala index 5dba1cf8ba..1fb458cf9a 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/IBM4690PackedDecimalUnparsers.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/IBM4690PackedDecimalUnparsers.scala @@ -58,7 +58,7 @@ final class IBM4690PackedIntegerDelimitedUnparser(e: ElementRuntimeData) override def getBitLength(state: ParseOrUnparseState): Int = { 0 } } -final class IBM4690PackedIntegerPrefixedLengthUnparser(e: ElementRuntimeData) +final class IBM4690PackedIntegerMinimumLengthUnparser(e: ElementRuntimeData) extends IBM4690PackedIntegerBaseUnparser(e) { override lazy val runtimeDependencies = Vector() @@ -108,7 +108,7 @@ final class IBM4690PackedDecimalDelimitedUnparser( override def getBitLength(state: ParseOrUnparseState): Int = { 0 } } -final class IBM4690PackedDecimalPrefixedLengthUnparser( +final class IBM4690PackedDecimalMinimumLengthUnparser( e: ElementRuntimeData, binaryDecimalVirtualPoint: Int ) extends IBM4690PackedDecimalBaseUnparser(e, binaryDecimalVirtualPoint) { diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/PackedDecimalUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/PackedDecimalUnparsers.scala index 6464d94460..c378f80b3f 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/PackedDecimalUnparsers.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/PackedDecimalUnparsers.scala @@ -64,7 +64,7 @@ final class PackedIntegerDelimitedUnparser( override def getBitLength(state: ParseOrUnparseState): Int = { 0 } } -final class PackedIntegerPrefixedLengthUnparser( +final class PackedIntegerMinimumLengthUnparser( e: ElementRuntimeData, packedSignCodes: PackedSignCodes ) extends PackedIntegerBaseUnparser(e, packedSignCodes) { @@ -118,7 +118,7 @@ final class PackedDecimalDelimitedUnparser( override def getBitLength(state: ParseOrUnparseState): Int = { 0 } } -final class PackedDecimalPrefixedLengthUnparser( +final class PackedDecimalMinimumLengthUnparser( e: ElementRuntimeData, binaryDecimalVirtualPoint: Int, packedSignCodes: PackedSignCodes diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/SpecifiedLengthUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/SpecifiedLengthUnparsers.scala index e3d3bf1635..0407fab3a3 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/SpecifiedLengthUnparsers.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/SpecifiedLengthUnparsers.scala @@ -286,8 +286,8 @@ final class SpecifiedLengthExplicitImplicitUnparser( /** * This trait is to be used with prefixed length unparsers where the length - * must be calculated based on the value length of the data. This means the - * data must be unparsed, the value length calculated, and that value will be + * must be calculated based on the content length of the data. This means the + * data must be unparsed, the content length calculated, and that value will be * assigned to the prefix length element. */ trait CalculatedPrefixedLengthUnparserMixin { diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/BCDParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/BCDParsers.scala index 631b09146a..959612a62a 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/BCDParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/BCDParsers.scala @@ -52,11 +52,11 @@ class BCDDecimalRuntimeLengthParser( } -class BCDDecimalPrefixedLengthParser( +class BCDDecimalBitLimitLengthParser( e: ElementRuntimeData, binaryDecimalVirtualPoint: Int ) extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.bcdToBigInteger(num) override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = @@ -86,9 +86,9 @@ class BCDIntegerKnownLengthParser(e: ElementRuntimeData, val lengthInBits: Int) } -class BCDIntegerPrefixedLengthParser(e: ElementRuntimeData) +class BCDIntegerBitLimitLengthParser(e: ElementRuntimeData) extends PackedBinaryIntegerBaseParser(e) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.bcdToBigInteger(num) override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/IBM4690PackedDecimalParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/IBM4690PackedDecimalParsers.scala index 4082c2865b..490e11fff4 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/IBM4690PackedDecimalParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/IBM4690PackedDecimalParsers.scala @@ -54,11 +54,11 @@ class IBM4690PackedDecimalRuntimeLengthParser( } -class IBM4690PackedDecimalPrefixedLengthParser( +class IBM4690PackedDecimalBitLimitLengthParser( e: ElementRuntimeData, binaryDecimalVirtualPoint: Int ) extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.ibm4690ToBigInteger(num) @@ -96,9 +96,9 @@ class IBM4690PackedIntegerKnownLengthParser( } -class IBM4690PackedIntegerPrefixedLengthParser(e: ElementRuntimeData, signed: Boolean) +class IBM4690PackedIntegerBitLimitLengthParser(e: ElementRuntimeData, signed: Boolean) extends PackedBinaryIntegerBaseParser(e, signed) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.ibm4690ToBigInteger(num) diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/PackedDecimalParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/PackedDecimalParsers.scala index c860bdddc3..9f1757cd39 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/PackedDecimalParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/PackedDecimalParsers.scala @@ -56,12 +56,12 @@ class PackedDecimalRuntimeLengthParser( } -class PackedDecimalPrefixedLengthParser( +class PackedDecimalBitLimitLengthParser( e: ElementRuntimeData, binaryDecimalVirtualPoint: Int, packedSignCodes: PackedSignCodes ) extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.packedToBigInteger(num, packedSignCodes) @@ -100,12 +100,12 @@ class PackedIntegerKnownLengthParser( } -class PackedIntegerPrefixedLengthParser( +class PackedIntegerBitLimitLengthParser( e: ElementRuntimeData, signed: Boolean, packedSignCodes: PackedSignCodes ) extends PackedBinaryIntegerBaseParser(e, signed) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.packedToBigInteger(num, packedSignCodes) diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryBooleanParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryBooleanParsers.scala index 430330512a..3ce64df07a 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryBooleanParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryBooleanParsers.scala @@ -105,13 +105,13 @@ class BinaryBooleanParser( } } -class BinaryBooleanPrefixedLengthParser( +class BinaryBooleanBitLimitLengthParser( override val context: ElementRuntimeData, binaryBooleanTrueRep: MaybeULong, binaryBooleanFalseRep: ULong, lengthUnits: LengthUnits ) extends BinaryBooleanParserBase(binaryBooleanTrueRep, binaryBooleanFalseRep, lengthUnits) - with PrefixedLengthParserMixin2 { + with BitLengthFromBitLimitMixin { override val runtimeDependencies = Vector() diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberParsers.scala index 8009579258..1c98266704 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberParsers.scala @@ -77,12 +77,12 @@ class BinaryDecimalRuntimeLengthParser( ) extends BinaryDecimalParserBase(e, signed, binaryDecimalVirtualPoint) with HasRuntimeExplicitLength {} -class BinaryDecimalPrefixedLengthParser( +class BinaryDecimalBitLimitLengthParser( e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int ) extends BinaryDecimalParserBase(e, signed, binaryDecimalVirtualPoint) - with PrefixedLengthParserMixin2 + with BitLengthFromBitLimitMixin abstract class BinaryDecimalParserBase( override val context: ElementRuntimeData, @@ -125,9 +125,9 @@ class BinaryIntegerKnownLengthParser( ) extends BinaryIntegerBaseParser(e, signed) with HasKnownLengthInBits {} -class BinaryIntegerPrefixedLengthParser(e: ElementRuntimeData, signed: Boolean) +class BinaryIntegerBitLimitLengthParser(e: ElementRuntimeData, signed: Boolean) extends BinaryIntegerBaseParser(e, signed) - with PrefixedLengthParserMixin2 + with BitLengthFromBitLimitMixin abstract class BinaryIntegerBaseParser( override val context: ElementRuntimeData, diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberTraits.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberTraits.scala index 8ef23965d5..41b14f132a 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberTraits.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberTraits.scala @@ -170,7 +170,7 @@ trait PrefixedLengthParserMixin { * This mixin doesn't require parsing the prefix length element and just uses * the state's bitLimit and position to get the bitLength instead */ -trait PrefixedLengthParserMixin2 { +trait BitLengthFromBitLimitMixin { def getBitLength(s: ParseOrUnparseState): Int = { val pState = s.asInstanceOf[PState] diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/HexBinaryLengthParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/HexBinaryLengthParsers.scala index ba66549cdf..b211ce2ee0 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/HexBinaryLengthParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/HexBinaryLengthParsers.scala @@ -92,10 +92,3 @@ final class HexBinaryEndOfBitLimitParser(erd: ElementRuntimeData) pstate.bitLimit0b.get - pstate.bitPos0b } } - -final class HexBinaryLengthPrefixedParser(erd: ElementRuntimeData) - extends HexBinaryLengthParser(erd) - with PrefixedLengthParserMixin2 { - - override val runtimeDependencies = Vector() -}