Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix JS Ptr factory namespace regression#28213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Shubh3155 wants to merge1 commit intoopencv:4.x
base:4.x
Choose a base branch
Loading
fromShubh3155:fix-js-ptr-namespace-regression

Conversation

@Shubh3155
Copy link
Contributor

This PR fixes a regression in the JS bindings generator where factory methods
returning Ptr were not correctly namespace-qualified.

The fix restores unconditional namespace qualification when '::' is missing
and ensures the type substitution loop always runs.

Verified locally with:
make gen_opencv_js_source

CopilotAI review requested due to automatic review settingsDecember 17, 2025 13:29
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

This PR fixes a regression in the JavaScript bindings generator where factory methods returningPtr<T> were not being correctly namespace-qualified. The issue stemmed from comparing the C++ class name (inner) with the normalized Python class name (class_info.name), which have different formats and would never match. The fix removes this comparison to restore namespace qualification.

Key Changes:

  • Removes theinner == class_info.name check that was preventing namespace qualification from occurring
  • Ensures unqualifiedPtr<T> return types in factory methods are properly namespace-qualified

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

inner=ret_type[len('Ptr<'):-1].strip()
if'::'notininnerandinner==class_info.name:
if'::'notininner:
ret_type='Ptr<%s>'%class_info.cname

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The unconditional replacement withclass_info.cname could cause incorrect type substitution. When a factory method returns a pointer to a class different from the current class, this will incorrectly use the current class's fully qualified name instead of the returned class's name. Consider using the cname of the actual return type by looking it up:if inner in self.classes: ret_type = 'Ptr<%s>' % self.classes[inner].cname (which is already extracted asbase_class_name on line 514).

Suggested change
ret_type='Ptr<%s>'%class_info.cname
# Prefer thecname of the actual pointee class if known; fall back to the
# enclosing class's cname to preserve previous behavior.
ifinnerinself.classes:
ret_type='Ptr<%s>'%self.classes[inner].cname
else:
ret_type='Ptr<%s>'%class_info.cname

Copilot uses AI. Check for mistakes.
@vrabaud
Copy link
Contributor

It's actually that one you need to fix:

if'::'notininnerandinner==class_info.name:

I do not understand the copilot comment fully but it seems valid and works for me.@Shubh3155 , please use it if you think it is valid

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@vrabaudvrabaudvrabaud approved these changes

Assignees

@vrabaudvrabaud

Projects

None yet

Milestone

4.13.0

Development

Successfully merging this pull request may close these issues.

2 participants

@Shubh3155@vrabaud

[8]ページ先頭

©2009-2025 Movatter.jp