From 0e041364e7b8354e046e1898884e5d73554dd8b5 Mon Sep 17 00:00:00 2001 From: olabusayoT <50379531+olabusayoT@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:29:48 -0400 Subject: [PATCH] Add support for lengthUnit=bits for any type - verify test that uses lengthUnit=bits with calendar type no longer produces warning - verify test that uses lengthUnit=bits with integer type no longer produces warning - verify test that uses lengthUnit=bits with decimal type no longer produces warning - deprecate allowBigIntegerBits tunable and the DeprecatedBigIntegerBits WarnID Deprecation/Compatibility - allowBigIntegerBits tunable no longer has any effect. All types are allowed to use lengthUnit=bits. - WarnID DeprecatedBigIntegerBits has been deprecated. It is no longer in use in the codebase. DAFFODIL-2931 --- .../grammar/ElementBaseGrammarMixin.scala | 32 ++------- .../org/apache/daffodil/xsd/dafext.xsd | 15 +++-- .../section05/simple_types/SimpleTypes.tdml | 17 +++++ .../section12/lengthKind/ExplicitTests.tdml | 65 +++++++++---------- .../section12/lengthKind/PrefixedTests.tdml | 12 ++-- .../simple_types/TestSimpleTypes.scala | 1 + .../lengthKind/TestLengthKindExplicit.scala | 12 ++-- .../lengthKind/TestLengthKindPrefixed.scala | 4 +- 8 files changed, 76 insertions(+), 82 deletions(-) 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 d230c94f05..43589cd096 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 @@ -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 _ => } diff --git a/daffodil-propgen/src/main/resources/org/apache/daffodil/xsd/dafext.xsd b/daffodil-propgen/src/main/resources/org/apache/daffodil/xsd/dafext.xsd index 3d89c56617..1f776029d9 100644 --- a/daffodil-propgen/src/main/resources/org/apache/daffodil/xsd/dafext.xsd +++ b/daffodil-propgen/src/main/resources/org/apache/daffodil/xsd/dafext.xsd @@ -104,12 +104,8 @@ - Previous Daffodil releases let schemas define every type's length using "bits" as the length unit - even though the specification allows bit length units only for a specific set of types' binary - representations and does not allow bit length units for any other type's binary representation - or any type's text representation. When this tunable is true, a deprecation warning is issued - when bit length units are incorrectly used. When this tunable is false, a schema definition - error will be issued instead. + Deprecated. This tunable no longer has any affect and is only kept for + backwards compatability. @@ -696,7 +692,12 @@ - + + + + Deprecated. + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml index d3562569ba..8593f015de 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml @@ -338,6 +338,9 @@ dfdl:lengthKind="explicit" dfdl:length="{ 3 }" dfdl:lengthUnits="bytes" dfdl:binaryCalendarRep="ibm4690Packed" /> + + @@ -2992,6 +2995,20 @@ + + + + 12 14 23 + + + + 2023-12-14 + + + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/ExplicitTests.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/ExplicitTests.tdml index b622a67eb2..2af41931b8 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/ExplicitTests.tdml +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/ExplicitTests.tdml @@ -962,12 +962,12 @@ - + @@ -977,51 +977,52 @@ - + 0f - f + 15 - - lengthUnits='bits' - will only be supported - - - + config="enforceBigIntegerBits" + ignoreUnexpectedWarnings="false"> + + 0f - - lengthUnits='bits' - is only supported - + + + 15 + + - + @@ -1033,22 +1034,20 @@ dfdl:binaryDecimalVirtualPoint="2"/> - - + + + 0f - f + 0.15 - - lengthUnits='bits' - will only be supported -