stevedlawrence commented on a change in pull request #218: Implement
dfdl:choiceLength='explicit'
URL: https://github.com/apache/incubator-daffodil/pull/218#discussion_r286266446
##########
File path:
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLength2.scala
##########
@@ -460,6 +463,64 @@ class ElementUnusedUnparser(
}
+/**
+ * This is basically a simplified version of the
ElementUnusedUnparserSuspendableOperation.
+ * For explicit length choices, we do not need to handle length expressions,
choiceLength is
+ * simply a non-negative integer.
+ */
+class ChoiceUnusedUnparserSuspendableOperation(
+ override val rd: TermRuntimeData,
+ targetLengthInBits: Long)
+ extends SuspendableOperation {
+
+ /**
+ * determine delta between value length and target length
+ *
+ * and skip that many bits.
+ */
+ override def continuation(ustate: UState) {
+ val e = ustate.currentInfosetNode.asInstanceOf[DIElement]
Review comment:
I think we have to be careful around where the state is stored.
ChoiceParser/Unparser and ChoiceRUntimeData are both shared between different
parses/unparses. So putting state there needs to think about thread safety, the
state might need to be in a thread local. I suggested the infoset since it is
unique per parse and it has all the logic for dealing with suppressions and
calculating lengths when there's relative stuff going on.
Maybe instead of adding a ChoiceNode to the infoset, each ComplexNode in the
infoset has both a length state for itself **and** an array of length state for
any child choices with explicit lengths? Each choice would need to statically
know which state in the array is its own, so that might have some challenges.
So the below might look something like:
```scala
val v1 = e.choiceValueLength[staticIndex].lengthInBits.longValue
```
----------------------------------------------------------------
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