From 91fcafe282c5e9e1a45638247a480d1f215a504f Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Mon, 29 Jul 2013 16:11:16 +0200 Subject: Formatting fixes for AnyVal The files are not regenerated here, because additional fixes will follow in the next commit. --- src/compiler/scala/tools/cmd/gen/AnyVals.scala | 101 ++++++++++--------------- 1 file changed, 42 insertions(+), 59 deletions(-) diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 7e01afac2b..ce2019725f 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -6,24 +6,21 @@ package scala.tools.cmd package gen -/** Code generation of the AnyVal types and their companions. - */ +/** Code generation of the AnyVal types and their companions. */ trait AnyValReps { self: AnyVals => - sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { + sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) + extends AnyValRep(name,repr,javaEquiv) { case class Op(op : String, doc : String) private def companionCoercions(tos: AnyValRep*) = { tos.toList map (to => - """implicit def @javaequiv@2%s(x: @name@): %s = x.to%s""".format(to.javaEquiv, to.name, to.name) + s"implicit def @javaequiv@2${to.javaEquiv}(x: @name@): ${to.name} = x.to${to.name}" ) } - def coercionCommentExtra = "" - def coercionComment = """ -/** Language mandated coercions from @name@ to "wider" types.%s - */""".format(coercionCommentExtra) + def coercionComment = """/** Language mandated coercions from @name@ to "wider" types. */""" def implicitCoercions: List[String] = { val coercions = this match { @@ -41,12 +38,8 @@ trait AnyValReps { def isCardinal: Boolean = isIntegerType(this) def unaryOps = { val ops = List( - Op("+", "/**\n" + - " * Returns this value, unmodified.\n" + - " */"), - Op("-", "/**\n" + - " * Returns the negation of this value.\n" + - " */")) + Op("+", "/** Returns this value, unmodified. */"), + Op("-", "/** Returns the negation of this value. */")) if(isCardinal) Op("~", "/**\n" + @@ -95,7 +88,7 @@ trait AnyValReps { " */")) else Nil - def shiftOps = + def shiftOps = if (isCardinal) List( Op("<<", "/**\n" + @@ -127,20 +120,20 @@ trait AnyValReps { " */")) else Nil - def comparisonOps = List( - Op("==", "/**\n * Returns `true` if this value is equal to x, `false` otherwise.\n */"), - Op("!=", "/**\n * Returns `true` if this value is not equal to x, `false` otherwise.\n */"), - Op("<", "/**\n * Returns `true` if this value is less than x, `false` otherwise.\n */"), - Op("<=", "/**\n * Returns `true` if this value is less than or equal to x, `false` otherwise.\n */"), - Op(">", "/**\n * Returns `true` if this value is greater than x, `false` otherwise.\n */"), - Op(">=", "/**\n * Returns `true` if this value is greater than or equal to x, `false` otherwise.\n */")) + def comparisonOps = List( + Op("==", "/** Returns `true` if this value is equal to x, `false` otherwise. */"), + Op("!=", "/** Returns `true` if this value is not equal to x, `false` otherwise. */"), + Op("<", "/** Returns `true` if this value is less than x, `false` otherwise. */"), + Op("<=", "/** Returns `true` if this value is less than or equal to x, `false` otherwise. */"), + Op(">", "/** Returns `true` if this value is greater than x, `false` otherwise. */"), + Op(">=", "/** Returns `true` if this value is greater than or equal to x, `false` otherwise. */")) def otherOps = List( - Op("+", "/**\n * Returns the sum of this value and `x`.\n */"), - Op("-", "/**\n * Returns the difference of this value and `x`.\n */"), - Op("*", "/**\n * Returns the product of this value and `x`.\n */"), - Op("/", "/**\n * Returns the quotient of this value and `x`.\n */"), - Op("%", "/**\n * Returns the remainder of the division of this value by `x`.\n */")) + Op("+", "/** Returns the sum of this value and `x`. */"), + Op("-", "/** Returns the difference of this value and `x`. */"), + Op("*", "/** Returns the product of this value and `x`. */"), + Op("/", "/** Returns the quotient of this value and `x`. */"), + Op("%", "/** Returns the remainder of the division of this value by `x`. */")) // Given two numeric value types S and T , the operation type of S and T is defined as follows: // If both S and T are subrange types then the operation type of S and T is Int. @@ -278,8 +271,7 @@ trait AnyValReps { } trait AnyValTemplates { - def headerTemplate = (""" -/* __ *\ + def headerTemplate = """/* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** @@ -287,12 +279,15 @@ trait AnyValTemplates { ** |/ ** \* */ -%s +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. + package scala import scala.language.implicitConversions -""".trim.format(timestampString) + "\n\n") +""" def classDocTemplate = (""" /** `@name@`@representation@ (equivalent to Java's `@javaequiv@` primitive type) is a @@ -304,8 +299,6 @@ import scala.language.implicitConversions */ """.trim + "\n") - def timestampString = "// DO NOT EDIT, CHANGES WILL BE LOST.\n" - def allCompanions = """ /** Transform a value type into a boxed reference type. *@boxRunTimeDoc@ @@ -324,20 +317,17 @@ def box(x: @name@): @boxed@ = @boxImpl@ */ def unbox(x: java.lang.Object): @name@ = @unboxImpl@ -/** The String representation of the scala.@name@ companion object. - */ +/** The String representation of the scala.@name@ companion object. */ override def toString = "object scala.@name@" """ def nonUnitCompanions = "" // todo def cardinalCompanion = """ -/** The smallest value representable as a @name@. - */ +/** The smallest value representable as a @name@. */ final val MinValue = @boxed@.MIN_VALUE -/** The largest value representable as a @name@. - */ +/** The largest value representable as a @name@. */ final val MaxValue = @boxed@.MAX_VALUE """ @@ -372,18 +362,16 @@ class AnyVals extends AnyValReps with AnyValTemplates { object D extends AnyValNum("Double", Some("64-bit IEEE-754 floating point number"), "double") object Z extends AnyValRep("Boolean", None, "boolean") { def classLines = """ -/** - * Negates a Boolean expression. - * - * - `!a` results in `false` if and only if `a` evaluates to `true` and - * - `!a` results in `true` if and only if `a` evaluates to `false`. - * - * @return the negated expression - */ +/** Negates a Boolean expression. + * + * - `!a` results in `false` if and only if `a` evaluates to `true` and + * - `!a` results in `true` if and only if `a` evaluates to `false`. + * + * @return the negated expression + */ def unary_! : Boolean -/** - * Compares two Boolean expressions and returns `true` if they evaluate to the same value. +/** Compares two Boolean expressions and returns `true` if they evaluate to the same value. * * `a == b` returns `true` if and only if * - `a` and `b` are `true` or @@ -400,8 +388,7 @@ def ==(x: Boolean): Boolean */ def !=(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. * * `a || b` returns `true` if and only if * - `a` is `true` or @@ -414,8 +401,7 @@ def !=(x: Boolean): Boolean */ def ||(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if both of them evaluate to true. * * `a && b` returns `true` if and only if * - `a` and `b` are `true`. @@ -430,8 +416,7 @@ def &&(x: Boolean): Boolean // def ||(x: => Boolean): Boolean // def &&(x: => Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. * * `a | b` returns `true` if and only if * - `a` is `true` or @@ -442,8 +427,7 @@ def &&(x: Boolean): Boolean */ def |(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if both of them evaluate to true. * * `a & b` returns `true` if and only if * - `a` and `b` are `true`. @@ -452,8 +436,7 @@ def |(x: Boolean): Boolean */ def &(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if they evaluate to a different value. +/** Compares two Boolean expressions and returns `true` if they evaluate to a different value. * * `a ^ b` returns `true` if and only if * - `a` is `true` and `b` is `false` or -- cgit v1.2.3