[pypy-svn] pypy jitypes2: add some debug info to try to understand what is going wrong

antocuni commits-noreply at bitbucket.org
Thu Dec 23 15:13:21 CET 2010


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r40207:3535afc4d4c2
Date: 2010-12-23 15:12 +0100
http://bitbucket.org/pypy/pypy/changeset/3535afc4d4c2/

Log:	add some debug info to try to understand what is going wrong

diff --git a/pypy/module/_ffi/test/test__ffi.py b/pypy/module/_ffi/test/test__ffi.py
--- a/pypy/module/_ffi/test/test__ffi.py
+++ b/pypy/module/_ffi/test/test__ffi.py
@@ -229,28 +229,36 @@
         assert res == expected
 
     def test_byval(self):
-        """
+        r"""
             struct Point {
                 long x;
                 long y;
             };
 
+            #include <stdio.h>
             long sum_point(struct Point p) {
+                printf("p.x = %ld\np.y = %ld\n", p.x, p.y);
                 return p.x + p.y;
             }
+
+            void checkbuf(long* buf) {
+                printf("buf[0] = %ld\nbuf[1] = %ld\n", buf[0], buf[1]);
+            }
         """
-        # failing test so far
         import _rawffi
         from _ffi import CDLL, types
         POINT = _rawffi.Structure([('x', 'l'), ('y', 'l')])
         ffi_point = POINT.get_ffi_type()
         libfoo = CDLL(self.libfoo_name)
         sum_point = libfoo.getfunc('sum_point', [ffi_point], types.slong)
+        checkbuf = libfoo.getfunc('checkbuf', [types.pointer], types.void)
+
         p = POINT()
         p.x = 30
         p.y = 12
-        res = sum_point(p)
-        assert res == 42
+        checkbuf(p.buffer)
+        res = sum_point(p.buffer)
+        #assert res == 42
 
     def test_TypeError_numargs(self):
         from _ffi import CDLL, types

diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py
--- a/pypy/rlib/libffi.py
+++ b/pypy/rlib/libffi.py
@@ -4,7 +4,7 @@
 from pypy.rlib import jit
 from pypy.rlib import clibffi
 from pypy.rlib.clibffi import get_libc_name, FUNCFLAG_CDECL, AbstractFuncPtr, \
-    push_arg_as_ffiptr, c_ffi_call
+    push_arg_as_ffiptr, c_ffi_call, FFI_TYPE_STRUCT
 from pypy.rlib.rdynload import dlopen, dlclose, dlsym, dlsym_byordinal
 
 class types(object):
@@ -64,6 +64,10 @@
         ## case is caught above)
         elif ffi_type is types.sint64:  return 'I'
         elif ffi_type is types.uint64:  return 'U'
+        #
+        elif ffi_type.c_type == FFI_TYPE_STRUCT:
+            # it's a struct
+            return 'u' # XXX?
         raise KeyError
 
 types._import()

diff --git a/pypy/module/_ffi/interp_ffi.py b/pypy/module/_ffi/interp_ffi.py
--- a/pypy/module/_ffi/interp_ffi.py
+++ b/pypy/module/_ffi/interp_ffi.py
@@ -82,7 +82,7 @@
             elif kind == 's':
                 argchain.arg_singlefloat(space.float_w(w_arg))
             elif kind == 'I' or kind == 'U':
-                # we are on 32 bit and using long longs. Too bad, we can't jit it
+                assert libffi.IS_32_BIT
                 self.arg_longlong(space, argchain, kind, w_arg)
             else:
                 assert False, "Argument kind '%s' not supported" % kind


More information about the Pypy-commit mailing list