NativeScript / NativeScript/ios

Metadata-generator creates enums with incorrect values

Open
#258 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
150
Forks
43
Avg merge
3d 10h
Merged PRs (30d)
22

Description

There is the case of metadata-generator creating enums with wrong values if the original value is unsigned.
This became apparent with UIRectCornerAllCorners case where value is an unsigned long in obj-c.

UIRectCornerAllCorners = ~0UL

See: https://developer.apple.com/documentation/uikit/uirectcorner/uirectcornerallcorners?language=objc

Unfortunately, generator converts the value into a signed value resulting in -1 and when it's used as a function parameter, it brings unexpected results.

In JavaScript, the proper value would probably be 0xffffffff or 4294967295 to match the unsigned value.

I found this part of generator that looks suspicious: https://github.com/NativeScript/ios/blob/main/metadata-generator/src/Meta/MetaFactory.cpp#L321

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at metadata-generator/src/Meta/MetaFactory.cpp around line 321 and inspect how the unsigned Objective-C value UIRectCornerAllCorners = ~0UL is converted. Verify that the generated JavaScript preserves the unsigned value as 0xffffffff or 4294967295, including when passed as a function parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, objective-c
Domain
mobile, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.