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
@@ -68,6 +68,26 @@ class DecodeCborCallbacks {
|
||||
Done(DecodeCborResult& result, sync_io::Input& input, IOBuffer& buffer);
|
||||
};
|
||||
|
||||
// The FooArgBar types add structure to Foo's optional arguments. They wrap
|
||||
// inner representations for several reasons:
|
||||
// - It provides a home for the DefaultValue static method, for Foo callers
|
||||
// that want to override some but not all optional arguments.
|
||||
// - It provides the "Bar" name at Foo call sites, which can help self-
|
||||
// document Foo calls with many arguemnts.
|
||||
// - It provides some type safety against accidentally transposing or omitting
|
||||
// adjacent fundamentally-numeric-typed optional arguments.
|
||||
|
||||
// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
|
||||
struct DecodeCborArgQuirks {
|
||||
explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeCborArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
};
|
||||
|
||||
// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
|
||||
//
|
||||
// On success, the returned error_message is empty and cursor_position counts
|
||||
@@ -77,6 +97,6 @@ class DecodeCborCallbacks {
|
||||
DecodeCborResult //
|
||||
DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__slice_u32 quirks = wuffs_base__empty_slice_u32());
|
||||
DecodeCborArgQuirks quirks = DecodeCborArgQuirks::DefaultValue());
|
||||
|
||||
} // namespace wuffs_aux
|
||||
Reference in new issue
Block a user