How to use the cffi.recompiler.make_py_source function in cffi

To help you get started, we’ve selected a few cffi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holzschu / python3_ios / extraPackages / cffi-1.11.5 / testing / cffi1 / test_dlopen.py View on Github external
def test_enum():
    ffi = FFI()
    ffi.cdef("enum myenum_e { AA, BB, CC=-42 };")
    target = udir.join('test_enum.py')
    make_py_source(ffi, 'test_enum', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github JarryShaw / f2format / vendor / pypy / extra_tests / cffi_tests / cffi1 / test_dlopen.py View on Github external
def test_struct():
    ffi = FFI()
    ffi.cdef("struct foo_s { int a; signed char b[]; }; struct bar_s;")
    target = udir.join('test_struct.py')
    make_py_source(ffi, 'test_struct', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github JarryShaw / f2format / vendor / pypy / extra_tests / cffi_tests / cffi1 / test_dlopen.py View on Github external
def test_simple():
    ffi = FFI()
    ffi.cdef("int close(int); static const int BB = 42; extern int somevar;")
    target = udir.join('test_simple.py')
    make_py_source(ffi, 'test_simple', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github JarryShaw / f2format / vendor / pypy / extra_tests / cffi_tests / cffi1 / test_dlopen.py View on Github external
def test_include():
    ffi = FFI()
    ffi.cdef("#define ABC 123")
    ffi.set_source('test_include', None)
    target = udir.join('test_include.py')
    make_py_source(ffi, 'test_include', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend

ffi = _cffi_backend.FFI('test_include',
    _version = 0x2601,
    _types = b'',
    _globals = (b'\xFF\xFF\xFF\x1FABC',123,),
)
"""
    #
    ffi2 = FFI()
    ffi2.include(ffi)
    target2 = udir.join('test2_include.py')
    make_py_source(ffi2, 'test2_include', str(target2))
    assert target2.read() == r"""# auto-generated file
import _cffi_backend
github holzschu / python3_ios / extraPackages / cffi-1.11.5 / testing / cffi1 / test_dlopen.py View on Github external
def test_negative_constant():
    ffi = FFI()
    ffi.cdef("static const int BB = -42;")
    target = udir.join('test_negative_constant.py')
    make_py_source(ffi, 'test_negative_constant', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github mozillazg / pypy / extra_tests / cffi_tests / cffi1 / test_dlopen.py View on Github external
def test_simple():
    ffi = FFI()
    ffi.cdef("int close(int); static const int BB = 42; int somevar;")
    target = udir.join('test_simple.py')
    make_py_source(ffi, 'test_simple', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github holzschu / python3_ios / extraPackages / cffi-1.11.5 / testing / cffi1 / test_dlopen.py View on Github external
def test_bitfield():
    ffi = FFI()
    ffi.cdef("struct foo_s { int y:10; short x:5; };")
    target = udir.join('test_bitfield.py')
    make_py_source(ffi, 'test_bitfield', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github JarryShaw / f2format / vendor / pypy / extra_tests / cffi_tests / cffi1 / test_dlopen.py View on Github external
def test_global_constant():
    ffi = FFI()
    ffi.cdef("static const long BB; static const float BF = 12;")
    target = udir.join('test_valid_global_constant.py')
    make_py_source(ffi, 'test_valid_global_constant', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend
github scalyr / scalyr-agent-2 / scalyr_agent / third_party_tls / cffi / setuptools_ext.py View on Github external
def generate_mod(py_file):
        log.info("generating cffi module %r" % py_file)
        mkpath(os.path.dirname(py_file))
        updated = recompiler.make_py_source(ffi, module_name, py_file)
        if not updated:
            log.info("already up-to-date")
github cloudera / hue / desktop / core / ext-py / cffi-1.5.2 / cffi / setuptools_ext.py View on Github external
def generate_mod(py_file):
        log.info("generating cffi module %r" % py_file)
        mkpath(os.path.dirname(py_file))
        updated = recompiler.make_py_source(ffi, module_name, py_file)
        if not updated:
            log.info("already up-to-date")