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

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala
 ##########
 @@ -187,14 +188,32 @@ class LengthInBitsEv(lengthUnits: LengthUnits,
 class MinLengthInBitsEv(lengthUnits: LengthUnits,
   lengthKind: LengthKind,
   override val maybeCharsetEv: Maybe[CharsetEv],
-  minLen: Long, rd: ElementRuntimeData)
+  minLen: Long, rd: TermRuntimeData)
   extends LengthInBitsEvBase(rd, lengthUnits, lengthKind) {
 
   override lazy val runtimeDependencies = maybeCharsetEv.toList
 
   override protected def lengthInLengthUnits(state: ParseOrUnparseState) = 
minLen
 }
 
+/**
+ * Since the minimum text length might be specified in LengthUnits.Characters
+ * for the minLength facet, and for the textOutputMinLength property, then
+ * converting those to bits requires possibly not knowing the
+ * encoding until runtime.
+ *
+ * Hence, we have to compute this similarly at runtime.
+ */
+class ChoiceMinLengthInBitsEv(lengthUnits: LengthUnits,
+  lengthKind: LengthKind,
+  lengthEv: LengthEv,
+  rd: TermRuntimeData)
+  extends MinLengthInBitsEv(lengthUnits, lengthKind, Nope, 0, rd) {
+
+  override protected def lengthInLengthUnits(state: ParseOrUnparseState) =
+    lengthEv.evaluate(state).longValue()
 
 Review comment:
   This also changes since there is no expression to evaluate. 

----------------------------------------------------------------
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