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

getxsick at codespeak.net getxsick at codespeak.net
Fri Jun 4 23:56:31 CEST 2010


Author: getxsick
Date: Fri Jun  4 23:56:30 2010
New Revision: 75125

Modified:
   pypy/branch/fast-ctypes/pypy/rlib/jitffi.py
   pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py
Log:
support for functions which return void


Modified: pypy/branch/fast-ctypes/pypy/rlib/jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/jitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/jitffi.py	Fri Jun  4 23:56:30 2010
@@ -2,7 +2,7 @@
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.jit.backend.x86.runner import CPU
 from pypy.jit.metainterp.history import LoopToken, BasicFailDescr
-from pypy.jit.metainterp.history import BoxInt, BoxFloat, BoxPtr
+from pypy.jit.metainterp.history import BoxInt, BoxFloat, BoxPtr, NULLBOX
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.metainterp.typesystem import deref
 
@@ -97,8 +97,8 @@
             self.bres = BoxPtr()
             res = lltype.Signed
         elif self.res_type == 'void':
-            self.bres = None
-            res = None
+            self.bres = NULLBOX
+            res = lltype.Void
         else:
             raise ValueError(self.res_type)
 

Modified: pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py	Fri Jun  4 23:56:30 2010
@@ -37,10 +37,17 @@
         {
            return 1;
         }
+
+        void return_void(int a, int b)
+        {
+            int c;
+            c = a + b;
+        }
         '''
         ))
 
-        symbols = ['add_integers', 'add_floats', 'return_float', 'max3', 'fvoid']
+        symbols = ['add_integers', 'add_floats', 'return_float',
+                   'max3', 'fvoid', 'return_void']
         eci = ExternalCompilationInfo(export_symbols=symbols)
 
         return str(platform.compile([c_file], eci, 'x', standalone=False))
@@ -96,6 +103,9 @@
         func = lib.get('fvoid', ['void'], 'int')
         assert 1 == func('void')
 
+        func = lib.get('return_void', ['int', 'int'], 'void')
+        assert func(1, 2) is None
+
     def test_undefined_func(self):
         lib = jitffi.CDLL(self.lib_name)
         # xxxfoo888baryyy - not existed function



More information about the Pypy-commit mailing list