コード例 #1
0
ファイル: test_rffi.py プロジェクト: zcxowwww/pypy
    def test_rffi_sizeof(self):
        try:
            import ctypes
        except ImportError:
            py.test.skip("Cannot test without ctypes")
        cache = {
            lltype.Signed: ctypes.c_long,
            lltype.Unsigned: ctypes.c_ulong,
            lltype.UniChar: ctypes.c_wchar,
            lltype.Char: ctypes.c_ubyte,
            DOUBLE: ctypes.c_double,
            FLOAT: ctypes.c_float,
            SIGNEDCHAR: ctypes.c_byte,
            UCHAR: ctypes.c_ubyte,
            SHORT: ctypes.c_short,
            USHORT: ctypes.c_ushort,
            INT: ctypes.c_int,
            UINT: ctypes.c_uint,
            LONG: ctypes.c_long,
            ULONG: ctypes.c_ulong,
            LONGLONG: ctypes.c_longlong,
            ULONGLONG: ctypes.c_ulonglong,
            SIZE_T: ctypes.c_size_t,
        }

        for ll, ctp in cache.items():
            assert sizeof(ll) == ctypes.sizeof(ctp)
            assert sizeof(lltype.Typedef(ll, 'test')) == sizeof(ll)
        assert not size_and_sign(lltype.Signed)[1]
        assert size_and_sign(lltype.Char) == (1, True)
        assert size_and_sign(lltype.UniChar)[1]
        assert size_and_sign(UINT)[1]
        assert not size_and_sign(INT)[1]
コード例 #2
0
ファイル: api.py プロジェクト: juokaz/pypy
from rpython.rlib.entrypoint import entrypoint_lowlevel
from rpython.rlib.rposix import is_valid_fd, validate_fd
from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib.objectmodel import specialize
from rpython.rlib.exports import export_struct
from pypy.module import exceptions
from pypy.module.exceptions import interp_exceptions
# CPython 2.4 compatibility
from py.builtin import BaseException
from rpython.tool.sourcetools import func_with_new_name
from rpython.rtyper.lltypesystem.lloperation import llop

DEBUG_WRAPPER = True

# update these for other platforms
Py_ssize_t = lltype.Typedef(rffi.SSIZE_T, 'Py_ssize_t')
Py_ssize_tP = rffi.CArrayPtr(Py_ssize_t)
size_t = rffi.ULONG
ADDR = lltype.Signed

pypydir = py.path.local(pypydir)
include_dir = pypydir / 'module' / 'cpyext' / 'include'
source_dir = pypydir / 'module' / 'cpyext' / 'src'
translator_c_dir = py.path.local(cdir)
include_dirs = [
    include_dir,
    translator_c_dir,
    udir,
    ]

class CConfig: