-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,526 additions
and
285 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cbor | ||
|
||
// major type in LSB position | ||
type majorType byte | ||
|
||
const ( | ||
majorTypeUint majorType = iota | ||
majorTypeNegInt | ||
majorTypeSlice | ||
majorTypeString | ||
majorTypeList | ||
majorTypeMap | ||
majorTypeTag | ||
majorType7 | ||
) | ||
|
||
// masks for major/minor component in encoded head | ||
const ( | ||
maskMajor = 0b111 << 5 | ||
maskMinor = 0b11111 | ||
) | ||
|
||
// minor value encodings to represent arg bit length (and indefinite) | ||
const ( | ||
minorArg1 = 24 | ||
minorArg2 = 25 | ||
minorArg4 = 26 | ||
minorArg8 = 27 | ||
minorIndefinite = 31 | ||
) | ||
|
||
// minor sentinels for everything in major 7 | ||
const ( | ||
major7False = 20 | ||
major7True = 21 | ||
major7Nil = 22 | ||
major7Undefined = 23 | ||
major7Float16 = minorArg2 | ||
major7Float32 = minorArg4 | ||
major7Float64 = minorArg8 | ||
) | ||
|
||
// we allocate for 256 items in containers to start at most to prevent huge | ||
// arguments from blowing up memory | ||
const maxAlloc = 0xff |
Oops, something went wrong.