[pypy-commit] pypy default: Move the "_ffi" module into the "_rawffi.alt" submodule. This is an

arigo noreply at buildbot.pypy.org
Tue Jan 21 11:22:44 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r68799:3e844dad3e26
Date: 2014-01-21 10:12 +0100
http://bitbucket.org/pypy/pypy/changeset/3e844dad3e26/

Log:	Move the "_ffi" module into the "_rawffi.alt" submodule. This is an
	attempt to reduce namespace conflicts with the potentially confusing
	name "_ffi", as well as moving this half-finished module (which will
	likely never be finished now) out of the way.

diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -1,4 +1,4 @@
-import _ffi
+from _rawffi import alt as _ffi
 import _rawffi
 
 from _ctypes.basics import _CData, cdata_from_address, _CDataMeta, sizeof
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -1,6 +1,6 @@
 
 import _rawffi
-import _ffi
+from _rawffi import alt as _ffi
 import sys
 
 try: from __pypy__ import builtinify
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -5,7 +5,7 @@
 from _ctypes.basics import is_struct_shape
 from _ctypes.builtin import get_errno, set_errno, get_last_error, set_last_error
 import _rawffi
-import _ffi
+from _rawffi import alt as _ffi
 import sys
 import traceback
 
diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -1,6 +1,6 @@
 
 import _rawffi
-import _ffi
+from _rawffi import alt as _ffi
 from _ctypes.basics import _CData, _CDataMeta, cdata_from_address, ArgumentError
 from _ctypes.basics import keepalive_key, store_reference, ensure_objects
 from _ctypes.basics import sizeof, byref, as_ffi_pointer
diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py
--- a/lib_pypy/_ctypes/primitive.py
+++ b/lib_pypy/_ctypes/primitive.py
@@ -1,4 +1,4 @@
-import _ffi
+from _rawffi import alt as _ffi
 import _rawffi
 import weakref
 import sys
diff --git a/lib_pypy/_ffi.py b/lib_pypy/_ffi.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_ffi.py
@@ -0,0 +1,2 @@
+# Backward compatibility hack
+from _rawffi.alt import *
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -34,14 +34,14 @@
      "struct", "_hashlib", "_md5", "_sha", "_minimal_curses", "cStringIO",
      "thread", "itertools", "pyexpat", "_ssl", "cpyext", "array",
      "binascii", "_multiprocessing", '_warnings',
-     "_collections", "_multibytecodec", "micronumpy", "_ffi",
+     "_collections", "_multibytecodec", "micronumpy",
      "_continuation", "_cffi_backend", "_csv", "cppyy", "_pypyjson"]
 ))
 
 translation_modules = default_modules.copy()
 translation_modules.update(dict.fromkeys(
     ["fcntl", "rctime", "select", "signal", "_rawffi", "zlib",
-     "struct", "_md5", "cStringIO", "array", "_ffi",
+     "struct", "_md5", "cStringIO", "array",
      "binascii",
      # the following are needed for pyrepl (and hence for the
      # interactive prompt/pdb)
@@ -96,7 +96,6 @@
     # no _rawffi if importing rpython.rlib.clibffi raises ImportError
     # or CompilationError or py.test.skip.Exception
     "_rawffi"   : ["rpython.rlib.clibffi"],
-    "_ffi"      : ["rpython.rlib.clibffi"],
 
     "zlib"      : ["rpython.rlib.rzlib"],
     "bz2"       : ["pypy.module.bz2.interp_bz2"],
diff --git a/pypy/module/_multiprocessing/test/test_memory.py b/pypy/module/_multiprocessing/test/test_memory.py
--- a/pypy/module/_multiprocessing/test/test_memory.py
+++ b/pypy/module/_multiprocessing/test/test_memory.py
@@ -1,6 +1,6 @@
 class AppTestMemory:
     spaceconfig = dict(usemodules=('_multiprocessing', 'mmap',
-                                   '_rawffi', '_ffi', 'itertools'))
+                                   '_rawffi', 'itertools'))
 
     def test_address_of(self):
         import _multiprocessing
diff --git a/pypy/module/_rawffi/__init__.py b/pypy/module/_rawffi/__init__.py
--- a/pypy/module/_rawffi/__init__.py
+++ b/pypy/module/_rawffi/__init__.py
@@ -2,6 +2,7 @@
 """
 
 from pypy.interpreter.mixedmodule import MixedModule
+from pypy.module._rawffi import alt
 
 class Module(MixedModule):
     interpleveldefs = {
@@ -33,6 +34,10 @@
     appleveldefs = {
     }
 
+    submodules = {
+        'alt': alt.Module,
+    }
+
     def buildloaders(cls):
         from pypy.module._rawffi import interp_rawffi
 
diff --git a/pypy/module/_ffi/__init__.py b/pypy/module/_rawffi/alt/__init__.py
rename from pypy/module/_ffi/__init__.py
rename to pypy/module/_rawffi/alt/__init__.py
diff --git a/pypy/module/_ffi/app_struct.py b/pypy/module/_rawffi/alt/app_struct.py
rename from pypy/module/_ffi/app_struct.py
rename to pypy/module/_rawffi/alt/app_struct.py
--- a/pypy/module/_ffi/app_struct.py
+++ b/pypy/module/_rawffi/alt/app_struct.py
@@ -1,4 +1,4 @@
-import _ffi
+from _rawffi import alt
 
 class MetaStructure(type):
 
@@ -11,7 +11,7 @@
         fields = dic.get('_fields_')
         if fields is None:
             return
-        struct_descr = _ffi._StructDescr(name, fields)
+        struct_descr = alt._StructDescr(name, fields)
         for field in fields:
             dic[field.name] = field
         dic['_struct_'] = struct_descr
diff --git a/pypy/module/_ffi/interp_ffitype.py b/pypy/module/_rawffi/alt/interp_ffitype.py
rename from pypy/module/_ffi/interp_ffitype.py
rename to pypy/module/_rawffi/alt/interp_ffitype.py
--- a/pypy/module/_ffi/interp_ffitype.py
+++ b/pypy/module/_rawffi/alt/interp_ffitype.py
@@ -116,7 +116,7 @@
     types = [
         # note: most of the type name directly come from the C equivalent,
         # with the exception of bytes: in C, ubyte and char are equivalent,
-        # but for _ffi the first expects a number while the second a 1-length
+        # but for here the first expects a number while the second a 1-length
         # string
         W_FFIType('slong',     libffi.types.slong),
         W_FFIType('sint',      libffi.types.sint),
diff --git a/pypy/module/_ffi/interp_funcptr.py b/pypy/module/_rawffi/alt/interp_funcptr.py
rename from pypy/module/_ffi/interp_funcptr.py
rename to pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_ffi/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -3,7 +3,7 @@
     operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef
-from pypy.module._ffi.interp_ffitype import W_FFIType
+from pypy.module._rawffi.alt.interp_ffitype import W_FFIType
 #
 from rpython.rtyper.lltypesystem import lltype, rffi
 #
@@ -13,7 +13,7 @@
 from rpython.rlib.rdynload import DLOpenError
 from rpython.rlib.rarithmetic import r_uint
 from rpython.rlib.objectmodel import we_are_translated
-from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
+from pypy.module._rawffi.alt.type_converter import FromAppLevelConverter, ToAppLevelConverter
 from pypy.module._rawffi.interp_rawffi import got_libffi_error, wrap_dlopenerror
 
 import os
@@ -302,7 +302,7 @@
 
 
 W_FuncPtr.typedef = TypeDef(
-    '_ffi.FuncPtr',
+    '_rawffi.alt.FuncPtr',
     __call__ = interp2app(W_FuncPtr.call),
     getaddr = interp2app(W_FuncPtr.getaddr),
     free_temp_buffers = interp2app(W_FuncPtr.free_temp_buffers),
@@ -346,7 +346,7 @@
 
 
 W_CDLL.typedef = TypeDef(
-    '_ffi.CDLL',
+    '_rawffi.alt.CDLL',
     __new__     = interp2app(descr_new_cdll),
     getfunc     = interp2app(W_CDLL.getfunc),
     getaddressindll = interp2app(W_CDLL.getaddressindll),
@@ -363,7 +363,7 @@
 
 
 W_WinDLL.typedef = TypeDef(
-    '_ffi.WinDLL',
+    '_rawffi.alt.WinDLL',
     __new__     = interp2app(descr_new_windll),
     getfunc     = interp2app(W_WinDLL.getfunc),
     getaddressindll = interp2app(W_WinDLL.getaddressindll),
diff --git a/pypy/module/_ffi/interp_struct.py b/pypy/module/_rawffi/alt/interp_struct.py
rename from pypy/module/_ffi/interp_struct.py
rename to pypy/module/_rawffi/alt/interp_struct.py
--- a/pypy/module/_ffi/interp_struct.py
+++ b/pypy/module/_rawffi/alt/interp_struct.py
@@ -8,8 +8,8 @@
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.error import operationerrfmt
-from pypy.module._ffi.interp_ffitype import W_FFIType
-from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
+from pypy.module._rawffi.alt.interp_ffitype import W_FFIType
+from pypy.module._rawffi.alt.type_converter import FromAppLevelConverter, ToAppLevelConverter
 
 
 class W_Field(W_Root):
diff --git a/pypy/module/_ffi/test/__init__.py b/pypy/module/_rawffi/alt/test/__init__.py
rename from pypy/module/_ffi/test/__init__.py
rename to pypy/module/_rawffi/alt/test/__init__.py
diff --git a/pypy/module/_ffi/test/test_ffitype.py b/pypy/module/_rawffi/alt/test/test_ffitype.py
rename from pypy/module/_ffi/test/test_ffitype.py
rename to pypy/module/_rawffi/alt/test/test_ffitype.py
--- a/pypy/module/_ffi/test/test_ffitype.py
+++ b/pypy/module/_rawffi/alt/test/test_ffitype.py
@@ -1,21 +1,21 @@
-from pypy.module._ffi.test.test_funcptr import BaseAppTestFFI
+from pypy.module._rawffi.alt.test.test_funcptr import BaseAppTestFFI
 
 class AppTestFFIType(BaseAppTestFFI):
 
     def test_simple_types(self):
-        from _ffi import types
+        from _rawffi.alt import types
         assert str(types.sint) == "<ffi type sint>"
         assert str(types.uint) == "<ffi type uint>"
         assert types.sint.name == 'sint'
         assert types.uint.name == 'uint'
         
     def test_sizeof(self):
-        from _ffi import types
+        from _rawffi.alt import types
         assert types.sbyte.sizeof() == 1
         assert types.sint.sizeof() == 4
 
     def test_typed_pointer(self):
-        from _ffi import types
+        from _rawffi.alt import types
         intptr = types.Pointer(types.sint) # create a typed pointer to sint
         assert intptr.deref_pointer() is types.sint
         assert str(intptr) == '<ffi type (pointer to sint)>'
@@ -23,7 +23,7 @@
         raises(TypeError, "types.Pointer(42)")
 
     def test_pointer_identity(self):
-        from _ffi import types
+        from _rawffi.alt import types
         x = types.Pointer(types.slong)
         y = types.Pointer(types.slong)
         z = types.Pointer(types.char)
@@ -31,7 +31,7 @@
         assert x is not z
 
     def test_char_p_cached(self):
-        from _ffi import types
+        from _rawffi.alt import types
         x = types.Pointer(types.char)
         assert x is types.char_p
         x = types.Pointer(types.unichar)
diff --git a/pypy/module/_ffi/test/test_funcptr.py b/pypy/module/_rawffi/alt/test/test_funcptr.py
rename from pypy/module/_ffi/test/test_funcptr.py
rename to pypy/module/_rawffi/alt/test/test_funcptr.py
--- a/pypy/module/_ffi/test/test_funcptr.py
+++ b/pypy/module/_rawffi/alt/test/test_funcptr.py
@@ -7,7 +7,7 @@
 import sys, py
 
 class BaseAppTestFFI(object):
-    spaceconfig = dict(usemodules=('_ffi', '_rawffi'))
+    spaceconfig = dict(usemodules=('_rawffi',))
 
     @classmethod
     def prepare_c_example(cls):
@@ -62,17 +62,17 @@
         cls.w_f_12_34_plus_56_78 = space.wrap(f_result)
 
     def test_libload(self):
-        import _ffi
-        _ffi.CDLL(self.libc_name)
+        import _rawffi.alt
+        _rawffi.alt.CDLL(self.libc_name)
 
     def test_libload_fail(self):
-        import _ffi
-        raises(OSError, _ffi.CDLL, "xxxxx_this_name_does_not_exist_xxxxx")
+        import _rawffi.alt
+        raises(OSError, _rawffi.alt.CDLL, "xxxxx_this_name_does_not_exist_xxxxx")
 
     def test_libload_None(self):
         if self.iswin32:
             skip("unix specific")
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         # this should return *all* loaded libs, dlopen(NULL)
         dll = CDLL(None)
         # libm should be loaded
@@ -80,20 +80,20 @@
         assert res == 1.0
 
     def test_callfunc(self):
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libm = CDLL(self.libm_name)
         pow = libm.getfunc('pow', [types.double, types.double], types.double)
         assert pow(2, 3) == 8
 
     def test_getaddr(self):
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libm = CDLL(self.libm_name)
         pow = libm.getfunc('pow', [types.double, types.double], types.double)
         assert pow.getaddr() == self.pow_addr
 
     def test_getaddressindll(self):
         import sys
-        from _ffi import CDLL
+        from _rawffi.alt import CDLL
         libm = CDLL(self.libm_name)
         pow_addr = libm.getaddressindll('pow')
         fff = sys.maxint*2-1
@@ -102,7 +102,7 @@
         assert pow_addr == self.pow_addr & fff
 
     def test_func_fromaddr(self):
-        from _ffi import CDLL, types, FuncPtr
+        from _rawffi.alt import CDLL, types, FuncPtr
         libm = CDLL(self.libm_name)
         pow_addr = libm.getaddressindll('pow')
         pow = FuncPtr.fromaddr(pow_addr, 'pow', [types.double, types.double],
@@ -117,7 +117,7 @@
             }
         """
         import sys
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy', [types.sint, types.sint], types.sint)
         assert sum_xy(30, 12) == 42
@@ -129,7 +129,7 @@
             DLLEXPORT void set_dummy(int val) { dummy = val; }
             DLLEXPORT int get_dummy() { return dummy; }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         set_dummy = libfoo.getfunc('set_dummy', [types.sint], types.void)
         get_dummy = libfoo.getfunc('get_dummy', [], types.sint)
@@ -144,7 +144,7 @@
             DLLEXPORT int* get_dummy_ptr() { return &dummy; }
             DLLEXPORT void set_val_to_ptr(int* ptr, int val) { *ptr = val; }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt 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)
@@ -163,7 +163,7 @@
             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
+        from _rawffi.alt import CDLL, types
 
         class MyPointerWrapper(object):
             def __init__(self, value):
@@ -197,7 +197,7 @@
                 return len;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         import _rawffi
         libfoo = CDLL(self.libfoo_name)
         mystrlen = libfoo.getfunc('mystrlen', [types.char_p], types.slong)
@@ -223,7 +223,7 @@
                 return len;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         import _rawffi
         libfoo = CDLL(self.libfoo_name)
         mystrlen = libfoo.getfunc('mystrlen_u', [types.unichar_p], types.slong)
@@ -247,7 +247,7 @@
                 return s;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         import _rawffi
         libfoo = CDLL(self.libfoo_name)
         do_nothing = libfoo.getfunc('do_nothing', [types.char_p], types.char_p)
@@ -264,7 +264,7 @@
             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
+        from _rawffi.alt import CDLL, types
 
         libfoo = CDLL(self.libfoo_name)
         intptr = types.Pointer(types.sint)
@@ -283,7 +283,7 @@
             DLLEXPORT long is_null_ptr(void* ptr) { return ptr == NULL; }
         """
         import sys
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         is_null_ptr = libfoo.getfunc('is_null_ptr', [types.void_p], types.ulong)
         assert not is_null_ptr(sys.maxint+1)
@@ -296,7 +296,7 @@
             }
         """
         import sys
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_ul', [types.ulong, types.ulong],
                                 types.ulong)
@@ -313,7 +313,7 @@
                 return x+y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_us', [types.ushort, types.ushort],
                                 types.ushort)
@@ -327,7 +327,7 @@
                 return x+y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_us', [types.ubyte, types.ubyte],
                                 types.ubyte)
@@ -342,7 +342,7 @@
             }
         """
         import sys
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         maxint32 = 2147483647
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_ui', [types.uint, types.uint],
@@ -357,7 +357,7 @@
                 return x+y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_sb', [types.sbyte, types.sbyte],
                                 types.sbyte)
@@ -371,7 +371,7 @@
                 return x - ('a'-'A');
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         my_toupper = libfoo.getfunc('my_toupper', [types.char],
                                     types.char)
@@ -385,7 +385,7 @@
                 return x + y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_wc', [types.unichar, types.unichar],
                                 types.unichar)
@@ -400,7 +400,7 @@
                 return x+y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy_float', [types.float, types.float],
                                 types.float)
@@ -415,7 +415,7 @@
                 return x+y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         maxint32 = 2147483647 # we cannot really go above maxint on 64 bits
                               # (and we would not test anything, as there long
                               # is the same as long long)
@@ -437,7 +437,7 @@
                 return x+y;
             }
         """
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         maxint64 = 9223372036854775807 # maxint64+1 does not fit into a
                                        # longlong, but it does into a
                                        # ulonglong
@@ -464,7 +464,7 @@
                 return p.x + p.y;
             }
         """
-        from _ffi import CDLL, types, _StructDescr, Field
+        from _rawffi.alt import CDLL, types, _StructDescr, Field
         Point = _StructDescr('Point', [
                 Field('x', types.slong),
                 Field('y', types.slong),
@@ -487,7 +487,7 @@
                 return p;
             }
         """
-        from _ffi import CDLL, types, _StructDescr, Field
+        from _rawffi.alt import CDLL, types, _StructDescr, Field
         Point = _StructDescr('Point', [
                 Field('x', types.slong),
                 Field('y', types.slong),
@@ -500,9 +500,9 @@
         assert p.getfield('x') == 12
         assert p.getfield('y') == 34
 
-    # XXX: support for _rawffi structures should be killed as soon as we
-    # implement ctypes.Structure on top of _ffi. In the meantime, we support
-    # both
+    # XXX: long ago the plan was to kill _rawffi structures in favor of
+    # _rawffi.alt structures.  The plan never went anywhere, so we're
+    # stuck with both.
     def test_byval_argument__rawffi(self):
         """
             // defined above
@@ -510,7 +510,7 @@
             DLLEXPORT long sum_point(struct Point p);
         """
         import _rawffi
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         POINT = _rawffi.Structure([('x', 'l'), ('y', 'l')])
         ffi_point = POINT.get_ffi_type()
         libfoo = CDLL(self.libfoo_name)
@@ -529,7 +529,7 @@
             DLLEXPORT struct Point make_point(long x, long y);
         """
         import _rawffi
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         POINT = _rawffi.Structure([('x', 'l'), ('y', 'l')])
         ffi_point = POINT.get_ffi_type()
         libfoo = CDLL(self.libfoo_name)
@@ -542,23 +542,23 @@
 
 
     def test_TypeError_numargs(self):
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         sum_xy = libfoo.getfunc('sum_xy', [types.sint, types.sint], types.sint)
         raises(TypeError, "sum_xy(1, 2, 3)")
         raises(TypeError, "sum_xy(1)")
 
     def test_TypeError_voidarg(self):
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         raises(TypeError, "libfoo.getfunc('sum_xy', [types.void], types.sint)")
 
     def test_OSError_loading(self):
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         raises(OSError, "CDLL('I do not exist')")
 
     def test_AttributeError_missing_function(self):
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         raises(AttributeError, "libfoo.getfunc('I_do_not_exist', [], types.void)")
         if self.iswin32:
@@ -569,7 +569,7 @@
     def test_calling_convention1(self):
         if not self.iswin32:
             skip("windows specific")
-        from _ffi import WinDLL, types
+        from _rawffi.alt import WinDLL, types
         libm = WinDLL(self.libm_name)
         pow = libm.getfunc('pow', [types.double, types.double], types.double)
         try:
@@ -582,7 +582,7 @@
     def test_calling_convention2(self):
         if not self.iswin32:
             skip("windows specific")
-        from _ffi import WinDLL, types
+        from _rawffi.alt import WinDLL, types
         kernel = WinDLL('Kernel32.dll')
         sleep = kernel.getfunc('Sleep', [types.uint], types.void)
         sleep(10)
@@ -590,7 +590,7 @@
     def test_calling_convention3(self):
         if not self.iswin32:
             skip("windows specific")
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         wrong_kernel = CDLL('Kernel32.dll')
         wrong_sleep = wrong_kernel.getfunc('Sleep', [types.uint], types.void)
         try:
@@ -603,7 +603,7 @@
     def test_func_fromaddr2(self):
         if not self.iswin32:
             skip("windows specific")
-        from _ffi import CDLL, types, FuncPtr
+        from _rawffi.alt import CDLL, types, FuncPtr
         from _rawffi import FUNCFLAG_STDCALL
         libm = CDLL(self.libm_name)
         pow_addr = libm.getaddressindll('pow')
@@ -619,7 +619,7 @@
     def test_func_fromaddr3(self):
         if not self.iswin32:
             skip("windows specific")
-        from _ffi import WinDLL, types, FuncPtr
+        from _rawffi.alt import WinDLL, types, FuncPtr
         from _rawffi import FUNCFLAG_STDCALL
         kernel = WinDLL('Kernel32.dll')
         sleep_addr = kernel.getaddressindll('Sleep')
@@ -636,7 +636,7 @@
         """
         if not self.iswin32:
             skip("windows specific")
-        from _ffi import CDLL, types
+        from _rawffi.alt import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         f_name = libfoo.getfunc('AAA_first_ordinal_function', [], types.sint)
         f_ordinal = libfoo.getfunc(1, [], types.sint)
diff --git a/pypy/module/_ffi/test/test_struct.py b/pypy/module/_rawffi/alt/test/test_struct.py
rename from pypy/module/_ffi/test/test_struct.py
rename to pypy/module/_rawffi/alt/test/test_struct.py
--- a/pypy/module/_ffi/test/test_struct.py
+++ b/pypy/module/_rawffi/alt/test/test_struct.py
@@ -1,7 +1,7 @@
 from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.module._ffi.interp_ffitype import app_types, W_FFIType
-from pypy.module._ffi.interp_struct import compute_size_and_alignement, W_Field
-from pypy.module._ffi.test.test_funcptr import BaseAppTestFFI
+from pypy.module._rawffi.alt.interp_ffitype import app_types, W_FFIType
+from pypy.module._rawffi.alt.interp_struct import compute_size_and_alignement, W_Field
+from pypy.module._rawffi.alt.test.test_funcptr import BaseAppTestFFI
 
 
 class TestStruct(object):
@@ -69,7 +69,7 @@
         cls.w_runappdirect = cls.space.wrap(cls.runappdirect)
         
     def test__StructDescr(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.slong),
@@ -80,7 +80,7 @@
         assert descr.ffitype.name == 'struct foo'
 
     def test_alignment(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.sbyte),
@@ -92,7 +92,7 @@
         assert fields[1].offset == longsize # aligned to WORD
 
     def test_missing_field(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.slong),
@@ -106,7 +106,7 @@
     def test_unknown_type(self):
         if self.runappdirect:
             skip('cannot use self.dummy_type with -A')
-        from _ffi import _StructDescr, Field
+        from _rawffi.alt import _StructDescr, Field
         fields = [
             Field('x', self.dummy_type),
             ]
@@ -116,7 +116,7 @@
         raises(TypeError, "struct.setfield('x', 42)")
 
     def test_getfield_setfield(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.slong),
@@ -133,7 +133,7 @@
 
     def test_getfield_setfield_signed_types(self):
         import sys
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('sbyte', types.sbyte),
@@ -156,7 +156,7 @@
 
     def test_getfield_setfield_unsigned_types(self):
         import sys
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('ubyte', types.ubyte),
@@ -188,7 +188,7 @@
     
     def test_getfield_setfield_longlong(self):
         import sys
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('slonglong', types.slonglong),
@@ -205,7 +205,7 @@
 
     def test_getfield_setfield_float(self):
         import sys
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.double),
@@ -219,7 +219,7 @@
 
     def test_getfield_setfield_singlefloat(self):
         import sys
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.float),
@@ -237,7 +237,7 @@
         assert mem == [123.5]
 
     def test_define_fields(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.slong),
@@ -255,7 +255,7 @@
         raises(ValueError, "descr.define_fields(fields)")
 
     def test_pointer_to_incomplete_struct(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         fields = [
             Field('x', types.slong),
@@ -271,7 +271,7 @@
         assert types.Pointer(descr.ffitype) is foo_p
 
     def test_nested_structure(self):
-        from _ffi import _StructDescr, Field, types
+        from _rawffi.alt import _StructDescr, Field, types
         longsize = types.slong.sizeof()
         foo_fields = [
             Field('x', types.slong),
@@ -310,7 +310,7 @@
 
 
     def test_compute_shape(self):
-        from _ffi import Structure, Field, types
+        from _rawffi.alt import Structure, Field, types
         class Point(Structure):
             _fields_ = [
                 Field('x', types.slong),
diff --git a/pypy/module/_ffi/test/test_type_converter.py b/pypy/module/_rawffi/alt/test/test_type_converter.py
rename from pypy/module/_ffi/test/test_type_converter.py
rename to pypy/module/_rawffi/alt/test/test_type_converter.py
--- a/pypy/module/_ffi/test/test_type_converter.py
+++ b/pypy/module/_rawffi/alt/test/test_type_converter.py
@@ -1,8 +1,8 @@
 import sys
 from rpython.rlib.rarithmetic import r_uint, r_singlefloat, r_longlong, r_ulonglong
 from rpython.rlib.libffi import IS_32_BIT
-from pypy.module._ffi.interp_ffitype import app_types, descr_new_pointer
-from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
+from pypy.module._rawffi.alt.interp_ffitype import app_types, descr_new_pointer
+from pypy.module._rawffi.alt.type_converter import FromAppLevelConverter, ToAppLevelConverter
 
 class DummyFromAppLevelConverter(FromAppLevelConverter):
 
@@ -29,7 +29,7 @@
 
 
 class TestFromAppLevel(object):
-    spaceconfig = dict(usemodules=('_ffi',))
+    spaceconfig = dict(usemodules=('_rawffi',))
 
     def setup_class(cls):
         converter = DummyFromAppLevelConverter(cls.space)
@@ -104,12 +104,12 @@
     def test__as_ffi_pointer_(self):
         space = self.space
         w_MyPointerWrapper = space.appexec([], """():
-            import _ffi
+            from _rawffi.alt import types
             class MyPointerWrapper(object):
                 def __init__(self, value):
                     self.value = value
                 def _as_ffi_pointer_(self, ffitype):
-                    assert ffitype is _ffi.types.void_p
+                    assert ffitype is types.void_p
                     return self.value
 
             return MyPointerWrapper
@@ -151,7 +151,7 @@
 
 
 class TestToAppLevel(object):
-    spaceconfig = dict(usemodules=('_ffi',))
+    spaceconfig = dict(usemodules=('_rawffi',))
 
     def setup_class(cls):
         converter = DummyToAppLevelConverter(cls.space)
diff --git a/pypy/module/_ffi/test/test_ztranslation.py b/pypy/module/_rawffi/alt/test/test_ztranslation.py
rename from pypy/module/_ffi/test/test_ztranslation.py
rename to pypy/module/_rawffi/alt/test/test_ztranslation.py
--- a/pypy/module/_ffi/test/test_ztranslation.py
+++ b/pypy/module/_rawffi/alt/test/test_ztranslation.py
@@ -1,4 +1,4 @@
-from pypy.objspace.fake.checkmodule import checkmodule
-
-def test__ffi_translates():
-    checkmodule('_ffi', '_rawffi')
+from pypy.objspace.fake.checkmodule import checkmodule
+
+def test__ffi_translates():
+    checkmodule('_rawffi')
diff --git a/pypy/module/_ffi/type_converter.py b/pypy/module/_rawffi/alt/type_converter.py
rename from pypy/module/_ffi/type_converter.py
rename to pypy/module/_rawffi/alt/type_converter.py
--- a/pypy/module/_ffi/type_converter.py
+++ b/pypy/module/_rawffi/alt/type_converter.py
@@ -3,7 +3,7 @@
 from rpython.rlib.rarithmetic import r_uint
 from pypy.interpreter.error import operationerrfmt, OperationError
 from pypy.module._rawffi.structure import W_StructureInstance, W_Structure
-from pypy.module._ffi.interp_ffitype import app_types
+from pypy.module._rawffi.alt.interp_ffitype import app_types
 
 class FromAppLevelConverter(object):
     """
@@ -17,7 +17,7 @@
         self.space = space
 
     def unwrap_and_do(self, w_ffitype, w_obj):
-        from pypy.module._ffi.interp_struct import W__StructInstance
+        from pypy.module._rawffi.alt.interp_struct import W__StructInstance
         space = self.space
         if w_ffitype.is_longlong():
             # note that we must check for longlong first, because either
@@ -194,7 +194,7 @@
         self.space = space
 
     def do_and_wrap(self, w_ffitype):
-        from pypy.module._ffi.interp_struct import W__StructDescr
+        from pypy.module._rawffi.alt.interp_struct import W__StructDescr
         space = self.space
         if w_ffitype.is_longlong():
             # note that we must check for longlong first, because either
diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -311,10 +311,7 @@
         raise NotImplementedError
 
     def descr_get_ffi_type(self, space):
-        # XXX: this assumes that you have the _ffi module enabled. In the long
-        # term, probably we will move the code for build structures and arrays
-        # from _rawffi to _ffi
-        from pypy.module._ffi.interp_ffitype import W_FFIType
+        from pypy.module._rawffi.alt.interp_ffitype import W_FFIType
         return W_FFIType('<unknown>', self.get_basic_ffi_type(), self)
 
     @unwrap_spec(n=int)
diff --git a/pypy/module/cppyy/test/test_crossing.py b/pypy/module/cppyy/test/test_crossing.py
--- a/pypy/module/cppyy/test/test_crossing.py
+++ b/pypy/module/cppyy/test/test_crossing.py
@@ -65,7 +65,7 @@
     return str(pydname)
 
 class AppTestCrossing(AppTestCpythonExtensionBase):
-    spaceconfig = dict(usemodules=['cpyext', 'cppyy', 'thread', '_rawffi', '_ffi',
+    spaceconfig = dict(usemodules=['cpyext', 'cppyy', 'thread', '_rawffi',
                                    'array', 'itertools', 'rctime', 'binascii'])
 
     def setup_class(cls):
diff --git a/pypy/module/cpyext/test/test_ztranslation.py b/pypy/module/cpyext/test/test_ztranslation.py
--- a/pypy/module/cpyext/test/test_ztranslation.py
+++ b/pypy/module/cpyext/test/test_ztranslation.py
@@ -1,4 +1,4 @@
 from pypy.objspace.fake.checkmodule import checkmodule
 
 def test_cpyext_translates():
-    checkmodule('cpyext', '_ffi')
+    checkmodule('cpyext')
diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -105,7 +105,7 @@
         else:
             rest = ''
         if modname in ['pypyjit', 'signal', 'micronumpy', 'math', 'exceptions',
-                       'imp', 'sys', 'array', '_ffi', 'itertools', 'operator',
+                       'imp', 'sys', 'array', 'itertools', 'operator',
                        'posix', '_socket', '_sre', '_lsprof', '_weakref',
                        '__pypy__', 'cStringIO', '_collections', 'struct',
                        'mmap', 'marshal', '_codecs', 'rctime', 'cppyy',
diff --git a/pypy/module/test_lib_pypy/test_grp_extra.py b/pypy/module/test_lib_pypy/test_grp_extra.py
--- a/pypy/module/test_lib_pypy/test_grp_extra.py
+++ b/pypy/module/test_lib_pypy/test_grp_extra.py
@@ -2,7 +2,7 @@
 
 
 class AppTestGrp:
-    spaceconfig = dict(usemodules=('binascii', '_ffi', '_rawffi', 'itertools'))
+    spaceconfig = dict(usemodules=('binascii', '_rawffi', 'itertools'))
 
     def setup_class(cls):
         cls.w_grp = import_lib_pypy(cls.space, 'grp',
diff --git a/pypy/module/test_lib_pypy/test_os_wait.py b/pypy/module/test_lib_pypy/test_os_wait.py
--- a/pypy/module/test_lib_pypy/test_os_wait.py
+++ b/pypy/module/test_lib_pypy/test_os_wait.py
@@ -10,7 +10,7 @@
 
 class AppTestOsWait:
 
-    spaceconfig = dict(usemodules=('_ffi', '_rawffi', 'itertools'))
+    spaceconfig = dict(usemodules=('_rawffi', 'itertools'))
 
     def setup_class(cls):
         if not hasattr(os, "fork"):
diff --git a/pypy/module/test_lib_pypy/test_pwd.py b/pypy/module/test_lib_pypy/test_pwd.py
--- a/pypy/module/test_lib_pypy/test_pwd.py
+++ b/pypy/module/test_lib_pypy/test_pwd.py
@@ -1,7 +1,7 @@
 import py, sys
 
 class AppTestPwd:
-    spaceconfig = dict(usemodules=('_ffi', '_rawffi', 'itertools', 'binascii'))
+    spaceconfig = dict(usemodules=('_rawffi', 'itertools', 'binascii'))
 
     def setup_class(cls):
         if sys.platform == 'win32':
diff --git a/pypy/module/test_lib_pypy/test_resource.py b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -9,7 +9,7 @@
 
 class AppTestResource:
 
-    spaceconfig = dict(usemodules=('_ffi', '_rawffi', 'itertools'))
+    spaceconfig = dict(usemodules=('_rawffi', 'itertools'))
 
     def setup_class(cls):
         rebuild.rebuild_one('resource.ctc.py')
diff --git a/pypy/tool/pypyjit.py b/pypy/tool/pypyjit.py
--- a/pypy/tool/pypyjit.py
+++ b/pypy/tool/pypyjit.py
@@ -37,7 +37,7 @@
 config.objspace.usemodules._sre = False
 config.objspace.usemodules._lsprof = False
 #
-config.objspace.usemodules._ffi = False
+config.objspace.usemodules._rawffi = False
 config.objspace.usemodules.micronumpy = False
 #
 set_pypy_opt_level(config, level='jit')


More information about the pypy-commit mailing list