ctypeslib icon indicating copy to clipboard operation
ctypeslib copied to clipboard

Use of "-r" option makes clang2py crash

Open FloSim82 opened this issue 3 years ago • 1 comments

Let say you have the following header api/api_version.h you want to parse:

#define API_NAME  "this is a test"
#define API_VER_MAJOR  3
#define API_VER_MINOR  1
#define API_VER_PATCH  0

When using command clang2py -k emstu api/api_version.h, we got the following:

(...)
API_NAME  "this is a test" # macro
API_VER_MAJOR = 3 # macro
API_VER_MINOR = 1 # macro
API_VER_PATCH = 0 # macro
__all__ = \
    ['API_NAME','API_VER_MAJOR', 'API_VER_MINOR', 'API_VER_PATCH']

But if using command clang2py -k emstu -r "API_VER_" api/api_version.h, we got an empty issue. Of course, I tried with several derivations of the regex ("$API_VER_.*", etc.)

Do you have any clue? Thanks

FloSim82 avatar Mar 14 '22 11:03 FloSim82

I was about to post about a similar issue. The -r option is broken. Best I could tell it's due to map() returning a map object and not a list. The code then fails silently here:

https://github.com/trolldbois/ctypeslib/blob/master/ctypeslib/codegen/codegenerator.py#L1095

wrapping the map function in list: list(map(re.compile, options.expressions)) on this line will fix:

https://github.com/trolldbois/ctypeslib/blob/master/ctypeslib/codegen/config.py#L43

biodafes avatar Sep 06 '22 19:09 biodafes

fixed in main

trolldbois avatar Apr 04 '23 04:04 trolldbois