MultiLine macro define are not parsed
Closed this issue · 1 comments
Erignik commented
Hi everyone!
when using this library, I find struct define like this
#define MM int aa;\
int bb;\
int cc;
typedef struct {
int a;
int b;
int c;
int d;
MM
};are not well parsed.
output below show var aa,bb,cc defined in macro MM are not parsed.
struct <anon-struct-1>
{
public
// Properties
{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 9, 'function_pointer': 0, 'type': 'int', 'name': 'a', 'aliases': [], 'parent': {'nested_classes': [], 'parent': None, 'abstract': False, 'final': False, 'namespace': '', 'using': {}, 'name': '<anon-struct-1>', 'bare_name': '<anon-struct-1>', 'inherits': [], 'filename': 'test.h', 'line_number': 8, 'methods': {'public': [], 'protected': [], 'private': []}, 'properties': {'public': [{...}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 10, 'function_pointer': 0, 'type': 'int', 'name': 'b', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 11, 'function_pointer': 0, 'type': 'int', 'name': 'c', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 12, 'function_pointer': 0, 'type': 'int', 'name': 'd', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'struct'}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}
{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 10, 'function_pointer': 0, 'type': 'int', 'name': 'b', 'aliases': [], 'parent': {'nested_classes': [], 'parent': None, 'abstract': False, 'final': False, 'namespace': '', 'using': {}, 'name': '<anon-struct-1>', 'bare_name': '<anon-struct-1>', 'inherits': [], 'filename': 'test.h', 'line_number': 8, 'methods': {'public': [], 'protected': [], 'private': []}, 'properties': {'public': [{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 9, 'function_pointer': 0, 'type': 'int', 'name': 'a', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {...}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 11, 'function_pointer': 0, 'type': 'int', 'name': 'c', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 12, 'function_pointer': 0, 'type': 'int', 'name': 'd', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'struct'}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}
{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 11, 'function_pointer': 0, 'type': 'int', 'name': 'c', 'aliases': [], 'parent': {'nested_classes': [], 'parent': None, 'abstract': False, 'final': False, 'namespace': '', 'using': {}, 'name': '<anon-struct-1>', 'bare_name': '<anon-struct-1>', 'inherits': [], 'filename': 'test.h', 'line_number': 8, 'methods': {'public': [], 'protected': [], 'private': []}, 'properties': {'public': [{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 9, 'function_pointer': 0, 'type': 'int', 'name': 'a', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 10, 'function_pointer': 0, 'type': 'int', 'name': 'b', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {...}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 12, 'function_pointer': 0, 'type': 'int', 'name': 'd', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'struct'}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}
{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 12, 'function_pointer': 0, 'type': 'int', 'name': 'd', 'aliases': [], 'parent': {'nested_classes': [], 'parent': None, 'abstract': False, 'final': False, 'namespace': '', 'using': {}, 'name': '<anon-struct-1>', 'bare_name': '<anon-struct-1>', 'inherits': [], 'filename': 'test.h', 'line_number': 8, 'methods': {'public': [], 'protected': [], 'private': []}, 'properties': {'public': [{'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 9, 'function_pointer': 0, 'type': 'int', 'name': 'a', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 10, 'function_pointer': 0, 'type': 'int', 'name': 'b', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {'extern': False, 'array': 0, 'filename': 'test.h', 'line_number': 11, 'function_pointer': 0, 'type': 'int', 'name': 'c', 'aliases': [], 'parent': {...}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}, {...}], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'struct'}, 'typedef': None, 'constant': 0, 'constexpr': 0, 'reference': 0, 'pointer': 0, 'static': 0, 'typedefs': 0, 'class': 0, 'fundamental': True, 'unresolved': False, 'namespace': '', 'property_of_class': '<anon-struct-1>', 'mutable': False, 'ctypes_type': 'ctypes.c_int', 'raw_type': 'int'}
protected
private
}virtuald commented
From the README:
CppHeaderParser only does some very minimal interpretation of preprocessor directives -- and we're looking at removing some of that from this library. If you need anything complex, you should preprocess the code yourself. You can use the excellent pure python preprocessor pcpp, or the preprocessing facilities provided by your favorite compiler.