From 2e005f5dc2e94cda334cd84d2932fcf6dc911097 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 31 Mar 2021 20:24:32 +0000 Subject: [PATCH] python: allow to customize Python namespaces - extra methods through PYOPENCV_EXTRA_METHODS_ macros - extra constants through PYOPENCV_EXTRA_CONSTANTS_ macros --- modules/python/src2/gen2.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 0e0a6e2ba3..262662496b 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -976,6 +976,8 @@ class PythonWrapperGenerator(object): if func.isconstructor: continue self.code_ns_reg.write(func.get_tab_entry()) + custom_entries_macro = 'PYOPENCV_EXTRA_METHODS_{}'.format(wname.upper()) + self.code_ns_reg.write('#ifdef {}\n {}\n#endif\n'.format(custom_entries_macro, custom_entries_macro)) self.code_ns_reg.write(' {NULL, NULL}\n};\n\n') self.code_ns_reg.write('static ConstDef consts_%s[] = {\n'%wname) @@ -984,6 +986,8 @@ class PythonWrapperGenerator(object): compat_name = re.sub(r"([a-z])([A-Z])", r"\1_\2", name).upper() if name != compat_name: self.code_ns_reg.write(' {"%s", static_cast(%s)},\n'%(compat_name, cname)) + custom_entries_macro = 'PYOPENCV_EXTRA_CONSTANTS_{}'.format(wname.upper()) + self.code_ns_reg.write('#ifdef {}\n {}\n#endif\n'.format(custom_entries_macro, custom_entries_macro)) self.code_ns_reg.write(' {NULL, 0}\n};\n\n') def gen_enum_reg(self, enum_name): -- 2.34.1