mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 00:47:28 +01:00
Add colons to const syntax
This commit is contained in:
1 parent
80071730a3
commit
532e18c4a5
16 files changed
+119
-99
No files matched your search
@@ -21,18 +21,18 @@ pub status "#unsupported recursion depth"
|
||||
|
||||
pri status "#internal error: inconsistent I/O"
|
||||
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE base.u64 = 0
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
|
||||
|
||||
// DECODER_DEPTH_MAX_INCL is the maximum supported recursion depth: how deeply
|
||||
// nested [] arrays and {} objects can be.
|
||||
//
|
||||
// The JSON spec itself does not define a limit, but allows implementations to
|
||||
// set their own limits.
|
||||
pub const DECODER_DEPTH_MAX_INCL base.u64 = 1024
|
||||
pub const DECODER_DEPTH_MAX_INCL : base.u64 = 1024
|
||||
|
||||
// DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL is the minimum length of the dst
|
||||
// wuffs_base__token_buffer passed to the decoder.
|
||||
pub const DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL base.u64 = 1
|
||||
pub const DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL : base.u64 = 1
|
||||
|
||||
// DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL is the minimum length of the src
|
||||
// wuffs_base__io_buffer passed to the decoder.
|
||||
@@ -42,7 +42,7 @@ pub const DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL base.u64 = 1
|
||||
// the backing array's length, not the length of the JSON-formatted input per
|
||||
// se. It is perfectly valid to decode "[1,2]" (of length 5) as JSON, as long
|
||||
// as that content is placed in an io_buffer whose data.len is at least 100.
|
||||
pub const DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL base.u64 = 100
|
||||
pub const DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL : base.u64 = 100
|
||||
|
||||
// DECODER_NUMBER_LENGTH_MAX_INCL is the longest supported byte length for a
|
||||
// JSON number. Unlike JSON strings, this package's tokenizer never splits a
|
||||
@@ -52,7 +52,7 @@ pub const DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL base.u64 = 100
|
||||
//
|
||||
// The JSON spec itself does not define a limit, but allows implementations to
|
||||
// set their own limits.
|
||||
pri const DECODER_NUMBER_LENGTH_MAX_INCL base.u64 = 99
|
||||
pri const DECODER_NUMBER_LENGTH_MAX_INCL : base.u64 = 99
|
||||
|
||||
// --------
|
||||
|
||||
@@ -77,7 +77,7 @@ pri const DECODER_NUMBER_LENGTH_MAX_INCL base.u64 = 99
|
||||
//
|
||||
// If the element is zero then "\i" is invalid, or it is a special case, the
|
||||
// start of "\x12", "\u1234" or "\U12345678".
|
||||
pri const LUT_BACKSLASHES array[256] base.u8 = [
|
||||
pri const LUT_BACKSLASHES : array[256] base.u8 = [
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
|
||||
@@ -122,7 +122,7 @@ pri const LUT_BACKSLASHES array[256] base.u8 = [
|
||||
// LUT_QUIRKY_BACKSLASHES is discussed in the LUT_BACKSLASHES comment. The
|
||||
// first element (index 0) is not used, but 8 is a round power of 2, so
|
||||
// enforcing index-in-bounds is a simple "&7" operation.
|
||||
pri const LUT_QUIRKY_BACKSLASHES array[8] base.u8 = [
|
||||
pri const LUT_QUIRKY_BACKSLASHES : array[8] base.u8 = [
|
||||
0x00, 0x07, 0x1B, 0x0A, 0x3F, 0x27, 0x0B, 0x00,
|
||||
]
|
||||
|
||||
@@ -145,7 +145,7 @@ pri const LUT_QUIRKY_BACKSLASHES array[8] base.u8 = [
|
||||
// UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
|
||||
// %xF4 %x80-8F 2( UTF8-tail )
|
||||
// UTF8-tail = %x80-BF
|
||||
pri const LUT_CHARS array[256] base.u8 = [
|
||||
pri const LUT_CHARS : array[256] base.u8 = [
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x00 ..= 0x07. C0 control codes.
|
||||
@@ -187,19 +187,19 @@ pri const LUT_CHARS array[256] base.u8 = [
|
||||
// 8 9 A B C D E F
|
||||
]
|
||||
|
||||
pri const CLASS_WHITESPACE base.u8 = 0x00
|
||||
pri const CLASS_STRING base.u8 = 0x01
|
||||
pri const CLASS_COMMA base.u8 = 0x02
|
||||
pri const CLASS_COLON base.u8 = 0x03
|
||||
pri const CLASS_NUMBER base.u8 = 0x04
|
||||
pri const CLASS_OPEN_CURLY_BRACE base.u8 = 0x05
|
||||
pri const CLASS_CLOSE_CURLY_BRACE base.u8 = 0x06
|
||||
pri const CLASS_OPEN_SQUARE_BRACKET base.u8 = 0x07
|
||||
pri const CLASS_CLOSE_SQUARE_BRACKET base.u8 = 0x08
|
||||
pri const CLASS_FALSE base.u8 = 0x09
|
||||
pri const CLASS_TRUE base.u8 = 0x0A
|
||||
pri const CLASS_NULL_NAN_INF base.u8 = 0x0B
|
||||
pri const CLASS_COMMENT base.u8 = 0x0C
|
||||
pri const CLASS_WHITESPACE : base.u8 = 0x00
|
||||
pri const CLASS_STRING : base.u8 = 0x01
|
||||
pri const CLASS_COMMA : base.u8 = 0x02
|
||||
pri const CLASS_COLON : base.u8 = 0x03
|
||||
pri const CLASS_NUMBER : base.u8 = 0x04
|
||||
pri const CLASS_OPEN_CURLY_BRACE : base.u8 = 0x05
|
||||
pri const CLASS_CLOSE_CURLY_BRACE : base.u8 = 0x06
|
||||
pri const CLASS_OPEN_SQUARE_BRACKET : base.u8 = 0x07
|
||||
pri const CLASS_CLOSE_SQUARE_BRACKET : base.u8 = 0x08
|
||||
pri const CLASS_FALSE : base.u8 = 0x09
|
||||
pri const CLASS_TRUE : base.u8 = 0x0A
|
||||
pri const CLASS_NULL_NAN_INF : base.u8 = 0x0B
|
||||
pri const CLASS_COMMENT : base.u8 = 0x0C
|
||||
|
||||
// LUT_CLASSES is:
|
||||
// - 0x00 (bitmask 0x0001) is CLASS_WHITESPACE.
|
||||
@@ -245,7 +245,7 @@ pri const CLASS_COMMENT base.u8 = 0x0C
|
||||
//
|
||||
// Comments are always expected. Whether the relevant quirks are enabled are
|
||||
// checked elsewhere.
|
||||
pri const LUT_CLASSES array[256] base.u8[..= 0x0F] = [
|
||||
pri const LUT_CLASSES : array[256] base.u8[..= 0x0F] = [
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x00 ..= 0x07.
|
||||
@@ -287,7 +287,7 @@ pri const LUT_CLASSES array[256] base.u8[..= 0x0F] = [
|
||||
// 8 9 A B C D E F
|
||||
]
|
||||
|
||||
pri const LUT_DECIMAL_DIGITS array[256] base.u8 = [
|
||||
pri const LUT_DECIMAL_DIGITS : array[256] base.u8 = [
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
|
||||
@@ -329,7 +329,7 @@ pri const LUT_DECIMAL_DIGITS array[256] base.u8 = [
|
||||
// 8 9 A B C D E F
|
||||
]
|
||||
|
||||
pri const LUT_HEXADECIMAL_DIGITS array[256] base.u8 = [
|
||||
pri const LUT_HEXADECIMAL_DIGITS : array[256] base.u8 = [
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
|
||||
|
||||
@@ -33,22 +33,22 @@
|
||||
//
|
||||
// Any indentation following a new line is not stripped, but remains part of
|
||||
// the decoded string.
|
||||
pub const QUIRK_ALLOW_ASCII_CONTROL_CODES base.u32 = 0x4909_9400 | 0x00
|
||||
pub const QUIRK_ALLOW_ASCII_CONTROL_CODES : base.u32 = 0x4909_9400 | 0x00
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\az" is accepted as a JSON string,
|
||||
// equivalent to "abc\u0007z", containing an ASCII Bell control character.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_A base.u32 = 0x4909_9400 | 0x01
|
||||
pub const QUIRK_ALLOW_BACKSLASH_A : base.u32 = 0x4909_9400 | 0x01
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\U0001F4A9z" is accepted as a JSON
|
||||
// string, equivalent to "abc\uD83D\uDCA9z", containing the U+0001F4A9 PILE OF
|
||||
// POO Unicode code point. There are exactly 8 encoded bytes after each "\U".
|
||||
//
|
||||
// This quirk can combine with QUIRK_REPLACE_INVALID_UNICODE.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_CAPITAL_U base.u32 = 0x4909_9400 | 0x02
|
||||
pub const QUIRK_ALLOW_BACKSLASH_CAPITAL_U : base.u32 = 0x4909_9400 | 0x02
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\ez" is accepted as a JSON string,
|
||||
// equivalent to "abc\u001Bz", containing an ASCII Escape control character.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_E base.u32 = 0x4909_9400 | 0x03
|
||||
pub const QUIRK_ALLOW_BACKSLASH_E : base.u32 = 0x4909_9400 | 0x03
|
||||
|
||||
// When this quirk is enabled, e.g. ("abc\
|
||||
// z") is accepted as a JSON string, equivalent to "abc\nz".
|
||||
@@ -59,20 +59,20 @@ pub const QUIRK_ALLOW_BACKSLASH_E base.u32 = 0x4909_9400 | 0x03
|
||||
//
|
||||
// Any indentation following a new line is not stripped, but remains part of
|
||||
// the decoded string.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_NEW_LINE base.u32 = 0x4909_9400 | 0x04
|
||||
pub const QUIRK_ALLOW_BACKSLASH_NEW_LINE : base.u32 = 0x4909_9400 | 0x04
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\?z" is accepted as a JSON string,
|
||||
// equivalent to "abc?z".
|
||||
pub const QUIRK_ALLOW_BACKSLASH_QUESTION_MARK base.u32 = 0x4909_9400 | 0x05
|
||||
pub const QUIRK_ALLOW_BACKSLASH_QUESTION_MARK : base.u32 = 0x4909_9400 | 0x05
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\'z" is accepted as a JSON string,
|
||||
// equivalent to "abc'z".
|
||||
pub const QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE base.u32 = 0x4909_9400 | 0x06
|
||||
pub const QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE : base.u32 = 0x4909_9400 | 0x06
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\vz" is accepted as a JSON string,
|
||||
// equivalent to "abc\u000Bz", containing an ASCII Vertical Tab control
|
||||
// character.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_V base.u32 = 0x4909_9400 | 0x07
|
||||
pub const QUIRK_ALLOW_BACKSLASH_V : base.u32 = 0x4909_9400 | 0x07
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\xeFz" is accepted as a JSON string,
|
||||
// There are exactly 2 encoded bytes after each "\x".
|
||||
@@ -91,11 +91,11 @@ pub const QUIRK_ALLOW_BACKSLASH_V base.u32 = 0x4909_9400 | 0x07
|
||||
// 0xAF and 0x7A. The UTF-8 encoding of U+00EF LATIN SMALL LETTER I WITH
|
||||
// DIAERESIS is the two byte sequence (0xC3, 0xAF). Decoded strings are still
|
||||
// valid UTF-8 and tokens still split on UTF-8 boundaries.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_X base.u32 = 0x4909_9400 | 0x08
|
||||
pub const QUIRK_ALLOW_BACKSLASH_X : base.u32 = 0x4909_9400 | 0x08
|
||||
|
||||
// When this quirk is enabled, e.g. "abc\0z" is accepted as a JSON string,
|
||||
// equivalent to "abc\u0000z", containing an ASCII NUL control character.
|
||||
pub const QUIRK_ALLOW_BACKSLASH_ZERO base.u32 = 0x4909_9400 | 0x09
|
||||
pub const QUIRK_ALLOW_BACKSLASH_ZERO : base.u32 = 0x4909_9400 | 0x09
|
||||
|
||||
// When this quirk is enabled, "/* C/C++ style block comments */" are accepted
|
||||
// anywhere whitespace would be, although see the QUIRK_ALLOW_TRAILING_NEW_LINE
|
||||
@@ -103,7 +103,7 @@ pub const QUIRK_ALLOW_BACKSLASH_ZERO base.u32 = 0x4909_9400 | 0x09
|
||||
//
|
||||
// They produce WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK tokens. The token
|
||||
// chain's source bytes includes the starting "/*" and the ending "*/".
|
||||
pub const QUIRK_ALLOW_COMMENT_BLOCK base.u32 = 0x4909_9400 | 0x0A
|
||||
pub const QUIRK_ALLOW_COMMENT_BLOCK : base.u32 = 0x4909_9400 | 0x0A
|
||||
|
||||
// When this quirk is enabled, "// C/C++ style line comments\n" are accepted
|
||||
// anywhere whitespace would be, although see the QUIRK_ALLOW_TRAILING_NEW_LINE
|
||||
@@ -118,7 +118,7 @@ pub const QUIRK_ALLOW_COMMENT_BLOCK base.u32 = 0x4909_9400 | 0x0A
|
||||
// Even if the line comments are on consecutive lines, each line comment is a
|
||||
// separate token chain. There may be whitespace tokens between one line
|
||||
// comment's ending "\n" and the next one's starting "//".
|
||||
pub const QUIRK_ALLOW_COMMENT_LINE base.u32 = 0x4909_9400 | 0x0B
|
||||
pub const QUIRK_ALLOW_COMMENT_LINE : base.u32 = 0x4909_9400 | 0x0B
|
||||
|
||||
// When this quirk is enabled, there may be a comma after the final array
|
||||
// element or object key-value pair and before the closing "]" or "}". A comma
|
||||
@@ -127,12 +127,12 @@ pub const QUIRK_ALLOW_COMMENT_LINE base.u32 = 0x4909_9400 | 0x0B
|
||||
//
|
||||
// For example, `[1,]`, `[1,2,3,]` and `{"k":"v",}` all become acceptable, but
|
||||
// `[,]`, `{,}` and `{"k",:"v"}` are still rejected.
|
||||
pub const QUIRK_ALLOW_EXTRA_COMMA base.u32 = 0x4909_9400 | 0x0C
|
||||
pub const QUIRK_ALLOW_EXTRA_COMMA : base.u32 = 0x4909_9400 | 0x0C
|
||||
|
||||
// When this quirk is enabled, "inf", "Infinity", "NAN" and their
|
||||
// case-insensitive variants, optionally preceded immediately by "-" or "+",
|
||||
// are accepted anywhere a JSON number would be.
|
||||
pub const QUIRK_ALLOW_INF_NAN_NUMBERS base.u32 = 0x4909_9400 | 0x0D
|
||||
pub const QUIRK_ALLOW_INF_NAN_NUMBERS : base.u32 = 0x4909_9400 | 0x0D
|
||||
|
||||
// When this quirk is enabled, the input byte stream may optionally start with
|
||||
// "\x1E" (the ASCII Record Separator control character). That byte is skipped
|
||||
@@ -143,7 +143,7 @@ pub const QUIRK_ALLOW_INF_NAN_NUMBERS base.u32 = 0x4909_9400 | 0x0D
|
||||
//
|
||||
// When combined with QUIRK_ALLOW_TRAILING_NEW_LINE, this format is also known
|
||||
// as RFC 7464, Json Text Sequences and MIME type "application/json-seq".
|
||||
pub const QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR base.u32 = 0x4909_9400 | 0x0E
|
||||
pub const QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR : base.u32 = 0x4909_9400 | 0x0E
|
||||
|
||||
// When this quirk is enabled, the input byte stream may optionally start with
|
||||
// "\xEF\xBB\xBF", the UTF-8 encoding of the Unicode BOM (Byte Order Mark).
|
||||
@@ -151,7 +151,7 @@ pub const QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR base.u32 = 0x4909_9400 | 0x
|
||||
//
|
||||
// When combined with QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR, either mark
|
||||
// may come first in the byte stream.
|
||||
pub const QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK base.u32 = 0x4909_9400 | 0x0F
|
||||
pub const QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK : base.u32 = 0x4909_9400 | 0x0F
|
||||
|
||||
// When this quirk is enabled, following a successful decoding of a top-level
|
||||
// JSON value, any trailing whitespace (ASCII characters 0x09, 0x0A, 0x0D or
|
||||
@@ -187,7 +187,7 @@ pub const QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK base.u32 = 0x4909_9400 | 0
|
||||
// end-of-file or '\n' is encountered. Treating this as an error avoids any
|
||||
// ambiguity in accounting for new lines within a block comment or ending a
|
||||
// line comment.
|
||||
pub const QUIRK_ALLOW_TRAILING_NEW_LINE base.u32 = 0x4909_9400 | 0x10
|
||||
pub const QUIRK_ALLOW_TRAILING_NEW_LINE : base.u32 = 0x4909_9400 | 0x10
|
||||
|
||||
// When this quirk is enabled, invalid UTF-8 inside a JSON string is accepted.
|
||||
// Each byte of invalid UTF-8 is equivalent to "\uFFFD", the Unicode
|
||||
@@ -203,4 +203,4 @@ pub const QUIRK_ALLOW_TRAILING_NEW_LINE base.u32 = 0x4909_9400 | 0x10
|
||||
// When combined with QUIRK_ALLOW_BACKSLASH_CAPITAL_U, a "\U12345678" 10-byte
|
||||
// unit that is an invalid Unicode code point (i.e. in the range U+D800 ..=
|
||||
// U+DFFF or above U+10FFFF) is similarly replaced with U+FFFD.
|
||||
pub const QUIRK_REPLACE_INVALID_UNICODE base.u32 = 0x4909_9400 | 0x11
|
||||
pub const QUIRK_REPLACE_INVALID_UNICODE : base.u32 = 0x4909_9400 | 0x11
|
||||
Reference in new issue
Block a user