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

 ##########
 File path: 
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataOutputStreamImplMixin.scala
 ##########
 @@ -843,26 +736,49 @@ trait DataOutputStreamImplMixin extends 
DataStreamCommonState
   private val unionIntBuffer = unionByteBuffer.asIntBuffer()
   protected val unionLongBuffer = unionByteBuffer.asLongBuffer()
 
-  def putBinaryFloat(v: Float, finfo: FormatInfo): Boolean = {
+  final override def putBinaryFloat(v: Float, finfo: FormatInfo): Boolean = {
     unionFloatBuffer.put(0, v)
     val i = unionIntBuffer.get(0)
-    putLong(i, 32, finfo)
+    val res = putLongChecked(i, 32, finfo)
+    setPriorBitOrder(finfo.bitOrder)
+    res
   }
 
-  def putBinaryDouble(v: Double, finfo: FormatInfo): Boolean = {
+  final override def putBinaryDouble(v: Double, finfo: FormatInfo): Boolean = {
     unionDoubleBuffer.put(0, v)
     val l = unionLongBuffer.get(0)
-    putLong(l, 64, finfo)
+    val res = putLongChecked(l, 64, finfo)
+    setPriorBitOrder(finfo.bitOrder)
+    res
   }
 
-  def skip(nBits: Long, finfo: FormatInfo): Boolean = {
+  /**
+   * Used when we have to fill in things that are larger or smaller than a byte
+   */
+  private def fillLong(fillByte: Byte) = {
+    var fl: Long = 0L
+    val fb = fillByte.toInt & 0xFF
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl = (fl << 8) + fb
+    fl
+  }
 
 Review comment:
   Does it make sense to turn this into an Evalutable so that it doesn't need 
to be recalculated very often? But maybe that's a pre-optimization? The above 
should be prety fast?

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

Reply via email to