Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_type_table(input, expected_output, included=None):
ffi = FFI()
if included:
ffi1 = FFI()
ffi1.cdef(included)
ffi.include(ffi1)
ffi.cdef(input)
recomp = recompiler.Recompiler(ffi, 'testmod')
recomp.collect_type_table()
assert ''.join(map(str, recomp.cffi_types)) == expected_output
def check_type_table(input, expected_output, included=None):
ffi = FFI()
if included:
ffi1 = FFI()
ffi1.cdef(included)
ffi.include(ffi1)
ffi.cdef(input)
recomp = recompiler.Recompiler(ffi, 'testmod')
recomp.collect_type_table()
assert ''.join(map(str, recomp.cffi_types)) == expected_output
def check_type_table(input, expected_output, included=None):
ffi = FFI()
if included:
ffi1 = FFI()
ffi1.cdef(included)
ffi.include(ffi1)
ffi.cdef(input)
recomp = recompiler.Recompiler(ffi, 'testmod')
recomp.collect_type_table()
assert ''.join(map(str, recomp.cffi_types)) == expected_output
def cffi(module_name, c_header):
"""Generates CFFI C source for given C header"""
ffibuilder = FFI()
# Use the header twice:-
ffibuilder.cdef(c_header) # once for the declaration of exported code...
recompiler = Recompiler(ffibuilder, module_name, target_is_python=False)
recompiler.collect_type_table()
recompiler.collect_step_tables()
f = io.StringIO()
# ... and once for the internal declaration.
# In this case, "stdbool" needs to be added
header = '#include "stdbool.h"\n' + c_header
recompiler.write_source_to_f(f, header)
return f.getvalue()