Merge pull request #19816 from alalek:python_customize_namespaces

This commit is contained in:
Alexander Alekhin
2021-04-01 12:27:04 +00:00
4 changed files with 35 additions and 26 deletions
-2
View File
@@ -2222,8 +2222,6 @@ static PyMethodDef special_methods[] = {
#endif
#ifdef HAVE_OPENCV_GAPI
{"GIn", CV_PY_FN_WITH_KW(pyopencv_cv_GIn), "GIn(...) -> GInputProtoArgs"},
{"gapi_wip_kernels", CV_PY_FN_WITH_KW(pyopencv_cv_gapi_kernels), "kernels(...) -> GKernelPackage"},
{"gapi_wip_op", CV_PY_FN_WITH_KW_(pyopencv_cv_gapi_op, 0), "kernels(...) -> retval\n"},
{"GOut", CV_PY_FN_WITH_KW(pyopencv_cv_GOut), "GOut(...) -> GOutputProtoArgs"},
{"gin", CV_PY_FN_WITH_KW(pyopencv_cv_gin), "gin(...) -> ExtractArgsCallback"},
{"descr_of", CV_PY_FN_WITH_KW(pyopencv_cv_descr_of), "descr_of(...) -> ExtractMetaCallback"},
+4
View File
@@ -995,6 +995,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)
@@ -1003,6 +1005,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<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')
def gen_enum_reg(self, enum_name):