diff options
author | Haoyi Li <haoyi@haoyi-mbp.corp.dropbox.com> | 2014-11-26 00:45:31 -0800 |
---|---|---|
committer | Haoyi Li <haoyi@haoyi-mbp.corp.dropbox.com> | 2014-11-26 00:45:31 -0800 |
commit | 24f31e120f9537faede7a174bb09ee35f64e1ce4 (patch) | |
tree | 06ffc3ecc7847789008352b7e2b7c040dad48907 /examples/scala-js/library/src/main/scala/scala/scalajs/runtime/BooleanReflectiveCall.scala | |
parent | b89ce9cbf79363f8cab09186a5d7ba94bc0af02a (diff) | |
parent | 2c4b142503bd2d871e6818b5cab8c38627d9e4a0 (diff) | |
download | hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.tar.gz hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.tar.bz2 hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.zip |
Merge commit '2c4b142503bd2d871e6818b5cab8c38627d9e4a0' as 'examples/scala-js'
Diffstat (limited to 'examples/scala-js/library/src/main/scala/scala/scalajs/runtime/BooleanReflectiveCall.scala')
-rw-r--r-- | examples/scala-js/library/src/main/scala/scala/scalajs/runtime/BooleanReflectiveCall.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/scala-js/library/src/main/scala/scala/scalajs/runtime/BooleanReflectiveCall.scala b/examples/scala-js/library/src/main/scala/scala/scalajs/runtime/BooleanReflectiveCall.scala new file mode 100644 index 0000000..0cd562a --- /dev/null +++ b/examples/scala-js/library/src/main/scala/scala/scalajs/runtime/BooleanReflectiveCall.scala @@ -0,0 +1,31 @@ +package scala.scalajs.runtime + +import java.lang.{Boolean => JBoolean} + +/** Explicit box for boolean values when doing a reflective call. + * This class and its methods are only here to properly support reflective + * calls on booleans. + */ +class BooleanReflectiveCall(value: Boolean) { + + // Methods of java.lang.Boolean + + def booleanValue(): Boolean = value + + def compareTo(that: JBoolean): Int = + new JBoolean(value).compareTo(that) + def compareTo(that: AnyRef): Int = + new JBoolean(value).compareTo(that.asInstanceOf[JBoolean]) + + // Methods of scala.Boolean + + def unary_! : Boolean = !value + def ==(x: Boolean): Boolean = value == x + def !=(x: Boolean): Boolean = value != x + def ||(x: Boolean): Boolean = value || x + def &&(x: Boolean): Boolean = value && x + def |(x: Boolean): Boolean = value | x + def &(x: Boolean): Boolean = value & x + def ^(x: Boolean): Boolean = value ^ x + +} |