[pypy-commit] pypy ffi-backend: nonstandard_integer_types().
arigo
noreply at buildbot.pypy.org
Wed Jun 20 12:29:10 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r55725:f8d25c49148a
Date: 2012-06-19 19:32 +0200
http://bitbucket.org/pypy/pypy/changeset/f8d25c49148a/
Log: nonstandard_integer_types().
diff --git a/pypy/module/_ffi_backend/__init__.py b/pypy/module/_ffi_backend/__init__.py
--- a/pypy/module/_ffi_backend/__init__.py
+++ b/pypy/module/_ffi_backend/__init__.py
@@ -5,5 +5,7 @@
appleveldefs = {
}
interpleveldefs = {
+ 'nonstandard_integer_types':
+ 'interp_extra_types.nonstandard_integer_types',
'load_library': 'interp_library.load_library',
}
diff --git a/pypy/module/_ffi_backend/interp_extra_types.py b/pypy/module/_ffi_backend/interp_extra_types.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_ffi_backend/interp_extra_types.py
@@ -0,0 +1,28 @@
+from pypy.rpython.lltypesystem import lltype, rffi
+
+
+UNSIGNED = 0x1000
+
+TYPES = [
+ ("int8_t", 1),
+ ("uint8_t", 1 | UNSIGNED),
+ ("int16_t", 2),
+ ("uint16_t", 2 | UNSIGNED),
+ ("int32_t", 4),
+ ("uint32_t", 4 | UNSIGNED),
+ ("int64_t", 8),
+ ("uint64_t", 8 | UNSIGNED),
+
+ ("intptr_t", rffi.sizeof(rffi.INTPTR_T)),
+ ("uintptr_t", rffi.sizeof(rffi.UINTPTR_T) | UNSIGNED),
+ ("ptrdiff_t", rffi.sizeof(rffi.INTPTR_T)), # XXX can it be different?
+ ("size_t", rffi.sizeof(rffi.SIZE_T) | UNSIGNED),
+ ("ssize_t", rffi.sizeof(rffi.SSIZE_T)),
+]
+
+
+def nonstandard_integer_types(space):
+ w_d = space.newdict()
+ for name, size in TYPES:
+ space.setitem(w_d, space.wrap(name), space.wrap(size))
+ return w_d
diff --git a/pypy/module/_ffi_backend/test/test_c.py b/pypy/module/_ffi_backend/test/test_c.py
--- a/pypy/module/_ffi_backend/test/test_c.py
+++ b/pypy/module/_ffi_backend/test/test_c.py
@@ -36,7 +36,7 @@
assert repr(x).startswith("<clibrary '")
def test_nonstandard_integer_types(self):
- d = nonstandard_integer_types()
+ d = self.b.nonstandard_integer_types()
assert type(d) is dict
assert 'char' not in d
assert d['size_t'] in (0x1004, 0x1008)
More information about the pypy-commit
mailing list