[pypy-svn] r75851 - in pypy/branch/fast-ctypes/pypy/rlib: . test

getxsick at codespeak.net getxsick at codespeak.net
Mon Jul 5 20:00:53 CEST 2010


Author: getxsick
Date: Mon Jul  5 20:00:52 2010
New Revision: 75851

Modified:
   pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
   pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
Log:
remove func_args as it's not RPython. update tests to use push_*() directly


Modified: pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py	Mon Jul  5 20:00:52 2010
@@ -71,16 +71,7 @@
         FUNC = deref(FPTR)
         self.calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
 
-    def call(self, func_args=None):
-        if func_args is not None:
-            for tp, value in zip(self.args_type, func_args):
-                if tp == 'int':
-                    self.push_int(value)
-                elif tp == 'float':
-                    self.push_float(value)
-                elif tp == 'ref':
-                    self.push_ref(value)
-
+    def call(self):
         inputargs = [self.bfuncaddr] + self.bargs
 
         oplist = [ResOperation(rop.CALL, inputargs, self.bres,

Modified: pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py	Mon Jul  5 20:00:52 2010
@@ -69,35 +69,59 @@
         lib = rjitffi.CDLL(self.lib_name)
 
         func = lib.get('add_integers', ['int', 'int'], 'int')
-        assert 3 == func.call([1,2])
+        func.push_int(1)
+        func.push_int(2)
+        assert func.call() == 3
+
         func = lib.get('add_integers', ['int', 'int'], 'int')
-        assert 1 == func.call([-1,2])
+        func.push_int(-1)
+        func.push_int(2)
+        assert func.call() == 1
+
         func = lib.get('add_integers', ['int', 'int'], 'int')
-        assert 0 == func.call([0,0])
+        func.push_int(0)
+        func.push_int(0)
+        assert func.call() == 0
 
         func = lib.get('max3', ['int', 'int', 'int'], 'int')
-        assert 8 == func.call([2, 8, 3])
+        func.push_int(2)
+        func.push_int(8)
+        func.push_int(3)
+        assert func.call() == 8
 
         func = lib.get('add_floats', ['float', 'float'], 'float')
-        assert 2.7 == func.call([1.2, 1.5])
+        func.push_float(1.2)
+        func.push_float(1.5)
+        assert func.call() == 2.7
 
     def test_get_void(self):
         lib = rjitffi.CDLL(self.lib_name)
 
         func = lib.get('fvoid', [], 'int')
-        assert 1 == func.call()
+        assert func.call() == 1
 
         func = lib.get('return_void', ['int', 'int'], 'void')
-        assert func.call([1, 2]) is None
+        func.push_int(1)
+        func.push_int(2)
+        assert func.call() is None
+
         func = lib.get('return_void', ['int', 'int'])
-        assert func.call([1, 2]) is None
+        func.push_int(1)
+        func.push_int(2)
+        assert func.call() is None
 
     def test_various_type_args(self):
         lib = rjitffi.CDLL(self.lib_name)
 
         func = lib.get('add_intfloat', ['int', 'float'], 'int')
-        assert func.call([1, 2.9]) == 3
-        assert func.call([0, 1.3]) == 1
+        func.push_int(1)
+        func.push_float(2.9)
+        assert func.call() == 3
+        
+        # stack is cleaned up after calling
+        func.push_int(0)
+        func.push_float(1.3)
+        assert func.call() == 1
 
     def test_undefined_func(self):
         lib = rjitffi.CDLL(self.lib_name)



More information about the Pypy-commit mailing list