[pypy-svn] r64851 - pypy/branch/js-refactoring/pypy/lang/js
jandem at codespeak.net
jandem at codespeak.net
Thu Apr 30 13:23:07 CEST 2009
Author: jandem
Date: Thu Apr 30 13:22:59 2009
New Revision: 64851
Modified:
pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
Log:
Implement String.toLowerCase/toUpperCase. Some tests fail due to Unicode (locale?) mismatch, not sure how to fix that...
Modified: pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/interpreter.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/interpreter.py Thu Apr 30 13:22:59 2009
@@ -366,11 +366,7 @@
temp = []
for arg in args:
i = arg.ToInt32(ctx) % 65536 # XXX should be uint16
- if i > 255:
- temp.append(unichr(i))
- else:
- temp.append(chr(i))
-
+ temp.append(unichr(i))
return W_String(''.join(temp))
class W_CharAt(W_NewBuiltin):
@@ -461,6 +457,15 @@
return w_array
+class W_ToLowerCase(W_NewBuiltin):
+ def Call(self, ctx, args=[], this=None):
+ string = this.ToString(ctx)
+ return W_String(string.lower())
+
+class W_ToUpperCase(W_NewBuiltin):
+ def Call(self, ctx, args=[], this=None):
+ string = this.ToString(ctx)
+ return W_String(string.upper())
def common_join(ctx, this, sep=','):
length = this.Get(ctx, 'length').ToUInt32(ctx)
@@ -652,6 +657,8 @@
'indexOf': w_IndexOf,
'substring': W_Substring(ctx),
'split': w_Split,
+ 'toLowerCase': W_ToLowerCase(ctx),
+ 'toUpperCase': W_ToUpperCase(ctx)
})
# 15.5.3.2
More information about the Pypy-commit
mailing list