stevedlawrence commented on a change in pull request #16: Implemented packed
binary formats
URL: https://github.com/apache/incubator-daffodil/pull/16#discussion_r162376061
##########
File path:
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/ElementBaseGrammarMixin.scala
##########
@@ -738,16 +770,25 @@ trait ElementBaseGrammarMixin
}
case PrimType.Decimal => {
- Assert.invariant(binaryIntRep == bin)
if (binaryDecimalVirtualPoint > tunable.maxBinaryDecimalVirtualPoint)
SDE("Property binaryDecimalVirtualPoint %s is greater than limit
%s", binaryDecimalVirtualPoint, tunable.maxBinaryDecimalVirtualPoint)
if (binaryDecimalVirtualPoint < tunable.minBinaryDecimalVirtualPoint)
SDE("Property binaryDecimalVirtualPoint %s is less than limit %s",
binaryDecimalVirtualPoint, tunable.minBinaryDecimalVirtualPoint)
if (binaryNumberKnownLengthInBits == -1 ||
binaryNumberKnownLengthInBits > 8) byteOrderRaw // must have or SDE
- binaryNumberKnownLengthInBits match {
- case -1 => new BinaryDecimalRuntimeLength(this)
- case _ => new BinaryDecimalKnownLength(this,
binaryNumberKnownLengthInBits)
+
+ (binaryNumberRep, lengthKind, binaryNumberKnownLengthInBits) match {
+ case (BinaryNumberRep.Binary, _, -1) => new
BinaryDecimalRuntimeLength(this)
+ case (BinaryNumberRep.Binary, _, _) => new
BinaryDecimalKnownLength(this, binaryNumberKnownLengthInBits)
+ case (BinaryNumberRep.Packed, LengthKind.Delimited, -1) => new
PackedDecimalDelimitedEndOfData(this)
+ case (BinaryNumberRep.Packed, _, -1) => new
PackedDecimalRuntimeLength(this)
+ case (BinaryNumberRep.Packed, _, _) => new
PackedDecimalKnownLength(this, binaryNumberKnownLengthInBits)
+ case (BinaryNumberRep.Bcd, LengthKind.Delimited, -1) => new
BCDDecimalDelimitedEndOfData(this)
+ case (BinaryNumberRep.Bcd, _, -1) => new
BCDDecimalRuntimeLength(this)
+ case (BinaryNumberRep.Bcd, _, _) => new BCDDecimalKnownLength(this,
binaryNumberKnownLengthInBits)
+ case (BinaryNumberRep.Ibm4690Packed, LengthKind.Delimited, -1) =>
new IBM4690PackedDecimalDelimitedEndOfData(this)
+ case (BinaryNumberRep.Ibm4690Packed, _, -1) => new
IBM4690PackedDecimalRuntimeLength(this)
+ case (BinaryNumberRep.Ibm4690Packed, _, _) => new
IBM4690PackedDecimalKnownLength(this, binaryNumberKnownLengthInBits)
Review comment:
Section 12.3.7.2.3 says it is a schema definition error if the specified
length is not a multiple of 4 bits. Need to check that at schema compilation
time for constant value and at runtime for runtime values.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services