diff --git a/modules/python/generator/visp_python_bindgen/generator.py b/modules/python/generator/visp_python_bindgen/generator.py index 926d0171f0..174b0b9233 100644 --- a/modules/python/generator/visp_python_bindgen/generator.py +++ b/modules/python/generator/visp_python_bindgen/generator.py @@ -67,6 +67,7 @@ def generate_module(generate_path: Path, config_path: Path) -> None: raise RuntimeError('There was an exception when processing headers: You should either ignore the faulty header/class, or fix the generator code!') new_all_headers.append(result) + # Sort headers according to the dependencies. This is done across all modules. # TODO: sort module generation order. For now this works but it's fairly brittle new_all_headers = sort_headers(new_all_headers) @@ -125,4 +126,4 @@ def main(): generate_module(generation_path, config_path) if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/modules/python/generator/visp_python_bindgen/header.py b/modules/python/generator/visp_python_bindgen/header.py index 68b73a1d54..ce19465115 100644 --- a/modules/python/generator/visp_python_bindgen/header.py +++ b/modules/python/generator/visp_python_bindgen/header.py @@ -70,8 +70,10 @@ def preprocess(self) -> None: Preprocess the header to obtain the abstract representation of the cpp classes available. Additionally get the path to the xml documentation file generated by doxygen ''' + from cxxheaderparser.options import ParserOptions self.preprocessed_header_str = self.run_preprocessor() # Run preprocessor, get only code that can be compiled with current visp - self.header_repr: ParsedData = parse_string(self.preprocessed_header_str) # Get the cxxheaderparser representation of the header + + self.header_repr: ParsedData = parse_string(self.preprocessed_header_str, options=ParserOptions(verbose=False, convert_void_to_zero_params=True)) # Get the cxxheaderparser representation of the header # Get dependencies of this header. This is important for the code generation order for cls in self.header_repr.namespace.classes: @@ -98,7 +100,7 @@ def run_preprocessor(self): # Includes that should be appended at the start of every file forced_includes = [ 'visp3/core/vpConfig.h', # Always include vpConfig: ensure that VISP macros are correctly defined - 'opencv2/opencv_modules.hpp' + 'opencv2/opencv.hpp' ] for include in forced_includes: tmp_file_content.append(f'#include <{include}>\n') @@ -110,6 +112,9 @@ def run_preprocessor(self): matches = re.search(include_regex, line) if matches is None: # Include line if its not an include tmp_file_content.append(line) + # else: + # if 'visp3' in matches.group() or 'opencv' in matches.group(): + # tmp_file_content.append(line) with open(tmp_file_path.absolute(), 'w') as tmp_file: tmp_file.write(''.join(tmp_file_content)) @@ -130,6 +135,7 @@ def run_preprocessor(self): preprocessed_header_lines.append(line) preprocessed_header_content = '\n'.join(preprocessed_header_lines) preprocessed_header_content = preprocessed_header_content.replace('#include<', '#include <') # Bug in cpp header parser + return preprocessed_header_content def generate_binding_code(self) -> None: