diff options
-rw-r--r-- | build.sbt | 13 | ||||
-rw-r--r-- | project/GenerateAnyVals.scala (renamed from src/compiler/scala/tools/cmd/gen/AnyVals.scala) | 31 | ||||
-rw-r--r-- | src/compiler/scala/tools/cmd/gen/Codegen.scala | 39 | ||||
-rw-r--r-- | src/compiler/scala/tools/cmd/gen/CodegenSpec.scala | 25 | ||||
-rw-r--r-- | src/library/scala/Boolean.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Byte.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Char.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Double.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Float.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Int.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Long.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Short.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Unit.scala | 4 | ||||
-rwxr-xr-x | tools/codegen | 8 | ||||
-rwxr-xr-x | tools/codegen-anyvals | 5 |
15 files changed, 43 insertions, 114 deletions
@@ -649,11 +649,14 @@ lazy val root = (project in file(".")) publish := {}, publishLocal := {}, commands ++= ScriptCommands.all, - // Generate (Product|TupleN|Function|AbstractFunction)*.scala files. Once the ANT build is gone, - // we should move them into a managedSources dir instead of overwriting sources checked into git. - commands += Command.command("genprod") { state => - val dir = (((baseDirectory in ThisBuild).value) / "src" / "library" / "scala").getPath - genprod.main(Array(dir)) + // Generate (Product|TupleN|Function|AbstractFunction)*.scala files and scaladoc stubs for all AnyVal sources. + // They should really go into a managedSources dir instead of overwriting sources checked into git but scaladoc + // source links (could be fixed by shipping these sources with the scaladoc bundles) and scala-js source maps + // rely on them being on github. + commands += Command.command("generateSources") { state => + val dir = (((baseDirectory in ThisBuild).value) / "src" / "library" / "scala") + genprod.main(Array(dir.getPath)) + GenerateAnyVals.run(dir.getAbsoluteFile) state } ) diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/project/GenerateAnyVals.scala index 0588d2dc77..921982aeec 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/project/GenerateAnyVals.scala @@ -1,14 +1,6 @@ -/* NSC -- new Scala compiler - * Copyright 2007-2013 LAMP/EPFL - * @author Paul Phillips - */ - -package scala.tools.cmd -package gen - /** Code generation of the AnyVal types and their companions. */ -trait AnyValReps { - self: AnyVals => +trait GenerateAnyValReps { + self: GenerateAnyVals => sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { @@ -271,7 +263,7 @@ import scala.language.implicitConversions""" } } -trait AnyValTemplates { +trait GenerateAnyValTemplates { def headerTemplate = """/* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** @@ -281,8 +273,8 @@ trait AnyValTemplates { \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala @@ -351,7 +343,7 @@ final val MaxValue = @boxed@.MAX_VALUE """ } -class AnyVals extends AnyValReps with AnyValTemplates { +class GenerateAnyVals extends GenerateAnyValReps with GenerateAnyValTemplates { object B extends AnyValNum("Byte", Some("8-bit signed integer"), "byte") object S extends AnyValNum("Short", Some("16-bit signed integer"), "short") object C extends AnyValNum("Char", Some("16-bit unsigned integer"), "char") @@ -481,3 +473,14 @@ override def getClass(): Class[Boolean] = ??? def make() = values map (x => (x.name, x.make())) } + +object GenerateAnyVals { + def run(outDir: java.io.File) { + val av = new GenerateAnyVals + + av.make() foreach { case (name, code ) => + val file = new java.io.File(outDir, name + ".scala") + sbt.IO.write(file, code, java.nio.charset.Charset.forName("UTF-8"), false) + } + } +} diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala deleted file mode 100644 index c3aa527ef2..0000000000 --- a/src/compiler/scala/tools/cmd/gen/Codegen.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* NEST (New Scala Test) - * Copyright 2007-2013 LAMP/EPFL - * @author Paul Phillips - */ - -package scala.tools.cmd -package gen - -class Codegen(args: List[String]) extends { - val parsed = CodegenSpec(args: _*) -} with CodegenSpec with Instance - -object Codegen { - def echo(msg: String) = Console println msg - - def main(args0: Array[String]): Unit = { - val runner = new Codegen(args0.toList) - import runner._ - - if (args0.isEmpty) - return println (CodegenSpec.helpMsg) - - val out = outDir getOrElse { return println("--out is required.") } - val all = genall || !anyvals - - echo("Generating sources into " + out) - - if (anyvals || all) { - val av = new AnyVals { } - - av.make() foreach { case (name, code ) => - val file = (out / (name + ".scala")).toFile - echo("Writing: " + file) - file writeAll code - } - } - } -} - diff --git a/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala b/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala deleted file mode 100644 index 4b4a1e482d..0000000000 --- a/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* NEST (New Scala Test) - * Copyright 2007-2013 LAMP/EPFL - * @author Paul Phillips - */ - -package scala.tools.cmd -package gen - -import FromString.ExistingDir - -trait CodegenSpec extends Spec with Meta.StdOpts with Interpolation { - def referenceSpec = CodegenSpec - def programInfo = Spec.Info("codegen", "", "scala.tools.cmd.gen.Codegen") - - help("Usage: codegen [<options>]") - - val outDir = "out" / "directory for generated files" --^ ExistingDir - val anyvals = "anyvals" / "generate sources for AnyVal types" --? - val genall = "all" / "generate sources for everything" --? -} - -object CodegenSpec extends CodegenSpec with Reference { - type ThisCommandLine = CommandLine - def creator(args: List[String]): ThisCommandLine = new CommandLine(CodegenSpec, args) -} diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index 60fb594ecc..017f10a283 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index c0b376ee70..3709586f2e 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index 0abf68f117..7dbb0209c3 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index 9b2cca2cbc..08bcb9fefc 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala index 8933ff1257..01fdbc00e4 100644 --- a/src/library/scala/Float.scala +++ b/src/library/scala/Float.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index 77c026f0cc..b605af5e37 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index 1d219ecf1e..84e6f09da3 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index 8bfe6f935f..136d745f16 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 873281bb8f..397d7b823b 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -7,8 +7,8 @@ \* */ // 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. +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. package scala diff --git a/tools/codegen b/tools/codegen deleted file mode 100755 index 35c93fba16..0000000000 --- a/tools/codegen +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# - -THISDIR=`dirname $0` -SCALALIB=$THISDIR/../src/library/scala -BINDIR=$THISDIR/../build/quick/bin - -$BINDIR/scala scala.tools.cmd.gen.Codegen "$@" diff --git a/tools/codegen-anyvals b/tools/codegen-anyvals deleted file mode 100755 index 27d1c40134..0000000000 --- a/tools/codegen-anyvals +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# - -THISDIR=`dirname $0` -$THISDIR/codegen --anyvals --out $THISDIR/../src/library/scala |