Skip to content

Trying to upstream changes from the Apache Daffodil project#4

Open
mbeckerle wants to merge 3 commits into
nystrom:masterfrom
mbeckerle:daf-changes
Open

Trying to upstream changes from the Apache Daffodil project#4
mbeckerle wants to merge 3 commits into
nystrom:masterfrom
mbeckerle:daf-changes

Conversation

@mbeckerle

Copy link
Copy Markdown

Daffodil uses this library. We've made some fixes/improvements and would like to get them back into the original master.

@mbeckerle mbeckerle left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments, markers for a few fixups to put tests back, and reduce the number of whitespace-only changes.

override def byteValue = intRep.toByte
override def shortValue = intRep.toShort

trait SmallUInt[U <: Unsigned[U, UInt, Int]] extends Any with Unsigned[U, UInt, Int] with Serializable {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the exception of the with Serializable change, all the change here could be reverted by just putting back the def intRep.

The only other changes are removal of some commented out code lines, and whitespace changes.

The only necessary change was the "with Serializable"

class UInt(val intValue: Int) extends AnyVal with SmallUInt[UInt] with Serializable {
override def toUInt = this
private def intRep = intValue
// private def intRep = intValue

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put back.

Promoted <: Unsigned[_, Promoted, SignedPromoted],
SignedPromoted]
extends Any with ScalaNumericAnyConversions {
trait Unsigned[U <: Unsigned[U, Promoted, SignedPromoted], Promoted <: Unsigned[_, Promoted, SignedPromoted], SignedPromoted]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long. Could put back to the original indentation.


import scala.math.ScalaNumericAnyConversions

@serializable

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change to this file is the "with Serializable". The rest is just whitespace standardization.

@@ -1,9 +1,34 @@
/*

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change to this file was adding the banner, Removing commented code (which has been superceded), and whitespace changes.

import org.scalacheck.Prop._
import passera.unsigned._

object UnsignedCheck extends Properties("Unsigned") {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put back scalacheck and this properties test-rig. We don't use those in Daffodil, but no reason not to here.

property(">> and >>> equivalent") =
forAll { (a: Int, b: Int) => a.toUInt >> (b & 0x1f) == a.toUInt >>> (b & 0x1f) }

@Test def testLongToString = {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests should all perhaps go into a separate test class.

@@ -0,0 +1,65 @@
<!--
Copyright (c) 2011-2013, Nate Nystrom

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright banners were added to all files that didn't have them. This makes it easier to reuse the source. It meets our source-code labeling requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant