stevedlawrence commented on code in PR #1332:
URL: https://github.com/apache/daffodil/pull/1332#discussion_r1799333619
##########
daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala:
##########
@@ -1714,35 +1714,15 @@ trait ElementBaseGrammarMixin
mtaBase
}
- val allowedBitTypes = Set[PrimType](
- PrimType.Boolean,
- PrimType.Byte,
- PrimType.Short,
- PrimType.Int,
- PrimType.Long,
- PrimType.UnsignedByte,
- PrimType.UnsignedShort,
- PrimType.UnsignedInt,
- PrimType.UnsignedLong
- )
- val allowedBitTypesText = allowedBitTypes.map("xs:" +
_.toString).toList.sorted.mkString(", ")
-
private def checkLengthUnits(elem: ElementBase = context): Unit = {
elem.lengthUnits match {
- case LengthUnits.Bits if elem.representation == Representation.Binary =>
+ case LengthUnits.Bits =>
elem.optPrimType match {
- case Some(primType) =>
- if (!allowedBitTypes.contains(primType))
- if (tunable.allowBigIntegerBits)
- elem.SDW(
- WarnID.DeprecatedBigIntegerBits,
- s"In a future release, lengthUnits='bits' will only be
supported for the following types: $allowedBitTypesText"
- )
- else
- elem.SDE(
- "lengthUnits='bits' is only supported for the following
types: $allowedBitTypesText"
- )
- case None =>
+ case Some(_) => {
+ // allow all types to use lengthUnits bits
+ // PORTABILITY: See https://github.com/OpenGridForum/DFDL/issues/12
+ }
+ case None => // do nothing
}
case _ =>
}
Review Comment:
Should we just remove this function, it's literally just one big no-op now.
##########
daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindExplicit.scala:
##########
@@ -98,14 +98,14 @@ class TestLengthKindExplicit {
runner.runOneTest("denseBit_lengthKind_explicit")
}
- @Test def test_invalidLengthUnitsIntegerWarning_explicit(): Unit = {
- runner.runOneTest("invalidLengthUnitsIntegerWarning_explicit")
+ @Test def test_lengthUnitsBitsForInteger_explicit(): Unit = {
+ runner.runOneTest("lengthUnitsBitsForInteger_explicit")
}
- @Test def test_invalidLengthUnitsIntegerError_explicit(): Unit = {
- runner.runOneTest("invalidLengthUnitsIntegerError_explicit")
+ @Test def test_lengthUnitsBitsForInteger_explicit2(): Unit = {
+ runner.runOneTest("lengthUnitsBitsForInteger_explicit2")
}
- @Test def test_invalidLengthUnitsDecimalWarning_explicit(): Unit = {
- runner.runOneTest("invalidLengthUnitsDecimalWarning_explicit")
+ @Test def lengthUnitsBitsForDecimal_explicit(): Unit = {
+ runner.runOneTest("lengthUnitsBitsForDecimal_explicit")
}
Review Comment:
We might want some tests for xs:double, xs:float, and xs:date/time/dateTime
with binaryCalendarRep set to binarySeconds and binaryMilliseconds.
For example, `binaryValue` in `ElementBaseGrammarMixin.scala` has logic for
knownLength float/double, but I'm not sure it handles an expression for
dfdl:length, unless that's handled somewhere else. Maybe we don't support
expressions at all since those need to be 32/64 bits exactly?
Also, in that same val, the date/time/dateTime case errors that require
lenghtUnits must be bytes for binarySeconds/Milliseconds, which this PR should
fix, as long as the length is correct number of bits, we sholudn't care whether
it was specified in bits or bytes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]