I need to write Python2 wrapper for proprietary library, consists of few .h files (I made one big), bunch of .dll and one .lib file to link all this stuff.
I think I need API level, because of all this `typedef' in .h files
Script to create wrapper: build_wrapper.py
from cffi import FFI
import setuptools
ffibuilder = FFI()
ffibuilder.set_unicode(enabled_flag=True)
with open(os.path.join(curdir, 'include', 'ScadWrapper.h'), 'r') as f:
source = f.read()
ffibuilder.set_source('_wrapper', source,
extra_link_args=[r'C:\Documents\python\pyScadApi\pyScadApi\include\SCADAPIX.lib', ],
source_extension='.cpp')
if __name__ == '__main__':
ffibuilder.compile(verbose=True)
This runs without errors Creating library .\Release\_wrapper.lib and object .\Release\_wrapper.exp
But, for example,
from _wrapper import ffi, lib
lp_api = ffi.new('ScadAPI *')
r = lib.ApiCreate(lp_api)
Fails with
lp_api = ffi.new('ScadAPI *')
ffi.error: undefined type name
ScadAPI *
ScadAPI
defined as
struct APIHandle_tag;
typedef APIHandle_tag * ScadAPI;
in ScadWrapper.h