From a579c6906f9f7fe6e19c70a44f74c0d2148c8085 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 5 Aug 2016 18:23:04 +0200 Subject: Bindings example update Signed-off-by: Szczepan Zalega --- README.md | 9 ++++++--- python_bindings_example.py | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5a3df26..4e3a4e6 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,16 @@ get_string = ffi.string def get_library(): fp = 'NK_C_API.h' # path to C API header - declarations = [] + declarations = [] with open(fp, 'r') as f: declarations = f.readlines() - for declaration in declarations: - if 'extern' in declaration and not '"C"' in declaration: + a = iter(declarations) + for declaration in a: + if declaration.startswith('extern') and not '"C"' in declaration: declaration = declaration.replace('extern', '').strip() + while not ';' in declaration: + declaration += (next(a)).strip() # print(declaration) ffi.cdef(declaration) diff --git a/python_bindings_example.py b/python_bindings_example.py index a690874..31cf285 100755 --- a/python_bindings_example.py +++ b/python_bindings_example.py @@ -12,9 +12,12 @@ def get_library(): with open(fp, 'r') as f: declarations = f.readlines() - for declaration in declarations: - if 'extern' in declaration and not '"C"' in declaration: + a = iter(declarations) + for declaration in a: + if declaration.startswith('extern') and not '"C"' in declaration: declaration = declaration.replace('extern', '').strip() + while not ';' in declaration: + declaration += (next(a)).strip() # print(declaration) ffi.cdef(declaration) -- cgit v1.2.3