stevedlawrence commented on a change in pull request #225: Implement
daf:lookAhead
URL: https://github.com/apache/incubator-daffodil/pull/225#discussion_r290264328
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DAFFunctions.scala
##########
@@ -72,3 +78,63 @@ case object DAFError extends RecipeOp {
}
}
}
+
+case class DAFLookAhead(recipes: List[CompiledDPath])
+ extends FNTwoArgs(recipes) {
+
+ def computeValue(arg1: AnyRef, arg2: AnyRef, dstate: DState): AnyRef = {
+ val offset = arg1.asInstanceOf[JLong]
+ val lBitSize = arg2.asInstanceOf[JLong]
+
+ /*
+ * Since daf:lookAhead is defined to take unsigned arguements, the DPath
interperater
+ * will error out on the cast if a negative arguement is supplied, so we
do not need to SDE here.
+ */
+
+ Assert.invariant(offset >= 0)
+ Assert.invariant(lBitSize >= 0)
+
+ val totalLookahead = offset + lBitSize
+ if (totalLookahead > 512) {
Review comment:
This should be a constant variable, or maybe even a tunable? I don't see
anything code that actually has a limit of 512, so it seems this is just to
prevent people from accidentally doing the wrong thing or abusing this
function. A tunable probably make sense in that case, so if someone reeeeeally
wants to abuse this they can.
----------------------------------------------------------------
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