Add the Foundation geometry structs: NSPoint, NSSize, NSRect - #10
Merged
Merged
Conversation
They are an ABI contract, not a convenience. A message that takes an NSSize takes it by value in floating-point registers, so a struct of the wrong shape is not a compile error — it is two garbage numbers arriving at AppKit. Every caller redeclaring its own is every caller getting one chance to be wrong. The immediate consumer is go-widgets/tray. An NSImage built from data takes its size from the bitmap's pixel count, so a 36-pixel icon reports 36 POINTS and lands in a 22-point menu bar taller than the bar itself. Fixing that needs -[NSImage setSize:], which needs an NSSize. Measured through purego before writing this, not assumed: size read back 36x36 before, 18x18 after.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A message that takes an
NSSizetakes it by value, in floating-pointregisters. A struct of the wrong shape is not a compile error — it is two
garbage numbers arriving at AppKit. Every caller redeclaring its own is every
caller getting one chance to be wrong, so the shape belongs here once.
The tests assert the layout rather than arithmetic, because the layout is the
part that is a contract: sizes, and the offset of every field.
The immediate consumer. An
NSImagebuilt from data takes its size fromthe bitmap's pixel count, so a 36-pixel icon reports 36 points — and lands
in a 22-point menu bar taller than the bar it sits in. That is a live defect in
go-widgets/traytoday. Fixing it needs-[NSImage setSize:], which needs anNSSize.Measured through purego before this was written, not assumed: