diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-16 07:49:16 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-16 07:49:16 +0000 |
commit | eb0b73b1160c7e62e2ae0e338a9664b8b53ddbde (patch) | |
tree | d1836661a909a33fc805d302183741868582876f /src/library | |
parent | f80801c67545a28f61abd1a36a5ef8b5bc337d87 (diff) | |
download | scala-eb0b73b1160c7e62e2ae0e338a9664b8b53ddbde.tar.gz scala-eb0b73b1160c7e62e2ae0e338a9664b8b53ddbde.tar.bz2 scala-eb0b73b1160c7e62e2ae0e338a9664b8b53ddbde.zip |
Undoing some much too hacky code to implement a...
Undoing some much too hacky code to implement a -jar option and then
following wherever that led me. Tangible results include:
* much beautified scala -help, including documenting some things
never before documented in this plane of existence
* an improved Jar abstraction
* further systemization of system properties
In addition, the jars created by -savecompiled are given the right
manifest so the jar is runnable. That means you can:
scala -savecompiled bippy.scala arg1 arg2
scala -jar bippy.scala.jar arg1 arg2
And both lines should yield the same result. No review.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/sys/BooleanProp.scala | 34 | ||||
-rw-r--r-- | src/library/scala/sys/Prop.scala | 21 | ||||
-rw-r--r-- | src/library/scala/sys/SystemProperties.scala | 6 | ||||
-rw-r--r-- | src/library/scala/util/control/NoStackTrace.scala | 11 |
4 files changed, 41 insertions, 31 deletions
diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala new file mode 100644 index 0000000000..0f04d1f45e --- /dev/null +++ b/src/library/scala/sys/BooleanProp.scala @@ -0,0 +1,34 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.sys + +/** A few additional conveniences for Boolean properties. + */ +trait BooleanProp extends Prop[Boolean] { + /** The default implementation of `value` adheres to java's definition + * of truth, which means it is true only if there is a value in the map and + * that value, once converted to all lower case, is equal to "true". + * + * @return true if the current String is considered true, false otherwise + */ + def value: Boolean + + /** Alter this property so that `value` will be true. */ + def enable(): Unit + + /** Alter this property so that `value` will be false. */ + def disable(): Unit + + /** Toggle the property between enabled and disabled states. */ + def toggle(): Unit +} + +object BooleanProp { + implicit def booleanPropAsBoolean(b: BooleanProp): Boolean = b.value +} diff --git a/src/library/scala/sys/Prop.scala b/src/library/scala/sys/Prop.scala index 8444976826..1ac63ebc71 100644 --- a/src/library/scala/sys/Prop.scala +++ b/src/library/scala/sys/Prop.scala @@ -60,27 +60,6 @@ trait Prop[T] { protected def zero: T } -/** A few additional conveniences for Boolean properties. - */ -trait BooleanProp extends Prop[Boolean] { - /** The default implementation of `value` adheres to java's definition - * of truth, which means it is true only if there is a value in the map and - * that value, once converted to all lower case, is equal to "true". - * - * @return true if the current String is considered true, false otherwise - */ - def value: Boolean - - /** Alter this property so that `value` will be true. */ - def enable(): Unit - - /** Alter this property so that `value` will be false. */ - def disable(): Unit - - /** Toggle the property between enabled and disabled states. */ - def toggle(): Unit -} - object Prop extends PropCompanion { /** A creator of property instances. For any type `T`, if an implicit * parameter of type Creator[T] is in scope, a Prop[T] can be created diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala index cc8131220f..de3f9598f0 100644 --- a/src/library/scala/sys/SystemProperties.scala +++ b/src/library/scala/sys/SystemProperties.scala @@ -48,6 +48,8 @@ object SystemProperties { // Todo: bring some sanity to the intersection of system properties aka "mutable // state shared by everyone and everything" and the reality that there is no other // mechanism for accomplishing some things on the jvm. - lazy val headless = bool("java.awt.headless", "system should not utilize a display device") - lazy val preferIPv4 = bool("java.net.preferIPv4Stack", "system should prefer IPv4 sockets") + lazy val headless = bool("java.awt.headless", "system should not utilize a display device") + lazy val preferIPv4 = bool("java.net.preferIPv4Stack", "system should prefer IPv4 sockets") + lazy val noTraceSupression = bool("scala.control.no-trace-suppression", "scala should not suppress any stack trace creation") } + diff --git a/src/library/scala/util/control/NoStackTrace.scala b/src/library/scala/util/control/NoStackTrace.scala index d8cd36aa02..f33e8cd013 100644 --- a/src/library/scala/util/control/NoStackTrace.scala +++ b/src/library/scala/util/control/NoStackTrace.scala @@ -10,19 +10,14 @@ package scala.util.control /** A trait for exceptions which, for efficiency reasons, do not * fill in the stack trace. Stack trace suppression can be disabled - * on a global basis by setting the system property named at - * NoStackTrace.DisableProperty. + * on a global basis via a system property wrapper in + * [[ scala.sys.SystemProperties ]]. * * @author Paul Phillips * @since 2.8 */ trait NoStackTrace extends Throwable { override def fillInStackTrace(): Throwable = - if (sys.props contains NoStackTrace.DisableProperty) super.fillInStackTrace() + if (sys.SystemProperties.noTraceSupression) super.fillInStackTrace() else this } - -object NoStackTrace { - // TODO: systematic naming scheme. - final val DisableProperty = "scala.control.no-trace-suppression" -} |