[pypy-commit] lang-js default: renamed ToBoolean to to_boolean

stepahn noreply at buildbot.pypy.org
Fri Dec 28 11:34:44 CET 2012


Author: Stephan <stephan at stzal.com>
Branch: 
Changeset: r262:0c9f4be45611
Date: 2012-06-06 13:01 +0200
http://bitbucket.org/pypy/lang-js/changeset/0c9f4be45611/

Log:	renamed ToBoolean to to_boolean

diff --git a/js/baseop.py b/js/baseop.py
--- a/js/baseop.py
+++ b/js/baseop.py
@@ -198,7 +198,7 @@
         elif type1 == "string":
             return x.to_string() == y.to_string()
         elif type1 == "boolean":
-            return x.ToBoolean() == x.ToBoolean()
+            return x.to_boolean() == x.to_boolean()
         # XXX rethink it here
         return x.to_string() == y.to_string()
     else:
@@ -256,7 +256,7 @@
     if type1 == "string":
         return x.to_string() == y.to_string()
     if type1 == "boolean":
-        return x.ToBoolean() == x.ToBoolean()
+        return x.to_boolean() == x.to_boolean()
     return x == y
 
 
diff --git a/js/builtins_boolean.py b/js/builtins_boolean.py
--- a/js/builtins_boolean.py
+++ b/js/builtins_boolean.py
@@ -45,7 +45,7 @@
     else:
         raise JsTypeError()
 
-    if b.ToBoolean() == True:
+    if b.to_boolean() == True:
         return 'true'
     else:
         return 'false'
diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -16,7 +16,7 @@
     def type(self):
         return self._type_
 
-    def ToBoolean(self):
+    def to_boolean(self):
         return False
 
     def ToPrimitive(self, hint = None):
@@ -93,7 +93,7 @@
 class W_Null(W_Primitive):
     _type_ = 'null'
 
-    def ToBoolean(self):
+    def to_boolean(self):
         return False
 
     def to_string(self):
@@ -563,7 +563,7 @@
         return True
 
     ##########
-    def ToBoolean(self):
+    def to_boolean(self):
         return True
 
     def ToNumber(self):
@@ -798,7 +798,8 @@
 class W_BooleanConstructor(W_BasicFunction):
     def Call(self, args = [], this = None, calling_context = None):
         if len(args) >= 1 and not isnull_or_undefined(args[0]):
-            return _w(args[0].ToBoolean())
+            boolval = args[0].to_boolean()
+            return _w(boolval)
         else:
             return _w(False)
 
@@ -1193,7 +1194,7 @@
             return 1.0
         return 0.0
 
-    def ToBoolean(self):
+    def to_boolean(self):
         return self._boolval_
 
 class W_String(W_Primitive):
@@ -1217,7 +1218,7 @@
     def to_string(self):
         return self._strval_
 
-    def ToBoolean(self):
+    def to_boolean(self):
         if len(self._strval_) == 0:
             return False
         else:
@@ -1255,7 +1256,7 @@
     def ToObject(self):
         return W_NumericObject(self)
 
-    def ToBoolean(self):
+    def to_boolean(self):
         num = self.ToNumber()
         if isnan(num):
             return False
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -336,7 +336,10 @@
 
 class NOT(BaseUnaryOperation):
     def eval(self, ctx):
-        ctx.stack_append(newbool(not ctx.stack_pop().ToBoolean()))
+        val = ctx.stack_pop()
+        boolval = val.to_boolean()
+        inv_boolval = not boolval
+        ctx.stack_append(_w(inv_boolval))
 
 class INCR(BaseUnaryOperation):
     def eval(self, ctx):
@@ -451,12 +454,12 @@
 class BaseIfJump(BaseJump):
     def eval(self, ctx):
         value = ctx.stack_pop()
-        self.decision = value.ToBoolean()
+        self.decision = value.to_boolean()
 
 class BaseIfNopopJump(BaseJump):
     def eval(self, ctx):
         value = ctx.stack_top()
-        self.decision = value.ToBoolean()
+        self.decision = value.to_boolean()
 
 class JUMP_IF_FALSE(BaseIfJump):
     def do_jump(self, ctx, pos):
diff --git a/js/test/ecma/conftest.py b/js/test/ecma/conftest.py
--- a/js/test/ecma/conftest.py
+++ b/js/test/ecma/conftest.py
@@ -207,7 +207,7 @@
         def get_result(test_num):
             w_test_number = _w(test_num)
             result_obj = run_test_func.Call(args = [w_test_number])
-            result_passed = result_obj.get('passed').ToBoolean()
+            result_passed = result_obj.get('passed').to_boolean()
             result_reason = result_obj.get('reason').to_string();
             return (result_passed, result_reason) # result.to_string()
 


More information about the pypy-commit mailing list