mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
base: add optional_u63 type
This commit is contained in:
1 parent
e517ca4bee
commit
82ea1985b4
32 files changed
+470
-295
No files matched your search
@@ -111,14 +111,16 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
"wuffs_aux::DecodeCbor: internal error: io_buf is closed";
|
||||
goto done;
|
||||
}
|
||||
io_buf->compact_retaining(dec->history_retain_length());
|
||||
io_buf->compact_retaining(
|
||||
dec->history_retain_length().value_or(UINT64_MAX));
|
||||
if (io_buf->meta.wi >= io_buf->data.len) {
|
||||
ret_error_message =
|
||||
"wuffs_aux::DecodeCbor: internal error: io_buf is full";
|
||||
goto done;
|
||||
}
|
||||
cursor_index = io_buf->meta.ri;
|
||||
io_error_message = input.CopyIn(io_buf, dec->history_retain_length());
|
||||
io_error_message = input.CopyIn(
|
||||
io_buf, dec->history_retain_length().value_or(UINT64_MAX));
|
||||
} else {
|
||||
ret_error_message = tok_status.message();
|
||||
goto done;
|
||||
|
||||
@@ -436,8 +436,9 @@ redirect:
|
||||
} else if (io_buf.meta.closed) {
|
||||
return DecodeImageResult(DecodeImage_UnexpectedEndOfFile);
|
||||
} else {
|
||||
std::string error_message =
|
||||
input.CopyIn(&io_buf, image_decoder->history_retain_length());
|
||||
std::string error_message = input.CopyIn(
|
||||
&io_buf,
|
||||
image_decoder->history_retain_length().value_or(UINT64_MAX));
|
||||
if (!error_message.empty()) {
|
||||
return DecodeImageResult(std::move(error_message));
|
||||
}
|
||||
@@ -519,8 +520,8 @@ redirect:
|
||||
} else if (io_buf.meta.closed) {
|
||||
return DecodeImageResult(DecodeImage_UnexpectedEndOfFile);
|
||||
} else {
|
||||
std::string error_message =
|
||||
input.CopyIn(&io_buf, image_decoder->history_retain_length());
|
||||
std::string error_message = input.CopyIn(
|
||||
&io_buf, image_decoder->history_retain_length().value_or(UINT64_MAX));
|
||||
if (!error_message.empty()) {
|
||||
return DecodeImageResult(std::move(error_message));
|
||||
}
|
||||
@@ -549,8 +550,8 @@ redirect:
|
||||
message = DecodeImage_UnexpectedEndOfFile;
|
||||
break;
|
||||
} else {
|
||||
std::string error_message =
|
||||
input.CopyIn(&io_buf, image_decoder->history_retain_length());
|
||||
std::string error_message = input.CopyIn(
|
||||
&io_buf, image_decoder->history_retain_length().value_or(UINT64_MAX));
|
||||
if (!error_message.empty()) {
|
||||
message = std::move(error_message);
|
||||
break;
|
||||
@@ -578,8 +579,9 @@ redirect:
|
||||
} else if (io_buf.meta.closed) {
|
||||
return DecodeImageResult(DecodeImage_UnexpectedEndOfFile);
|
||||
} else {
|
||||
std::string error_message =
|
||||
input.CopyIn(&io_buf, image_decoder->history_retain_length());
|
||||
std::string error_message = input.CopyIn(
|
||||
&io_buf,
|
||||
image_decoder->history_retain_length().value_or(UINT64_MAX));
|
||||
if (!error_message.empty()) {
|
||||
return DecodeImageResult(std::move(error_message));
|
||||
}
|
||||
|
||||
@@ -54,58 +54,60 @@ DecodeJsonArgJsonPointer::DefaultValue() {
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \
|
||||
while (tok_buf.meta.ri >= tok_buf.meta.wi) { \
|
||||
if (tok_status.repr == nullptr) { \
|
||||
goto done; \
|
||||
} else if (tok_status.repr == wuffs_base__suspension__short_write) { \
|
||||
tok_buf.compact(); \
|
||||
} else if (tok_status.repr == wuffs_base__suspension__short_read) { \
|
||||
if (!io_error_message.empty()) { \
|
||||
ret_error_message = std::move(io_error_message); \
|
||||
goto done; \
|
||||
} else if (cursor_index != io_buf->meta.ri) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: bad cursor_index"; \
|
||||
goto done; \
|
||||
} else if (io_buf->meta.closed) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: io_buf is closed"; \
|
||||
goto done; \
|
||||
} \
|
||||
io_buf->compact_retaining(dec->history_retain_length()); \
|
||||
if (io_buf->meta.wi >= io_buf->data.len) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: io_buf is full"; \
|
||||
goto done; \
|
||||
} \
|
||||
cursor_index = io_buf->meta.ri; \
|
||||
io_error_message = input.CopyIn(io_buf, dec->history_retain_length()); \
|
||||
} else { \
|
||||
ret_error_message = tok_status.message(); \
|
||||
goto done; \
|
||||
} \
|
||||
tok_status = \
|
||||
dec->decode_tokens(&tok_buf, io_buf, wuffs_base__empty_slice_u8()); \
|
||||
if ((tok_buf.meta.ri > tok_buf.meta.wi) || \
|
||||
(tok_buf.meta.wi > tok_buf.data.len) || \
|
||||
(io_buf->meta.ri > io_buf->meta.wi) || \
|
||||
(io_buf->meta.wi > io_buf->data.len)) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: bad buffer indexes"; \
|
||||
goto done; \
|
||||
} \
|
||||
} \
|
||||
wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \
|
||||
uint64_t token_len = token.length(); \
|
||||
if ((io_buf->meta.ri < cursor_index) || \
|
||||
((io_buf->meta.ri - cursor_index) < token_len)) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: bad token indexes"; \
|
||||
goto done; \
|
||||
} \
|
||||
uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \
|
||||
(void)(token_ptr); \
|
||||
#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \
|
||||
while (tok_buf.meta.ri >= tok_buf.meta.wi) { \
|
||||
if (tok_status.repr == nullptr) { \
|
||||
goto done; \
|
||||
} else if (tok_status.repr == wuffs_base__suspension__short_write) { \
|
||||
tok_buf.compact(); \
|
||||
} else if (tok_status.repr == wuffs_base__suspension__short_read) { \
|
||||
if (!io_error_message.empty()) { \
|
||||
ret_error_message = std::move(io_error_message); \
|
||||
goto done; \
|
||||
} else if (cursor_index != io_buf->meta.ri) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: bad cursor_index"; \
|
||||
goto done; \
|
||||
} else if (io_buf->meta.closed) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: io_buf is closed"; \
|
||||
goto done; \
|
||||
} \
|
||||
io_buf->compact_retaining( \
|
||||
dec->history_retain_length().value_or(UINT64_MAX)); \
|
||||
if (io_buf->meta.wi >= io_buf->data.len) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: io_buf is full"; \
|
||||
goto done; \
|
||||
} \
|
||||
cursor_index = io_buf->meta.ri; \
|
||||
io_error_message = input.CopyIn( \
|
||||
io_buf, dec->history_retain_length().value_or(UINT64_MAX)); \
|
||||
} else { \
|
||||
ret_error_message = tok_status.message(); \
|
||||
goto done; \
|
||||
} \
|
||||
tok_status = \
|
||||
dec->decode_tokens(&tok_buf, io_buf, wuffs_base__empty_slice_u8()); \
|
||||
if ((tok_buf.meta.ri > tok_buf.meta.wi) || \
|
||||
(tok_buf.meta.wi > tok_buf.data.len) || \
|
||||
(io_buf->meta.ri > io_buf->meta.wi) || \
|
||||
(io_buf->meta.wi > io_buf->data.len)) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: bad buffer indexes"; \
|
||||
goto done; \
|
||||
} \
|
||||
} \
|
||||
wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \
|
||||
uint64_t token_len = token.length(); \
|
||||
if ((io_buf->meta.ri < cursor_index) || \
|
||||
((io_buf->meta.ri - cursor_index) < token_len)) { \
|
||||
ret_error_message = \
|
||||
"wuffs_aux::DecodeJson: internal error: bad token indexes"; \
|
||||
goto done; \
|
||||
} \
|
||||
uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \
|
||||
(void)(token_ptr); \
|
||||
cursor_index += static_cast<size_t>(token_len)
|
||||
|
||||
// --------
|
||||
|
||||
Reference in new issue
Block a user