Skip to content

js: Fix C preprocessor stringification#26644

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
vrabaud:opencv_js2
Dec 19, 2024
Merged

js: Fix C preprocessor stringification#26644
asmorkalov merged 1 commit intoopencv:4.xfrom
vrabaud:opencv_js2

Conversation

@vrabaud
Copy link
Copy Markdown
Contributor

@vrabaud vrabaud commented Dec 18, 2024

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • 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

@vrabaud vrabaud added this to the 4.11.0 milestone Dec 18, 2024
@vrabaud vrabaud requested a review from asmorkalov December 18, 2024 21:17
@vrabaud vrabaud mentioned this pull request Dec 18, 2024
4 tasks
@asmorkalov asmorkalov self-assigned this Dec 19, 2024
@asmorkalov
Copy link
Copy Markdown
Contributor

What issue do you try to fix. IMHO, the original code is correct.

@vrabaud
Copy link
Copy Markdown
Contributor Author

vrabaud commented Dec 19, 2024

This is the kind of code I get in typescript:

export type Range = {
  start: number,
  end: number
};

export type #type = {
  width: number,
  height: number
};

export type #type = {
  x: number,
  y: number
};

export type Rect = {
  x: number,
  y: number,
  width: number,
  height: number
};

Which triggers the error

opencv_wasm_types.d.ts:1304:1 - error TS1128: Declaration or statement expected.

1304 export type #type = {
     ~~~~~~
opencv_wasm_types.d.ts:1304:13 - error TS2457: Type alias name cannot be '#type'.

1304 export type #type = {

@vrabaud
Copy link
Copy Markdown
Contributor Author

vrabaud commented Dec 19, 2024

We want the macro to behave like emscripten::value_object<type>("Point")

@vrabaud
Copy link
Copy Markdown
Contributor Author

vrabaud commented Dec 19, 2024

It should be obvious here: https://godbolt.org/z/hE956cEGM

@asmorkalov asmorkalov merged commit 3073ba2 into opencv:4.x Dec 19, 2024
@asmorkalov asmorkalov mentioned this pull request Jan 15, 2025
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.

2 participants