bsloane1650 commented on a change in pull request #207: Added support for 
enumerations and TypeValueCalc
URL: https://github.com/apache/incubator-daffodil/pull/207#discussion_r275534884
 
 

 ##########
 File path: daffodil-lib/src/main/scala/org/apache/daffodil/util/Cursor.scala
 ##########
 @@ -160,18 +196,24 @@ trait CursorImplMixin[AccessorType <: 
Accessor[AccessorType]] { self: Cursor[Acc
     val res = priorOpKind match {
       case Advance => {
         priorOpKind = Inspect
-        doAdvance(true)
+        doAdvance(true, true)
       }
-      case Inspect => true // inspect again does nothing.
+      case InspectPure => {
+        priorOpKind = Inspect
+        doAdvance(true, advanceInput=false)
+      }
+      case Inspect      => true // inspect again does nothing.
       case Unsuccessful => return false
     }
     // successful
     Assert.invariant(isFilled == true || !res)
     res
   }
 
-  private def doAdvance(isFilledValue: Boolean) = {
-    val res = fill()
+  //inpsectPure implemented in InfosetInputter.scala
+
+  private def doAdvance(isFilledValue: Boolean, advanceInput: Boolean) = {
 
 Review comment:
   Again, we have a really wonky API here. I'll add a comment in this part of 
the code explaining, but for the sake of discussion I'll include an explanation 
here to.
   
   Logically speaking, there are two "streams" that we need to keep in our mind 
when thinking about an InfosetCursor.
   
   There is the input stream, which contains a series of infoset events, and 
the output stream, which is a sequence of infoset nodes.
   
   The first time you observe an infoset node, you consume it from the input 
stream. However, it is not consumed from the output stream until the "last" 
time you observe it (eg. you observe it through calling advance()). The 
advanceInput flag is used to indicate if the call to advance() is also the 
first time the node is being observed, in which case it also needs to consume 
the relevent portion of the input stream.
   
   Arguably, this logic really belongs in the priorOpKind state machine we have 
sprinkled throughout the advance/inspect/inspectPure methods.
   

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