[pypy-commit] pypy default: Backout b28cc6f1e4b3. Turns out to be restrictive...

arigo noreply at buildbot.pypy.org
Sat Jun 25 19:41:16 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r45128:8678888acad7
Date: 2011-06-25 19:46 +0200
http://bitbucket.org/pypy/pypy/changeset/8678888acad7/

Log:	Backout b28cc6f1e4b3. Turns out to be restrictive...

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
@@ -217,7 +217,7 @@
         if meth:
             return space.call_function(meth, w_arg, w_argtype)
         else:
-            raise OperationError(space.w_TypeError, space.wrap('not an ffi pointer type'))
+            return w_arg
 
     @jit.dont_look_inside
     def arg_longlong(self, space, argchain, kind, w_arg):
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
@@ -139,13 +139,32 @@
         assert get_dummy() == 42
         set_dummy(0)
 
-    def test_convert_pointer_args(self):
+    def test_pointer_args(self):
         """
             extern int dummy; // defined in test_void_result 
             DLLEXPORT int* get_dummy_ptr() { return &dummy; }
             DLLEXPORT void set_val_to_ptr(int* ptr, int val) { *ptr = val; }
         """
         from _ffi import CDLL, types
+        libfoo = CDLL(self.libfoo_name)
+        get_dummy = libfoo.getfunc('get_dummy', [], types.sint)
+        get_dummy_ptr = libfoo.getfunc('get_dummy_ptr', [], types.void_p)
+        set_val_to_ptr = libfoo.getfunc('set_val_to_ptr',
+                                        [types.void_p, types.sint],
+                                        types.void)
+        assert get_dummy() == 0
+        ptr = get_dummy_ptr()
+        set_val_to_ptr(ptr, 123)
+        assert get_dummy() == 123
+        set_val_to_ptr(ptr, 0)
+
+    def test_convert_pointer_args(self):
+        """
+            extern int dummy; // defined in test_void_result 
+            DLLEXPORT int* get_dummy_ptr(); // defined in test_pointer_args
+            DLLEXPORT void set_val_to_ptr(int* ptr, int val); // ditto
+        """
+        from _ffi import CDLL, types
 
         class MyPointerWrapper(object):
             def __init__(self, value):
@@ -194,19 +213,11 @@
 
         libfoo = CDLL(self.libfoo_name)
         intptr = types.Pointer(types.sint)
-
-        class MyPointerWrapper(object):
-            def __init__(self, value):
-                self.value = value
-            def _as_ffi_pointer_(self, ffitype):
-                assert ffitype is intptr
-                return self.value
-        
         get_dummy = libfoo.getfunc('get_dummy', [], types.sint)
         get_dummy_ptr = libfoo.getfunc('get_dummy_ptr', [], intptr)
         set_val_to_ptr = libfoo.getfunc('set_val_to_ptr', [intptr, types.sint], types.void)
         assert get_dummy() == 0
-        ptr = MyPointerWrapper(get_dummy_ptr())
+        ptr = get_dummy_ptr()
         set_val_to_ptr(ptr, 123)
         assert get_dummy() == 123
         set_val_to_ptr(ptr, 0)
@@ -219,16 +230,8 @@
         import sys
         from _ffi import CDLL, types
         libfoo = CDLL(self.libfoo_name)
-
-        class MyPointerWrapper(object):
-            def __init__(self, value):
-                self.value = value
-            def _as_ffi_pointer_(self, ffitype):
-                assert ffitype is types.void_p
-                return self.value
-
         is_null_ptr = libfoo.getfunc('is_null_ptr', [types.void_p], types.ulong)
-        assert not is_null_ptr(MyPointerWrapper(sys.maxint+1))
+        assert not is_null_ptr(sys.maxint+1)
 
     def test_unsigned_long_args(self):
         """


More information about the pypy-commit mailing list