Repository navigation
Simplify the protocol code - #65
Merged
Merged
Conversation
- ObjectHeader.parse matches on the qualifier, in place of seven parser objects. Start/stop headers parse their objects by count, so Variation.parse(range) is gone, and a variation that takes neither says so in one message. - Integers.fromBytesLE is the one little-endian decoder: the field parsers, UInt16LE and the device attribute values use it. One fixed-width field parser replaces the seven for 16-, 32- and 48-bit integers and floats. - One point builder for each kind of value, given the point type by the variation: an event variation's points are events, and any other's static. The Static/Event factory pairs are gone. - BitFields packs and unpacks single and double bits, in place of two parsers, two builders and Bits. - TestDriver.toFrames is the one place a message becomes link frames. A seeded corpus of every variation with every qualifier, counts and payloads parses, iterates and serializes the same as before, apart from the message above. Part of #59.
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.
Item 5 of #59.
Changes
ObjectHeader.parse, matched on the qualifier, replacesObjectHeaderParserand its seven parser objects. A start/stop header now parses its objects by count, stop − start + 1, soVariation.parse(range)is gone. A variation that takes neither header gives a single message for both: "may not be used with a start/stop or count header". The "may not by used" typo is also fixed in the two prefix messages.Integers.fromBytesLEis now the only little-endian decoder. The field parsers,UInt16LEand the device attribute values all use it, and the byte-taking constructors ofSInt16LE,SInt32LE,UInt32LEandUInt48LEare gone. One fixed-width field parser replaces the seven separate ones for the 16-, 32- and 48-bit integers and the floats.copy_with_timestampoverrides are unchanged.BitFieldspacks and unpacks both single and double bits. It replacesBitFieldParser,DoubleBitFieldParser,DoubleBits,BitFieldBuilderand the now-unusedBits.TestDriver.toFramesis the one place a message becomes link frames.frameBytes,writeMessageandsendDatagramsall use it, and the order of logging is unchanged.Checks
A differential test ran a seeded corpus of about 775,000 inputs before and after the change. The corpus has:
For each input it recorded the parsed headers, their contents and points, the re-serialized bytes, and the result of parsing the input as a response. Before and after are identical except for the error message above.