mirror of
https://github.com/opencv/opencv.git
synced 2025-06-28 15:30:49 +08:00
python: allow to customize Python namespaces
- extra methods through PYOPENCV_EXTRA_METHODS_<NS_UPPER> macros - extra constants through PYOPENCV_EXTRA_CONSTANTS_<NS_UPPER> macros
This commit is contained in:
parent
e11408f6ad
commit
2e005f5dc2
@ -976,6 +976,8 @@ class PythonWrapperGenerator(object):
|
|||||||
if func.isconstructor:
|
if func.isconstructor:
|
||||||
continue
|
continue
|
||||||
self.code_ns_reg.write(func.get_tab_entry())
|
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(' {NULL, NULL}\n};\n\n')
|
||||||
|
|
||||||
self.code_ns_reg.write('static ConstDef consts_%s[] = {\n'%wname)
|
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()
|
compat_name = re.sub(r"([a-z])([A-Z])", r"\1_\2", name).upper()
|
||||||
if name != compat_name:
|
if name != compat_name:
|
||||||
self.code_ns_reg.write(' {"%s", static_cast<long>(%s)},\n'%(compat_name, cname))
|
self.code_ns_reg.write(' {"%s", static_cast<long>(%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')
|
self.code_ns_reg.write(' {NULL, 0}\n};\n\n')
|
||||||
|
|
||||||
def gen_enum_reg(self, enum_name):
|
def gen_enum_reg(self, enum_name):
|
||||||
|
Loading…
Reference in New Issue
Block a user