Repository: opencv/opencv
File: modules/js/generator/embindgen.py (Python)

Code before:
                base_class_name = base_class_name.replace("Ptr<","").replace(">","").strip()
                if base_class_name in self.classes:
                    self.classes[base_class_name].has_smart_ptr = True
                else:
                    print(base_class_name, ' not found in classes for registering smart pointer using ', class_info.name, 'instead')
                    self.classes[class_info.name].has_smart_ptr = True

            def_args = []
            has_def_param = False

            # Return type
            ret_type = 'void' if variant.rettype.strip() == '' else variant.rettype
            # FIX: Ensure namespaced smart-pointer return types in factory methods, e.g.:
            #      Ptr<EdgeDrawing> → Ptr<cv::ximgproc::EdgeDrawing>
            if factory and class_info is not None and ret_type.startswith('Ptr<'):
                inner = ret_type[len('Ptr<'):-1].strip()
                if '::' not in inner:
                    ret_type = 'Ptr<%s>' % class_info.cname

            if ret_type.startswith('Ptr'):  # smart pointer
                ptr_type = ret_type.replace('Ptr<', '').replace('>', '')
                if ptr_type in type_dict:
                    ret_type = type_dict[ptr_type]
                for key in type_dict:
                    if key in ret_type:
                        ret_type = re.sub(r"\b" + key + r"\b", type_dict[key], ret_type) 
            arg_types = []
            unwrapped_arg_types = []
            for arg in variant.args:
                arg_type = None
                if arg.tp in type_dict:
                    arg_type = type_dict[arg.tp]
                else:
                    arg_type = arg.tp
                # Add default value
                if with_default_params and arg.defval != '':
                    def_args.append(arg.defval);
                arg_types.append(arg_type)
                unwrapped_arg_types.append(arg_type)

            # Function attribute
            func_attribs = ''
            if '*' in ''.join(arg_types):
                func_attribs += ', allow_raw_pointers()'

            if variant.is_pure_virtual:
                func_attribs += ', pure_virtual()'


            # Wrapper function
            if ns_name != None and ns_name != "cv":

Review comment (suggestion):
This indentation change modifies the logic behavior. Previously, the `for key in type_dict` loop ran for all return types. Now it only runs when `ret_type.startswith('Ptr')`. This means type substitutions from `type_dict` (like `InputArray` → `const cv::Mat&`) will no longer be applied to non-pointer return types. This is likely unintended and could break type conversions for regular return types. The loop should remain at the previous indentation level (unindented relative to the `if ret_type.startswith('Ptr')` block).

Additionally, there is trailing whitespace at the end of line 539.
```suggestion

            for key in type_dict:
                if key in ret_type:
                    ret_type = re.sub(r"\b" + key + r"\b", type_dict[key], ret_type)
```

Code after:
                base_class_name = base_class_name.replace("Ptr<","").replace(">","").strip()
                if base_class_name in self.classes:
                    self.classes[base_class_name].has_smart_ptr = True
                else:
                    print(base_class_name, ' not found in classes for registering smart pointer using ', class_info.name, 'instead')
                    self.classes[class_info.name].has_smart_ptr = True

            def_args = []
            has_def_param = False

            # Return type
            ret_type = 'void' if variant.rettype.strip() == '' else variant.rettype
            # FIX: Ensure namespaced smart-pointer return types in factory methods, e.g.:
            #      Ptr<EdgeDrawing> → Ptr<cv::ximgproc::EdgeDrawing>
            if factory and class_info is not None and ret_type.startswith('Ptr<'):
                inner = ret_type[len('Ptr<'):-1].strip()
                if '::' not in inner and inner == class_info.name:
                    ret_type = 'Ptr<%s>' % class_info.cname

            if ret_type.startswith('Ptr'):  # smart pointer
                ptr_type = ret_type.replace('Ptr<', '').replace('>', '')
                if ptr_type in type_dict:
                    ret_type = type_dict[ptr_type]
                for key in type_dict:
                    if key in ret_type:
                        ret_type = re.sub(r"\b" + key + r"\b", type_dict[key], ret_type)
            arg_types = []
            unwrapped_arg_types = []
            for arg in variant.args:
                arg_type = None
                if arg.tp in type_dict:
                    arg_type = type_dict[arg.tp]
                else:
                    arg_type = arg.tp
                # Add default value
                if with_default_params and arg.defval != '':
                    def_args.append(arg.defval);
                arg_types.append(arg_type)
                unwrapped_arg_types.append(arg_type)

            # Function attribute
            func_attribs = ''
            if '*' in ''.join(arg_types):
                func_attribs += ', allow_raw_pointers()'

            if variant.is_pure_virtual:
                func_attribs += ', pure_virtual()'


            # Wrapper function
            if ns_name != None and ns_name != "cv":