Skip to content

Add safe NSValue geometry wrappers#862

Merged
Kyle-Ye merged 1 commit into
mainfrom
bugfix/nsvalue_geometry
May 16, 2026
Merged

Add safe NSValue geometry wrappers#862
Kyle-Ye merged 1 commit into
mainfrom
bugfix/nsvalue_geometry

Conversation

@Kyle-Ye
Copy link
Copy Markdown
Collaborator

@Kyle-Ye Kyle-Ye commented May 16, 2026

Summary

Adds a UIFoundation shim for NSValue geometry boxing so OpenSwiftUICore can use CGPoint, CGSize, and CGRect initializers without depending on UIKit.

The new wrappers first call the platform implementation when selectors like valueWithCGSize: are available, which should keep the UIKit/iOS path aligned with the system behavior. When those selectors are unavailable, such as on macOS where Foundation exposes NSValue(size:) instead of NSValue(cgSize:), the wrappers fall back to valueWithBytes:objCType: using the CoreGraphics encoding.

Changes

  • Add UIGeometry.h / UIGeometry.m under OpenSwiftUI_SPI/Shims/UIFoundation.
  • Expose Swift names for NSValue(cgPoint:), NSValue(cgSize:), and NSValue(cgRect:) through OpenSwiftUI-safe wrappers.
  • Update display-list and shape-layer property boxing to use the new cg* APIs via UIFoundation_Private.

Validation

  • swift package describe --type json
  • OPENSWIFTUI_USE_LOCAL_DEPS=1 swift package describe --type json
  • swift build --target OpenSwiftUICore

Builds completed successfully with existing warnings only.

@Kyle-Ye Kyle-Ye changed the title [codex] Add safe NSValue geometry wrappers Add safe NSValue geometry wrappers May 16, 2026
@Kyle-Ye Kyle-Ye marked this pull request as ready for review May 16, 2026 08:50
@Kyle-Ye Kyle-Ye merged commit 32b3832 into main May 16, 2026
4 of 8 checks passed
@Kyle-Ye Kyle-Ye deleted the bugfix/nsvalue_geometry branch May 16, 2026 08:51
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 16, 2026

🤖 Augment PR Summary

Summary: This PR adds OpenSwiftUI-safe NSValue geometry boxing APIs so OpenSwiftUICore can construct NSValue from CGPoint, CGSize, and CGRect without importing UIKit.

Changes:

  • Introduces a new UIFoundation shim (UIGeometry.h/.m) that exposes NSValue(cgPoint:), NSValue(cgSize:), and NSValue(cgRect:) to Swift via UIFoundation_Private.
  • The shim calls platform implementations (e.g. valueWithCGSize:) when available to match system behavior, and falls back to valueWithBytes:objCType: otherwise.
  • Updates display-list and shape-layer boxing to use the new cg* initializers and imports UIFoundation_Private where needed.

Technical Notes: Runtime selector checks keep iOS/UIKit behavior aligned while still supporting macOS/Foundation differences in geometry boxing APIs.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


@interface NSValue (OpenSwiftUI_UIGeometry)

+ (NSValue *)valueWithCGPoint_openswiftui_safe_wrapper:(CGPoint)point OPENSWIFTUI_SWIFT_NAME(init(cgPoint:));
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 16, 2026

Choose a reason for hiding this comment

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

valueWithCGPoint_openswiftui_safe_wrapper/valueWithCGSize_openswiftui_safe_wrapper/valueWithCGRect_openswiftui_safe_wrapper look like Swift-mapped initializers; consider returning instancetype instead of NSValue * so Swift imports them as returning Self (and it stays correct if NSValue is subclassed/class-clustered).

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.70%. Comparing base (39e3855) to head (bfc2c01).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ore/Render/DisplayList/DisplayListAsyncLayer.swift 0.00% 2 Missing ⚠️
Sources/OpenSwiftUICore/Shape/ShapeLayer.swift 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #862   +/-   ##
=======================================
  Coverage   25.69%   25.70%           
=======================================
  Files         677      677           
  Lines       46905    46905           
=======================================
+ Hits        12053    12056    +3     
+ Misses      34852    34849    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant