From 9715d09e8069e5a7ea62ef06d9cefe342b5f1c8b Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 20 Mar 2007 17:59:27 +0000 Subject: added Array.deepEquals, improved external links... added Array.deepEquals, improved external links to sources in API doc --- .../scala/tools/nsc/doc/DocGenerator.scala | 13 +- src/compiler/scala/tools/nsc/doc/script.js | 174 ++++++++++++++++++++- src/compiler/scala/tools/nsc/doc/source.png | Bin 431 -> 0 bytes src/library/scala/Array.scala | 20 +++ src/library/scala/runtime/BoxedArray.scala | 42 ++++- 5 files changed, 235 insertions(+), 14 deletions(-) delete mode 100644 src/compiler/scala/tools/nsc/doc/source.png (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index 2140f9ee76..41e83f8383 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -689,16 +689,19 @@ abstract class DocGenerator extends Models { private def header0: NodeSeq = { val sym = clazz.tree.symbol - val name = sym.fullNameString.replace("$object", "") + val dir = + if (sym.toplevelClass.isPackageClass) sym.toplevelClass + else sym.toplevelClass.owner + val name = dir.fullNameString('/') + "/" + sym.sourceFile.name.replace(".scala", "")
in {aref(urlFor(sym.owner), "_self", sym.owner.fullNameString('.'))}
{Text(codeFor(kind))} {Text(sym.nameString)} - - source - +
+
+ [source: {name + ".scala"}]

; @@ -1172,7 +1175,7 @@ abstract class DocGenerator extends Models { def descr = boxedValDescr(sym) } val rsrcdir = "scala/tools/nsc/doc/".replace('/', File.separatorChar) - for (val base <- List("style.css", "script.js", "source.png")) { + for (val base <- List("style.css", "script.js")) { try { val in = loader.getResourceAsStream(rsrcdir + base) val out = new FileOutputStream(new File(outdir + File.separator + base)) diff --git a/src/compiler/scala/tools/nsc/doc/script.js b/src/compiler/scala/tools/nsc/doc/script.js index 95db6afb98..e2c8f39cd4 100644 --- a/src/compiler/scala/tools/nsc/doc/script.js +++ b/src/compiler/scala/tools/nsc/doc/script.js @@ -361,6 +361,7 @@ function init() { src['scala/Responder'] = lib_svn_root; src['scala/Seq'] = lib_svn_root; src['scala/SeqProxy'] = lib_svn_root; + src['scala/SerialVersionUID'] = lib_svn_root; src['scala/Some'] = lib_svn_root; src['scala/StaticAnnotation'] = lib_svn_root; src['scala/Stream'] = lib_svn_root; @@ -391,8 +392,32 @@ function init() { src['scala/collection/SortedMap'] = lib_svn_root; src['scala/collection/SortedSet'] = lib_svn_root; src['scala/collection/immutable/BitSet'] = lib_svn_root; + src['scala/collection/immutable/EmptyMap'] = lib_svn_root; + src['scala/collection/immutable/EmptySet'] = lib_svn_root; src['scala/collection/immutable/HashMap'] = lib_svn_root; src['scala/collection/immutable/HashSet'] = lib_svn_root; + src['scala/collection/immutable/ImmutableIterator'] = lib_svn_root; + src['scala/collection/immutable/ListMap'] = lib_svn_root; + src['scala/collection/immutable/ListSet'] = lib_svn_root; + src['scala/collection/immutable/Map'] = lib_svn_root; + src['scala/collection/immutable/Map1'] = lib_svn_root; + src['scala/collection/immutable/Map2'] = lib_svn_root; + src['scala/collection/immutable/Map3'] = lib_svn_root; + src['scala/collection/immutable/Map4'] = lib_svn_root; + src['scala/collection/immutable/Queue'] = lib_svn_root; + src['scala/collection/immutable/RedBlack'] = lib_svn_root; + src['scala/collection/immutable/Set'] = lib_svn_root; + src['scala/collection/immutable/Set1'] = lib_svn_root; + src['scala/collection/immutable/Set2'] = lib_svn_root; + src['scala/collection/immutable/Set3'] = lib_svn_root; + src['scala/collection/immutable/Set4'] = lib_svn_root; + src['scala/collection/immutable/SortedMap'] = lib_svn_root; + src['scala/collection/immutable/SortedSet'] = lib_svn_root; + src['scala/collection/immutable/Stack'] = lib_svn_root; + src['scala/collection/immutable/Tree'] = lib_svn_root; + src['scala/collection/immutable/TreeMap'] = lib_svn_root; + src['scala/collection/immutable/TreeSet'] = lib_svn_root; + src['scala/collection/immutable/UnbalancedTreeMap'] = lib_svn_root; src['scala/collection/jcl/ArrayList'] = lib_svn_root; src['scala/collection/jcl/Buffer'] = lib_svn_root; src['scala/collection/jcl/BufferIterator'] = lib_svn_root; @@ -403,6 +428,26 @@ function init() { src['scala/collection/jcl/HashSet'] = lib_svn_root; src['scala/collection/jcl/IdentityHashMap'] = lib_svn_root; src['scala/collection/jcl/IterableWrapper'] = lib_svn_root; + src['scala/collection/jcl/LinkedHashMap'] = lib_svn_root; + src['scala/collection/jcl/LinkedHashSet'] = lib_svn_root; + src['scala/collection/jcl/LinkedList'] = lib_svn_root; + src['scala/collection/jcl/Map'] = lib_svn_root; + src['scala/collection/jcl/MapWrapper'] = lib_svn_root; + src['scala/collection/jcl/MutableIterable'] = lib_svn_root; + src['scala/collection/jcl/MutableIterator'] = lib_svn_root; + src['scala/collection/jcl/MutableSeq'] = lib_svn_root; + src['scala/collection/jcl/Ranged'] = lib_svn_root; + src['scala/collection/jcl/SeqIterator'] = lib_svn_root; + src['scala/collection/jcl/Set'] = lib_svn_root; + src['scala/collection/jcl/SetWrapper'] = lib_svn_root; + src['scala/collection/jcl/Sorted'] = lib_svn_root; + src['scala/collection/jcl/SortedMap'] = lib_svn_root; + src['scala/collection/jcl/SortedMapWrapper'] = lib_svn_root; + src['scala/collection/jcl/SortedSet'] = lib_svn_root; + src['scala/collection/jcl/SortedSetWrapper'] = lib_svn_root; + src['scala/collection/jcl/TreeMap'] = lib_svn_root; + src['scala/collection/jcl/TreeSet'] = lib_svn_root; + src['scala/collection/jcl/WeakHashMap'] = lib_svn_root; src['scala/collection/mutable/ArrayBuffer'] = lib_svn_root; src['scala/collection/mutable/BitSet'] = lib_svn_root; src['scala/collection/mutable/Buffer'] = lib_svn_root; @@ -410,6 +455,7 @@ function init() { src['scala/collection/mutable/DefaultEntry'] = lib_svn_root; src['scala/collection/mutable/HashMap'] = lib_svn_root; src['scala/collection/mutable/HashSet'] = lib_svn_root; + src['scala/collection/mutable/JavaMapAdaptor'] = lib_svn_root; src['scala/collection/mutable/Location'] = lib_svn_root; src['scala/collection/mutable/Map'] = lib_svn_root; src['scala/collection/mutable/MapProxy'] = lib_svn_root; @@ -438,7 +484,22 @@ function init() { src['scala/collection/mutable/SynchronizedSet'] = lib_svn_root; src['scala/collection/mutable/SynchronizedStack'] = lib_svn_root; src['scala/collection/mutable/Undoable'] = lib_svn_root; + src['scala/compat/StringBuilder'] = lib_svn_root; + src['scala/compat/Math'] = lib_svn_root; + src['scala/compat/Platform'] = lib_svn_root; src['scala/concurrent/Actor'] = lib_svn_root; + src['scala/concurrent/Channel'] = lib_svn_root; + src['scala/concurrent/Lock'] = lib_svn_root; + src['scala/concurrent/MailBox'] = lib_svn_root; + src['scala/concurrent/NameServer'] = lib_svn_root; + src['scala/concurrent/Pid'] = lib_svn_root; + src['scala/concurrent/Process'] = lib_svn_root; + src['scala/concurrent/SyncChannel'] = lib_svn_root; + src['scala/concurrent/SyncVar'] = lib_svn_root; + src['scala/concurrent/TIMEOUT'] = lib_svn_root; // object + src['scala/concurrent/jolib'] = lib_svn_root; // object + src['scala/concurrent/ops'] = lib_svn_root; // object + src['scala/concurrent/pilib'] = lib_svn_root; // object src['scala/io/BytePickle'] = lib_svn_root; src['scala/io/Position'] = lib_svn_root; @@ -453,11 +514,54 @@ function init() { src['scala/reflect/Type'] = lib_svn_root; src['scala/reflect/TypedCode'] = lib_svn_root; + src['scala/runtime/BoxedAnyArray'] = lib_svn_root; + src['scala/runtime/BoxedArray'] = lib_svn_root; + src['scala/runtime/BoxedBooleanArray'] = lib_svn_root; + src['scala/runtime/BoxedByteArray'] = lib_svn_root; + src['scala/runtime/BoxedCharArray'] = lib_svn_root; + src['scala/runtime/BoxedDoubleArray'] = lib_svn_root; + src['scala/runtime/BoxedFloatArray'] = lib_svn_root; + src['scala/runtime/BoxedIntArray'] = lib_svn_root; + src['scala/runtime/BoxedLongArray'] = lib_svn_root; + src['scala/runtime/BoxedObjectArray'] = lib_svn_root; + src['scala/runtime/BoxedShortArray'] = lib_svn_root; + src['scala/runtime/NonLocalReturnException'] = lib_svn_root; + src['scala/runtime/Nothing$'] = lib_svn_root; + src['scala/runtime/Null$'] = lib_svn_root; + src['scala/runtime/RichBoolean'] = lib_svn_root; + src['scala/runtime/RichByte'] = lib_svn_root; + src['scala/runtime/RichChar'] = lib_svn_root; + src['scala/runtime/RichDouble'] = lib_svn_root; + src['scala/runtime/RichException'] = lib_svn_root; + src['scala/runtime/RichFloat'] = lib_svn_root; + src['scala/runtime/RichInt'] = lib_svn_root; + src['scala/runtime/RichLong'] = lib_svn_root; + src['scala/runtime/RichShort'] = lib_svn_root; + src['scala/runtime/RichString'] = lib_svn_root; + src['scala/runtime/ScalaRunTime'] = lib_svn_root; + src['scala/runtime/StringAdd'] = lib_svn_root; + + src['scala/testing/Benchmark'] = lib_svn_root; + src['scala/testing/SUnit'] = lib_svn_root; + src['scala/testing/UnitTest'] = lib_svn_root; // object + src['scala/text/Document'] = lib_svn_root; src['scala/util/Fluid'] = lib_svn_root; - src['scala/util/RichSorting'] = lib_svn_root; src['scala/util/Sorting'] = lib_svn_root; + src['scala/util/automata/BaseBerrySethi'] = lib_svn_root; + src['scala/util/automata/DetWordAutom'] = lib_svn_root; + src['scala/util/automata/Inclusion'] = lib_svn_root; + src['scala/util/automata/NondetWordAutomata'] = lib_svn_root; + src['scala/util/automata/SubsetConstruction'] = lib_svn_root; + src['scala/util/automata/WordBerrySethi'] = lib_svn_root; + src['scala/util/grammar/HedgeRHS'] = lib_svn_root; + src['scala/util/grammar/TreeRHS'] = lib_svn_root; + src['scala/util/logging/ConsoleLogger'] = lib_svn_root; + src['scala/util/logging/Logged'] = lib_svn_root; + src['scala/util/parsing/CharInputStreamIterator'] = lib_svn_root; + src['scala/util/parsing/Parsers'] = lib_svn_root; + src['scala/util/parsing/SimpleTokenizer'] = lib_svn_root; src['scala/util/regexp/Base'] = lib_svn_root; src['scala/util/regexp/PointedHedgeExp'] = lib_svn_root; src['scala/util/regexp/SyntaxError'] = lib_svn_root; @@ -470,18 +574,54 @@ function init() { src['scala/xml/Entityef'] = lib_svn_root; src['scala/xml/Group'] = lib_svn_root; src['scala/xml/HasKeyValue'] = lib_svn_root; + src['scala/xml/MalformedAttributeException'] = lib_svn_root; + src['scala/xml/MetaData'] = lib_svn_root; + src['scala/xml/NamespaceBinding'] = lib_svn_root; src['scala/xml/Node'] = lib_svn_root; src['scala/xml/NodeBuffer'] = lib_svn_root; src['scala/xml/NodeSeq'] = lib_svn_root; src['scala/xml/NodeTraverser'] = lib_svn_root; - src['scala/xml/Null'] = lib_svn_root; + src['scala/xml/Null'] = lib_svn_root; // object src['scala/xml/PrettyPrinter'] = lib_svn_root; src['scala/xml/SpecialNode'] = lib_svn_root; src['scala/xml/Text'] = lib_svn_root; src['scala/xml/TextBuffer'] = lib_svn_root; + src['scala/xml/TopScope'] = lib_svn_root; // object src['scala/xml/TypeSymbol'] = lib_svn_root; src['scala/xml/Unparsed'] = lib_svn_root; src['scala/xml/UnprefixedAttribute'] = lib_svn_root; + src['scala/xml/Utility'] = lib_svn_root; + src['scala/xml/XML'] = lib_svn_root; + src['scala/xml/dtd/ContentModel'] = lib_svn_root; + src['scala/xml/dtd/ContentModelParser'] = lib_svn_root; + src['scala/xml/dtd/DTD'] = lib_svn_root; + src['scala/xml/dtd/Decl'] = lib_svn_root; + src['scala/xml/dtd/DocType'] = lib_svn_root; + src['scala/xml/dtd/DtdTypeSymbol'] = lib_svn_root; + src['scala/xml/dtd/ElementValidator'] = lib_svn_root; + src['scala/xml/dtd/ExternalID'] = lib_svn_root; + src['scala/xml/dtd/Scanner'] = lib_svn_root; + src['scala/xml/dtd/Tokens'] = lib_svn_root; + src['scala/xml/factory/Binder'] = lib_svn_root; + src['scala/xml/factory/LoggedNodeFactory'] = lib_svn_root; + src['scala/xml/factory/NodeFactory'] = lib_svn_root; + src['scala/xml/parsing/ConstructingHandler'] = lib_svn_root; + src['scala/xml/parsing/ConstructingParser'] = lib_svn_root; + src['scala/xml/parsing/DefaultMarkupHandler'] = lib_svn_root; + src['scala/xml/parsing/ExternalSources'] = lib_svn_root; + src['scala/xml/parsing/FactoryAdapter'] = lib_svn_root; + src['scala/xml/parsing/FatalError'] = lib_svn_root; + src['scala/xml/parsing/MarkupHandler'] = lib_svn_root; + src['scala/xml/parsing/MarkupParser'] = lib_svn_root; + src['scala/xml/parsing/NoBindingFactoryAdapter'] = lib_svn_root; + src['scala/xml/parsing/TokenTests'] = lib_svn_root; + src['scala/xml/parsing/ValidatingMarkupHandler'] = lib_svn_root; + src['scala/xml/path/Expression'] = lib_svn_root; + src['scala/xml/pull/XMLEvent'] = lib_svn_root; + src['scala/xml/pull/XMLEventReader'] = lib_svn_root; + src['scala/xml/transform/BasicTransformer'] = lib_svn_root; + src['scala/xml/transform/RewriteRule'] = lib_svn_root; + src['scala/xml/transform/RuleTransformer'] = lib_svn_root; // scala-actors-src.jar src['scala/actors/Actor'] = actors_svn_root; @@ -555,8 +695,38 @@ function init() { src['scala/dbc/statement/Table'] = dbc_svn_root; src['scala/dbc/statement/Transaction'] = dbc_svn_root; src['scala/dbc/statement/Update'] = dbc_svn_root; + src['scala/dbc/statement/expression/Aggregate'] = dbc_svn_root; + src['scala/dbc/statement/expression/BinaryOperator'] = dbc_svn_root; + src['scala/dbc/statement/expression/Constant'] = dbc_svn_root; + src['scala/dbc/statement/expression/Default'] = dbc_svn_root; + src['scala/dbc/statement/expression/Field'] = dbc_svn_root; + src['scala/dbc/statement/expression/FunctionCall'] = dbc_svn_root; + src['scala/dbc/statement/expression/Select'] = dbc_svn_root; + src['scala/dbc/statement/expression/SetFunction'] = dbc_svn_root; + src['scala/dbc/statement/expression/TypeCast'] = dbc_svn_root; + src['scala/dbc/statement/expression/UnaryOperator'] = dbc_svn_root; + src['scala/dbc/syntax/DataTypeUtil'] = dbc_svn_root; + src['scala/dbc/syntax/Database'] = dbc_svn_root; + src['scala/dbc/syntax/Statement'] = dbc_svn_root; + src['scala/dbc/syntax/StatementExpression'] = dbc_svn_root; + src['scala/dbc/value/ApproximateNumeric'] = dbc_svn_root; + src['scala/dbc/value/Boolean'] = dbc_svn_root; + src['scala/dbc/value/Character'] = dbc_svn_root; + src['scala/dbc/value/CharacterLargeObject'] = dbc_svn_root; + src['scala/dbc/value/CharacterVarying'] = dbc_svn_root; + src['scala/dbc/value/Conversion'] = dbc_svn_root; + src['scala/dbc/value/ExactNumeric'] = dbc_svn_root; + src['scala/dbc/value/Factory'] = dbc_svn_root; + src['scala/dbc/value/Unknown'] = dbc_svn_root; // scala-compiler-src.jar + src['scala/tools/nsc/CompilationUnits'] = comp_svn_root; + src['scala/tools/nsc/CompileClient'] = comp_svn_root; + src['scala/tools/nsc/CompileServer'] = comp_svn_root; + src['scala/tools/nsc/CompileSocket'] = comp_svn_root; + src['scala/tools/nsc/CompilerCommand'] = comp_svn_root; + src['scala/tools/nsc/CompilerRun'] = comp_svn_root; + src['scala/tools/nsc/ConsoleWriter'] = comp_svn_root; src['scala/tools/nsc/Global'] = comp_svn_root; src['scala/tools/nsc/symtab/Definitions'] = comp_svn_root; diff --git a/src/compiler/scala/tools/nsc/doc/source.png b/src/compiler/scala/tools/nsc/doc/source.png deleted file mode 100644 index ecbca8cad7..0000000000 Binary files a/src/compiler/scala/tools/nsc/doc/source.png and /dev/null differ diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index be53af2ff0..21a65a284b 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -315,4 +315,24 @@ final class Array[A](_length: Int) extends Seq[A] { */ def deepMkString(sep: String): String = throw new Error() + /**

+ * Returns true if the two specified arrays are + * deeply equal to one another. + *

+ *

+ * Two array references are considered deeply equal if both are null, + * or if they refer to arrays that contain the same number of elements + * and all corresponding pairs of elements in the two arrays are deeply + * equal. + *

+ *

+ * See also method deepEquals in the Java class + * java.utils.Arrays + *

+ * + * @param that the second + * @return true iff both arrays are deeply equal. + */ + def deepEquals(that: Any): Boolean = throw new Error() } diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala index cead9fb1a2..bc44e93a37 100644 --- a/src/library/scala/runtime/BoxedArray.scala +++ b/src/library/scala/runtime/BoxedArray.scala @@ -18,6 +18,9 @@ import compat.StringBuilder /** *

A class representing Array[T]

+ * + * @author Martin Odersky, Stephane Micheloud + * @version 1.0 */ abstract class BoxedArray extends Seq[Any] { /** The length of the array */ @@ -121,19 +124,13 @@ abstract class BoxedArray extends Seq[Any] { final def deepToString() = deepMkString(stringPrefix + "(", ",", ")") final def deepMkString(start: String, sep: String, end: String): String = { - val buf = new StringBuilder() - deepAddString(buf, start, sep, end).toString - } - - final def deepMkString(sep: String): String = this.deepMkString("", sep, "") - - private def deepAddString(buf: StringBuilder, start: String, sep: String, end: String): StringBuilder = { def _deepToString(x: Any) = x match { case a: AnyRef if ScalaRunTime.isArray(a) => ScalaRunTime.boxArray(a).deepMkString(start, sep, end) case _ => x.toString } + val buf = new StringBuilder() buf.append(start) val elems = elements if (elems.hasNext) buf.append(_deepToString(elems.next)) @@ -141,6 +138,37 @@ abstract class BoxedArray extends Seq[Any] { buf.append(sep); buf.append(_deepToString(elems.next)) } buf.append(end) + buf.toString + } + + final def deepMkString(sep: String): String = this.deepMkString("", sep, "") + + final def deepEquals(that: Any): Boolean = { + def _deepEquals(x1: Any, x2: Any) = (x1, x2) match { + case (a1: BoxedArray, a2: BoxedArray) => + _sameElements(a1, a2) + case (a1: AnyRef, a2: AnyRef) + if ScalaRunTime.isArray(a1) && ScalaRunTime.isArray(a2) => + _sameElements(ScalaRunTime.boxArray(a1), ScalaRunTime.boxArray(a2)) + case _ => + x1.equals(x2) + } + def _sameElements(a1: BoxedArray, a2: BoxedArray): Boolean = { + val it1 = a1.elements + val it2 = a2.elements + var res = true + while (res && it1.hasNext && it2.hasNext) + res = _deepEquals(it1.next, it2.next) + !it1.hasNext && !it2.hasNext && res + } + that match { + case a: BoxedArray => + _sameElements(this, a) + case a: AnyRef if ScalaRunTime.isArray(a) => + _sameElements(this, ScalaRunTime.boxArray(a)) + case _ => + false + } } override final def stringPrefix: String = "Array" -- cgit v1.2.3