diff -r 7c4442271367 -r 9359b006782b emul/src/main/java/java/lang/String.java --- a/emul/src/main/java/java/lang/String.java Sat Jan 12 15:39:33 2013 +0100 +++ b/emul/src/main/java/java/lang/String.java Mon Jan 14 11:30:56 2013 +0100 @@ -169,11 +169,11 @@ * @param value * The initial value of the string */ - @JavaScriptBody(args = { "self", "charArr" }, body= + @JavaScriptBody(args = { "charArr" }, body= "for (var i = 0; i < charArr.length; i++) {\n" + " if (typeof charArr[i] === 'number') charArr[i] = String.fromCharCode(charArr[i]);\n" + "}\n" - + "self.fld_r = charArr.join('');\n" + + "this.fld_r = charArr.join('');\n" ) public String(char value[]) { } @@ -199,12 +199,12 @@ * If the {@code offset} and {@code count} arguments index * characters outside the bounds of the {@code value} array */ - @JavaScriptBody(args = { "self", "charArr", "off", "cnt" }, body = + @JavaScriptBody(args = { "charArr", "off", "cnt" }, body = "var up = off + cnt;\n" + "for (var i = off; i < up; i++) {\n" + " if (typeof charArr[i] === 'number') charArr[i] = String.fromCharCode(charArr[i]);\n" + "}\n" + - "self.fld_r = charArr.slice(off, up).join(\"\");\n" + "this.fld_r = charArr.slice(off, up).join(\"\");\n" ) public String(char value[], int offset, int count) { } @@ -618,7 +618,7 @@ * @return the length of the sequence of characters represented by this * object. */ - @JavaScriptBody(args = "self", body = "return self.toString().length;") + @JavaScriptBody(args = {}, body = "return this.toString().length;") public int length() { throw new UnsupportedOperationException(); } @@ -631,7 +631,7 @@ * * @since 1.6 */ - @JavaScriptBody(args = "self", body="return self.toString().length === 0;") + @JavaScriptBody(args = {}, body="return this.toString().length === 0;") public boolean isEmpty() { return length() == 0; } @@ -654,8 +654,8 @@ * argument is negative or not less than the length of this * string. */ - @JavaScriptBody(args = { "self", "index" }, - body = "return self.toString().charCodeAt(index);" + @JavaScriptBody(args = { "index" }, + body = "return this.toString().charCodeAt(index);" ) public char charAt(int index) { throw new UnsupportedOperationException(); @@ -780,8 +780,8 @@ * Copy characters from this string into dst starting at dstBegin. * This method doesn't perform any range checking. */ - @JavaScriptBody(args = { "self", "arr", "to" }, body = - "var s = self.toString();\n" + + @JavaScriptBody(args = { "arr", "to" }, body = + "var s = this.toString();\n" + "for (var i = 0; i < s.length; i++) {\n" + " arr[to++] = s[i];\n" + "}" @@ -820,8 +820,8 @@ *
  • dstBegin+(srcEnd-srcBegin) is larger than * dst.length */ - @JavaScriptBody(args = { "self", "beg", "end", "arr", "dst" }, body= - "var s = self.toString();\n" + + @JavaScriptBody(args = { "beg", "end", "arr", "dst" }, body= + "var s = this.toString();\n" + "while (beg < end) {\n" + " arr[dst++] = s[beg++];\n" + "}\n" @@ -993,9 +993,9 @@ * @see #compareTo(String) * @see #equalsIgnoreCase(String) */ - @JavaScriptBody(args = { "self", "obj" }, body = + @JavaScriptBody(args = { "obj" }, body = "return obj.$instOf_java_lang_String && " - + "self.toString() === obj.toString();" + + "this.toString() === obj.toString();" ) public boolean equals(Object anObject) { if (this == anObject) { @@ -1420,9 +1420,9 @@ * this.substring(toffset).startsWith(prefix) * */ - @JavaScriptBody(args = { "self", "find", "from" }, body= + @JavaScriptBody(args = { "find", "from" }, body= "find = find.toString();\n" + - "return self.toString().substring(from, from + find.length) === find;\n" + "return this.toString().substring(from, from + find.length) === find;\n" ) public boolean startsWith(String prefix, int toffset) { char ta[] = toCharArray(); @@ -1570,9 +1570,9 @@ * than or equal to fromIndex, or -1 * if the character does not occur. */ - @JavaScriptBody(args = { "self", "ch", "from" }, body = + @JavaScriptBody(args = { "ch", "from" }, body = "if (typeof ch === 'number') ch = String.fromCharCode(ch);\n" + - "return self.toString().indexOf(ch, from);\n" + "return this.toString().indexOf(ch, from);\n" ) public int indexOf(int ch, int fromIndex) { if (fromIndex < 0) { @@ -1679,9 +1679,9 @@ * than or equal to fromIndex, or -1 * if the character does not occur before that point. */ - @JavaScriptBody(args = { "self", "ch", "from" }, body = + @JavaScriptBody(args = { "ch", "from" }, body = "if (typeof ch === 'number') ch = String.fromCharCode(ch);\n" + - "return self.toString().lastIndexOf(ch, from);" + "return this.toString().lastIndexOf(ch, from);" ) public int lastIndexOf(int ch, int fromIndex) { if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) { @@ -1754,8 +1754,8 @@ * starting at the specified index, * or {@code -1} if there is no such occurrence. */ - @JavaScriptBody(args = { "self", "str", "fromIndex" }, body = - "return self.toString().indexOf(str.toString(), fromIndex);" + @JavaScriptBody(args = { "str", "fromIndex" }, body = + "return this.toString().indexOf(str.toString(), fromIndex);" ) public native int indexOf(String str, int fromIndex); @@ -1794,8 +1794,8 @@ * searching backward from the specified index, * or {@code -1} if there is no such occurrence. */ - @JavaScriptBody(args = { "self", "s", "from" }, body = - "return self.toString().lastIndexOf(s.toString(), from);" + @JavaScriptBody(args = { "s", "from" }, body = + "return this.toString().lastIndexOf(s.toString(), from);" ) public int lastIndexOf(String str, int fromIndex) { return lastIndexOf(toCharArray(), offset(), length(), str.toCharArray(), str.offset(), str.length(), fromIndex); @@ -1903,8 +1903,8 @@ * beginIndex is larger than * endIndex. */ - @JavaScriptBody(args = { "self", "beginIndex", "endIndex" }, body = - "return self.toString().substring(beginIndex, endIndex);" + @JavaScriptBody(args = { "beginIndex", "endIndex" }, body = + "return this.toString().substring(beginIndex, endIndex);" ) public String substring(int beginIndex, int endIndex) { if (beginIndex < 0) { @@ -2012,10 +2012,10 @@ * @return a string derived from this string by replacing every * occurrence of oldChar with newChar. */ - @JavaScriptBody(args = { "self", "arg1", "arg2" }, body = + @JavaScriptBody(args = { "arg1", "arg2" }, body = "if (typeof arg1 === 'number') arg1 = String.fromCharCode(arg1);\n" + "if (typeof arg2 === 'number') arg2 = String.fromCharCode(arg2);\n" + - "var s = self.toString();\n" + + "var s = this.toString();\n" + "for (;;) {\n" + " var ret = s.replace(arg1, arg2);\n" + " if (ret === s) {\n" + @@ -2078,8 +2078,8 @@ * @since 1.4 * @spec JSR-51 */ - @JavaScriptBody(args = { "self", "regex" }, body = - "self = self.toString();\n" + @JavaScriptBody(args = { "regex" }, body = + "var self = this.toString();\n" + "var re = new RegExp(regex.toString());\n" + "var r = re.exec(self);\n" + "return r != null && r.length > 0 && self.length == r[0].length;" @@ -2496,7 +2496,7 @@ * @return the String, converted to lowercase. * @see java.lang.String#toLowerCase(Locale) */ - @JavaScriptBody(args = "self", body = "return self.toLowerCase();") + @JavaScriptBody(args = {}, body = "return this.toLowerCase();") public String toLowerCase() { throw new UnsupportedOperationException("Should be supported but without connection to locale"); } @@ -2662,7 +2662,7 @@ * @return the String, converted to uppercase. * @see java.lang.String#toUpperCase(Locale) */ - @JavaScriptBody(args = "self", body = "return self.toUpperCase();") + @JavaScriptBody(args = {}, body = "return this.toUpperCase();") public String toUpperCase() { throw new UnsupportedOperationException(); } @@ -2718,7 +2718,7 @@ * * @return the string itself. */ - @JavaScriptBody(args = "self", body = "return self.toString();") + @JavaScriptBody(args = {}, body = "return this.toString();") public String toString() { return this; }