From 79d019b4f1a5e89460eb3c7f2d41f646fd759a76 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Thu, 19 Dec 2024 05:59:01 +0100 Subject: [PATCH] Merge pull request #26640 from vrabaud:opencv_js3 js: fix generation of "const const" in code #26640 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- modules/js/generator/embindgen.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/js/generator/embindgen.py b/modules/js/generator/embindgen.py index 00d2406046..25cb90cfb9 100644 --- a/modules/js/generator/embindgen.py +++ b/modules/js/generator/embindgen.py @@ -248,16 +248,17 @@ class ArgInfo(object): self.const = True elif m == "/Ref": self.reference = True - if self.tp == "Mat": - if self.outputarg: - self.tp = "cv::Mat&" - elif self.inputarg: - self.tp = "const cv::Mat&" - if self.tp == "vector_Mat": - if self.outputarg: - self.tp = "std::vector&" - elif self.inputarg: - self.tp = "const std::vector&" + if self.tp == "Mat" and (self.inputarg or self.outputarg): + self.tp = "cv::Mat&" + if self.inputarg and not self.outputarg: + self.const = True + if self.tp == "vector_Mat" and (self.inputarg or self.outputarg): + self.tp = "std::vector&" + if self.reference and not self.const: + self.inputarg = False + self.outputarg = True + elif self.inputarg and not self.outputarg: + self.const = True self.tp = handle_vector(self.tp).strip() if self.const: self.tp = "const " + self.tp