Merge pull request #26147 from vrabaud:opencv_js

js: fix enum generation issues
This commit is contained in:
Alexander Smorkalov 2024-12-19 17:35:16 +03:00 committed by GitHub
commit 6a0affdbce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,7 +132,7 @@ white_list = None
namespace_prefix_override = None
# Features to be exported
export_enums = False
export_enums = True
export_consts = True
with_wrapped_functions = True
with_default_params = True
@ -917,7 +917,7 @@ class JSWrapperGenerator(object):
if ns_name.split('.')[0] != 'cv':
continue
for name, enum in sorted(ns.enums.items()):
if not name.endswith('.anonymous'):
if '.unnamed_' not in name:
name = name.replace("cv.", "")
enum_values = []
for enum_val in enum:
@ -937,7 +937,10 @@ class JSWrapperGenerator(object):
for ns_name, ns in sorted(self.namespaces.items()):
if ns_name.split('.')[0] != 'cv':
continue
# TODO CALIB_FIX_FOCAL_LENGTH is defined both in cv:: and cv::fisheye
prefix = 'FISHEYE_' if 'fisheye' in ns_name else ''
for name, const in sorted(ns.consts.items()):
name = prefix + name
# print("Gen consts: ", name, const)
self.bindings.append(const_template.substitute(js_name=name, value=const))