Convert injection mode from strings to bitfield constants#42
Merged
Conversation
Replace string-based injection modes ('key:pre', 'key:post', 'val')
with bitfield constants (M_KEYPRE=1, M_KEYPOST=2, M_VAL=4). Update
InjectMode type to number, checkPlacement to use bitmask operations,
and export mode constants for external use.
https://claude.ai/code/session_01GSURzK61tcu7JjT19KWWbp
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.
Summary
Refactored the injection mode system from string-based values to numeric bitfield constants for improved performance and type safety. This change affects the internal representation of injection modes throughout the codebase while maintaining the same functional behavior.
Key Changes
Mode Constants: Replaced string constants (
S_MKEYPRE,S_MKEYPOST,S_MVAL) with numeric bitfield constants:M_KEYPRE = 1M_KEYPOST = 2M_VAL = 4Type Definition: Changed
InjectModetype from'key:pre' | 'key:post' | 'val'tonumberPlacement Checking: Updated
checkPlacement()function signature to accept a singleInjectModebitfield instead of an array, using bitwise AND (&) operations for validationMode Name Mapping: Added
MODENAMEconstant object to map numeric modes back to string representations for logging and debugging purposesExports: Added new constants (
M_KEYPRE,M_KEYPOST,M_VAL,MODENAME) to public API exportsUpdated All References: Changed all mode comparisons and assignments throughout the codebase to use the new numeric constants instead of string values
Implementation Details
MODENAMEmapping preserves human-readable output in debug/logging contextsInjectionclass constructor now initializes mode toM_VALinstead of the string'val'https://claude.ai/code/session_01GSURzK61tcu7JjT19KWWbp