8000 Fix incomplete ctype-pytype conversion · opencv/opencv@c0661ad · GitHub
[go: up one dir, main page]

Skip to content

Commit c0661ad

Browse files
committed
Fix incomplete ctype-pytype conversion
1 parent b3e5703 commit c0661ad

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

modules/python/src2/gen2.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ def normalize_ctype_name(typename):
452452
for prefix_to_remove in PREFIXES_TO_REMOVE:
453453
if typename.startswith(prefix_to_remove):
454454
typename = typename[len(prefix_to_remove):]
455-
return typename.replace("::", "_")
455+
if typename.endswith('&'):
456+
typename = typename[:-1]
457+
return typename.strip()
456458

457459

458460
def is_tuple(typename):
@@ -482,10 +484,17 @@ def get_template_instantiation_type(typename):
482484

483485

484486
def convert_ctype_name_to_pytype_name(typename, classnames):
485-
typename = normalize_ctype_name(typename)
487+
typename = normalize_ctype_name(typename.strip())
486488
pytype = CTYPE_TO_PYTYPE_MAP.get(typename)
487489
if pytype is not None:
488490
return pytype
491+
492+
# GAPI types
493+
if typename.startswith("GArray_") or typename.startswith("GArray<"):
494+
return "GArray"
495+
if typename.startswith("GOpaque_") or typename.startswith("GOpaque<"):
496+
return "GOpaque"
497+
489498
if is_sequence_type(typename):
490499
if is_template_class_instantiation(typename):
491500
sequence_pytype = convert_ctype_name_to_pytype_name(
@@ -517,7 +526,7 @@ def convert_ctype_name_to_pytype_name(typename, classnames):
517526
for classname in classnames:
518527
if classname.endswith('_' + typename):
519528
return classname
520-
return typename
529+
return typename.replace("::", "_")
521530

522531

523532
def get_named_params_info(all_classes, args):

0 commit comments

Comments
 (0)
0