robotpy / robotpy-cppheaderparser

DEPRECATED: use cxxheaderparser instead
Other
123 stars 39 forks source link

Function Pointer not well parsed. #66

Closed Erignik closed 3 years ago

Erignik commented 3 years ago

I'am using this package to do some info collect in file. h, and find this: test.h

typedef int U32;
typedef int(*p)(int, int);

main,py

import CppHeaderParser
cppHeader = CppHeaderParser.CppHeader('test.h')
print(cppHeader.typedefs)

the output show as: {')': 'int ( * p ) ( int , int', 'U32': 'int'}

U32 is parsed well, but the function pointer var shows upon is not as I expected(the key should be p?). Is this design on purpose?

virtuald commented 3 years ago

Yeah, cppheaderparser is pretty bad at dealing with function pointers. Recommend you try https://github.com/robotpy/cxxheaderparser instead; once I migrate my large project to use it I will be dropping maintenance of this project.

Erignik commented 3 years ago

I have seen https://github.com/robotpy/cxxheaderparser, but my project need to stay Python2.x. Maybe we can do some optimization: before call function _parse_typedef, do regular expression matching, if it's function pointer, do some data collect, else call _parse_typedef.

virtuald commented 3 years ago

I'm happy to accept a pull request (+tests) fixing the issue, but I'm not willing to put in the effort myself.

Erignik commented 3 years ago

I'm going to fix it.

Erignik commented 3 years ago

67