Bindings: handle-only graphics API with index addressing and options objects #440
Labels
No labels
area/ci-release
area/cli
area/docs
area/dungeon
area/ftl
area/graphics
area/gui
area/music
area/saves
area/tooling
port/amiga
port/dos
port/fm-towns
port/mac
port/pc98
port/sega-cd
priority/high
priority/low
priority/medium
type/bug
type/chore
type/docs
type/feature
type/research
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jqueuniet/dm2-tools#440
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The
graphics.datbindings grew one function per decoder, twice (free function +GraphicsArchivemethod), with positional options. Each new option (fill,language,style/light) changed signatures in wasm, FFI and Python, the C header and both READMEs.Proposal
One deliberate break (pre-1.0), after which options are additive.
1.
GraphicsArchiveonlyDrop the
graphics*free functions. They have no performance case: one call through a handle costs the same as one free call, and every further call is ~9× slower through the free functions (#431). Their only advantage is not needingfree():--weak-refsso a forgottenfree()is reclaimed by aFinalizationRegistry.2. Records by listing index
entries()gainsindex, the ENT1 record position. Decoders take it instead of(cls1, cls2, cls4). That addresses every record exactly, includingcls5language variants, which a tuple lookup resolves last-wins (#429). Wrong-kind checks stay:image(i)on a sound errors. A convenience lookup by tuple stays:find(cls1, cls2, cls3, cls4, {language})returns an index.3. One options type per kind
Defined once in
dm2-convert, passed through by every binding:&ImageOptionsserde-wasm-bindgenoptions_json+ length; empty = defaultsdeny_unknown_fieldsturns typos into errors.decodePnganddecodePngTransparentmerge into oneimagewithtransparent.Resulting surface
Methods:
header,entries,find,labels,image,icon,sound,music,font,text,palette.Costs
serde-wasm-bindgen. TypeScript seesanyfor options unless a type declaration is hand-written.dm2-web-editor, the save editor's item icons) migrate once.Acceptance
graphics*exports are gone.Later
The same shape fits the magic map:
dungeon_map_pngre-parsesgraphics.daton every call. Dungeon and save handles would follow this pattern.https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7