You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/07/02 19:02:30 UTC

[GitHub] [daffodil] Samarth08 opened a new pull request #603: Daffodil 2473 remaining[WIP]

Samarth08 opened a new pull request #603:
URL: https://github.com/apache/daffodil/pull/603


   


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r666858023



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()

Review comment:
       I don't think so. The documentation for [BigInt.not() function](https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#not()) says:
   
   > This method returns a negative value if and only if this BigInteger is non-negative.
   
   The value for us will always be non-negative since it's unsigned, which means just calling `getBigInt.not()` will always created a signed value, which is definitely wrong. Instead, we need to use the ULong, with something similar to the other unsigned types. I think something like this should do it:
   
   ```scala
   case NodeInfo.UnsignedLong => (~ULong(arg1.getBigInt.longValue()).toBigInt
   ```
   So we get the BigInteger, convert it to a long, then convert that to a ULong, `not` the ULong, and then convert that back to a BigInt.
   
   




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r669108699



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()

Review comment:
       Probably easier to get this working than to back out changes. Can you push what you have and we can take a look?




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-883793657


   Latest changes look good to me, but we can't rebase/merge this PR because it contains conflicts due to the merge commit. In the future, avoid running `git merge` or `git pull` (which does a merge behind the scenes), since they lead to these merge commits that cause issues. Lots of places online say to use git pull or git merge, but for Daffodil those commands should be avoided.
   
   Here's the commands to fix your branch up and squash into a single commit:
   
   ```bash
   # make sure we are on your branch
   git checkout DAFFODIL-2473_Remaining
   
   # create a backup branch just in case we mess things up
   git branch DAFFODIL-2473-backup
   
   # create a diff between your branch and master
   git diff asf/master > daffodil-2473.patch
   
   # move your branch to asf/master
   git reset --hard asf/master
   
   # apply the patch and stage the changes
   git apply --index daffodil-2473.patch
   
   # delete the patch file
   rm daffodil-2473.patch
   
   # commit your changes, add a new commit message
   git commit
   ```
   
   If that all works, you should now have a single commit containing your squashed changes on top of asf/master. You can force push that to your fork to update the PR, and delete the backup branch.
   ```bash
   # update the PR with your new changes (assuming "origin" is your fork)
   git push --force origin DAFFODIL-2473_Remaining
   
   # delete backup branch
   git branch -D DAFFODIL-2473-backup
   ```
   
   If at any point a command doesn't work or looks wrong, you can always reset to the backup branch and it will be like none of this happened:
   ```
   git reset --hard DAFFODIL-2474-backup
   ```
   I've also got a clone of your PR, so if something goes really wrong, I'll have the changes and we can restore them.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] mbeckerle commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r663391698



##########
File path: daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestBitFunctions.scala
##########
@@ -59,6 +61,18 @@ class TestBitFunctions {
   @Test def rightShiftDecimalError01():Unit = {runner.runOneTest("rightShiftDecimalError01")}
   @Test def leftShiftNonNegativeIntegerError01():Unit = {runner.runOneTest("leftShiftNonNegativeIntegerError01")}
   @Test def rightShiftNonNegativeIntegerError01():Unit = {runner.runOneTest("rightShiftNonNegativeIntegerError01")}
+  @Test def testIntXor():Unit = {runner1.runOneTest("testIntXor")}

Review comment:
        Need tests for bitAnd, bitOr, and bitNot as well. 

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -127,7 +127,7 @@ case class DFDLXAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extend
       case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
       case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
       //$COVERAGE-OFF$
-      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+      case _ => Assert.invariantFailed(s"dfdlx:AND not supported")

Review comment:
       Should this be dfdlx:bitAnd ?

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -145,7 +145,25 @@ case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends
       case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
       case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
       //$COVERAGE-OFF$
-      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+      case _ => Assert.invariantFailed(s"dfdlx:OR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()
+      case NodeInfo.UnsignedInt => ~arg1.getLong
+      case NodeInfo.UnsignedShort => ~arg1.getInt
+      case NodeInfo.UnsignedByte => ~arg1.getShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:NOT not supported")

Review comment:
       dfdlx:bitNot

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -145,7 +145,25 @@ case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends
       case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
       case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
       //$COVERAGE-OFF$
-      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+      case _ => Assert.invariantFailed(s"dfdlx:OR not supported")

Review comment:
       dfdlx:bitOr




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r669104523



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()

Review comment:
       This is also not working.
   Should I remove not form the PR and merge rest of them.Not can be picked separately later.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875567940


   overloaded method value load with alternatives:
     (url: java.net.URL)scala.xml.Node <and>
     (source: scala.xml.InputSource)scala.xml.Node <and>
     (sysID: String)scala.xml.Node <and>
     (reader: java.io.Reader)scala.xml.Node <and>
     (is: java.io.InputStream)scala.xml.Node
    cannot be applied to (org.apache.daffodil.api.URISchemaSource)
           val node = loader.load(URISchemaSource(configOpt.get))
   


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-886688135


   +1 to the latest changes.
   
   Please squash into a single commit following the steps in https://github.com/apache/daffodil/pull/603#issuecomment-883793657 and this can be merged.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r669969896



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -110,13 +162,47 @@ case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extend
       case NodeInfo.UnsignedShort => arg1.getInt ^ arg2.getInt
       case NodeInfo.UnsignedByte => (arg1.getShort ^ arg2.getShort).toShort
           //$COVERAGE-OFF$
-      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+      case _ => Assert.invariantFailed(s"dfdlx:bitXOR not supported")
           // $COVERAGE-ON$
     }
     }
   }
 
+case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOr not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {

Review comment:
       I think this is a duplicate class? DFDLXBitNot is the right one. I think this can be removed.

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte

Review comment:
       Java's bitwise-not returns an Int, even if the type is short or a byte. But we need Short to stay Short, and Byte to stay Byte, so we need to case then. So these two lines should be:
   
   ```scala
   case NodeInfo.Short => (~arg1.getShort).toShort
   case NodeInfo.Byte => (~arg1.getByte).toByte
   ```
   The unsigned cases looked right to me.

##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,9 +1634,19 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
-      case (RefQName(_, "xor", DFDLX), args) =>
+      case (RefQName(_, "bitXor", DFDLX), args) =>
         DFDLXBitExpr(functionQNameString, functionQName, args,
           DFDLXXor(_,_))

Review comment:
       This should be DFDLXBitXor

##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/BitFunctionsNot.tdml
##########
@@ -0,0 +1,305 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+      http://www.apache.org/licenses/LICENSE-2.0
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<tdml:testSuite suiteName="SimpleTypes" description="Section 5 - simple types"
+  xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+  xmlns:ex="http://example.com"
+  xmlns:home="http://home.com"
+  xmlns:first="http://first.com"
+  defaultRoundTrip="onePass">
+  <tdml:defineSchema elementFormDefault="unqualified" name="BitFunctions">
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+    <dfdl:format ref="ex:GeneralFormat" />
+
+  <xs:complexType name="IntNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:int" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:int" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testIntNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="IntNot1" type="ex:IntNot"/>
+        <xs:element name="IntNot2" type="ex:IntNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="LongNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:long" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:long" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testLongNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="LongNot1" type="ex:LongNot"/>
+        <xs:element name="LongNot2" type="ex:LongNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="ShortNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:short" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:short" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testShortNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="ShortNot1" type="ex:ShortNot"/>
+        <xs:element name="ShortNot2" type="ex:ShortNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="ByteNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:byte" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:byte" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testByteNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="ByteNot1" type="ex:ByteNot"/>
+        <xs:element name="ByteNot2" type="ex:ByteNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedIntNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedInt" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedInt" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedIntNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedIntNot1" type="ex:UnsignedIntNot"/>
+        <xs:element name="UnsignedIntNot2" type="ex:UnsignedIntNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedLongNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedLong" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedLong" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedLongNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedLongNot1" type="ex:UnsignedLongNot"/>
+        <xs:element name="UnsignedLongNot2" type="ex:UnsignedLongNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedShortNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedShort" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedShort" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedShortNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedShortNot1" type="ex:UnsignedShortNot"/>
+        <xs:element name="UnsignedShortNot2" type="ex:UnsignedShortNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedByteNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedByte" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedByte" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedByteNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedByteNot1" type="ex:UnsignedByteNot"/>
+        <xs:element name="UnsignedByteNot2" type="ex:UnsignedByteNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  </tdml:defineSchema>
+
+  <tdml:parserTestCase name="testIntNot" root="testIntNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testIntNot>
+            <ex:IntNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:IntNot1>
+            <ex:IntNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:IntNot2>
+          </ex:testIntNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testLongNot" root="testLongNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testLongNot>
+            <ex:LongNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:LongNot1>
+            <ex:LongNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:LongNot2>
+          </ex:testLongNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testShortNot" root="testShortNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testShortNot>
+            <ex:ShortNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:ShortNot1>
+            <ex:ShortNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:ShortNot2>
+          </ex:testShortNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testByteNot" root="testByteNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testByteNot>
+            <ex:ByteNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:ByteNot1>
+            <ex:ByteNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:ByteNot2>
+          </ex:testByteNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testUnsignedIntNot" root="testUnsignedIntNot" model="BitFunctions">
+    <tdml:document>2|1</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testUnsignedIntNot>
+            <ex:UnsignedIntNot1>
+              <num>2</num>
+              <value>4294967293</value>
+            </ex:UnsignedIntNot1>
+            <ex:UnsignedIntNot2>
+              <num>1</num>
+              <value>4294967294</value>
+            </ex:UnsignedIntNot2>
+          </ex:testUnsignedIntNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+
+  <tdml:parserTestCase name="testUnsignedLongNot" root="testUnsignedLongNot" model="BitFunctions">

Review comment:
       This test isn't right. This is bitNot of unsigned types, so the <value> part of the infoset should be unsigned, but these test expects -3 and -1. Those should be something else that is signed.

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => ULong((~arg1.getBigInt.longValue)).toBigInt
+      case NodeInfo.UnsignedInt => UInt((~arg1.getLong).toInt).toLong
+      case NodeInfo.UnsignedShort => UShort((~arg1.getInt).toShort).toInt
+      case NodeInfo.UnsignedByte => UByte((~arg1.getShort).toByte).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:NOT not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {

Review comment:
       This class should be rename DFDLXBitXor

##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -2205,6 +2215,31 @@ case class DFDLXBitExpr(nameAsParsed: String, fnQName: RefQName,
     res
   }
 }
+
+case class DFDLXBitNot(nameAsParsed: String, fnQName: RefQName,

Review comment:
       I think this should be renamed DFDLXBitNotExpr. DFDLXBitNot should be the name of the runtime class that actually does the bitwise-not.

##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/BitFunctionsNot.tdml
##########
@@ -0,0 +1,305 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+      http://www.apache.org/licenses/LICENSE-2.0
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<tdml:testSuite suiteName="SimpleTypes" description="Section 5 - simple types"
+  xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+  xmlns:ex="http://example.com"
+  xmlns:home="http://home.com"
+  xmlns:first="http://first.com"
+  defaultRoundTrip="onePass">
+  <tdml:defineSchema elementFormDefault="unqualified" name="BitFunctions">
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+    <dfdl:format ref="ex:GeneralFormat" />
+
+  <xs:complexType name="IntNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:int" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:int" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testIntNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="IntNot1" type="ex:IntNot"/>
+        <xs:element name="IntNot2" type="ex:IntNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="LongNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:long" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:long" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testLongNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="LongNot1" type="ex:LongNot"/>
+        <xs:element name="LongNot2" type="ex:LongNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="ShortNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:short" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:short" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testShortNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="ShortNot1" type="ex:ShortNot"/>
+        <xs:element name="ShortNot2" type="ex:ShortNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="ByteNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:byte" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:byte" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testByteNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="ByteNot1" type="ex:ByteNot"/>
+        <xs:element name="ByteNot2" type="ex:ByteNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedIntNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedInt" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedInt" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedIntNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedIntNot1" type="ex:UnsignedIntNot"/>
+        <xs:element name="UnsignedIntNot2" type="ex:UnsignedIntNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedLongNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedLong" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedLong" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedLongNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedLongNot1" type="ex:UnsignedLongNot"/>
+        <xs:element name="UnsignedLongNot2" type="ex:UnsignedLongNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedShortNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedShort" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedShort" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedShortNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedShortNot1" type="ex:UnsignedShortNot"/>
+        <xs:element name="UnsignedShortNot2" type="ex:UnsignedShortNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="UnsignedByteNot">
+    <xs:sequence dfdl:separator=",">
+      <xs:element name="num" type="xs:unsignedByte" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#0"/>
+      <xs:element name="value" type="xs:unsignedByte" dfdl:inputValueCalc="{dfdlx:bitNot(../num)}"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="testUnsignedByteNot">
+    <xs:complexType>
+      <xs:sequence dfdl:separator="|">
+        <xs:element name="UnsignedByteNot1" type="ex:UnsignedByteNot"/>
+        <xs:element name="UnsignedByteNot2" type="ex:UnsignedByteNot"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  </tdml:defineSchema>
+
+  <tdml:parserTestCase name="testIntNot" root="testIntNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testIntNot>
+            <ex:IntNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:IntNot1>
+            <ex:IntNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:IntNot2>
+          </ex:testIntNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testLongNot" root="testLongNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testLongNot>
+            <ex:LongNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:LongNot1>
+            <ex:LongNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:LongNot2>
+          </ex:testLongNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testShortNot" root="testShortNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testShortNot>
+            <ex:ShortNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:ShortNot1>
+            <ex:ShortNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:ShortNot2>
+          </ex:testShortNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testByteNot" root="testByteNot" model="BitFunctions">
+    <tdml:document>1|0</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testByteNot>
+            <ex:ByteNot1>
+              <num>1</num>
+              <value>-2</value>
+            </ex:ByteNot1>
+            <ex:ByteNot2>
+              <num>0</num>
+              <value>-1</value>
+            </ex:ByteNot2>
+          </ex:testByteNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testUnsignedIntNot" root="testUnsignedIntNot" model="BitFunctions">
+    <tdml:document>2|1</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testUnsignedIntNot>
+            <ex:UnsignedIntNot1>
+              <num>2</num>
+              <value>4294967293</value>
+            </ex:UnsignedIntNot1>
+            <ex:UnsignedIntNot2>
+              <num>1</num>
+              <value>4294967294</value>
+            </ex:UnsignedIntNot2>
+          </ex:testUnsignedIntNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+
+  <tdml:parserTestCase name="testUnsignedLongNot" root="testUnsignedLongNot" model="BitFunctions">
+    <tdml:document>2|1</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testUnsignedLongNot>
+            <ex:UnsignedLongNot1>
+              <num>2</num>
+              <value>-3</value>
+            </ex:UnsignedLongNot1>
+            <ex:UnsignedLongNot2>
+              <num>1</num>
+              <value>-2</value>
+            </ex:UnsignedLongNot2>
+          </ex:testUnsignedLongNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testUnsignedShortNot" root="testUnsignedShortNot" model="BitFunctions">
+    <tdml:document>2|1</tdml:document>
+      <tdml:infoset>
+        <tdml:dfdlInfoset>
+          <ex:testUnsignedShortNot>
+            <ex:UnsignedShortNot1>
+              <num>1</num>
+              <value>4294967293</value>
+            </ex:UnsignedShortNot1>
+            <ex:UnsignedShortNot2>
+              <num>1</num>
+              <value>4294967294</value>
+            </ex:UnsignedShortNot2>
+          </ex:testUnsignedShortNot>
+        </tdml:dfdlInfoset>
+      </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="testUnsignedByteNot" root="testUnsignedByteNot" model="BitFunctions">
+    <tdml:document>-1|6</tdml:document>

Review comment:
       -1 isn't a valid unsignedByte so this will fail to parse. The test also expects the bitwise-not of 6 is -7, which isn't correct for unsigned bytes.

##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,9 +1634,19 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
-      case (RefQName(_, "xor", DFDLX), args) =>
+      case (RefQName(_, "bitXor", DFDLX), args) =>
         DFDLXBitExpr(functionQNameString, functionQName, args,
           DFDLXXor(_,_))
+      case (RefQName(_, "bitAnd", DFDLX), args) =>
+        DFDLXBitExpr(functionQNameString, functionQName, args,
+          DFDLXBitAnd(_,_))
+      case (RefQName(_, "bitOr", DFDLX), args) =>
+        DFDLXBitExpr(functionQNameString, functionQName, args,
+          DFDLXOr(_,_))

Review comment:
       This should be DFDLXBitOr

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -110,13 +162,47 @@ case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extend
       case NodeInfo.UnsignedShort => arg1.getInt ^ arg2.getInt
       case NodeInfo.UnsignedByte => (arg1.getShort ^ arg2.getShort).toShort
           //$COVERAGE-OFF$
-      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+      case _ => Assert.invariantFailed(s"dfdlx:bitXOR not supported")

Review comment:
       This error message should be dfdlx:bitXor to match the function name that we actually expect.

##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,9 +1634,19 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
-      case (RefQName(_, "xor", DFDLX), args) =>
+      case (RefQName(_, "bitXor", DFDLX), args) =>
         DFDLXBitExpr(functionQNameString, functionQName, args,
           DFDLXXor(_,_))
+      case (RefQName(_, "bitAnd", DFDLX), args) =>
+        DFDLXBitExpr(functionQNameString, functionQName, args,
+          DFDLXBitAnd(_,_))
+      case (RefQName(_, "bitOr", DFDLX), args) =>
+        DFDLXBitExpr(functionQNameString, functionQName, args,
+          DFDLXOr(_,_))
+      case (RefQName(_, "bitNot", DFDLX), args) =>
+        DFDLXBitNot(functionQNameString, functionQName, args,
+          DFDLXNot(_,_))

Review comment:
       With this renamed, this should become:
   ```scala
    DFDLXBitNotExpr(functionQNameString, functionQName, args,
       DFDLXBitNot(_,_))
   ```




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] mbeckerle commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r663206094



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,6 +1634,16 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
+      case (RefQName(_, "xor", DFDLX), args) =>

Review comment:
       xor, and, or should be renamed to xorBits, andBits, and orBits to clearly distinguish them from boolean operations.
   
   XPath already has regular and/or operators. 
   
   Given that these new things are functions, not operators, and they're in the dfdlx namespace that may seem like overkill, but I would propose that these get added to the DFDL expression language officially at some point, at which point the namespace prefix would go away and they might be recast as infix operators. 
   
   Do we have a notBits operator. We need that also.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r663208162



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,6 +1634,16 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
+      case (RefQName(_, "xor", DFDLX), args) =>

Review comment:
       For notBits we will have just one argument?
   




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875811125


   Based on what you've pushed, I'm not sure why you would get the error about ``loader.load``. Did that go away?
   
   Double check your ``DFDLXFunctions.scala`` file. There is a duplicate DFDLXBitAnd classe that are causing issues. Remove that duplicate. Also check ``Expression.scala`, that file is reference DFDLXAnd but should be DFDLXBitAnd.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r664477116



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -98,6 +98,79 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
   }
 }
 
+case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong ^ arg2.getLong
+      case NodeInfo.Int => arg1.getInt ^ arg2.getInt
+      case NodeInfo.Short => (arg1.getShort ^ arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte ^ arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.xor(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong ^ arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt ^ arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort ^ arg2.getShort).toShort
+          //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+          // $COVERAGE-ON$
+    }
+    }
+  }
+case class DFDLXAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:AND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {

Review comment:
       This is also a duplicate and can be deleted. DFDLXBitOr is the correct class which you have above.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875539822


   After rebasing it with master facing issues with DaffodilTunablesGen.Scala while running the test cases.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-895406726


   Looks good! Thanks!


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r667521084



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()

Review comment:
       I am not sure whether not is not working properly or is there something with the test cases.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875826260


   The loader.load error was resolved after doing sbt compile again.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence merged pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence merged pull request #603:
URL: https://github.com/apache/daffodil/pull/603


   


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] tuxji commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
tuxji commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r674075820



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -2205,6 +2215,31 @@ case class DFDLXBitExpr(nameAsParsed: String, fnQName: RefQName,
     res
   }
 }
+
+case class DFDLXBitUnaryExpr(nameAsParsed: String, fnQName: RefQName,
+                        args: List[Expression], constructor: (CompiledDPath, NodeInfo.Kind) => RecipeOp)
+  extends FunctionCallBase(nameAsParsed, fnQName, args) {
+  override lazy val inherentType = {
+    val arg0Type = args(0).inherentType
+    schemaDefinitionUnless(
+      arg0Type.isSubtypeOf(NodeInfo.PrimType.UnsignedLong) || arg0Type.isSubtypeOf(NodeInfo.PrimType.Long),
+      "Both arguments for %s must be either xs:unsignedLong or xs:long or a subtype of those, but was %s.",
+      nameAsParsed,arg0Type.globalQName)

Review comment:
       Steve's comment about `Both arguments ...` above still needs to be addressed.  Also, we prefer spaces between comma-separated arguments on this line (2227) and line 2237 (also compare lines 2236 & 2237 with line 2253 & 2254 - please follow the same formatting as existing code).




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875613507


   I have fetched the latest master but I am not able to run the tests.I am not able to test bitNot.Rest all are tested.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r664477116



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -98,6 +98,79 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
   }
 }
 
+case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong ^ arg2.getLong
+      case NodeInfo.Int => arg1.getInt ^ arg2.getInt
+      case NodeInfo.Short => (arg1.getShort ^ arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte ^ arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.xor(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong ^ arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt ^ arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort ^ arg2.getShort).toShort
+          //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+          // $COVERAGE-ON$
+    }
+    }
+  }
+case class DFDLXAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:AND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {

Review comment:
       Rename this class to DFDLXBitOr. This is particularly useful in this case since this could easily be confused with the XOR function. Adding "Bit" makes the difference a bit more obvious.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875563121


   @Samarth08, what errors are you getting?


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r673379635



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1629,22 +1629,22 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
         FNExactlyOneExpr(functionQNameString, functionQName, args)
 
       case (RefQName(_, "leftShift", DFDLX), args) =>
-        DFDLXShiftExpr(functionQNameString, functionQName, args,
+        DFDLXBitBinaryExpr(functionQNameString, functionQName, args,
           DFDLXLeftShift(_, _))
       case (RefQName(_, "rightShift", DFDLX), args) =>
-        DFDLXShiftExpr(functionQNameString, functionQName, args,
+        DFDLXBitBinaryExpr(functionQNameString, functionQName, args,

Review comment:
       left shift and right shift should still use DFDLXShiftExpr. Although they take two arguments like BinaryExpr, they have different restrictions. For example, the second argument must always be a unsigned int for shift. So it's sort of like unary, but with an extra argument. I think keeping these two as DFDLXShiftExpr makes sense. No rename or anything needed here.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r664472243



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -2177,6 +2190,55 @@ case class DFDLXShiftExpr(nameAsParsed: String, fnQName: RefQName,
     res
   }
 }
+case class DFDLXBitExpr(nameAsParsed: String, fnQName: RefQName,

Review comment:
       I believe this DFLXBitExpr class was already added in a previous pull request that has already been merged. You should rebase this pul request to the latest master so we can see just thing things that are new.

##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -2177,6 +2190,55 @@ case class DFDLXShiftExpr(nameAsParsed: String, fnQName: RefQName,
     res
   }
 }
+case class DFDLXBitExpr(nameAsParsed: String, fnQName: RefQName,
+                        args: List[Expression], constructor: (List[CompiledDPath], NodeInfo.Kind) => RecipeOp)
+  extends FunctionCallBase(nameAsParsed, fnQName, args) {
+  override lazy val inherentType = {
+    val arg0Type = args(0).inherentType
+    val arg1Type = args(1).inherentType
+    val argInherentType = if (arg1Type.isSubtypeOf(arg0Type)) arg0Type else arg1Type
+    schemaDefinitionUnless(
+      argInherentType.isSubtypeOf(NodeInfo.PrimType.UnsignedLong) || argInherentType.isSubtypeOf(NodeInfo.PrimType.Long),
+      "Both arguments for %s must be either xs:unsignedLong or xs:long or a subtype of those, but was %s.",
+      nameAsParsed,argInherentType.globalQName)
+    argInherentType
+  }
+    override def targetTypeForSubexpression(subexp: Expression): NodeInfo.Kind = inherentType
+
+  override def compiledDPath: CompiledDPath = {
+    checkArgCount(2)
+    val argType = inherentType
+    val arg0Recipe = args(0).compiledDPath
+    val arg1Recipe=args(1).compiledDPath
+    val c=conversions
+    val res = new CompiledDPath(constructor(List(arg0Recipe,arg1Recipe),argType)+:c)
+    res
+  }
+}
+
+case class DFDLXBitNot(nameAsParsed: String, fnQName: RefQName,
+                        args: List[Expression], constructor: (CompiledDPath, NodeInfo.Kind) => RecipeOp)
+  extends FunctionCallBase(nameAsParsed, fnQName, args) {
+  override lazy val inherentType = {
+    val arg0Type = args(0).inherentType
+    schemaDefinitionUnless(
+      arg0Type.isSubtypeOf(NodeInfo.PrimType.UnsignedLong) || arg0Type.isSubtypeOf(NodeInfo.PrimType.Long),
+      "Both arguments for %s must be either xs:unsignedLong or xs:long or a subtype of those, but was %s.",

Review comment:
       This says `Both arguments ...`, but there is only a single argument. Should probably just be something like `The argument ...`

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -98,6 +98,79 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
   }
 }
 
+case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong ^ arg2.getLong
+      case NodeInfo.Int => arg1.getInt ^ arg2.getInt
+      case NodeInfo.Short => (arg1.getShort ^ arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte ^ arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.xor(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong ^ arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt ^ arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort ^ arg2.getShort).toShort
+          //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+          // $COVERAGE-ON$
+    }
+    }
+  }
+case class DFDLXAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:AND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {

Review comment:
       Please make sure to rename the classs too (e.g. DFDLXBitOr). This is particularly useful in this case since this could easily be confused with the XOR function. Ading "Bit" makes the difference a bit more obvious.

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -98,6 +98,79 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
   }
 }
 
+case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong ^ arg2.getLong
+      case NodeInfo.Int => arg1.getInt ^ arg2.getInt
+      case NodeInfo.Short => (arg1.getShort ^ arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte ^ arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.xor(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong ^ arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt ^ arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort ^ arg2.getShort).toShort
+          //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:XOR not supported")
+          // $COVERAGE-ON$
+    }
+    }
+  }
+case class DFDLXAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:AND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:OR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()
+      case NodeInfo.UnsignedInt => ~arg1.getLong
+      case NodeInfo.UnsignedShort => ~arg1.getInt
+      case NodeInfo.UnsignedByte => ~arg1.getShort

Review comment:
       I *think* we need slightly different logic for each of the Unsigned operations, simiarly to what we needed to do for shifting. For example, say we have an xs:unsignedShort with a value of `1`. That will be represented here by a java Int. And `~1` is `-2`, so we end up with a negative value for something that should be unsigned.
   
   I think we need to get the value, convert it to the Unsigned type, perform the not operation on that, and then convert back to the right type for the infoset. So for example, for UnsignedInt I think we want something like:
   
   ```scala
   case NodeInfo.UnsignedInt => (~UInt(arg1.getLong.toInt)).toLong
   ```
   I've only done a couple simple tests, but this seems to work for what I've tested, and follows a similar pattern to what we came up with for shiftLeft/right. We'll need something similar for each of the Unsigned types.
   
   We'll definitely want some tests to make sure this is working as expected.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r673259289



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -138,14 +138,14 @@ case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends F
     argType match {
       case NodeInfo.Long => ~arg1.getLong
       case NodeInfo.Int => ~arg1.getInt
-      case NodeInfo.Short => ~arg1.getShort
-      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.Short => (~arg1.getShort).toShort
+      case NodeInfo.Byte => (~arg1.getByte).toByte
       case NodeInfo.UnsignedLong => ULong((~arg1.getBigInt.longValue)).toBigInt
       case NodeInfo.UnsignedInt => UInt((~arg1.getLong).toInt).toLong
       case NodeInfo.UnsignedShort => UShort((~arg1.getInt).toShort).toInt
       case NodeInfo.UnsignedByte => UByte((~arg1.getShort).toByte).toShort
       //$COVERAGE-OFF$
-      case _ => Assert.invariantFailed(s"dfdlx:NOT not supported")
+      case _ => Assert.invariantFailed(s"dfdlx:Not not supported")

Review comment:
       This should be `dfdlx:bitNot` in the error message.

##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1642,10 +1642,10 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
           DFDLXBitAnd(_,_))
       case (RefQName(_, "bitOr", DFDLX), args) =>
         DFDLXBitExpr(functionQNameString, functionQName, args,
-          DFDLXOr(_,_))
+          DFDLXBitOr(_,_))
       case (RefQName(_, "bitNot", DFDLX), args) =>
-        DFDLXBitNot(functionQNameString, functionQName, args,
-          DFDLXNot(_,_))
+        DFDLXBitExprNot(functionQNameString, functionQName, args,

Review comment:
       Minor thought looking at this one last time. It might make sense to rename `DFDLXBitExpr` to `DFDLXBitBinaryExpr` and `DFDLXBitExprNot` to `DFDLXBitUnaryExpr`. Those two renames make the difference between the two class more clear (i.e. binary vs unary). And it also makes it clear that Unary isn't necessarily specific to NOT, even though that's currently the only thing we use it for. Maybe someday we'll add NAND, NOR or some other binray or unary operations, and it will be more clear which of DFDLXBitBinaryExpr or DFDLXBitUnary is the right thing to use.

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => ULong((~arg1.getBigInt.longValue)).toBigInt
+      case NodeInfo.UnsignedInt => UInt((~arg1.getLong).toInt).toLong
+      case NodeInfo.UnsignedShort => UShort((~arg1.getInt).toShort).toInt
+      case NodeInfo.UnsignedByte => UByte((~arg1.getShort).toByte).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:NOT not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 case class DFDLXXor(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {

Review comment:
       Please rename this class to be consistent with the to others. Should be DFDLXBitXor.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r666725091



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()

Review comment:
       @stevedlawrence Is this correct for unsignedNot?




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #603:
URL: https://github.com/apache/daffodil/pull/603#issuecomment-875581937


   Commit 62ac1047a18979bea1f5d6c668eefeaaae39d64b changed the parameters to the `DaffodilXMLLoader.load` method, which is where the problem is on the line
   ```scala
   val node = loader.load(URISchemaSource(configOpt.get))
   ```
   That line should look like this now:
   ```scala
   val node = loader.load(URISchemaSource(configOpt.get), Some(XMLUtils.dafextURI))
   ```
   Which means that your `TunableGenerator.scala` file is old and isn't updated for some reason, but your `DaffodilXMLLoader.scala` file is the new correct one. Maybe you need to refresh files in your IDE or something? If you're still not sure, feel free to commit your changes and push to this PR and I can take a look and see whats going on.


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] Samarth08 commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
Samarth08 commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r663224732



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,6 +1634,16 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
+      case (RefQName(_, "xor", DFDLX), args) =>

Review comment:
       I have added not.




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] mbeckerle commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r663212234



##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
##########
@@ -1634,6 +1634,16 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       case (RefQName(_, "rightShift", DFDLX), args) =>
         DFDLXShiftExpr(functionQNameString, functionQName, args,
           DFDLXRightShift(_, _))
+      case (RefQName(_, "xor", DFDLX), args) =>

Review comment:
       Yes. That means another base class slightly different than the one you have for 2-args bits functions. 




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [daffodil] stevedlawrence commented on a change in pull request #603: Daffodil 2473 remaining[WIP]

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #603:
URL: https://github.com/apache/daffodil/pull/603#discussion_r667876012



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXFunctions.scala
##########
@@ -97,7 +97,59 @@ case class DFDLXRightShift(recipes: List[CompiledDPath], argType: NodeInfo.Kind)
     }
   }
 }
+case class DFDLXBitAnd(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong & arg2.getLong
+      case NodeInfo.Int => arg1.getInt & arg2.getInt
+      case NodeInfo.Short => (arg1.getShort & arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte & arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.and(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong & arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt & arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort & arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitAND not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
 
+case class DFDLXBitOr(recipes: List[CompiledDPath], argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => arg1.getLong | arg2.getLong
+      case NodeInfo.Int => arg1.getInt | arg2.getInt
+      case NodeInfo.Short => (arg1.getShort | arg2.getShort).toShort
+      case NodeInfo.Byte => (arg1.getByte | arg2.getByte).toByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.or(arg2.getBigInt)
+      case NodeInfo.UnsignedInt => arg1.getLong | arg2.getLong
+      case NodeInfo.UnsignedShort => arg1.getInt | arg2.getInt
+      case NodeInfo.UnsignedByte => (arg1.getShort | arg2.getShort).toShort
+      //$COVERAGE-OFF$
+      case _ => Assert.invariantFailed(s"dfdlx:bitOR not supported")
+      // $COVERAGE-ON$
+    }
+  }
+}
+
+case class DFDLXBitNot(recipes: CompiledDPath, argType: NodeInfo.Kind) extends FNOneArg(recipes,argType) {
+  override def computeValue(arg1: DataValuePrimitive, dstate: DState): DataValuePrimitive = {
+    argType match {
+      case NodeInfo.Long => ~arg1.getLong
+      case NodeInfo.Int => ~arg1.getInt
+      case NodeInfo.Short => ~arg1.getShort
+      case NodeInfo.Byte => ~arg1.getByte
+      case NodeInfo.UnsignedLong => arg1.getBigInt.not()

Review comment:
       Yeah, I hadn't totally understood how the ULong, UInt, etc. classes work. Apparently if you bitwise-not a UShort or a UByte, it returns a UInt. I guess this is similar to how shift's also return a UInt. Which all mimics Java and it's primitive types--in Java, if you bitwise-not a Short or Byte, you get an Int. I'm not sure why Java decided that made sense, but it means we have to do things differently.
   
   I think probably the cleanest way to do it is like this:
   ```scala
   case UnsignedShort => UShort((~arg1.getInt).toShort).toInt
   ```
   
   So we get the argument from the infoset, immediately invert it, which will get us an Int. We then cast that Int down to a Short since that's what the UShort constructor expects. We create a UShort with that and then we can get the int value, which will have all the correct bits masked off. So we're basically just using UShort to correctly mask of the bits when we convert it back to an int.
   
   Carrying this idea to the other types, I think we want something like this:
   
   ```scala
   case UnsignedLong => ULong((~arg1.getBigInt.longValue)).toBigInt
   case UnsignedInt => UInt((~arg1.getLong).toInt).toLong
   case UnsignedShort => UShort((~arg1.getInt).toShort).toInt
   case UnsignedByte => UByte((~arg1.getShort).toByte).toShort
   ```
   
   Just a side note, that if we ever update the infoset to represent these unsigned types as ULong/UInt/etc in the infoset (see [DAFFODIL-2511](https://issues.apache.org/jira/browse/DAFFODIL-2511)), then this would probably look something like this:
   
   ```scala
   case UnsignedLong => ~arg1.getULong
   case UnsignedInt => ~arg1.getUInt
   case UnsignedShort => (~arg1.getUShort).toUShort
   case UnsignedByte => (~arg1.getUByte).toUByte
   ```
   The UnsignedShort/Byte cases looks a bit weird due to bitwise-not returning a UInt, but its significantly cleaner.
   




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org