Skip to content

feat: Publish a per-run snapshot of string pattern encodings - #247

Open
scottanderson wants to merge 2 commits into
WerWolv:masterfrom
scottanderson:encoding2
Open

feat: Publish a per-run snapshot of string pattern encodings#247
scottanderson wants to merge 2 commits into
WerWolv:masterfrom
scottanderson:encoding2

Conversation

@scottanderson

Copy link
Copy Markdown

Add StringEncodingRegion: the address, size, and encoding of one string pattern. PatternLanguage builds a sorted snapshot of these after every successful run. It publishes the snapshot through an atomic shared_ptr.

getStringEncodingRegions() returns the full snapshot. findStringEncoding() looks up one exact address and size. Both functions are safe to call from any thread.

Depends on #246.

Add StringEncodeDecode: an interface with decode(), encode(), and
encodeLossy(). The host application sets one on the Evaluator. With
none set, a string pattern keeps its raw-byte behavior.

decode() and encode() return std::optional. A nullopt result marks a
byte sequence, or a character, the named encoding cannot represent.
encodeLossy() never fails. It substitutes a replacement character for
anything the encoding cannot represent.

PatternString routes reads and writes through the codec. getValue()
and getBytesOf() throw core::err::E0004 on a nullopt result. A script
can catch this error with try/catch. setValueLossy() writes through
encodeLossy(), and clears the cached bytes and the cached display
string; getBytesOf() otherwise reflects a write only after the next
pattern run.

setValue() clears the cached bytes the same way, on every pattern
type, not just PatternString.

formatDisplayValue() decodes through decode(). It returns the raw
decoded text. The host application escapes the text for display.

getBytesOf() caps the encoded result to the pattern's own size.
getEncodingName() reads the string's own encoding attribute.

PatternWideString keeps its fixed UTF-16 behavior. The codec does not
apply to it.

Add PatternLanguage::clearFormatCaches(). It clears every placed
pattern's cached display value, across every section.
Add StringEncodingRegion: the address, size, and encoding of one
string pattern. PatternLanguage builds a sorted snapshot of these
after every successful run. It publishes the snapshot through an
atomic shared_ptr.

getStringEncodingRegions() returns the full snapshot.
findStringEncoding() looks up one exact address and size. Both
functions are safe to call from any thread.
@WerWolv

WerWolv commented Sep 1, 2026

Copy link
Copy Markdown
Owner

This currently contains all the changes from #246 as well

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.

2 participants