[pypy-commit] lang-smalltalk default: added converting methods to interpreter proxy

lwassermann noreply at buildbot.pypy.org
Mon Jun 10 19:00:42 CEST 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r440:c00e555fc976
Date: 2013-06-10 18:55 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/c00e555fc976/

Log:	added converting methods to interpreter proxy

diff --git a/spyvm/interpreter_proxy.py b/spyvm/interpreter_proxy.py
--- a/spyvm/interpreter_proxy.py
+++ b/spyvm/interpreter_proxy.py
@@ -340,14 +340,42 @@
 
 #     /* InterpreterProxy methodsFor: 'converting' */
 
-#     sqInt  (*booleanValueOf)(sqInt obj);
-#     sqInt  (*checkedIntegerValueOf)(sqInt intOop);
-#     sqInt  (*floatObjectOf)(double aFloat);
-#     double (*floatValueOf)(sqInt oop);
-#     sqInt  (*integerObjectOf)(sqInt value);
-#     sqInt  (*integerValueOf)(sqInt oop);
-#     sqInt  (*positive32BitIntegerFor)(sqInt integerValue);
-#     sqInt  (*positive32BitValueOf)(sqInt oop);
+ at expose_on_virtual_machine_proxy([oop], bool)
+def booleanValueOf(w_object):
+    space = IProxy.space
+    if w_object is space.w_true:
+        return True
+    if w_object is space.w_false:
+        return False
+    raise ProxyFunctionFailed
+
+ at expose_on_virtual_machine_proxy([oop], int)
+def checkedIntegerValueOf(w_object):
+    return IProxy.space.unwrap_int(w_object)
+
+ at expose_on_virtual_machine_proxy([float], oop)
+def floatObjectOf(f):
+    return IProxy.space.wrap_float(f)
+
+ at expose_on_virtual_machine_proxy([oop], float)
+def floatValueOf(w_object):
+    return IProxy.space.unwrap_float(w_object)
+
+ at expose_on_virtual_machine_proxy([int], oop)
+def integerObjectOf(n):
+    return IProxy.space.wrap_int(n)
+
+ at expose_on_virtual_machine_proxy([oop], int)
+def integerValueOf(w_object):
+    return IProxy.space.unwrap_int(w_object)
+
+ at expose_on_virtual_machine_proxy([int], oop)
+def positive32BitIntegerFor(n):
+    return IProxy.space.wrap_positive_32bit_int(n)
+
+ at expose_on_virtual_machine_proxy([oop], int)
+def positive32BitValueOf(n):
+    return IProxy.space.unwrap_positive_32bit_int(n)
 
 #     /* InterpreterProxy methodsFor: 'special objects' */
 


More information about the pypy-commit mailing list