feat: Publish a per-run snapshot of string pattern encodings - #247
Open
scottanderson wants to merge 2 commits into
Open
feat: Publish a per-run snapshot of string pattern encodings#247scottanderson wants to merge 2 commits into
scottanderson wants to merge 2 commits into
Conversation
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.
Owner
|
This currently contains all the changes from #246 as well |
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.
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 atomicshared_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.