olabusayoT commented on code in PR #1337:
URL: https://github.com/apache/daffodil/pull/1337#discussion_r1872215086
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/PackedBinaryTraits.scala:
##########
@@ -69,17 +77,30 @@ abstract class PackedBinaryDecimalBaseParser(
}
abstract class PackedBinaryIntegerBaseParser(
- override val context: ElementRuntimeData,
- signed: Boolean = false
+ override val context: ElementRuntimeData
) extends PrimParser
with PackedBinaryConversion {
override lazy val runtimeDependencies = Vector()
+ val signed = {
+ context.optPrimType.get match {
+ case n: NodeInfo.PrimType.PrimNumeric => n.isSigned
+ // context.optPrimType can be of type date/time via
ConvertZonedCombinator
+ case _ => false
+ }
+ }
protected def getBitLength(s: ParseOrUnparseState): Int
def parse(start: PState): Unit = {
val nBits = getBitLength(start)
- if (nBits == 0) return // zero length is used for outputValueCalc often.
+ if (nBits == 0) {
Review Comment:
I can't find where we check the packed length is a multiple of 4 bits.
Unless you're referring to what we do in the function below?
```scala
def bcdFromBigIntegerLength(absBigIntAsString: String, minLengthInBits:
Int): (Int, Int) = {
val numDigits = absBigIntAsString.length
// Need to have an even number of digits to fill out a complete byte
val requiredBitLen = if (numDigits % 2 == 0) (numDigits * 4) else
((numDigits + 1) * 4)
val bitLen = scala.math.max(minLengthInBits, requiredBitLen)
val numBytes = (bitLen / 8)
val leadingZeros = bitLen / 4 - numDigits
(numBytes, leadingZeros)
}
```
--
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]