tuxji commented on code in PR #841:
URL: https://github.com/apache/daffodil/pull/841#discussion_r972451634
##########
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/LayeredSequenceUnparser.scala:
##########
@@ -35,29 +35,55 @@ class LayeredSequenceUnparser(ctxt: SequenceRuntimeData,
override def unparse(state: UState): Unit = {
val layerTransformer =
layerTransformerFactory.newInstance(layerRuntimeInfo)
- val originalDOS = state.dataOutputStream // layer will output to the
original, then finish it upon closing.
+ val originalDOS = state.dataOutputStream
+
+ // create a new buffered DOS that this layer will flush to when the layer
+ // completes unparsing. This ensures that any fragment bits or bitOrder
+ // state in the original DOS does not affect how the layer flushes bytes to
+ // the underlying DOS. Only when this new DOS is delivered to the
+ // originalDOS will the bitOrder checks be done.
+ val layerUnderlyingDOS = originalDOS.addBuffered()
+
+ // clone the UState to be used when the layer flushes its buffered content
+ // to layerUnderlyingDOS. This layer isn't a suspension, but this gives
+ // us an immutable clone that the layer can safely use
+ val finfoPre =
state.asInstanceOf[UStateMain].cloneForSuspension(layerUnderlyingDOS)
Review Comment:
When I read `finfoPre`, my eye read it as a typo for `finforPre`. What does
"finfoPre" actually look like when fully spelled out verbosely; is it short for
three words (fin, fo, Pre), or is it short for something else?
--
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]