feat(apple): give HtmlConfig's optional settings their real Swift types - #807
Merged
Conversation
andiwand
force-pushed
the
apple/html-config-optionals
branch
from
September 2, 2026 18:44
d5b53ad to
f9bb910
Compare
…ypes
`spreadsheetLimit` is an `NSValue`-boxed `ODRTableDimensions`, and Swift has no
`@encode`: a caller had to spell `"{ODRTableDimensions=II}"` out to build the
box at all, which is what OpenDocument.ios#185 carries — a second source of
truth for the struct's layout that a new field would break silently, since
`getValue:size:` checks the size and not the encoding.
The six boxed properties are now `NS_REFINED_FOR_SWIFT`, and
`apple/swift/Html+Optionals.swift` carries them under their own names as real
optionals: `TableDimensions?`, `UInt64?`, `HtmlViewportMode?`, `UInt32?`,
`Double?`, `UInt32?`. `@encode` stays in the ObjC layer, as an
`NSValue (ODRTableDimensions)` category beside the struct. ObjC callers see the
boxed properties unchanged.
Nothing under `apple/tests` set any of them, so the write path had no coverage;
two tests now round-trip all six and prove the sheet limit reaches the html.
Closes #759.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018cMYRXLJdiCkH65Jm2W9B5
andiwand
force-pushed
the
apple/html-config-optionals
branch
from
September 2, 2026 18:48
f9bb910 to
a57b7d3
Compare
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.
🤖 Generated with Claude Code
Closes #759.
HtmlConfig.spreadsheetLimitis aTableDimensionsboxed in anNSValue, and Swift has no@encode, so a caller had to write:That literal is a second source of truth for the struct's layout, sitting in a consumer — opendocument-app/OpenDocument.ios#185 carries it today — and a field added to
ODRTableDimensionsbreaks it silently, becausegetValue:size:checks the size and not the encoding.Now:
How
The six boxed properties are marked
NS_REFINED_FOR_SWIFT, so Swift sees them as__spreadsheetLimitetc., andapple/swift/Html+Optionals.swift— besideStyle+Optionals.swift, which solves the read half — carries them under their own names as real optionals:spreadsheetLimitNSValue?TableDimensions?spreadsheetCellLimitNSNumber?UInt64?spreadsheetViewportModeNSNumber?HtmlViewportMode?viewportWidthNSNumber?UInt32?initialZoomNSNumber?Double?pageRangeEndNSNumber?UInt32?@encodestays in the ObjC layer, as anNSValue (ODRTableDimensions)category beside the struct it encodes. ObjC callers see the boxed properties unchanged.Deviation from the issue's sketch
The issue proposed new names alongside the boxed ones (
sheetLimit,zoom), the wayStyle+Optionals.swiftrenamesfontColor→color. Refinement is better here: it keeps the names the API already has (nowidth/pageEndcoinages for properties whose names were already right), and it removes the boxed spelling from Swift rather than leaving both — so the encoding literal cannot be written again. It is the Apple-blessed mechanism for exactly this.apple/AGENTS.mdrecords the rule.This is a Swift-source-breaking change for anyone assigning the boxes, which today is the one workaround this PR exists to delete.
CHANGELOG.mdsays so.Verification
macOS slices built and
ODR_XCFRAMEWORK=OdrCoreObjC.xcframework swift test: 23 tests, 0 failures, including two new ones — nothing underapple/testsset any of these before, so the write path had no coverage at all.The end-to-end one renders a 3×2 csv (a csv renders as a spreadsheet, so it needs no fixture) with
spreadsheetLimit = (rows: 2, columns: 1)and asserts the third row and second column are gone. Checked non-vacuous: with the limit at 99×99 both assertions fail as expected.