mbeckerle commented on a change in pull request #12: Revised daffodil-io module to require passing in a FormatInfo object. URL: https://github.com/apache/incubator-daffodil/pull/12#discussion_r157905431
########## File path: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DirectOrBufferedDataOutputStream.scala ########## @@ -704,23 +724,27 @@ object DirectOrBufferedDataOutputStream { * Delivers the bits of bufDOS into directDOS's output stream. Deals with the possibility that * the directDOS ends with a fragment byte, or the bufDOS does, or both. */ - private def deliverBufferContent(directDOS: DirectOrBufferedDataOutputStream, bufDOS: DirectOrBufferedDataOutputStream, finfo: FormatInfo) { + private def deliverBufferContent(directDOS: DirectOrBufferedDataOutputStream, + bufDOS: DirectOrBufferedDataOutputStream, + finfo: FormatInfo) { Assert.invariant(bufDOS.isBuffering) Assert.invariant(!directDOS.isBuffering) val ba = bufDOS.bufferingJOS.getBuf val bufferNBits = bufDOS.relBitPos0b // don't have to subtract a starting offset. It's always zero in buffered case. - if (finfo.bitOrder ne directDOS.cst.priorBitOrder) { - if (!directDOS.isEndOnByteBoundary) { + val finfoBitOrder = finfo.bitOrder // bit order we are supposed to write with + val priorBitOrder = directDOS.cst.priorBitOrder // bit order that the directDOS has. + if (finfoBitOrder ne priorBitOrder) { + if ((bufferNBits > ULong.Zero) && + !directDOS.isEndOnByteBoundary) { // // If the bit order changes, it has to be on a byte boundary // It's simply not meaningful for it to change otherwise. // throw new BitOrderChangeException(directDOS, finfo) - } else { - directDOS.cst.priorBitOrder = finfo.bitOrder } + // directDOS.cst.setPriorBitOrder(finfoBitOrder) Review comment: delete commented code ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services