aux: add QuirkKeyValuePair type
diff --git a/example/imageviewer/imageviewer.cc b/example/imageviewer/imageviewer.cc index 17fb874..4acb4d9 100644 --- a/example/imageviewer/imageviewer.cc +++ b/example/imageviewer/imageviewer.cc
@@ -271,7 +271,10 @@ dia_flags |= wuffs_aux::DecodeImageArgFlags::REPORT_METADATA_GAMA; } - uint32_t wuffs_base__quirk_quality = WUFFS_BASE__QUIRK_QUALITY; + const wuffs_aux::QuirkKeyValuePair wuffs_base__quirk_quality = { + WUFFS_BASE__QUIRK_QUALITY, + WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY, + }; MyDecodeImageCallbacks callbacks; wuffs_aux::sync_io::FileInput input(file);
diff --git a/example/json-to-cbor/json-to-cbor.cc b/example/json-to-cbor/json-to-cbor.cc index f884e79..bcc546e 100644 --- a/example/json-to-cbor/json-to-cbor.cc +++ b/example/json-to-cbor/json-to-cbor.cc
@@ -139,7 +139,7 @@ uint8_t g_dst_array[DST_BUFFER_ARRAY_SIZE]; wuffs_base__io_buffer g_dst; -std::vector<uint32_t> g_quirks; +std::vector<wuffs_aux::QuirkKeyValuePair> g_quirks; struct { int remaining_argc; @@ -149,9 +149,9 @@ std::string // parse_flags(int argc, char** argv) { #if defined(WUFFS_EXAMPLE_SPEAK_JWCC_NOT_JSON) - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1}); #endif int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name. @@ -175,22 +175,22 @@ } if (!strcmp(arg, "input-allow-comments")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1}); continue; } if (!strcmp(arg, "input-allow-extra-comma")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1}); continue; } if (!strcmp(arg, "input-allow-inf-nan-numbers")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS, 1}); continue; } if (!strcmp(arg, "input-jwcc") || !strcmp(arg, "jwcc")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1}); continue; }
diff --git a/example/jsonfindptrs/jsonfindptrs.cc b/example/jsonfindptrs/jsonfindptrs.cc index 064c833..075bf2c 100644 --- a/example/jsonfindptrs/jsonfindptrs.cc +++ b/example/jsonfindptrs/jsonfindptrs.cc
@@ -215,7 +215,7 @@ // ---- -std::vector<uint32_t> g_quirks; +std::vector<wuffs_aux::QuirkKeyValuePair> g_quirks; std::string g_dst; @@ -239,9 +239,9 @@ g_flags.max_output_depth = 0xFFFFFFFF; #if defined(WUFFS_EXAMPLE_SPEAK_JWCC_NOT_JSON) - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1}); #endif int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name. @@ -281,22 +281,22 @@ return g_usage; } if (!strcmp(arg, "input-allow-comments")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1}); continue; } if (!strcmp(arg, "input-allow-extra-comma")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1}); continue; } if (!strcmp(arg, "input-allow-inf-nan-numbers")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS, 1}); continue; } if (!strcmp(arg, "input-jwcc") || !strcmp(arg, "jwcc")) { - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE); - g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1}); + g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1}); continue; } if (!strncmp(arg, "q=", 2) || !strncmp(arg, "query=", 6)) { @@ -547,7 +547,7 @@ TRY(parse_flags(argc, argv)); if (!g_flags.strict_json_pointer_syntax) { g_quirks.push_back( - WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T); + {WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T, 1}); } FILE* in = stdin;
diff --git a/fuzz/c/std/json_fuzzer.cc b/fuzz/c/std/json_fuzzer.cc index 102aa8a..df878db 100644 --- a/fuzz/c/std/json_fuzzer.cc +++ b/fuzz/c/std/json_fuzzer.cc
@@ -499,11 +499,11 @@ const char* json_pointer = json_pointers[hash & 15]; hash = wuffs_base__u64__rotate_right(hash, 4); - std::vector<uint32_t> quirks; + std::vector<wuffs_aux::QuirkKeyValuePair> quirks; for (uint32_t i = 0; g_quirks[i]; i++) { uint64_t bit = 1 << (i & 63); if (hash & bit) { - quirks.push_back(g_quirks[i]); + quirks.push_back({g_quirks[i], 1}); } }
diff --git a/internal/cgen/auxiliary/base.hh b/internal/cgen/auxiliary/base.hh index 03a49cb..36c26c4 100644 --- a/internal/cgen/auxiliary/base.hh +++ b/internal/cgen/auxiliary/base.hh
@@ -16,6 +16,7 @@ #include <stdio.h> #include <string> +#include <utility> namespace wuffs_aux { @@ -28,6 +29,8 @@ // nullptr, since calling free(nullptr) is a no-op. using MemOwner = std::unique_ptr<void, decltype(&free)>; +using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>; + namespace sync_io { // --------
diff --git a/internal/cgen/auxiliary/cbor.cc b/internal/cgen/auxiliary/cbor.cc index 75bf066..e09abd8 100644 --- a/internal/cgen/auxiliary/cbor.cc +++ b/internal/cgen/auxiliary/cbor.cc
@@ -28,15 +28,13 @@ sync_io::Input& input, IOBuffer& buffer) {} -DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0) - : repr(repr0) {} - -DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0) - : repr(wuffs_base__make_slice_u32(ptr0, len0)) {} +DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0) + : ptr(ptr0), len(len0) {} DecodeCborArgQuirks // DecodeCborArgQuirks::DefaultValue() { - return DecodeCborArgQuirks(wuffs_base__empty_slice_u32()); + return DecodeCborArgQuirks(nullptr, 0); } DecodeCborResult // @@ -65,8 +63,8 @@ ret_error_message = "wuffs_aux::DecodeCbor: out of memory"; goto done; } - for (size_t i = 0; i < quirks.repr.len; i++) { - dec->set_quirk(quirks.repr.ptr[i], 1); + for (size_t i = 0; i < quirks.len; i++) { + dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second); } // Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
diff --git a/internal/cgen/auxiliary/cbor.hh b/internal/cgen/auxiliary/cbor.hh index c45e114..66e2f95 100644 --- a/internal/cgen/auxiliary/cbor.hh +++ b/internal/cgen/auxiliary/cbor.hh
@@ -75,13 +75,14 @@ // DecodeCborArgQuirks wraps an optional argument to DecodeCbor. struct DecodeCborArgQuirks { - explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0); - explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len); + explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0); // DefaultValue returns an empty slice. static DecodeCborArgQuirks DefaultValue(); - wuffs_base__slice_u32 repr; + const QuirkKeyValuePair* ptr; + const size_t len; }; // DecodeCbor calls callbacks based on the CBOR-formatted data in input.
diff --git a/internal/cgen/auxiliary/image.cc b/internal/cgen/auxiliary/image.cc index fa6fdc7..d5b3ca7 100644 --- a/internal/cgen/auxiliary/image.cc +++ b/internal/cgen/auxiliary/image.cc
@@ -197,15 +197,13 @@ const char DecodeImage_UnsupportedPixelFormat[] = // "wuffs_aux::DecodeImage: unsupported pixel format"; -DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0) - : repr(repr0) {} - -DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0) - : repr(wuffs_base__make_slice_u32(ptr0, len0)) {} +DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0) + : ptr(ptr0), len(len0) {} DecodeImageArgQuirks // DecodeImageArgQuirks::DefaultValue() { - return DecodeImageArgQuirks(wuffs_base__empty_slice_u32()); + return DecodeImageArgQuirks(nullptr, 0); } DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {} @@ -303,7 +301,8 @@ DecodeImageCallbacks& callbacks, sync_io::Input& input, wuffs_base__io_buffer& io_buf, - wuffs_base__slice_u32 quirks, + const QuirkKeyValuePair* quirks_ptr, + const size_t quirks_len, uint64_t flags, wuffs_base__pixel_blend pixel_blend, wuffs_base__color_u32_argb_premul background_color, @@ -386,15 +385,8 @@ } // Apply quirks. - for (size_t i = 0; i < quirks.len; i++) { - // TODO: don't special-case this. - if (quirks.ptr[i] == WUFFS_BASE__QUIRK_QUALITY) { - image_decoder->set_quirk( - WUFFS_BASE__QUIRK_QUALITY, - WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY); - continue; - } - image_decoder->set_quirk(quirks.ptr[i], 1); + for (size_t i = 0; i < quirks_len; i++) { + image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second); } // Apply flags. @@ -621,10 +613,10 @@ } wuffs_base__image_decoder::unique_ptr image_decoder(nullptr); - DecodeImageResult result = - DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr, - flags.repr, pixel_blend.repr, background_color.repr, - max_incl_dimension.repr, max_incl_metadata_length.repr); + DecodeImageResult result = DecodeImage0( + image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len, + flags.repr, pixel_blend.repr, background_color.repr, + max_incl_dimension.repr, max_incl_metadata_length.repr); callbacks.Done(result, input, *io_buf, std::move(image_decoder)); return result; }
diff --git a/internal/cgen/auxiliary/image.hh b/internal/cgen/auxiliary/image.hh index 9688183..0680045 100644 --- a/internal/cgen/auxiliary/image.hh +++ b/internal/cgen/auxiliary/image.hh
@@ -200,13 +200,14 @@ // DecodeImageArgQuirks wraps an optional argument to DecodeImage. struct DecodeImageArgQuirks { - explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0); - explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len); + explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0); // DefaultValue returns an empty slice. static DecodeImageArgQuirks DefaultValue(); - wuffs_base__slice_u32 repr; + const QuirkKeyValuePair* ptr; + const size_t len; }; // DecodeImageArgFlags wraps an optional argument to DecodeImage.
diff --git a/internal/cgen/auxiliary/json.cc b/internal/cgen/auxiliary/json.cc index 6ab4b42..d8705af 100644 --- a/internal/cgen/auxiliary/json.cc +++ b/internal/cgen/auxiliary/json.cc
@@ -33,15 +33,13 @@ const char DecodeJson_NoMatch[] = // "wuffs_aux::DecodeJson: no match"; -DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0) - : repr(repr0) {} - -DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0) - : repr(wuffs_base__make_slice_u32(ptr0, len0)) {} +DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0) + : ptr(ptr0), len(len0) {} DecodeJsonArgQuirks // DecodeJsonArgQuirks::DefaultValue() { - return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32()); + return DecodeJsonArgQuirks(nullptr, 0); } DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0) @@ -386,11 +384,11 @@ goto done; } bool allow_tilde_n_tilde_r_tilde_t = false; - for (size_t i = 0; i < quirks.repr.len; i++) { - dec->set_quirk(quirks.repr.ptr[i], 1); - if (quirks.repr.ptr[i] == + for (size_t i = 0; i < quirks.len; i++) { + dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second); + if (quirks.ptr[i].first == WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) { - allow_tilde_n_tilde_r_tilde_t = true; + allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0); } }
diff --git a/internal/cgen/auxiliary/json.hh b/internal/cgen/auxiliary/json.hh index c0ce43f..c21c1dc 100644 --- a/internal/cgen/auxiliary/json.hh +++ b/internal/cgen/auxiliary/json.hh
@@ -76,13 +76,14 @@ // DecodeJsonArgQuirks wraps an optional argument to DecodeJson. struct DecodeJsonArgQuirks { - explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0); - explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len); + explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0); // DefaultValue returns an empty slice. static DecodeJsonArgQuirks DefaultValue(); - wuffs_base__slice_u32 repr; + const QuirkKeyValuePair* ptr; + const size_t len; }; // DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index f86c55c..e93d19a 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c
@@ -15061,6 +15061,7 @@ #include <stdio.h> #include <string> +#include <utility> namespace wuffs_aux { @@ -15073,6 +15074,8 @@ // nullptr, since calling free(nullptr) is a no-op. using MemOwner = std::unique_ptr<void, decltype(&free)>; +using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>; + namespace sync_io { // -------- @@ -15255,13 +15258,14 @@ // DecodeCborArgQuirks wraps an optional argument to DecodeCbor. struct DecodeCborArgQuirks { - explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0); - explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len); + explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0); // DefaultValue returns an empty slice. static DecodeCborArgQuirks DefaultValue(); - wuffs_base__slice_u32 repr; + const QuirkKeyValuePair* ptr; + const size_t len; }; // DecodeCbor calls callbacks based on the CBOR-formatted data in input. @@ -15469,13 +15473,14 @@ // DecodeImageArgQuirks wraps an optional argument to DecodeImage. struct DecodeImageArgQuirks { - explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0); - explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len); + explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0); // DefaultValue returns an empty slice. static DecodeImageArgQuirks DefaultValue(); - wuffs_base__slice_u32 repr; + const QuirkKeyValuePair* ptr; + const size_t len; }; // DecodeImageArgFlags wraps an optional argument to DecodeImage. @@ -15687,13 +15692,14 @@ // DecodeJsonArgQuirks wraps an optional argument to DecodeJson. struct DecodeJsonArgQuirks { - explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0); - explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len); + explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0); // DefaultValue returns an empty slice. static DecodeJsonArgQuirks DefaultValue(); - wuffs_base__slice_u32 repr; + const QuirkKeyValuePair* ptr; + const size_t len; }; // DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson. @@ -77522,15 +77528,13 @@ sync_io::Input& input, IOBuffer& buffer) {} -DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0) - : repr(repr0) {} - -DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0) - : repr(wuffs_base__make_slice_u32(ptr0, len0)) {} +DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0) + : ptr(ptr0), len(len0) {} DecodeCborArgQuirks // DecodeCborArgQuirks::DefaultValue() { - return DecodeCborArgQuirks(wuffs_base__empty_slice_u32()); + return DecodeCborArgQuirks(nullptr, 0); } DecodeCborResult // @@ -77559,8 +77563,8 @@ ret_error_message = "wuffs_aux::DecodeCbor: out of memory"; goto done; } - for (size_t i = 0; i < quirks.repr.len; i++) { - dec->set_quirk(quirks.repr.ptr[i], 1); + for (size_t i = 0; i < quirks.len; i++) { + dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second); } // Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB. @@ -78053,15 +78057,13 @@ const char DecodeImage_UnsupportedPixelFormat[] = // "wuffs_aux::DecodeImage: unsupported pixel format"; -DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0) - : repr(repr0) {} - -DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0) - : repr(wuffs_base__make_slice_u32(ptr0, len0)) {} +DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0) + : ptr(ptr0), len(len0) {} DecodeImageArgQuirks // DecodeImageArgQuirks::DefaultValue() { - return DecodeImageArgQuirks(wuffs_base__empty_slice_u32()); + return DecodeImageArgQuirks(nullptr, 0); } DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {} @@ -78159,7 +78161,8 @@ DecodeImageCallbacks& callbacks, sync_io::Input& input, wuffs_base__io_buffer& io_buf, - wuffs_base__slice_u32 quirks, + const QuirkKeyValuePair* quirks_ptr, + const size_t quirks_len, uint64_t flags, wuffs_base__pixel_blend pixel_blend, wuffs_base__color_u32_argb_premul background_color, @@ -78242,15 +78245,8 @@ } // Apply quirks. - for (size_t i = 0; i < quirks.len; i++) { - // TODO: don't special-case this. - if (quirks.ptr[i] == WUFFS_BASE__QUIRK_QUALITY) { - image_decoder->set_quirk( - WUFFS_BASE__QUIRK_QUALITY, - WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY); - continue; - } - image_decoder->set_quirk(quirks.ptr[i], 1); + for (size_t i = 0; i < quirks_len; i++) { + image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second); } // Apply flags. @@ -78477,10 +78473,10 @@ } wuffs_base__image_decoder::unique_ptr image_decoder(nullptr); - DecodeImageResult result = - DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr, - flags.repr, pixel_blend.repr, background_color.repr, - max_incl_dimension.repr, max_incl_metadata_length.repr); + DecodeImageResult result = DecodeImage0( + image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len, + flags.repr, pixel_blend.repr, background_color.repr, + max_incl_dimension.repr, max_incl_metadata_length.repr); callbacks.Done(result, input, *io_buf, std::move(image_decoder)); return result; } @@ -78515,15 +78511,13 @@ const char DecodeJson_NoMatch[] = // "wuffs_aux::DecodeJson: no match"; -DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0) - : repr(repr0) {} - -DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0) - : repr(wuffs_base__make_slice_u32(ptr0, len0)) {} +DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0, + const size_t len0) + : ptr(ptr0), len(len0) {} DecodeJsonArgQuirks // DecodeJsonArgQuirks::DefaultValue() { - return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32()); + return DecodeJsonArgQuirks(nullptr, 0); } DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0) @@ -78868,11 +78862,11 @@ goto done; } bool allow_tilde_n_tilde_r_tilde_t = false; - for (size_t i = 0; i < quirks.repr.len; i++) { - dec->set_quirk(quirks.repr.ptr[i], 1); - if (quirks.repr.ptr[i] == + for (size_t i = 0; i < quirks.len; i++) { + dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second); + if (quirks.ptr[i].first == WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) { - allow_tilde_n_tilde_r_tilde_t = true; + allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0); } }