mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 09:01:35 +01:00
Add wuffs_aux::FooArgBar types for optional args
Prior to this commit, with a "wuffs_aux::Foo(x, y, 0, 0, 4, 5)" call, with arguments after "y" optional, it was not a compile-time error to give the wrong number of "0"s or to transpose "4" and "5".
This commit is contained in:
1 parent
0460bfcd7a
commit
ca33506c01
10 files changed
+354
-51
No files matched your search
@@ -32,10 +32,21 @@ DecodeCborCallbacks::Done(DecodeCborResult& result,
|
||||
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::DefaultValue() {
|
||||
return DecodeCborArgQuirks(wuffs_base__empty_slice_u32());
|
||||
}
|
||||
|
||||
DecodeCborResult //
|
||||
DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__slice_u32 quirks) {
|
||||
DecodeCborArgQuirks quirks) {
|
||||
// Prepare the wuffs_base__io_buffer and the resultant error_message.
|
||||
wuffs_base__io_buffer* io_buf = input.BringsItsOwnIOBuffer();
|
||||
wuffs_base__io_buffer fallback_io_buf = wuffs_base__empty_io_buffer();
|
||||
@@ -58,8 +69,8 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
ret_error_message = "wuffs_aux::DecodeCbor: out of memory";
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk_enabled(quirks.ptr[i], true);
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk_enabled(quirks.repr.ptr[i], true);
|
||||
}
|
||||
|
||||
// Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
|
||||
|
||||
Reference in new issue
Block a user