stevedlawrence commented on a change in pull request #218: Implement 
dfdl:choiceLength='explicit'
URL: https://github.com/apache/incubator-daffodil/pull/218#discussion_r286251960
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
 ##########
 @@ -48,9 +50,22 @@ case class ChoiceCombinator(ch: ChoiceTermBase, 
rawAlternatives: Seq[Gram])
 
   override def isEmpty = super.isEmpty || alternatives.isEmpty
 
+  private lazy val bitsMultiplier = ch.lengthUnits match {
+    case LengthUnits.Bits => 1
+    case LengthUnits.Bytes => 8
+    case LengthUnits.Characters if ch.knownEncodingIsFixedWidth => 
ch.knownEncodingWidthInBits
+    case _ => 0 // zero means can't multiply to get width in bits.
+  }
 
 Review comment:
   The spec says choiceLength is always in units of bytes, so I think the 
bitsMultiplier should always be 8 and can just be hardcoded (maybe with a 
comment) where it's needed? Or maybe adda choiceLengthInBits that does the ``* 
8`` and can be used everywhere bits are expected?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to