Skip to content

Support Symbol.dispose for using keyword in OpenCV.js (#26157) #27613

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

kruid9403
Copy link

This PR adds support for the new Symbol.dispose proposal, allowing OpenCV.js objects such as cv.Mat and cv.UMat to be used with the upcoming using keyword in JavaScript (TC39 proposal) and TypeScript 5.2+.

  • Adds [Symbol.dispose] as an alias to .delete() for resource-managed OpenCV.js classes
  • Conditional logic ensures compatibility and no effect on environments without Symbol.dispose
  • Minimal, easily extensible design for future OpenCV classes

Closes #26157.

Motivation:
Manual .delete() calls can be error-prone and verbose. Supporting the new using keyword will improve resource safety and developer ergonomics per the TC39 proposal and TypeScript documentation.

Please let me know if there’s any other class to include, or if you’d like further tests or documentation.

@kruid9403
Copy link
Author

I’ve implemented Symbol.dispose support for OpenCV.js classes as described in #26157. All relevant JS-related CI suites have passed.

I did notice a failure in the test_videoio suite, but my changes are isolated to JavaScript/TypeScript bindings and should not affect that component. Please let me know if there’s anything I should address, or if this failure is known to be unrelated.

Thanks for reviewing—happy to make any adjustments needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS: Support new using javascript keyword for explicit resource management
3 participants