Synced dotnet-library/ with rev 12365

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@12367 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
mihaylov 2007-07-19 21:11:21 +00:00
parent 00ee246af3
commit 8b978fca22
5 changed files with 46 additions and 17 deletions

View File

@ -769,6 +769,7 @@ MSIL
<include name="scala/serializable.scala"/> <include name="scala/serializable.scala"/>
<include name="scala/transient.scala"/> <include name="scala/transient.scala"/>
<include name="scala/runtime/*.scala"/> <include name="scala/runtime/*.scala"/>
<exclude name="scala/runtime/RichStringBuilder.scala"/>
</quick> </quick>
<property name="ilasm.infile" value="${msil.dir}/predef.msil"/> <property name="ilasm.infile" value="${msil.dir}/predef.msil"/>
<property name="ilasm.outfile" value="${msil.dir}/predef.dll"/> <property name="ilasm.outfile" value="${msil.dir}/predef.dll"/>

View File

@ -35,7 +35,9 @@ object Predef {
type boolean = scala.Boolean type boolean = scala.Boolean
type unit = scala.Unit type unit = scala.Unit
@deprecated type All = Nothing /** @deprecated use <code>Nothing</code> instead */
@deprecated type All = Nothing
/** @deprecated use <code>Null</code> instead */
@deprecated type AllRef = Null @deprecated type AllRef = Null
type String = System.String type String = System.String
@ -167,6 +169,7 @@ object Predef {
implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x) implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
implicit def stringWrapper(x: String) = new runtime.RichString(x) implicit def stringWrapper(x: String) = new runtime.RichString(x)
//implicit def stringBuilderWrapper(x : StringBuilder) = new runtime.RichStringBuilder(x)
implicit def any2stringadd(x: Any) = new runtime.StringAdd(x) implicit def any2stringadd(x: Any) = new runtime.StringAdd(x)

View File

@ -34,7 +34,7 @@ final class StringBuilder(val self: StringBuffer) extends (Int => Char) with Pro
def charAt(i: Int): Char = self(i) def charAt(i: Int): Char = self(i)
def apply(i: Int): Char = self(i) def apply(i: Int): Char = self(i)
def deleteCharAt(index: Int) = self.Remote(index, 1) def deleteCharAt(index: Int) = self.Remove(index, 1)
def setCharAt(i: Int, c: Char) { self(i) = c } def setCharAt(i: Int, c: Char) { self(i) = c }
def update(i: Int, c: Char) { self(i) = c } def update(i: Int, c: Char) { self(i) = c }

View File

@ -14,21 +14,43 @@ package scala.runtime
import Predef._ import Predef._
final class RichString(val self: String) extends Seq[Char] with Ordered[String] with Proxy { final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char] with Ordered[String] {
override def apply(n: Int) = self charAt n
// Ordered[String] override def length = self.length
def compare(other: String) = self compareTo other override def toString = self
override def mkString = self
// Seq[Char] override def slice(from : Int, until : Int) : RichString = {
def length = self.length val from0 = if (from < 0) 0 else from
override def elements = Iterator.fromString(self) val until0 = if (from >= until || from >= self.length) return new RichString("")
else if (until > self.length) self.length else until
/** Retrieve the n-th character of the string new RichString(self.substring(from0, until0))
* }
* @param index into the string //override def ++ [B >: A](that: Iterable[B]): Seq[B] = {
* @return the character at position <code>index</code>. override def ++[B >: Char](that : Iterable[B]) : RandomAccessSeq[B] = that match {
*/ case that : RichString => new RichString(self + that.self)
def apply(n: Int) = self charAt n case that => super.++(that)
}
override def take(until : Int) : RichString = slice(0, until)
override def drop(from : Int) : RichString = slice(from, self.length)
override def startsWith[B](that : Seq[B]) = that match {
case that : RichString => self startsWith that.self
case that => super.startsWith(that)
}
override def endsWith[B](that : Seq[B]) = that match {
case that : RichString => self endsWith that.self
case that => super.endsWith(that)
}
override def indexOf[B](that : Seq[B]) = that match {
case that : RichString => self indexOf that.self
case that => super.indexOf(that)
}
override def containsSlice[B](that : Seq[B]) = that match {
case that : RichString => self contains that.self
case that => super.containsSlice(that)
}
override def compare(other: String) = self compareTo other
private final val LF: Char = 0x0A private final val LF: Char = 0x0A
private final val FF: Char = 0x0C private final val FF: Char = 0x0C

View File

@ -11,6 +11,9 @@
package scala package scala
import Predef._
/** Buffered iterators are iterators which allow to inspect the next /** Buffered iterators are iterators which allow to inspect the next
* element without discarding it. * element without discarding it.
* *