JS backend: cleanup strings code.

Added String.size and String.length().
This commit is contained in:
develar
2013-08-06 17:24:48 +04:00
committed by Zalim Bashorov
parent 678f6601dd
commit 7c18ab3ca8
9 changed files with 37 additions and 79 deletions
-6
View File
@@ -3,12 +3,6 @@ package java.lang
import java.io.IOException
import js.library
library("splitString")
public fun String.split(regex : String) : Array<String> = js.noImpl
library("splitString")
public fun String.split(regex : String, limit: Int) : Array<String> = js.noImpl
library
open public class Exception(message: String? = null) : Throwable() {}
+15 -3
View File
@@ -1,5 +1,13 @@
package js
native public fun String.startsWith(s: String): Boolean = noImpl
native public fun String.endsWith(s: String): Boolean = noImpl
native public fun String.contains(s: String): Boolean = noImpl
native public fun String.startsWith(char: Char): Boolean = noImpl
native public fun String.endsWith(char: Char): Boolean = noImpl
native public fun String.contains(char: Char): Boolean = noImpl
native public fun String.toUpperCase() : String = js.noImpl
native public fun String.toLowerCase() : String = js.noImpl
@@ -10,8 +18,11 @@ native public fun String.indexOf(str : String, fromIndex : Int) : Int = js.noImp
native public fun String.lastIndexOf(str: String) : Int = js.noImpl
native public fun String.lastIndexOf(str : String, fromIndex : Int) : Int = js.noImpl
// Defined in javalang.kt
//native public fun String.split(regex : String) : Array<String> = js.noImpl
library("splitString")
public fun String.split(regex: String): Array<String> = js.noImpl
library("splitString")
public fun String.split(regex: String, limit: Int): Array<String> = js.noImpl
native public fun String.substring(beginIndex : Int) : String = js.noImpl
native public fun String.substring(beginIndex : Int, endIndex : Int) : String = js.noImpl
@@ -24,9 +35,10 @@ native public fun String.match(regex : String) : Array<String> = js.noImpl
native public fun String.trim() : String = js.noImpl
native public val String.length : Int
public val String.size: Int
get() = js.noImpl
public fun String.length(): Int = js.noImpl
/*
-23
View File
@@ -11,29 +11,6 @@ public inline fun String.matches(regex : String) : Boolean {
return result != null && result.size > 0
}
public inline fun String.length(): Int = length
inline val String.size : Int
get() = length
public inline fun String.startsWith(ch: Char): Boolean {
return if (size > 0) charAt(0) == ch else false
}
public inline fun String.endsWith(ch: Char): Boolean {
val s = size
return if (s > 0) charAt(s - 1) == ch else false
}
native
fun String.startsWith(s:String):Boolean = noImpl
native
fun String.endsWith(s:String):Boolean = noImpl
native
fun String.contains(s:String):Boolean = noImpl
/**
* Returns a copy of this string capitalised if it is not empty or already starting with an uppper case letter, otherwise returns this
*