[pypy-svn] r75848 - in pypy/branch/fast-ctypes/pypy: module/jitffi/test rlib rlib/test

getxsick at codespeak.net getxsick at codespeak.net
Mon Jul 5 19:18:29 CEST 2010


Author: getxsick
Date: Mon Jul  5 19:18:28 2010
New Revision: 75848

Modified:
   pypy/branch/fast-ctypes/pypy/module/jitffi/test/test_jitffi.py
   pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
   pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
Log:
functions can be multiple called now


Modified: pypy/branch/fast-ctypes/pypy/module/jitffi/test/test_jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/module/jitffi/test/test_jitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/module/jitffi/test/test_jitffi.py	Mon Jul  5 19:18:28 2010
@@ -102,6 +102,7 @@
 
         func = lib.get('add_intfloat', ['int', 'float'], 'int')
         assert func.call([1, 2.9]) == 3
+        assert func.call([0, 1.3]) == 1
 
     def test_undefined_func(self):
         import jitffi

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 19:18:28 2010
@@ -33,7 +33,7 @@
         self.res_type = res_type
         self.cpu = cpu
         self.lib = lib.handler
-        self.esp = 1 # 0 is a func addr
+        self.setup_stack()
 
         if self.res_type == 'int':
             self.bres = BoxInt()
@@ -71,8 +71,6 @@
         FUNC = deref(FPTR)
         self.calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
 
-        self.bargs = []
-
     def call(self, func_args=None):
         if func_args is not None:
             for tp, value in zip(self.args_type, func_args):
@@ -97,6 +95,8 @@
         else:
             self.guard_failed = True
 
+        self.setup_stack() # clean up the stack
+
         if self.res_type == 'int':
             r = BoxInt(self.cpu.get_latest_value_int(0)).getint()
         elif self.res_type == 'float':
@@ -109,6 +109,10 @@
             raise ValueError(self.res_type)
         return r
 
+    def setup_stack(self):
+        self.bargs = []
+        self.esp = 1 # 0 is a func addr
+
     def push_int(self, value):
         self.cpu.set_future_value_int(self.esp, value)
         self.bargs.append(BoxInt(value))

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 19:18:28 2010
@@ -97,6 +97,7 @@
 
         func = lib.get('add_intfloat', ['int', 'float'], 'int')
         assert func.call([1, 2.9]) == 3
+        assert func.call([0, 1.3]) == 1
 
     def test_undefined_func(self):
         lib = rjitffi.CDLL(self.lib_name)



More information about the Pypy-commit mailing list