mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Don't use designated initializers
Some C/C++ compilers, such as MSVC, don't always support them. They're also not supported by GCC's "g++ -std=c++11 -Wpedantic".
This commit is contained in:
1 parent
ef7aa0d980
commit
c4b8a6a4cc
19 files changed
+639
-516
No files matched your search
+4
-4
@@ -50,15 +50,15 @@ go test github.com/google/wuffs/...
|
||||
wuffs gen
|
||||
|
||||
echo "Checking snapshot compiles cleanly (as C)"
|
||||
$CC -c -Wall -Werror -std=c99 \
|
||||
$CC -c -Wall -Werror -Wpedantic -std=c99 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
$CC -c -Wall -Werror -DWUFFS_IMPLEMENTATION -std=c99 \
|
||||
$CC -c -Wall -Werror -Wpedantic -DWUFFS_IMPLEMENTATION -std=c99 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
|
||||
echo "Checking snapshot compiles cleanly (as C++)"
|
||||
$CXX -c -Wall -Werror -std=c++11 \
|
||||
$CXX -c -Wall -Werror -Wpedantic -std=c++11 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
$CXX -c -Wall -Werror -DWUFFS_IMPLEMENTATION -std=c++11 \
|
||||
$CXX -c -Wall -Werror -Wpedantic -DWUFFS_IMPLEMENTATION -std=c++11 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
|
||||
wuffs genlib -skipgen
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__ignore_status(wuffs_base__status z) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.
|
||||
@@ -83,11 +83,6 @@ wuffs_base__ignore_status(wuffs_base__status z) {
|
||||
// inline attribute to guide optimizations such as inlining, to avoid the
|
||||
// -Wunused-function warning, and we like to compile with -Wall -Werror.
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__return_empty_struct() {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
}
|
||||
|
||||
// ---------------- Numeric Types
|
||||
|
||||
static inline uint8_t //
|
||||
@@ -417,19 +412,16 @@ wuffs_base__slice_u8__copy_from_slice(wuffs_base__slice_u8 dst,
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {
|
||||
if (y < t.height) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = t.ptr + (t.stride * y),
|
||||
.len = t.width,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Slices and Tables (Utility)
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__utility__null_slice_u8() {
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -456,7 +448,6 @@ wuffs_base__acknowledge_potentially_unused_functions__core_private() {
|
||||
(void)(wuffs_base__load_u64be);
|
||||
(void)(wuffs_base__load_u64le);
|
||||
(void)(wuffs_base__load_u8be);
|
||||
(void)(wuffs_base__return_empty_struct);
|
||||
(void)(wuffs_base__slice_u8__copy_from_slice);
|
||||
(void)(wuffs_base__slice_u8__prefix);
|
||||
(void)(wuffs_base__slice_u8__suffix);
|
||||
|
||||
@@ -118,6 +118,13 @@ typedef struct {
|
||||
uint8_t private_impl;
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__make_empty_struct() {
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
@@ -334,18 +341,47 @@ typedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;
|
||||
typedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;
|
||||
typedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__make_slice_u8(uint8_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u8 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u16 //
|
||||
wuffs_base__make_slice_u16(uint16_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u16 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u32 //
|
||||
wuffs_base__make_slice_u32(uint32_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u32 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u64 //
|
||||
wuffs_base__make_slice_u64(uint64_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u64 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// wuffs_base__slice_u8__subslice_i returns s[i:].
|
||||
//
|
||||
// It returns an empty slice if i is out of bounds.
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {
|
||||
if ((i <= SIZE_MAX) && (i <= s.len)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = s.ptr + i,
|
||||
.len = s.len - i,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(s.ptr + i, s.len - i);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// wuffs_base__slice_u8__subslice_j returns s[:j].
|
||||
@@ -354,12 +390,9 @@ wuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {
|
||||
if ((j <= SIZE_MAX) && (j <= s.len)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = s.ptr,
|
||||
.len = j,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(s.ptr, j);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// wuffs_base__slice_u8__subslice_ij returns s[i:j].
|
||||
@@ -370,12 +403,9 @@ wuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,
|
||||
uint64_t i,
|
||||
uint64_t j) {
|
||||
if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = s.ptr + i,
|
||||
.len = j - i,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(s.ptr + i, j - i);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -386,6 +416,11 @@ wuffs_base__acknowledge_potentially_unused_functions__core_public()
|
||||
|
||||
static inline void
|
||||
wuffs_base__acknowledge_potentially_unused_functions__core_public() {
|
||||
(void)(wuffs_base__make_empty_struct);
|
||||
(void)(wuffs_base__make_slice_u16);
|
||||
(void)(wuffs_base__make_slice_u32);
|
||||
(void)(wuffs_base__make_slice_u64);
|
||||
(void)(wuffs_base__make_slice_u8);
|
||||
(void)(wuffs_base__slice_u8__subslice_i);
|
||||
(void)(wuffs_base__slice_u8__subslice_ij);
|
||||
(void)(wuffs_base__slice_u8__subslice_j);
|
||||
|
||||
@@ -368,17 +368,20 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__pixel_config){
|
||||
.private_impl = {0},
|
||||
});
|
||||
|
||||
c->private_impl.pixfmt = 0;
|
||||
c->private_impl.pixsub = 0;
|
||||
c->private_impl.width = 0;
|
||||
c->private_impl.height = 0;
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__pixel_config){
|
||||
.private_impl = {0},
|
||||
});
|
||||
c->private_impl.pixfmt = 0;
|
||||
c->private_impl.pixsub = 0;
|
||||
c->private_impl.width = 0;
|
||||
c->private_impl.height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,13 +402,21 @@ wuffs_base__pixel_config__pixel_subsampling(wuffs_base__pixel_config* c) {
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__pixel_config__bounds(wuffs_base__pixel_config* c) {
|
||||
return c ? ((wuffs_base__rect_ie_u32){
|
||||
.min_incl_x = 0,
|
||||
.min_incl_y = 0,
|
||||
.max_excl_x = c->private_impl.width,
|
||||
.max_excl_y = c->private_impl.height,
|
||||
})
|
||||
: ((wuffs_base__rect_ie_u32){0});
|
||||
if (c) {
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = 0;
|
||||
ret.min_incl_y = 0;
|
||||
ret.max_excl_x = c->private_impl.width;
|
||||
ret.max_excl_y = c->private_impl.height;
|
||||
return ret;
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = 0;
|
||||
ret.min_incl_y = 0;
|
||||
ret.max_excl_x = 0;
|
||||
ret.max_excl_y = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -555,19 +566,24 @@ wuffs_base__image_config__set(wuffs_base__image_config* c,
|
||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||
return;
|
||||
}
|
||||
*c = ((wuffs_base__image_config){
|
||||
.pixcfg = {.private_impl = {0}},
|
||||
.private_impl = {0},
|
||||
});
|
||||
|
||||
c->pixcfg.private_impl.pixfmt = 0;
|
||||
c->pixcfg.private_impl.pixsub = 0;
|
||||
c->pixcfg.private_impl.width = 0;
|
||||
c->pixcfg.private_impl.height = 0;
|
||||
c->private_impl.first_frame_io_position = 0;
|
||||
c->private_impl.first_frame_is_opaque = 0;
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__image_config__invalidate(wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){
|
||||
.pixcfg = {.private_impl = {0}},
|
||||
.private_impl = {0},
|
||||
});
|
||||
c->pixcfg.private_impl.pixfmt = 0;
|
||||
c->pixcfg.private_impl.pixsub = 0;
|
||||
c->pixcfg.private_impl.width = 0;
|
||||
c->pixcfg.private_impl.height = 0;
|
||||
c->private_impl.first_frame_io_position = 0;
|
||||
c->private_impl.first_frame_is_opaque = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,7 +730,16 @@ wuffs_base__frame_config__update(wuffs_base__frame_config* c,
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {
|
||||
return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){0});
|
||||
if (c) {
|
||||
return c->private_impl.bounds;
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = 0;
|
||||
ret.min_incl_y = 0;
|
||||
ret.max_excl_x = 0;
|
||||
ret.max_excl_y = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -912,13 +937,10 @@ wuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* b) {
|
||||
wuffs_base__table_u8* tab =
|
||||
&b->private_impl.planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];
|
||||
if ((tab->width == 1024) && (tab->height == 1)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = tab->ptr,
|
||||
.len = 1024,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(tab->ptr, 1024);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format //
|
||||
@@ -931,9 +953,16 @@ wuffs_base__pixel_buffer__pixel_format(wuffs_base__pixel_buffer* b) {
|
||||
|
||||
static inline wuffs_base__table_u8 //
|
||||
wuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* b, uint32_t p) {
|
||||
return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))
|
||||
? b->private_impl.planes[p]
|
||||
: ((wuffs_base__table_u8){0});
|
||||
if (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX)) {
|
||||
return b->private_impl.planes[p];
|
||||
}
|
||||
|
||||
wuffs_base__table_u8 ret;
|
||||
ret.ptr = NULL;
|
||||
ret.width = 0;
|
||||
ret.height = 0;
|
||||
ret.stride = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -205,7 +205,10 @@ wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop_r = data.ptr;
|
||||
*ptr_io1_r = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
@@ -215,13 +218,19 @@ wuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,
|
||||
if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {
|
||||
o->private_impl.limit = iop_r + limit;
|
||||
}
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {
|
||||
o->private_impl.mark = mark;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
@@ -229,12 +238,9 @@ wuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {
|
||||
if (n <= ((size_t)(io1_r - *ptr_iop_r))) {
|
||||
uint8_t* p = *ptr_iop_r;
|
||||
*ptr_iop_r += n;
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = p,
|
||||
.len = n,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(p, n);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
@@ -254,25 +260,51 @@ wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop_w = data.ptr;
|
||||
*ptr_io1_w = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {
|
||||
o->private_impl.mark = mark;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---------------- I/O (Utility)
|
||||
|
||||
static inline wuffs_base__io_buffer //
|
||||
wuffs_base__utility__null_io_buffer() {
|
||||
wuffs_base__io_buffer ret;
|
||||
ret.data.ptr = NULL;
|
||||
ret.data.len = 0;
|
||||
ret.meta.wi = 0;
|
||||
ret.meta.ri = 0;
|
||||
ret.meta.pos = 0;
|
||||
ret.meta.closed = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__io_reader //
|
||||
wuffs_base__utility__null_io_reader() {
|
||||
return ((wuffs_base__io_reader){.private_impl = {0}});
|
||||
wuffs_base__io_reader ret;
|
||||
ret.private_impl.buf = NULL;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__io_writer //
|
||||
wuffs_base__utility__null_io_writer() {
|
||||
return ((wuffs_base__io_writer){.private_impl = {0}});
|
||||
wuffs_base__io_writer ret;
|
||||
ret.private_impl.buf = NULL;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -298,6 +330,7 @@ wuffs_base__acknowledge_potentially_unused_functions__io_private() {
|
||||
(void)(wuffs_base__io_writer__is_valid);
|
||||
(void)(wuffs_base__io_writer__set);
|
||||
(void)(wuffs_base__io_writer__set_mark);
|
||||
(void)(wuffs_base__utility__null_io_buffer);
|
||||
(void)(wuffs_base__utility__null_io_reader);
|
||||
(void)(wuffs_base__utility__null_io_writer);
|
||||
}
|
||||
@@ -89,15 +89,19 @@ wuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) {
|
||||
|
||||
static inline wuffs_base__io_reader //
|
||||
wuffs_base__io_buffer__reader(wuffs_base__io_buffer* buf) {
|
||||
wuffs_base__io_reader ret = ((wuffs_base__io_reader){.private_impl = {0}});
|
||||
wuffs_base__io_reader ret;
|
||||
ret.private_impl.buf = buf;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__io_writer //
|
||||
wuffs_base__io_buffer__writer(wuffs_base__io_buffer* buf) {
|
||||
wuffs_base__io_writer ret = ((wuffs_base__io_writer){.private_impl = {0}});
|
||||
wuffs_base__io_writer ret;
|
||||
ret.private_impl.buf = buf;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,10 @@ wuffs_base__malloc_slice_u8(void* (*malloc_func)(size_t), uint64_t num_u8) {
|
||||
if (malloc_func && (num_u8 <= (SIZE_MAX / sizeof(uint8_t)))) {
|
||||
void* p = (*malloc_func)(num_u8 * sizeof(uint8_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = (uint8_t*)(p),
|
||||
.len = num_u8,
|
||||
});
|
||||
return wuffs_base__make_slice_u8((uint8_t*)(p), num_u8);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u16 //
|
||||
@@ -48,13 +45,10 @@ wuffs_base__malloc_slice_u16(void* (*malloc_func)(size_t), uint64_t num_u16) {
|
||||
if (malloc_func && (num_u16 <= (SIZE_MAX / sizeof(uint16_t)))) {
|
||||
void* p = (*malloc_func)(num_u16 * sizeof(uint16_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u16){
|
||||
.ptr = (uint16_t*)(p),
|
||||
.len = num_u16,
|
||||
});
|
||||
return wuffs_base__make_slice_u16((uint16_t*)(p), num_u16);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u16){0});
|
||||
return wuffs_base__make_slice_u16(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u32 //
|
||||
@@ -62,13 +56,10 @@ wuffs_base__malloc_slice_u32(void* (*malloc_func)(size_t), uint64_t num_u32) {
|
||||
if (malloc_func && (num_u32 <= (SIZE_MAX / sizeof(uint32_t)))) {
|
||||
void* p = (*malloc_func)(num_u32 * sizeof(uint32_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u32){
|
||||
.ptr = (uint32_t*)(p),
|
||||
.len = num_u32,
|
||||
});
|
||||
return wuffs_base__make_slice_u32((uint32_t*)(p), num_u32);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u32){0});
|
||||
return wuffs_base__make_slice_u32(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u64 //
|
||||
@@ -76,13 +67,10 @@ wuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) {
|
||||
if (malloc_func && (num_u64 <= (SIZE_MAX / sizeof(uint64_t)))) {
|
||||
void* p = (*malloc_func)(num_u64 * sizeof(uint64_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u64){
|
||||
.ptr = (uint64_t*)(p),
|
||||
.len = num_u64,
|
||||
});
|
||||
return wuffs_base__make_slice_u64((uint64_t*)(p), num_u64);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u64){0});
|
||||
return wuffs_base__make_slice_u64(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
|
||||
@@ -60,34 +60,34 @@ wuffs_base__range_ie_u64__get_max_excl(const wuffs_base__range_ie_u64* r) {
|
||||
|
||||
static inline wuffs_base__range_ii_u32 //
|
||||
wuffs_base__utility__make_range_ii_u32(uint32_t min_incl, uint32_t max_incl) {
|
||||
return ((wuffs_base__range_ii_u32){
|
||||
.min_incl = min_incl,
|
||||
.max_incl = max_incl,
|
||||
});
|
||||
wuffs_base__range_ii_u32 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_incl = max_incl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__range_ie_u32 //
|
||||
wuffs_base__utility__make_range_ie_u32(uint32_t min_incl, uint32_t max_excl) {
|
||||
return ((wuffs_base__range_ie_u32){
|
||||
.min_incl = min_incl,
|
||||
.max_excl = max_excl,
|
||||
});
|
||||
wuffs_base__range_ie_u32 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_excl = max_excl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__range_ii_u64 //
|
||||
wuffs_base__utility__make_range_ii_u64(uint64_t min_incl, uint64_t max_incl) {
|
||||
return ((wuffs_base__range_ii_u64){
|
||||
.min_incl = min_incl,
|
||||
.max_incl = max_incl,
|
||||
});
|
||||
wuffs_base__range_ii_u64 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_incl = max_incl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__range_ie_u64 //
|
||||
wuffs_base__utility__make_range_ie_u64(uint64_t min_incl, uint64_t max_excl) {
|
||||
return ((wuffs_base__range_ie_u64){
|
||||
.min_incl = min_incl,
|
||||
.max_excl = max_excl,
|
||||
});
|
||||
wuffs_base__range_ie_u64 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_excl = max_excl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__rect_ii_u32 //
|
||||
@@ -95,12 +95,12 @@ wuffs_base__utility__make_rect_ii_u32(uint32_t min_incl_x,
|
||||
uint32_t min_incl_y,
|
||||
uint32_t max_incl_x,
|
||||
uint32_t max_incl_y) {
|
||||
return ((wuffs_base__rect_ii_u32){
|
||||
.min_incl_x = min_incl_x,
|
||||
.min_incl_y = min_incl_y,
|
||||
.max_incl_x = max_incl_x,
|
||||
.max_incl_y = max_incl_y,
|
||||
});
|
||||
wuffs_base__rect_ii_u32 ret;
|
||||
ret.min_incl_x = min_incl_x;
|
||||
ret.min_incl_y = min_incl_y;
|
||||
ret.max_incl_x = max_incl_x;
|
||||
ret.max_incl_y = max_incl_y;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
@@ -108,12 +108,12 @@ wuffs_base__utility__make_rect_ie_u32(uint32_t min_incl_x,
|
||||
uint32_t min_incl_y,
|
||||
uint32_t max_excl_x,
|
||||
uint32_t max_excl_y) {
|
||||
return ((wuffs_base__rect_ie_u32){
|
||||
.min_incl_x = min_incl_x,
|
||||
.min_incl_y = min_incl_y,
|
||||
.max_excl_x = max_excl_x,
|
||||
.max_excl_y = max_excl_y,
|
||||
});
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = min_incl_x;
|
||||
ret.min_incl_y = min_incl_y;
|
||||
ret.max_excl_x = max_excl_x;
|
||||
ret.max_excl_y = max_excl_y;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
|
||||
@@ -119,7 +119,7 @@ func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
// TODO: don't hard-code the recv being a_src.
|
||||
switch method {
|
||||
case t.IDUndoByte:
|
||||
b.writes("(iop_a_src--, wuffs_base__return_empty_struct())")
|
||||
b.writes("(iop_a_src--, wuffs_base__make_empty_struct())")
|
||||
return nil
|
||||
|
||||
case t.IDCanUndoByte:
|
||||
@@ -147,14 +147,11 @@ func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
}
|
||||
|
||||
if method == t.IDSinceMark {
|
||||
b.printf("((wuffs_base__slice_u8){ "+
|
||||
".ptr = %s%s.private_impl.mark, "+
|
||||
".len = (size_t)(",
|
||||
prefix, name)
|
||||
b.printf("wuffs_base__make_slice_u8(%s%s.private_impl.mark, (size_t)(", prefix, name)
|
||||
}
|
||||
b.printf("iop_%s%s - %s%s.private_impl.mark", prefix, name, prefix, name)
|
||||
if method == t.IDSinceMark {
|
||||
b.writes("), })")
|
||||
b.writes("))")
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -167,7 +164,7 @@ func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
if err := g.writeExpr(b, args[0].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(", wuffs_base__return_empty_struct())")
|
||||
b.writes(", wuffs_base__make_empty_struct())")
|
||||
return nil
|
||||
|
||||
case t.IDTake:
|
||||
@@ -250,14 +247,11 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
}
|
||||
|
||||
if method == t.IDSinceMark {
|
||||
b.printf("((wuffs_base__slice_u8){ "+
|
||||
".ptr = %s%s.private_impl.mark, "+
|
||||
".len = (size_t)(",
|
||||
prefix, name)
|
||||
b.printf("wuffs_base__make_slice_u8(%s%s.private_impl.mark, (size_t)(", prefix, name)
|
||||
}
|
||||
b.printf("iop_%s%s - %s%s.private_impl.mark", prefix, name, prefix, name)
|
||||
if method == t.IDSinceMark {
|
||||
b.writes("), })")
|
||||
b.writes("))")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -274,7 +268,7 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
if err := g.writeExpr(b, args[0].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.printf("), iop_a_dst += %d, wuffs_base__return_empty_struct())", p.n/8)
|
||||
b.printf("), iop_a_dst += %d, wuffs_base__make_empty_struct())", p.n/8)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ const baseImageImplC = "" +
|
||||
""
|
||||
|
||||
const baseCorePrivateH = "" +
|
||||
"static inline wuffs_base__empty_struct //\nwuffs_base__ignore_status(wuffs_base__status z) {\n return ((wuffs_base__empty_struct){0});\n}\n\n// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.\n// It's not foolproof, given C doesn't automatically zero memory before use,\n// but it should catch 99.99% of cases.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"wuffs\").\n#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)\n\n// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable\n// error was previously encountered.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"disabled\").\n#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)\n\n// Denote intentional fallthroughs for -Wimplicit-fallthrough.\n//\n// The order matters here. Clang also defines \"__GNUC__\".\n#if defined(__clang__) && __cplusplus >= 201103L\n#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]\n#elif !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 7)\n#define WUFFS_BASE__FALLTHROUGH __attribute" +
|
||||
"static inline wuffs_base__empty_struct //\nwuffs_base__ignore_status(wuffs_base__status z) {\n return wuffs_base__make_empty_struct();\n}\n\n// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.\n// It's not foolproof, given C doesn't automatically zero memory before use,\n// but it should catch 99.99% of cases.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"wuffs\").\n#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)\n\n// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable\n// error was previously encountered.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"disabled\").\n#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)\n\n// Denote intentional fallthroughs for -Wimplicit-fallthrough.\n//\n// The order matters here. Clang also defines \"__GNUC__\".\n#if defined(__clang__) && __cplusplus >= 201103L\n#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]\n#elif !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 7)\n#define WUFFS_BASE__FALLTHROUGH __attribute" +
|
||||
"__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use trivial macros instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status) { \\\n goto ok; \\\n } else if (*status != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point = n; " +
|
||||
" \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKELY(expr) (expr)\n#endif\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__return_empty_struct() {\n return ((wuffs_base__empty_struct){0});\n}\n\n" +
|
||||
" \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKELY(expr) (expr)\n#endif\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\n" +
|
||||
"" +
|
||||
"// ---------------- Numeric Types\n\nstatic inline uint8_t //\nwuffs_base__load_u8be(uint8_t* p) {\n return p[0];\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16be(uint8_t* p) {\n return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16le(uint8_t* p) {\n return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uin" +
|
||||
"t32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 32) | ((uint64_t)(p[1]) << 24) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 8) |\n ((uint64_t)(p[4]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 40) | ((uint64_t)(p[1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);\n}\n\nstatic inline u" +
|
||||
@@ -52,12 +52,12 @@ const baseCorePrivateH = "" +
|
||||
"// ---------------- Slices and Tables\n\n// wuffs_base__slice_u8__prefix returns up to the first up_to bytes of s.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__prefix(wuffs_base__slice_u8 s, uint64_t up_to) {\n if ((uint64_t)(s.len) > up_to) {\n s.len = up_to;\n }\n return s;\n}\n\n// wuffs_base__slice_u8__suffix returns up to the last up_to bytes of s.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__suffix(wuffs_base__slice_u8 s, uint64_t up_to) {\n if ((uint64_t)(s.len) > up_to) {\n s.ptr += (uint64_t)(s.len) - up_to;\n s.len = up_to;\n }\n return s;\n}\n\n// wuffs_base__slice_u8__copy_from_slice calls memmove(dst.ptr, src.ptr, len)\n// where len is the minimum of dst.len and src.len.\n//\n// Passing a wuffs_base__slice_u8 with all fields NULL or zero (a valid, empty\n// slice) is valid and results in a no-op.\nstatic inline uint64_t //\nwuffs_base__slice_u8__copy_from_slice(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t len = dst.l" +
|
||||
"en < src.len ? dst.len : src.len;\n if (len > 0) {\n memmove(dst.ptr, src.ptr, len);\n }\n return len;\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {\n if (y < t.height) {\n return ((wuffs_base__slice_u8){\n .ptr = t.ptr + (t.stride * y),\n .len = t.width,\n });\n }\n return ((wuffs_base__slice_u8){0});\n}\n\n" +
|
||||
"// --------\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {\n if (y < t.height) {\n return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Slices and Tables (Utility)\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__utility__null_slice_u8() {\n return ((wuffs_base__slice_u8){0});\n}\n\n" +
|
||||
"// ---------------- Slices and Tables (Utility)\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__utility__null_slice_u8() {\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_private()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_private() {\n (void)(wuffs_base__ignore_status);\n (void)(wuffs_base__load_u16be);\n (void)(wuffs_base__load_u16le);\n (void)(wuffs_base__load_u24be);\n (void)(wuffs_base__load_u24le);\n (void)(wuffs_base__load_u32be);\n (void)(wuffs_base__load_u32le);\n (void)(wuffs_base__load_u40be);\n (void)(wuffs_base__load_u40le);\n (void)(wuffs_base__load_u48be);\n (void)(wuffs_base__load_u48le);\n (void)(wuffs_base__load_u56be);\n (void)(wuffs_base__load_u56le);\n (void)(wuffs_base__load_u64be);\n (void)(wuffs_base__load_u64le);\n (void)(wuffs_base__load_u8be);\n (void)(wuffs_base__return_empty_struct);\n (void)(wuffs_base__slice_u8__copy_from_slice);\n (void)(wuffs_base__slice_u8__prefix);\n (void)(wuffs_base__slice_u8__suffix);\n (void)(wuffs_base__store_u16be);\n " +
|
||||
"(void)(wuffs_base__store_u16le);\n (void)(wuffs_base__store_u24be);\n (void)(wuffs_base__store_u24le);\n (void)(wuffs_base__store_u32be);\n (void)(wuffs_base__store_u32le);\n (void)(wuffs_base__store_u40be);\n (void)(wuffs_base__store_u40le);\n (void)(wuffs_base__store_u48be);\n (void)(wuffs_base__store_u48le);\n (void)(wuffs_base__store_u56be);\n (void)(wuffs_base__store_u56le);\n (void)(wuffs_base__store_u64be);\n (void)(wuffs_base__store_u64le);\n (void)(wuffs_base__store_u8be);\n (void)(wuffs_base__table_u8__row);\n (void)(wuffs_base__u16__sat_add_indirect);\n (void)(wuffs_base__u16__sat_sub_indirect);\n (void)(wuffs_base__u32__sat_add_indirect);\n (void)(wuffs_base__u32__sat_sub_indirect);\n (void)(wuffs_base__u64__sat_add_indirect);\n (void)(wuffs_base__u64__sat_sub_indirect);\n (void)(wuffs_base__u8__sat_add_indirect);\n (void)(wuffs_base__u8__sat_sub_indirect);\n (void)(wuffs_base__utility__null_slice_u8);\n}\n" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_private()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_private() {\n (void)(wuffs_base__ignore_status);\n (void)(wuffs_base__load_u16be);\n (void)(wuffs_base__load_u16le);\n (void)(wuffs_base__load_u24be);\n (void)(wuffs_base__load_u24le);\n (void)(wuffs_base__load_u32be);\n (void)(wuffs_base__load_u32le);\n (void)(wuffs_base__load_u40be);\n (void)(wuffs_base__load_u40le);\n (void)(wuffs_base__load_u48be);\n (void)(wuffs_base__load_u48le);\n (void)(wuffs_base__load_u56be);\n (void)(wuffs_base__load_u56le);\n (void)(wuffs_base__load_u64be);\n (void)(wuffs_base__load_u64le);\n (void)(wuffs_base__load_u8be);\n (void)(wuffs_base__slice_u8__copy_from_slice);\n (void)(wuffs_base__slice_u8__prefix);\n (void)(wuffs_base__slice_u8__suffix);\n (void)(wuffs_base__store_u16be);\n (void)(wuffs_base__store_u16le);\n (void)(w" +
|
||||
"uffs_base__store_u24be);\n (void)(wuffs_base__store_u24le);\n (void)(wuffs_base__store_u32be);\n (void)(wuffs_base__store_u32le);\n (void)(wuffs_base__store_u40be);\n (void)(wuffs_base__store_u40le);\n (void)(wuffs_base__store_u48be);\n (void)(wuffs_base__store_u48le);\n (void)(wuffs_base__store_u56be);\n (void)(wuffs_base__store_u56le);\n (void)(wuffs_base__store_u64be);\n (void)(wuffs_base__store_u64le);\n (void)(wuffs_base__store_u8be);\n (void)(wuffs_base__table_u8__row);\n (void)(wuffs_base__u16__sat_add_indirect);\n (void)(wuffs_base__u16__sat_sub_indirect);\n (void)(wuffs_base__u32__sat_add_indirect);\n (void)(wuffs_base__u32__sat_sub_indirect);\n (void)(wuffs_base__u64__sat_add_indirect);\n (void)(wuffs_base__u64__sat_sub_indirect);\n (void)(wuffs_base__u8__sat_add_indirect);\n (void)(wuffs_base__u8__sat_sub_indirect);\n (void)(wuffs_base__utility__null_slice_u8);\n}\n" +
|
||||
""
|
||||
|
||||
const baseCorePublicH = "" +
|
||||
@@ -66,8 +66,8 @@ const baseCorePublicH = "" +
|
||||
"__WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n#define WUFFS_BASE__POTENTIALLY_UNUSED\n#define WUFFS_BASE__WARN_UNUSED_RESULT\n#endif\n\n// Flags for wuffs_foo__bar__initialize functions.\n\n#define WUFFS_INITIALIZE__DEFAULT_OPTIONS ((uint32_t)0x00000000)\n\n// WUFFS_INITIALIZE__ALREADY_ZEROED means that the \"self\" receiver struct value\n// has already been set to all zeroes.\n#define WUFFS_INITIALIZE__ALREADY_ZEROED ((uint32_t)0x00000001)\n\n// WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED means that, absent\n// WUFFS_INITIALIZE__ALREADY_ZEROED, only some of the \"self\" receiver struct\n// value will be set to all zeroes. Internal buffers, which tend to be a large\n// proportion of the struct's size, will be left uninitialized. Internal means\n// that the buffer is contained by the receiver struct, as opposed to being\n// passed as a separately allocated \"work buffer\".\n//\n// With or without this bit set, the Wuffs compiler still enforces that no\n// reads or writes will overflow internal buffers' bound" +
|
||||
"s. Even with this bit\n// set, the Wuffs standard library also considers reading from an uninitialized\n// buffer to be a bug, and strives to never do so, but unlike buffer overflows,\n// it is not a bug class that the Wuffs compiler eliminates.\n//\n// For those paranoid about security, leave this bit unset, so that\n// wuffs_foo__bar__initialize will initialize the entire struct value to zeroes\n// (unless WUFFS_INITIALIZE__ALREADY_ZEROED is set).\n//\n// Setting this bit gives a small absolute improvement on micro-benchmarks, but\n// this can be a large relative effect, up to 2x faster, when the actual work\n// to be done is also small, such as decompressing small input. See git commit\n// 438fc105 \"Move some struct fields to private_data\" for some numbers and a\n// discussion, noting that its commit message was written before this\n// WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED option was defined.\n#define WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED \\\n ((uint32_t)0x00000002)\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n // private_impl is a pla" +
|
||||
"ceholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" +
|
||||
"// --------\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__make_empty_struct() {\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\n// wuffs_base__utility is" +
|
||||
" a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\n//\n// Statuses come in four categories:\n// - OK: the request was completed, successfully.\n// - Warnings: the request was completed, unsuccessfully.\n// - Suspensions: the request was not completed, but can be re-tried.\n// - Errors: the request was not completed, permanently.\n//\n// When a function returns an incomplete status, a suspension means that that\n// function should be called again within a new context, such as after flushing\n// or re-filling an I/O buffer. An error means that an irrecoverable failure\n// state was reached.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_bas" +
|
||||
"e__status names.\n\nstatic inline bool //\nwuffs_base__status__is_complete(wuffs_base__status z) {\n return (z == NULL) || ((*z != '$') && (*z != '#'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '#');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '#');\n}\n\n" +
|
||||
@@ -80,11 +80,12 @@ const baseCorePublicH = "" +
|
||||
"_u32__sat_sub(uint32_t x, uint32_t y) {\n uint32_t res = x - y;\n res &= -(res <= x);\n return res;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__sat_add(uint64_t x, uint64_t y) {\n uint64_t res = x + y;\n res |= -(res < x);\n return res;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {\n uint64_t res = x - y;\n res &= -(res <= x);\n return res;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Slices and Tables\n\n// WUFFS_BASE__SLICE is a 1-dimensional buffer.\n//\n// len measures a number of elements, not necessarily a size in bytes.\n//\n// A value with all fields NULL or zero is a valid, empty slice.\n#define WUFFS_BASE__SLICE(T) \\\n struct { \\\n T* ptr; \\\n size_t len; \\\n }\n\n// WUFFS_BASE__TABLE is a 2-dimensional buffer.\n//\n// width height, and stride measure a number of elements, not necessarily a\n// size in bytes.\n//\n// A value with all fields NULL or zero is a valid, empty table.\n#define WUFFS_BASE__TABLE(T) \\\n struct { \\\n T* ptr; \\\n size_t width; \\\n size_t height; \\\n size_t stride; \\\n }\n\ntypedef WUFFS_BASE__SLICE(uint8_t) wuffs_base__slice_u8;\ntypedef WUFFS_BASE__SLICE(uint16_t) wuffs_base__slice_u16;\ntypedef WUFFS_BASE__SLICE(uint32_t) wuffs_base__slice_u32;\ntypedef WUFFS_BASE__SLICE(uint64_t) wuffs_base__slice_u64;\n\ntypedef WUFFS_BASE__TABLE(u" +
|
||||
"int8_t) wuffs_base__table_u8;\ntypedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;\ntypedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;\ntypedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;\n\n// wuffs_base__slice_u8__subslice_i returns s[i:].\n//\n// It returns an empty slice if i is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {\n if ((i <= SIZE_MAX) && (i <= s.len)) {\n return ((wuffs_base__slice_u8){\n .ptr = s.ptr + i,\n .len = s.len - i,\n });\n }\n return ((wuffs_base__slice_u8){0});\n}\n\n// wuffs_base__slice_u8__subslice_j returns s[:j].\n//\n// It returns an empty slice if j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {\n if ((j <= SIZE_MAX) && (j <= s.len)) {\n return ((wuffs_base__slice_u8){\n .ptr = s.ptr,\n .len = j,\n });\n }\n return ((wuffs_base__slice_u8){0});\n}\n\n// wuffs_base__slice_u8__subslic" +
|
||||
"e_ij returns s[i:j].\n//\n// It returns an empty slice if i or j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,\n uint64_t i,\n uint64_t j) {\n if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {\n return ((wuffs_base__slice_u8){\n .ptr = s.ptr + i,\n .len = j - i,\n });\n }\n return ((wuffs_base__slice_u8){0});\n}\n\n" +
|
||||
"int8_t) wuffs_base__table_u8;\ntypedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;\ntypedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;\ntypedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__make_slice_u8(uint8_t* ptr, size_t len) {\n wuffs_base__slice_u8 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u16 //\nwuffs_base__make_slice_u16(uint16_t* ptr, size_t len) {\n wuffs_base__slice_u16 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u32 //\nwuffs_base__make_slice_u32(uint32_t* ptr, size_t len) {\n wuffs_base__slice_u32 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u64 //\nwuffs_base__make_slice_u64(uint64_t* ptr, size_t len) {\n wuffs_base__slice_u64 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\n// wuffs_base__slice_u8__subslice_i returns s[i:].\n//\n// It returns an empty slice if i is out of bounds.\nstatic inl" +
|
||||
"ine wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {\n if ((i <= SIZE_MAX) && (i <= s.len)) {\n return wuffs_base__make_slice_u8(s.ptr + i, s.len - i);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n// wuffs_base__slice_u8__subslice_j returns s[:j].\n//\n// It returns an empty slice if j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {\n if ((j <= SIZE_MAX) && (j <= s.len)) {\n return wuffs_base__make_slice_u8(s.ptr, j);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n// wuffs_base__slice_u8__subslice_ij returns s[i:j].\n//\n// It returns an empty slice if i or j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,\n uint64_t i,\n uint64_t j) {\n if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {\n return wuffs_base__make_slice_u8(s.ptr + i, j - i);\n " +
|
||||
" }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_public()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_public() {\n (void)(wuffs_base__slice_u8__subslice_i);\n (void)(wuffs_base__slice_u8__subslice_ij);\n (void)(wuffs_base__slice_u8__subslice_j);\n (void)(wuffs_base__status__is_complete);\n (void)(wuffs_base__status__is_error);\n (void)(wuffs_base__status__is_ok);\n (void)(wuffs_base__status__is_suspension);\n (void)(wuffs_base__status__is_warning);\n (void)(wuffs_base__u16__max);\n (void)(wuffs_base__u16__min);\n (void)(wuffs_base__u16__sat_add);\n (void)(wuffs_base__u16__sat_sub);\n (void)(wuffs_base__u32__max);\n (void)(wuffs_base__u32__min);\n (void)(wuffs_base__u32__sat_add);\n (void)(wuffs_base__u32__sat_sub);\n (void)(wuffs_base__u64__max);\n (void)(wuffs_base__u64__min);\n (void)(wuffs_base__u64__sat_add);\n (void)(wuffs_base__u64__sat_sub);\n (void)(" +
|
||||
"wuffs_base__u8__max);\n (void)(wuffs_base__u8__min);\n (void)(wuffs_base__u8__sat_add);\n (void)(wuffs_base__u8__sat_sub);\n}\n" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_public()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__core_public() {\n (void)(wuffs_base__make_empty_struct);\n (void)(wuffs_base__make_slice_u16);\n (void)(wuffs_base__make_slice_u32);\n (void)(wuffs_base__make_slice_u64);\n (void)(wuffs_base__make_slice_u8);\n (void)(wuffs_base__slice_u8__subslice_i);\n (void)(wuffs_base__slice_u8__subslice_ij);\n (void)(wuffs_base__slice_u8__subslice_j);\n (void)(wuffs_base__status__is_complete);\n (void)(wuffs_base__status__is_error);\n (void)(wuffs_base__status__is_ok);\n (void)(wuffs_base__status__is_suspension);\n (void)(wuffs_base__status__is_warning);\n (void)(wuffs_base__u16__max);\n (void)(wuffs_base__u16__min);\n (void)(wuffs_base__u16__sat_add);\n (void)(wuffs_base__u16__sat_sub);\n (void)(wuffs_base__u32__max);\n (void)(wuffs_base__u32__min);\n (void)(wuffs_base__u32_" +
|
||||
"_sat_add);\n (void)(wuffs_base__u32__sat_sub);\n (void)(wuffs_base__u64__max);\n (void)(wuffs_base__u64__min);\n (void)(wuffs_base__u64__sat_add);\n (void)(wuffs_base__u64__sat_sub);\n (void)(wuffs_base__u8__max);\n (void)(wuffs_base__u8__min);\n (void)(wuffs_base__u8__sat_add);\n (void)(wuffs_base__u8__sat_sub);\n}\n" +
|
||||
""
|
||||
|
||||
const baseMemoryPrivateH = "" +
|
||||
@@ -92,9 +93,9 @@ const baseMemoryPrivateH = "" +
|
||||
""
|
||||
|
||||
const baseMemoryPublicH = "" +
|
||||
"// ---------------- Memory Allocation\n\n// The memory allocation related functions in this section aren't used by Wuffs\n// per se, but they may be helpful to the code that uses Wuffs.\n\n// wuffs_base__malloc_slice_uxx wraps calling a malloc-like function, except\n// that it takes a uint64_t number of elements instead of a size_t size in\n// bytes, and it returns a slice (a pointer and a length) instead of just a\n// pointer.\n//\n// You can pass the C stdlib's malloc as the malloc_func.\n//\n// It returns an empty slice (containing a NULL ptr field) if (num_uxx *\n// sizeof(uintxx_t)) would overflow SIZE_MAX.\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__malloc_slice_u8(void* (*malloc_func)(size_t), uint64_t num_u8) {\n if (malloc_func && (num_u8 <= (SIZE_MAX / sizeof(uint8_t)))) {\n void* p = (*malloc_func)(num_u8 * sizeof(uint8_t));\n if (p) {\n return ((wuffs_base__slice_u8){\n .ptr = (uint8_t*)(p),\n .len = num_u8,\n });\n }\n }\n return ((wuffs_base__slice_u8){0});\n}\n\nstatic inl" +
|
||||
"ine wuffs_base__slice_u16 //\nwuffs_base__malloc_slice_u16(void* (*malloc_func)(size_t), uint64_t num_u16) {\n if (malloc_func && (num_u16 <= (SIZE_MAX / sizeof(uint16_t)))) {\n void* p = (*malloc_func)(num_u16 * sizeof(uint16_t));\n if (p) {\n return ((wuffs_base__slice_u16){\n .ptr = (uint16_t*)(p),\n .len = num_u16,\n });\n }\n }\n return ((wuffs_base__slice_u16){0});\n}\n\nstatic inline wuffs_base__slice_u32 //\nwuffs_base__malloc_slice_u32(void* (*malloc_func)(size_t), uint64_t num_u32) {\n if (malloc_func && (num_u32 <= (SIZE_MAX / sizeof(uint32_t)))) {\n void* p = (*malloc_func)(num_u32 * sizeof(uint32_t));\n if (p) {\n return ((wuffs_base__slice_u32){\n .ptr = (uint32_t*)(p),\n .len = num_u32,\n });\n }\n }\n return ((wuffs_base__slice_u32){0});\n}\n\nstatic inline wuffs_base__slice_u64 //\nwuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) {\n if (malloc_func && (num_u64 <= (SIZE_MAX / sizeof(uint64_t)))) {\n void* p = " +
|
||||
"(*malloc_func)(num_u64 * sizeof(uint64_t));\n if (p) {\n return ((wuffs_base__slice_u64){\n .ptr = (uint64_t*)(p),\n .len = num_u64,\n });\n }\n }\n return ((wuffs_base__slice_u64){0});\n}\n\n" +
|
||||
"// ---------------- Memory Allocation\n\n// The memory allocation related functions in this section aren't used by Wuffs\n// per se, but they may be helpful to the code that uses Wuffs.\n\n// wuffs_base__malloc_slice_uxx wraps calling a malloc-like function, except\n// that it takes a uint64_t number of elements instead of a size_t size in\n// bytes, and it returns a slice (a pointer and a length) instead of just a\n// pointer.\n//\n// You can pass the C stdlib's malloc as the malloc_func.\n//\n// It returns an empty slice (containing a NULL ptr field) if (num_uxx *\n// sizeof(uintxx_t)) would overflow SIZE_MAX.\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__malloc_slice_u8(void* (*malloc_func)(size_t), uint64_t num_u8) {\n if (malloc_func && (num_u8 <= (SIZE_MAX / sizeof(uint8_t)))) {\n void* p = (*malloc_func)(num_u8 * sizeof(uint8_t));\n if (p) {\n return wuffs_base__make_slice_u8((uint8_t*)(p), num_u8);\n }\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__slice_u16 //\nwuffs" +
|
||||
"_base__malloc_slice_u16(void* (*malloc_func)(size_t), uint64_t num_u16) {\n if (malloc_func && (num_u16 <= (SIZE_MAX / sizeof(uint16_t)))) {\n void* p = (*malloc_func)(num_u16 * sizeof(uint16_t));\n if (p) {\n return wuffs_base__make_slice_u16((uint16_t*)(p), num_u16);\n }\n }\n return wuffs_base__make_slice_u16(NULL, 0);\n}\n\nstatic inline wuffs_base__slice_u32 //\nwuffs_base__malloc_slice_u32(void* (*malloc_func)(size_t), uint64_t num_u32) {\n if (malloc_func && (num_u32 <= (SIZE_MAX / sizeof(uint32_t)))) {\n void* p = (*malloc_func)(num_u32 * sizeof(uint32_t));\n if (p) {\n return wuffs_base__make_slice_u32((uint32_t*)(p), num_u32);\n }\n }\n return wuffs_base__make_slice_u32(NULL, 0);\n}\n\nstatic inline wuffs_base__slice_u64 //\nwuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) {\n if (malloc_func && (num_u64 <= (SIZE_MAX / sizeof(uint64_t)))) {\n void* p = (*malloc_func)(num_u64 * sizeof(uint64_t));\n if (p) {\n return wuffs_base__make_slice_u64((uint64_" +
|
||||
"t*)(p), num_u64);\n }\n }\n return wuffs_base__make_slice_u64(NULL, 0);\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__memory_public()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__memory_public() {\n (void)(wuffs_base__malloc_slice_u16);\n (void)(wuffs_base__malloc_slice_u32);\n (void)(wuffs_base__malloc_slice_u64);\n (void)(wuffs_base__malloc_slice_u8);\n}\n" +
|
||||
""
|
||||
@@ -123,33 +124,33 @@ const baseImagePublicH = "" +
|
||||
" uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 2;\n return (s >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__shift_y(wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 0;\n return (s >> shift) & 0x03;\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_format pixfmt;\n wuffs_base__pixel_subsampling pixsub;\n uint32_t width;\n uint32_t height;\n } private_impl;\n\n#ifdef __cplusplus\n inline void set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height);\n inline void invalidate();\n inline bool is_valid();\n inline wuffs_base__pixel_format pixel_format();\n inline wuffs_base__pixel_subsampling pixel_subsampling();\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline uint64_t pixbuf_len();\n#endif // __cplusplus\n\n} wuffs_base__pixel_config;\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__pixel_config__set(wuffs_base__pixel_config* c,\n wuf" +
|
||||
"fs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n if (!c) {\n return;\n }\n if (pixfmt) {\n uint64_t wh = ((uint64_t)width) * ((uint64_t)height);\n // TODO: handle things other than 1 byte per pixel.\n if (wh <= ((uint64_t)SIZE_MAX)) {\n c->private_impl.pixfmt = pixfmt;\n c->private_impl.pixsub = pixsub;\n c->private_impl.width = width;\n c->private_impl.height = height;\n return;\n }\n }\n *c = ((wuffs_base__pixel_config){\n .private_impl = {0},\n });\n}\n\nstatic inline void //\nwuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {\n if (c) {\n *c = ((wuffs_base__pixel_config){\n .private_impl = {0},\n });\n }\n}\n\nstatic inline bool //\nwuffs_base__pixel_config__is_valid(wuffs_base__pixel_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_config__pi" +
|
||||
"xel_format(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config__pixel_subsampling(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config__bounds(wuffs_base__pixel_config* c) {\n return c ? ((wuffs_base__rect_ie_u32){\n .min_incl_x = 0,\n .min_incl_y = 0,\n .max_excl_x = c->private_impl.width,\n .max_excl_y = c->private_impl.height,\n })\n : ((wuffs_base__rect_ie_u32){0});\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__width(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__height(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? Should it allow\n// decoding into a color model diff" +
|
||||
"erent from the format's intrinsic one? For\n// example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline uint64_t //\nwuffs_base__pixel_config__pixbuf_len(wuffs_base__pixel_config* c) {\n if (!c) {\n return 0;\n }\n if (wuffs_base__pixel_format__is_planar(c->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return 0;\n }\n uint32_t bits_per_pixel =\n wuffs_base__pixel_format__bits_per_pixel(c->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?\n return 0;\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint64_t n =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n if (n > (UINT64_MAX / bytes_per_pixel)) {\n return 0;\n }\n n *= bytes_per_pixel;\n\n if (wuffs_base__pixel_format__is_indexed(c->private_impl.pixfmt)) {\n if (n > (UINT64_MAX - 1024)) {\n return 0;\n }\n n += 1024;\n }" +
|
||||
"\n\n return n;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__pixel_config::set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n wuffs_base__pixel_config__set(this, pixfmt, pixsub, width, height);\n}\n\ninline void //\nwuffs_base__pixel_config::invalidate() {\n wuffs_base__pixel_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__pixel_config::is_valid() {\n return wuffs_base__pixel_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_config::pixel_format() {\n return wuffs_base__pixel_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config::pixel_subsampling() {\n return wuffs_base__pixel_config__pixel_subsampling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config::bounds() {\n return wuffs_base__pixel_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config" +
|
||||
"::width() {\n return wuffs_base__pixel_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::height() {\n return wuffs_base__pixel_config__height(this);\n}\n\ninline uint64_t //\nwuffs_base__pixel_config::pixbuf_len() {\n return wuffs_base__pixel_config__pixbuf_len(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"fs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n if (!c) {\n return;\n }\n if (pixfmt) {\n uint64_t wh = ((uint64_t)width) * ((uint64_t)height);\n // TODO: handle things other than 1 byte per pixel.\n if (wh <= ((uint64_t)SIZE_MAX)) {\n c->private_impl.pixfmt = pixfmt;\n c->private_impl.pixsub = pixsub;\n c->private_impl.width = width;\n c->private_impl.height = height;\n return;\n }\n }\n\n c->private_impl.pixfmt = 0;\n c->private_impl.pixsub = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n}\n\nstatic inline void //\nwuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {\n if (c) {\n c->private_impl.pixfmt = 0;\n c->private_impl.pixsub = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__pixel_config__is_valid(wuffs_base__pixel_config* c) {\n return " +
|
||||
"c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_config__pixel_format(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config__pixel_subsampling(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config__bounds(wuffs_base__pixel_config* c) {\n if (c) {\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = c->private_impl.width;\n ret.max_excl_y = c->private_impl.height;\n return ret;\n }\n\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = 0;\n ret.max_excl_y = 0;\n return ret;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__width(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__height(wuffs_base__pixel_config* c) {\n" +
|
||||
" return c ? c->private_impl.height : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? Should it allow\n// decoding into a color model different from the format's intrinsic one? For\n// example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline uint64_t //\nwuffs_base__pixel_config__pixbuf_len(wuffs_base__pixel_config* c) {\n if (!c) {\n return 0;\n }\n if (wuffs_base__pixel_format__is_planar(c->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return 0;\n }\n uint32_t bits_per_pixel =\n wuffs_base__pixel_format__bits_per_pixel(c->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?\n return 0;\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint64_t n =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n if (n > (UINT64_MAX / bytes_per_pixel)) {\n return 0;\n }\n n *= byte" +
|
||||
"s_per_pixel;\n\n if (wuffs_base__pixel_format__is_indexed(c->private_impl.pixfmt)) {\n if (n > (UINT64_MAX - 1024)) {\n return 0;\n }\n n += 1024;\n }\n\n return n;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__pixel_config::set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n wuffs_base__pixel_config__set(this, pixfmt, pixsub, width, height);\n}\n\ninline void //\nwuffs_base__pixel_config::invalidate() {\n wuffs_base__pixel_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__pixel_config::is_valid() {\n return wuffs_base__pixel_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_config::pixel_format() {\n return wuffs_base__pixel_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config::pixel_subsampling() {\n return wuffs_base__pixel_config__pixel_subsampling(this);\n}\n\ninline wu" +
|
||||
"ffs_base__rect_ie_u32 //\nwuffs_base__pixel_config::bounds() {\n return wuffs_base__pixel_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::width() {\n return wuffs_base__pixel_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::height() {\n return wuffs_base__pixel_config__height(this);\n}\n\ninline uint64_t //\nwuffs_base__pixel_config::pixbuf_len() {\n return wuffs_base__pixel_config__pixbuf_len(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n uint64_t first_frame_io_position;\n bool first_frame_is_opaque;\n } private_impl;\n\n#ifdef __cplusplus\n inline void set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque);\n inline void invalidate();\n inline bool is_valid();\n inline uint64_t first_frame_io_position();\n inline bool first_frame_is_opaque();\n#endif // __cplusplus\n\n} wuffs_base__image_config;\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__image_config__set(wuffs_base__image_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__" +
|
||||
"pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (wuffs_base__pixel_format__is_valid(pixfmt)) {\n c->pixcfg.private_impl.pixfmt = pixfmt;\n c->pixcfg.private_impl.pixsub = pixsub;\n c->pixcfg.private_impl.width = width;\n c->pixcfg.private_impl.height = height;\n c->private_impl.first_frame_io_position = first_frame_io_position;\n c->private_impl.first_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n *c = ((wuffs_base__image_config){\n .pixcfg = {.private_impl = {0}},\n .private_impl = {0},\n });\n}\n\nstatic inline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){\n .pixcfg = {.private_impl = {0}},\n .private_impl = {0},\n });\n }\n}\n\nstatic inline bool //\nwuffs_base__im" +
|
||||
"age_config__is_valid(wuffs_base__image_config* c) {\n return c && wuffs_base__pixel_config__is_valid(&(c->pixcfg));\n}\n\nstatic inline uint64_t //\nwuffs_base__image_config__first_frame_io_position(wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_io_position : 0;\n}\n\nstatic inline bool //\nwuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__image_config::set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__set(this, pixfmt, pixsub, width, height,\n first_frame_io_position, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_" +
|
||||
"config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline uint64_t //\nwuffs_base__image_config::first_frame_io_position() {\n return wuffs_base__image_config__first_frame_io_position(this);\n}\n\ninline bool //\nwuffs_base__image_config::first_frame_is_opaque() {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (wuffs_base__pixel_format__is_valid(pixfmt)) {\n c->pixcfg.private_impl.pixfmt = pixfmt;\n c->pixcfg.private_impl.pixsub = pixsub;\n c->pixcfg.private_impl.width = width;\n c->pixcfg.private_impl.height = height;\n c->private_impl.first_frame_io_position = first_frame_io_position;\n c->private_impl.first_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n\n c->pixcfg.private_impl.pixfmt = 0;\n c->pixcfg.private_impl.pixsub = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.height = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n}\n\nstatic inline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n c->pixcfg.private_impl.p" +
|
||||
"ixfmt = 0;\n c->pixcfg.private_impl.pixsub = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.height = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__image_config__is_valid(wuffs_base__image_config* c) {\n return c && wuffs_base__pixel_config__is_valid(&(c->pixcfg));\n}\n\nstatic inline uint64_t //\nwuffs_base__image_config__first_frame_io_position(wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_io_position : 0;\n}\n\nstatic inline bool //\nwuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__image_config::set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first" +
|
||||
"_frame_io_position,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__set(this, pixfmt, pixsub, width, height,\n first_frame_io_position, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline uint64_t //\nwuffs_base__image_config::first_frame_io_position() {\n return wuffs_base__image_config__first_frame_io_position(this);\n}\n\ninline bool //\nwuffs_base__image_config::first_frame_is_opaque() {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__animation_blend encodes, for an animated image, how to blend the\n// transparent pixels of this frame with the existing canvas. In Porter-Duff\n// compositing operator terminology:\n// - 0 means the frame may be transparent, and should be blended \"src over\n// dst\", also known as just \"over\".\n// - 1 means the frame may be transparent, and should be blended \"src\".\n// - 2 means the frame is completely opaque, so that \"src over dst\" and \"src\"\n// are equivalent.\n//\n// These semantics are conservative. It is valid for a completely opaque frame\n// to have a blend value other than 2.\ntypedef uint8_t wuffs_base__animation_blend;\n\n#define WUFFS_BASE__ANIMATION_BLEND__SRC_OVER_DST \\\n ((wuffs_base__animation_blend)0)\n#define WUFFS_BASE__ANIMATION_BLEND__SRC ((wuffs_base__animation_blend)1)\n#define WUFFS_BASE__ANIMATION_BLEND__OPAQUE ((wuffs_base__animation_blend)2)\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__animation_disposal encodes, for an animated image, how to\n// dispose of a frame after displaying it:\n// - None means to draw the next frame on top of this one.\n// - Restore Background means to clear the frame's dirty rectangle to \"the\n// background color\" (in practice, this means transparent black) before\n// drawing the next frame.\n// - Restore Previous means to undo the current frame, so that the next frame\n// is drawn on top of the previous one.\ntypedef uint8_t wuffs_base__animation_disposal;\n\n#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \\\n ((wuffs_base__animation_disposal)1)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \\\n ((wuffs_base__animation_disposal)2)\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__rect_ie_u32 bounds;\n wuffs_base__flicks duration;\n uint64_t index;\n uint64_t io_position;\n wuffs_base__animation_blend blend;\n wuffs_base__animation_disposal disposal;\n } private_impl;\n\n#ifdef __cplusplus\n inline void update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_position,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal);\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline wuffs_base__flicks duration();\n inline uint64_t index();\n inline uint64_t io_position();\n inline wuffs_base__animation_blend blend();\n inline wuffs_base__animation_disposal disposal();\n#endif // __cpluspl" +
|
||||
"us\n\n} wuffs_base__frame_config;\n\nstatic inline void //\nwuffs_base__frame_config__update(wuffs_base__frame_config* c,\n wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_position,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal) {\n if (!c) {\n return;\n }\n\n c->private_impl.bounds = bounds;\n c->private_impl.duration = duration;\n c->private_impl.index = index;\n c->private_impl.io_position = io_position;\n c->private_impl.blend = blend;\n c->private_impl.disposal = disposal;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {\n return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){0});\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__width(wuffs_base__frame_config* c) {\n retu" +
|
||||
"rn c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__height(wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;\n}\n\n// wuffs_base__frame_config__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__frame_config__duration(wuffs_base__frame_config* c) {\n return c ? c->private_impl.duration : 0;\n}\n\n// wuffs_base__frame_config__index returns the index of this frame. The first\n// frame in an image has index 0, the second frame has index 1, and so on.\nstatic inline uint64_t //\nwuffs_base__frame_config__index(wuffs_base__frame_config* c) {\n return c ? c->private_impl.index : 0;\n}\n\n// wuffs_base__frame_config__io_position returns the I/O stream position before\n// the frame config.\nstatic inline uint64_t //\nwuffs_base__frame_config__io_position(wuffs_base__frame_config* c) {" +
|
||||
"\n return c ? c->private_impl.io_position : 0;\n}\n\n// wuffs_base__frame_config__blend returns, for an animated image, how to blend\n// the transparent pixels of this frame with the existing canvas.\nstatic inline wuffs_base__animation_blend //\nwuffs_base__frame_config__blend(wuffs_base__frame_config* c) {\n return c ? c->private_impl.blend : 0;\n}\n\n// wuffs_base__frame_config__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {\n return c ? c->private_impl.disposal : 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_position,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_di" +
|
||||
"sposal disposal) {\n wuffs_base__frame_config__update(this, bounds, duration, index, io_position,\n blend, disposal);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config::bounds() {\n return wuffs_base__frame_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::width() {\n return wuffs_base__frame_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::height() {\n return wuffs_base__frame_config__height(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__frame_config::duration() {\n return wuffs_base__frame_config__duration(this);\n}\n\ninline uint64_t //\nwuffs_base__frame_config::index() {\n return wuffs_base__frame_config__index(this);\n}\n\ninline uint64_t //\nwuffs_base__frame_config::io_position() {\n return wuffs_base__frame_config__io_position(this);\n}\n\ninline wuffs_base__animation_blend //\nwuffs_base__frame_config::blend() {\n return wuffs_base__frame_config__blend(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__f" +
|
||||
"rame_config::disposal() {\n return wuffs_base__frame_config__disposal(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"us\n\n} wuffs_base__frame_config;\n\nstatic inline void //\nwuffs_base__frame_config__update(wuffs_base__frame_config* c,\n wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_position,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal) {\n if (!c) {\n return;\n }\n\n c->private_impl.bounds = bounds;\n c->private_impl.duration = duration;\n c->private_impl.index = index;\n c->private_impl.io_position = io_position;\n c->private_impl.blend = blend;\n c->private_impl.disposal = disposal;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {\n if (c) {\n return c->private_impl.bounds;\n }\n\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = 0;\n ret.max_excl_y = 0;" +
|
||||
"\n return ret;\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__width(wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__height(wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;\n}\n\n// wuffs_base__frame_config__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__frame_config__duration(wuffs_base__frame_config* c) {\n return c ? c->private_impl.duration : 0;\n}\n\n// wuffs_base__frame_config__index returns the index of this frame. The first\n// frame in an image has index 0, the second frame has index 1, and so on.\nstatic inline uint64_t //\nwuffs_base__frame_config__index(wuffs_base__frame_config* c) {\n return c ? c->private_impl.index : 0;\n}\n\n// wuffs_base__frame_config__io_position returns the I/O stream position before\n//" +
|
||||
" the frame config.\nstatic inline uint64_t //\nwuffs_base__frame_config__io_position(wuffs_base__frame_config* c) {\n return c ? c->private_impl.io_position : 0;\n}\n\n// wuffs_base__frame_config__blend returns, for an animated image, how to blend\n// the transparent pixels of this frame with the existing canvas.\nstatic inline wuffs_base__animation_blend //\nwuffs_base__frame_config__blend(wuffs_base__frame_config* c) {\n return c ? c->private_impl.blend : 0;\n}\n\n// wuffs_base__frame_config__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {\n return c ? c->private_impl.disposal : 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_position,\n " +
|
||||
" wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal) {\n wuffs_base__frame_config__update(this, bounds, duration, index, io_position,\n blend, disposal);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config::bounds() {\n return wuffs_base__frame_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::width() {\n return wuffs_base__frame_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::height() {\n return wuffs_base__frame_config__height(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__frame_config::duration() {\n return wuffs_base__frame_config__duration(this);\n}\n\ninline uint64_t //\nwuffs_base__frame_config::index() {\n return wuffs_base__frame_config__index(this);\n}\n\ninline uint64_t //\nwuffs_base__frame_config::io_position() {\n return wuffs_base__frame_config__io_position(this);\n}\n\ninline wuffs_base__animation_blend //\nwuffs_base__frame_config::bl" +
|
||||
"end() {\n return wuffs_base__frame_config__blend(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__frame_config::disposal() {\n return wuffs_base__frame_config__disposal(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n // TODO: color spaces.\n } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status set_from_slice(wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory);\n inline wuffs_base__slice_u8 palette();\n inline wuffs_base__pixel_format pixel_format();\n inline wuffs_base__table_u8 plane(uint32_t p);\n#endif // __cplusplus\n\n} wuffs_base__pixel_buffer;\n\nstatic inline wuffs_base__status //\nwuffs_base__pixel_buffer__set_from_slice(wuffs_base__pixel_buffer* b,\n wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return wuffs_base__error__bad_receiver;\n }\n memset" +
|
||||
"(b, 0, sizeof(*b));\n if (!pixcfg) {\n return wuffs_base__error__bad_argument;\n }\n if (wuffs_base__pixel_format__is_planar(pixcfg->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return wuffs_base__error__bad_argument;\n }\n uint32_t bits_per_pixel =\n wuffs_base__pixel_format__bits_per_pixel(pixcfg->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n return wuffs_base__error__bad_argument;\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint8_t* ptr = pixbuf_memory.ptr;\n uint64_t len = pixbuf_memory.len;\n if (wuffs_base__pixel_format__is_indexed(pixcfg->private_impl.pixfmt)) {\n // Split a 1024 byte chunk (256 palette entries × 4 bytes per entry) from\n // the start of pixbuf_memory. We split from the start, not the end, so\n // that the both chunks' pointers have the same alignment as the original\n // pointer, up to an alignment of 1024.\n if (len < 1024) {\n return wuffs_base__error__" +
|
||||
"bad_argument_length_too_short;\n }\n wuffs_base__table_u8* tab =\n &b->private_impl.planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];\n tab->ptr = ptr;\n tab->width = 1024;\n tab->height = 1;\n tab->stride = 1024;\n ptr += 1024;\n len -= 1024;\n }\n\n uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *\n ((uint64_t)pixcfg->private_impl.height);\n size_t width = (size_t)(pixcfg->private_impl.width);\n if ((wh > (UINT64_MAX / bytes_per_pixel)) ||\n (width > (SIZE_MAX / bytes_per_pixel))) {\n return wuffs_base__error__bad_argument;\n }\n wh *= bytes_per_pixel;\n width *= bytes_per_pixel;\n if (wh > len) {\n return wuffs_base__error__bad_argument_length_too_short;\n }\n\n b->pixcfg = *pixcfg;\n wuffs_base__table_u8* tab = &b->private_impl.planes[0];\n tab->ptr = ptr;\n tab->width = width;\n tab->height = pixcfg->private_impl.height;\n tab->stride = width;\n return NULL;\n}\n\n// wuffs_base__pixel_buffer__palette returns the palette color data. If\n// non-empty, it wi" +
|
||||
"ll have length 1024.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* b) {\n if (b &&\n wuffs_base__pixel_format__is_indexed(b->pixcfg.private_impl.pixfmt)) {\n wuffs_base__table_u8* tab =\n &b->private_impl.planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];\n if ((tab->width == 1024) && (tab->height == 1)) {\n return ((wuffs_base__slice_u8){\n .ptr = tab->ptr,\n .len = 1024,\n });\n }\n }\n return ((wuffs_base__slice_u8){0});\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_buffer__pixel_format(wuffs_base__pixel_buffer* b) {\n if (b) {\n return b->pixcfg.private_impl.pixfmt;\n }\n return WUFFS_BASE__PIXEL_FORMAT__INVALID;\n}\n\nstatic inline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* b, uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.planes[p]\n : ((wuffs_base__table_u8){0});\n}\n\n#ifdef __cplu" +
|
||||
"splus\n\ninline wuffs_base__status //\nwuffs_base__pixel_buffer::set_from_slice(wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory) {\n return wuffs_base__pixel_buffer__set_from_slice(this, pixcfg, pixbuf_memory);\n}\n\ninline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer::palette() {\n return wuffs_base__pixel_buffer__palette(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_buffer::pixel_format() {\n return wuffs_base__pixel_buffer__pixel_format(this);\n}\n\ninline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer::plane(uint32_t p) {\n return wuffs_base__pixel_buffer__plane(this, p);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"ll have length 1024.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* b) {\n if (b &&\n wuffs_base__pixel_format__is_indexed(b->pixcfg.private_impl.pixfmt)) {\n wuffs_base__table_u8* tab =\n &b->private_impl.planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];\n if ((tab->width == 1024) && (tab->height == 1)) {\n return wuffs_base__make_slice_u8(tab->ptr, 1024);\n }\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_buffer__pixel_format(wuffs_base__pixel_buffer* b) {\n if (b) {\n return b->pixcfg.private_impl.pixfmt;\n }\n return WUFFS_BASE__PIXEL_FORMAT__INVALID;\n}\n\nstatic inline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* b, uint32_t p) {\n if (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX)) {\n return b->private_impl.planes[p];\n }\n\n wuffs_base__table_u8 ret;\n ret.ptr = NULL;\n ret.width = 0;\n ret.height = 0;\n ret.stride =" +
|
||||
" 0;\n return ret;\n}\n\n#ifdef __cplusplus\n\ninline wuffs_base__status //\nwuffs_base__pixel_buffer::set_from_slice(wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory) {\n return wuffs_base__pixel_buffer__set_from_slice(this, pixcfg, pixbuf_memory);\n}\n\ninline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer::palette() {\n return wuffs_base__pixel_buffer__palette(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_buffer::pixel_format() {\n return wuffs_base__pixel_buffer__pixel_format(this);\n}\n\ninline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer::plane(uint32_t p) {\n return wuffs_base__pixel_buffer__plane(this, p);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n uint8_t TODO;\n } private_impl;\n\n#ifdef __cplusplus\n#endif // __cplusplus\n\n} wuffs_base__decode_frame_options;\n\n#ifdef __cplusplus\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
@@ -169,20 +170,21 @@ const baseIOPrivateH = "" +
|
||||
"y, have a sloppy_copy_n_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_writer__copy_n_from_history_fast is like the\n// wuffs_base__io_writer__copy_n_from_history function above, but has stronger\n// pre-conditions. The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_iop_w - io0_w)\n// - length <= (io1_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,\n uint8_t* io0_w,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n uint8_t* q = p - distance;\n uint32_t n = length;\n for (; n" +
|
||||
" >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n uint8_t* io1_r) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = length;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n uint8_t* iop_r = *ptr_iop_r;\n if (n > ((size_t)(io1_r - iop_r))) {\n n = io1_r - iop_r;\n }\n if (n > 0) {\n memmove(iop_w, iop_r, n);\n *ptr_iop_w += n;\n *ptr_iop_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* iop" +
|
||||
"_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set(wuffs_base__io_reader* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n uint8_t** ptr_io1_r,\n wuffs_base__slice_u8 data) {\n b->data = " +
|
||||
"data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_r = data.ptr;\n *ptr_io1_r = data.ptr + data.len;\n return ((wuffs_base__empty_struct){0});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* iop_r,\n uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {\n o->private_impl.limit = iop_r + limit;\n }\n return ((wuffs_base__empty_struct){0});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){0});\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {\n if (n <= ((size_t)(io1_r - *ptr_iop_r)))" +
|
||||
" {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return ((wuffs_base__slice_u8){\n .ptr = p,\n .len = n,\n });\n }\n return ((wuffs_base__slice_u8){0});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io1_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_w = data.ptr;\n *ptr_io1_w = data.ptr + data.len;\n return ((wuffs_base__empty_struct){0});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){0});\n}\n\n" +
|
||||
"data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_r = data.ptr;\n *ptr_io1_r = data.ptr + data.len;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* iop_r,\n uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {\n o->private_impl.limit = iop_r + limit;\n }\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_" +
|
||||
"t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {\n if (n <= ((size_t)(io1_r - *ptr_iop_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return wuffs_base__make_slice_u8(p, n);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io1_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_w = data.ptr;\n *ptr_io1_w = data.ptr + data.len;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = " +
|
||||
"mark;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- I/O (Utility)\n\nstatic inline wuffs_base__io_reader //\nwuffs_base__utility__null_io_reader() {\n return ((wuffs_base__io_reader){.private_impl = {0}});\n}\n\nstatic inline wuffs_base__io_writer //\nwuffs_base__utility__null_io_writer() {\n return ((wuffs_base__io_writer){.private_impl = {0}});\n}\n\n" +
|
||||
"// ---------------- I/O (Utility)\n\nstatic inline wuffs_base__io_buffer //\nwuffs_base__utility__null_io_buffer() {\n wuffs_base__io_buffer ret;\n ret.data.ptr = NULL;\n ret.data.len = 0;\n ret.meta.wi = 0;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = false;\n return ret;\n}\n\nstatic inline wuffs_base__io_reader //\nwuffs_base__utility__null_io_reader() {\n wuffs_base__io_reader ret;\n ret.private_impl.buf = NULL;\n ret.private_impl.mark = NULL;\n ret.private_impl.limit = NULL;\n return ret;\n}\n\nstatic inline wuffs_base__io_writer //\nwuffs_base__utility__null_io_writer() {\n wuffs_base__io_writer ret;\n ret.private_impl.buf = NULL;\n ret.private_impl.mark = NULL;\n ret.private_impl.limit = NULL;\n return ret;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__io_private()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__io_private() {\n (void)(wuffs_base__io_buffer__is_valid);\n (void)(wuffs_base__io_reader__is_eof);\n (void)(wuffs_base__io_reader__is_valid);\n (void)(wuffs_base__io_reader__set);\n (void)(wuffs_base__io_reader__set_limit);\n (void)(wuffs_base__io_reader__set_mark);\n (void)(wuffs_base__io_reader__take);\n (void)(wuffs_base__io_writer__copy_from_slice);\n (void)(wuffs_base__io_writer__copy_n_from_history);\n (void)(wuffs_base__io_writer__copy_n_from_history_fast);\n (void)(wuffs_base__io_writer__copy_n_from_reader);\n (void)(wuffs_base__io_writer__copy_n_from_slice);\n (void)(wuffs_base__io_writer__is_valid);\n (void)(wuffs_base__io_writer__set);\n (void)(wuffs_base__io_writer__set_mark);\n (void)(wuffs_base__utility__null_io_reader);\n (void)(wuffs_base__utility_" +
|
||||
"_null_io_writer);\n}\n" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__io_private()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__io_private() {\n (void)(wuffs_base__io_buffer__is_valid);\n (void)(wuffs_base__io_reader__is_eof);\n (void)(wuffs_base__io_reader__is_valid);\n (void)(wuffs_base__io_reader__set);\n (void)(wuffs_base__io_reader__set_limit);\n (void)(wuffs_base__io_reader__set_mark);\n (void)(wuffs_base__io_reader__take);\n (void)(wuffs_base__io_writer__copy_from_slice);\n (void)(wuffs_base__io_writer__copy_n_from_history);\n (void)(wuffs_base__io_writer__copy_n_from_history_fast);\n (void)(wuffs_base__io_writer__copy_n_from_reader);\n (void)(wuffs_base__io_writer__copy_n_from_slice);\n (void)(wuffs_base__io_writer__is_valid);\n (void)(wuffs_base__io_writer__set);\n (void)(wuffs_base__io_writer__set_mark);\n (void)(wuffs_base__utility__null_io_buffer);\n (void)(wuffs_base__utility_" +
|
||||
"_null_io_reader);\n (void)(wuffs_base__utility__null_io_writer);\n}\n" +
|
||||
""
|
||||
|
||||
const baseIOPublicH = "" +
|
||||
"// ---------------- I/O\n\nstruct wuffs_base__io_buffer__struct;\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n struct wuffs_base__io_buffer__struct* buf;\n // The bounds values are typically NULL, when created by the Wuffs public\n // API. NULL means that the callee substitutes the implicit bounds derived\n // from buf.\n uint8_t* mark;\n uint8_t* limit;\n } private_impl;\n} wuffs_base__io_reader;\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n struct wuffs_base__io_buffer__struct* buf;\n // The bounds values are typically NULL, when created by the Wuffs public\n // API. NULL means that the callee substitutes the implicit bounds derived\n // from buf.\n uint8_t* mark;\n uint8_t* limit;\n } private_impl;\n} wuffs_base__io_writer;\n\n// wuffs_base__io_buffer_meta is the met" +
|
||||
"adata for a wuffs_base__io_buffer's\n// data.\ntypedef struct {\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n uint64_t pos; // Position of the buffer start relative to the stream start.\n bool closed; // No further writes are expected.\n} wuffs_base__io_buffer_meta;\n\n// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length) plus\n// additional metadata.\n//\n// A value with all fields zero is a valid, empty buffer.\ntypedef struct wuffs_base__io_buffer__struct {\n wuffs_base__slice_u8 data;\n wuffs_base__io_buffer_meta meta;\n\n#ifdef __cplusplus\n inline void compact();\n inline wuffs_base__io_reader reader();\n inline wuffs_base__io_writer writer();\n inline uint64_t reader_io_position();\n inline uint64_t writer_io_position();\n#endif // __cplusplus\n\n} wuffs_base__io_buffer;\n\n// wuffs_base__io_buffer__compact moves any written but unread bytes to the\n// start of the buffer.\nstatic inline void //\nwuffs_base__io_buffer__compact(wuffs" +
|
||||
"_base__io_buffer* buf) {\n if (!buf || (buf->meta.ri == 0)) {\n return;\n }\n buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri);\n size_t n = buf->meta.wi - buf->meta.ri;\n if (n != 0) {\n memmove(buf->data.ptr, buf->data.ptr + buf->meta.ri, n);\n }\n buf->meta.wi = n;\n buf->meta.ri = 0;\n}\n\nstatic inline wuffs_base__io_reader //\nwuffs_base__io_buffer__reader(wuffs_base__io_buffer* buf) {\n wuffs_base__io_reader ret = ((wuffs_base__io_reader){.private_impl = {0}});\n ret.private_impl.buf = buf;\n return ret;\n}\n\nstatic inline wuffs_base__io_writer //\nwuffs_base__io_buffer__writer(wuffs_base__io_buffer* buf) {\n wuffs_base__io_writer ret = ((wuffs_base__io_writer){.private_impl = {0}});\n ret.private_impl.buf = buf;\n return ret;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__reader_io_position(wuffs_base__io_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri) : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__writer_io_position(wuffs_base__" +
|
||||
"io_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.wi) : 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__io_buffer__struct::compact() {\n wuffs_base__io_buffer__compact(this);\n}\n\ninline wuffs_base__io_reader //\nwuffs_base__io_buffer__struct::reader() {\n return wuffs_base__io_buffer__reader(this);\n}\n\ninline wuffs_base__io_writer //\nwuffs_base__io_buffer__struct::writer() {\n return wuffs_base__io_buffer__writer(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer__struct::reader_io_position() {\n return wuffs_base__io_buffer__reader_io_position(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer__struct::writer_io_position() {\n return wuffs_base__io_buffer__writer_io_position(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"_base__io_buffer* buf) {\n if (!buf || (buf->meta.ri == 0)) {\n return;\n }\n buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri);\n size_t n = buf->meta.wi - buf->meta.ri;\n if (n != 0) {\n memmove(buf->data.ptr, buf->data.ptr + buf->meta.ri, n);\n }\n buf->meta.wi = n;\n buf->meta.ri = 0;\n}\n\nstatic inline wuffs_base__io_reader //\nwuffs_base__io_buffer__reader(wuffs_base__io_buffer* buf) {\n wuffs_base__io_reader ret;\n ret.private_impl.buf = buf;\n ret.private_impl.mark = NULL;\n ret.private_impl.limit = NULL;\n return ret;\n}\n\nstatic inline wuffs_base__io_writer //\nwuffs_base__io_buffer__writer(wuffs_base__io_buffer* buf) {\n wuffs_base__io_writer ret;\n ret.private_impl.buf = buf;\n ret.private_impl.mark = NULL;\n ret.private_impl.limit = NULL;\n return ret;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__reader_io_position(wuffs_base__io_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri) : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer_" +
|
||||
"_writer_io_position(wuffs_base__io_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.wi) : 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__io_buffer__struct::compact() {\n wuffs_base__io_buffer__compact(this);\n}\n\ninline wuffs_base__io_reader //\nwuffs_base__io_buffer__struct::reader() {\n return wuffs_base__io_buffer__reader(this);\n}\n\ninline wuffs_base__io_writer //\nwuffs_base__io_buffer__struct::writer() {\n return wuffs_base__io_buffer__writer(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer__struct::reader_io_position() {\n return wuffs_base__io_buffer__reader_io_position(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer__struct::writer_io_position() {\n return wuffs_base__io_buffer__writer_io_position(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__io_public()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__io_public() {\n (void)(wuffs_base__io_buffer__compact);\n (void)(wuffs_base__io_buffer__reader);\n (void)(wuffs_base__io_buffer__reader_io_position);\n (void)(wuffs_base__io_buffer__writer);\n (void)(wuffs_base__io_buffer__writer_io_position);\n}\n" +
|
||||
""
|
||||
@@ -191,8 +193,8 @@ const baseRangePrivateH = "" +
|
||||
"// ---------------- Ranges and Rects\n\nstatic inline uint32_t //\nwuffs_base__range_ii_u32__get_min_incl(const wuffs_base__range_ii_u32* r) {\n return r->min_incl;\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ii_u32__get_max_incl(const wuffs_base__range_ii_u32* r) {\n return r->max_incl;\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ie_u32__get_min_incl(const wuffs_base__range_ie_u32* r) {\n return r->min_incl;\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ie_u32__get_max_excl(const wuffs_base__range_ie_u32* r) {\n return r->max_excl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ii_u64__get_min_incl(const wuffs_base__range_ii_u64* r) {\n return r->min_incl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ii_u64__get_max_incl(const wuffs_base__range_ii_u64* r) {\n return r->max_incl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ie_u64__get_min_incl(const wuffs_base__range_ie_u64* r) {\n return r->min_incl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ie_u64__get_max_excl(const wuffs_base__range_" +
|
||||
"ie_u64* r) {\n return r->max_excl;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Ranges and Rects (Utility)\n\nstatic inline wuffs_base__range_ii_u32 //\nwuffs_base__utility__make_range_ii_u32(uint32_t min_incl, uint32_t max_incl) {\n return ((wuffs_base__range_ii_u32){\n .min_incl = min_incl,\n .max_incl = max_incl,\n });\n}\n\nstatic inline wuffs_base__range_ie_u32 //\nwuffs_base__utility__make_range_ie_u32(uint32_t min_incl, uint32_t max_excl) {\n return ((wuffs_base__range_ie_u32){\n .min_incl = min_incl,\n .max_excl = max_excl,\n });\n}\n\nstatic inline wuffs_base__range_ii_u64 //\nwuffs_base__utility__make_range_ii_u64(uint64_t min_incl, uint64_t max_incl) {\n return ((wuffs_base__range_ii_u64){\n .min_incl = min_incl,\n .max_incl = max_incl,\n });\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__utility__make_range_ie_u64(uint64_t min_incl, uint64_t max_excl) {\n return ((wuffs_base__range_ie_u64){\n .min_incl = min_incl,\n .max_excl = max_excl,\n });\n}\n\nstatic inline wuffs_base__rect_ii_u32 //\nwuffs_base__utility__make_rect_ii_" +
|
||||
"u32(uint32_t min_incl_x,\n uint32_t min_incl_y,\n uint32_t max_incl_x,\n uint32_t max_incl_y) {\n return ((wuffs_base__rect_ii_u32){\n .min_incl_x = min_incl_x,\n .min_incl_y = min_incl_y,\n .max_incl_x = max_incl_x,\n .max_incl_y = max_incl_y,\n });\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__utility__make_rect_ie_u32(uint32_t min_incl_x,\n uint32_t min_incl_y,\n uint32_t max_excl_x,\n uint32_t max_excl_y) {\n return ((wuffs_base__rect_ie_u32){\n .min_incl_x = min_incl_x,\n .min_incl_y = min_incl_y,\n .max_excl_x = max_excl_x,\n .max_excl_y = max_excl_y,\n });\n}\n\n" +
|
||||
"// ---------------- Ranges and Rects (Utility)\n\nstatic inline wuffs_base__range_ii_u32 //\nwuffs_base__utility__make_range_ii_u32(uint32_t min_incl, uint32_t max_incl) {\n wuffs_base__range_ii_u32 ret;\n ret.min_incl = min_incl;\n ret.max_incl = max_incl;\n return ret;\n}\n\nstatic inline wuffs_base__range_ie_u32 //\nwuffs_base__utility__make_range_ie_u32(uint32_t min_incl, uint32_t max_excl) {\n wuffs_base__range_ie_u32 ret;\n ret.min_incl = min_incl;\n ret.max_excl = max_excl;\n return ret;\n}\n\nstatic inline wuffs_base__range_ii_u64 //\nwuffs_base__utility__make_range_ii_u64(uint64_t min_incl, uint64_t max_incl) {\n wuffs_base__range_ii_u64 ret;\n ret.min_incl = min_incl;\n ret.max_incl = max_incl;\n return ret;\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__utility__make_range_ie_u64(uint64_t min_incl, uint64_t max_excl) {\n wuffs_base__range_ie_u64 ret;\n ret.min_incl = min_incl;\n ret.max_excl = max_excl;\n return ret;\n}\n\nstatic inline wuffs_base__rect_ii_u32 //\nwuffs_base__utility__make_rect_ii_" +
|
||||
"u32(uint32_t min_incl_x,\n uint32_t min_incl_y,\n uint32_t max_incl_x,\n uint32_t max_incl_y) {\n wuffs_base__rect_ii_u32 ret;\n ret.min_incl_x = min_incl_x;\n ret.min_incl_y = min_incl_y;\n ret.max_incl_x = max_incl_x;\n ret.max_incl_y = max_incl_y;\n return ret;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__utility__make_rect_ie_u32(uint32_t min_incl_x,\n uint32_t min_incl_y,\n uint32_t max_excl_x,\n uint32_t max_excl_y) {\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = min_incl_x;\n ret.min_incl_y = min_incl_y;\n ret.max_excl_x = max_excl_x;\n ret.max_excl_y = max_excl_y;\n return ret;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Bureaucracy re -Wunused-function\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__range_private()\n WUFFS_BASE__POTENTIALLY_UNUSED;\n\nstatic inline void\nwuffs_base__acknowledge_potentially_unused_functions__range_private() {\n (void)(wuffs_base__range_ie_u32__get_max_excl);\n (void)(wuffs_base__range_ie_u32__get_min_incl);\n (void)(wuffs_base__range_ie_u64__get_max_excl);\n (void)(wuffs_base__range_ie_u64__get_min_incl);\n (void)(wuffs_base__range_ii_u32__get_max_incl);\n (void)(wuffs_base__range_ii_u32__get_min_incl);\n (void)(wuffs_base__range_ii_u64__get_max_incl);\n (void)(wuffs_base__range_ii_u64__get_min_incl);\n (void)(wuffs_base__utility__make_range_ie_u32);\n (void)(wuffs_base__utility__make_range_ie_u64);\n (void)(wuffs_base__utility__make_range_ii_u32);\n (void)(wuffs_base__utility__make_range_ii_u64);\n (void)(wuffs_base__utility__make_rect_ie_u32);\n (void)(wuffs_base__utility__make_rect_ii_u32);\n}\n" +
|
||||
""
|
||||
|
||||
@@ -116,7 +116,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error {
|
||||
if err := g.writeExpr(b, recv, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.printf(", 0, sizeof (%s%s)), wuffs_base__return_empty_struct())",
|
||||
b.printf(", 0, sizeof (%s%s)), wuffs_base__make_empty_struct())",
|
||||
g.packagePrefix(qid), qid[1].Str(g.tm))
|
||||
} else {
|
||||
b.printf("wuffs_base__ignore_status("+
|
||||
@@ -165,13 +165,13 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error {
|
||||
lhsIsArray := lhs.MType().IsArrayType()
|
||||
if lhsIsArray {
|
||||
// TODO: don't assume that the slice is a slice of base.u8.
|
||||
b.writes("((wuffs_base__slice_u8){.ptr=")
|
||||
b.writes("wuffs_base__make_slice_u8(")
|
||||
}
|
||||
if err := g.writeExpr(b, lhs, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
if lhsIsArray {
|
||||
b.printf(",.len=%v,})", lhs.MType().ArrayLength().ConstValue())
|
||||
b.printf(", %v)", lhs.MType().ArrayLength().ConstValue())
|
||||
}
|
||||
|
||||
if mhs != nil {
|
||||
|
||||
@@ -218,17 +218,39 @@ func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error {
|
||||
|
||||
func (g *gen) writeOutParamZeroValue(b *buffer, typ *a.TypeExpr) error {
|
||||
if typ == nil {
|
||||
b.writes("((wuffs_base__empty_struct){0})")
|
||||
b.writes("wuffs_base__make_empty_struct()")
|
||||
return nil
|
||||
} else if typ.IsNumType() {
|
||||
b.writes("0")
|
||||
} else {
|
||||
b.writes("((")
|
||||
if err := g.writeCTypeName(b, typ, "", ""); err != nil {
|
||||
return err
|
||||
return nil
|
||||
} else if typ.IsSliceType() {
|
||||
if inner := typ.Inner(); (inner.Decorator() == 0) && (inner.QID() == t.QID{t.IDBase, t.IDU8}) {
|
||||
b.writes("wuffs_base__make_slice_u8(NULL, 0)")
|
||||
return nil
|
||||
}
|
||||
} else if (typ.Decorator() == 0) && (typ.QID()[0] == t.IDBase) {
|
||||
switch typ.QID()[1] {
|
||||
case t.IDRangeIEU32:
|
||||
b.writes("wuffs_base__utility__make_range_ie_u32(0, 0)")
|
||||
return nil
|
||||
case t.IDRangeIIU32:
|
||||
b.writes("wuffs_base__utility__make_range_ii_u32(0, 0)")
|
||||
return nil
|
||||
case t.IDRangeIEU64:
|
||||
b.writes("wuffs_base__utility__make_range_ie_u64(0, 0)")
|
||||
return nil
|
||||
case t.IDRangeIIU64:
|
||||
b.writes("wuffs_base__utility__make_range_ii_u64(0, 0)")
|
||||
return nil
|
||||
case t.IDRectIEU32:
|
||||
b.writes("wuffs_base__utility__make_rect_ie_u32(0, 0, 0, 0)")
|
||||
return nil
|
||||
case t.IDRectIIU32:
|
||||
b.writes("wuffs_base__utility__make_rect_ii_u32(0, 0, 0, 0)")
|
||||
return nil
|
||||
}
|
||||
b.writes("){0})")
|
||||
}
|
||||
return nil
|
||||
return fmt.Errorf("internal error: cannot write the zero value of type %q", typ.Str(g.tm))
|
||||
}
|
||||
|
||||
func (g *gen) writeFuncImplPrologue(b *buffer) error {
|
||||
@@ -385,7 +407,7 @@ func (g *gen) writeFuncImplEpilogue(b *buffer) error {
|
||||
}
|
||||
b.writes("return status;\n")
|
||||
} else if g.currFunk.astFunc.Out() == nil {
|
||||
b.writes("return ((wuffs_base__empty_struct){0});\n")
|
||||
b.writes("return wuffs_base__make_empty_struct();\n")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -454,7 +476,7 @@ func (g *gen) writeFuncImplArgChecks(b *buffer, n *a.Func) error {
|
||||
b.writes("return wuffs_base__error__bad_argument;\n\n")
|
||||
} else {
|
||||
// TODO: don't assume that the return type is empty.
|
||||
b.printf("return ((wuffs_base__empty_struct){0});\n")
|
||||
b.printf("return wuffs_base__make_empty_struct();\n")
|
||||
}
|
||||
b.writes("}\n")
|
||||
return nil
|
||||
|
||||
@@ -446,7 +446,7 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
||||
|
||||
b.writes("return ")
|
||||
if g.currFunk.astFunc.Out() == nil {
|
||||
b.writes("((wuffs_base__empty_struct){0})")
|
||||
b.writes("wuffs_base__make_empty_struct()")
|
||||
} else if err := g.writeExpr(b, retExpr, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -290,16 +290,18 @@ func (g *gen) writeVars(b *buffer, f *funk, inStructDecl bool) error {
|
||||
} else if typ.IsStatus() {
|
||||
b.writes(" = NULL;\n")
|
||||
} else if typ.IsIOType() {
|
||||
b.writes(" = {.private_impl = {0}};\n")
|
||||
typName := "reader"
|
||||
if typ.QID()[1] == t.IDIOWriter {
|
||||
typName = "writer"
|
||||
}
|
||||
b.printf(" = wuffs_base__utility__null_io_%s();\n", typName)
|
||||
} else {
|
||||
b.writes(" = {0};\n")
|
||||
}
|
||||
|
||||
if typ.IsIOType() {
|
||||
b.printf("wuffs_base__io_buffer %s%s WUFFS_BASE__POTENTIALLY_UNUSED = {"+
|
||||
".data = ((wuffs_base__slice_u8){0}),\n"+
|
||||
".meta = ((wuffs_base__io_buffer_meta){0}),\n"+
|
||||
"};\n", uPrefix, name)
|
||||
b.printf("wuffs_base__io_buffer %s%s WUFFS_BASE__POTENTIALLY_UNUSED = "+
|
||||
"wuffs_base__utility__null_io_buffer();\n", uPrefix, name)
|
||||
preName := vPrefix + name
|
||||
// TODO: io0_etc variables?
|
||||
b.printf("uint8_t* %s%s WUFFS_BASE__POTENTIALLY_UNUSED = NULL;\n", iopPrefix, preName)
|
||||
|
||||
@@ -76,10 +76,8 @@ int main(int argc, char** argv) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t checksum = h.update((wuffs_base__slice_u8){
|
||||
.ptr = src_buffer,
|
||||
.len = static_cast<size_t>(n),
|
||||
});
|
||||
uint32_t checksum =
|
||||
h.update(wuffs_base__make_slice_u8(src_buffer, static_cast<size_t>(n)));
|
||||
|
||||
if (n == 0) {
|
||||
printf("%08" PRIx32 "\n", checksum);
|
||||
|
||||
@@ -42,7 +42,7 @@ support true color: https://gist.github.com/XVilka/8346728
|
||||
bool started = false;
|
||||
struct timespec start_time;
|
||||
|
||||
uint64_t micros_since_start(struct timespec* now) {
|
||||
int64_t micros_since_start(struct timespec* now) {
|
||||
if (!started) {
|
||||
return 0;
|
||||
}
|
||||
@@ -88,13 +88,13 @@ wuffs_base__color_u32_argb_premul* curr_dst_buffer = NULL;
|
||||
wuffs_base__color_u32_argb_premul* prev_dst_buffer = NULL;
|
||||
size_t dst_len; // Length in bytes.
|
||||
|
||||
wuffs_base__slice_u8 pixbuf = ((wuffs_base__slice_u8){});
|
||||
wuffs_base__slice_u8 workbuf = ((wuffs_base__slice_u8){});
|
||||
wuffs_base__slice_u8 printbuf = ((wuffs_base__slice_u8){});
|
||||
wuffs_base__slice_u8 pixbuf = {0};
|
||||
wuffs_base__slice_u8 workbuf = {0};
|
||||
wuffs_base__slice_u8 printbuf = {0};
|
||||
|
||||
bool first_play = true;
|
||||
uint32_t num_loops_remaining = 0;
|
||||
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||
wuffs_base__pixel_buffer pb = {0};
|
||||
|
||||
wuffs_base__flicks cumulative_delay_micros = 0;
|
||||
|
||||
@@ -273,11 +273,11 @@ const char* allocate(wuffs_gif__decoder* dec, wuffs_base__image_config* ic) {
|
||||
const char* status = try_allocate(dec, ic);
|
||||
if (status) {
|
||||
free(printbuf.ptr);
|
||||
printbuf = ((wuffs_base__slice_u8){});
|
||||
printbuf = wuffs_base__make_slice_u8(NULL, 0);
|
||||
free(workbuf.ptr);
|
||||
workbuf = ((wuffs_base__slice_u8){});
|
||||
workbuf = wuffs_base__make_slice_u8(NULL, 0);
|
||||
free(pixbuf.ptr);
|
||||
pixbuf = ((wuffs_base__slice_u8){});
|
||||
pixbuf = wuffs_base__make_slice_u8(NULL, 0);
|
||||
free(prev_dst_buffer);
|
||||
prev_dst_buffer = NULL;
|
||||
free(curr_dst_buffer);
|
||||
@@ -295,22 +295,17 @@ const char* play() {
|
||||
return status;
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = src_buffer,
|
||||
.len = src_len,
|
||||
}),
|
||||
.meta = ((wuffs_base__io_buffer_meta){
|
||||
.wi = src_len,
|
||||
.ri = 0,
|
||||
.pos = 0,
|
||||
.closed = true,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer src;
|
||||
src.data.ptr = src_buffer;
|
||||
src.data.len = src_len;
|
||||
src.meta.wi = src_len;
|
||||
src.meta.ri = 0;
|
||||
src.meta.pos = 0;
|
||||
src.meta.closed = true;
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
|
||||
if (first_play) {
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__image_config ic = {0};
|
||||
status = wuffs_gif__decoder__decode_image_config(&dec, &ic, src_reader);
|
||||
if (status) {
|
||||
return status;
|
||||
@@ -342,7 +337,7 @@ const char* play() {
|
||||
}
|
||||
|
||||
while (1) {
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__frame_config fc = {0};
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_frame_config(&dec, &fc, src_reader);
|
||||
if (status) {
|
||||
@@ -391,7 +386,7 @@ const char* play() {
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &now)) {
|
||||
return strerror(errno);
|
||||
}
|
||||
uint64_t elapsed_micros = micros_since_start(&now);
|
||||
int64_t elapsed_micros = micros_since_start(&now);
|
||||
if (cumulative_delay_micros > elapsed_micros) {
|
||||
usleep(cumulative_delay_micros - elapsed_micros);
|
||||
}
|
||||
|
||||
+26
-29
@@ -43,10 +43,11 @@ for a C compiler $CC, such as clang or gcc.
|
||||
#include "wuffs/release/c/wuffs-unsupported-snapshot.c"
|
||||
|
||||
#ifndef DST_BUFFER_SIZE
|
||||
#define DST_BUFFER_SIZE (128 * 1024)
|
||||
#define DST_BUFFER_SIZE 1024
|
||||
#endif
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||
|
||||
// hello_ptr and hello_len hold a gzip-encoded "Hello Wuffs."
|
||||
// src_ptr and src_len hold a gzip-encoded "Hello Wuffs."
|
||||
//
|
||||
// $ echo "Hello Wuffs." | gzip --no-name | xxd
|
||||
// 00000000: 1f8b 0800 0000 0000 0003 f348 cdc9 c957 ...........H...W
|
||||
@@ -55,14 +56,14 @@ for a C compiler $CC, such as clang or gcc.
|
||||
//
|
||||
// Passing --no-name to the gzip command line also means to skip the timestamp,
|
||||
// which means that its output is deterministic.
|
||||
uint8_t hello_ptr[] = {
|
||||
uint8_t src_ptr[] = {
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 00..07
|
||||
0x00, 0x03, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, // 08..0F
|
||||
0x08, 0x2f, 0x4d, 0x4b, 0x2b, 0xd6, 0xe3, 0x02, // 10..17
|
||||
0x00, 0x3c, 0x84, 0x75, 0xbb, 0x0d, 0x00, 0x00, // 18..1F
|
||||
0x00, // 20..20
|
||||
};
|
||||
size_t hello_len = 0x21;
|
||||
size_t src_len = 0x21;
|
||||
|
||||
#define WORK_BUFFER_SIZE WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_SIZE > 0
|
||||
@@ -76,29 +77,27 @@ uint8_t work_buffer[1];
|
||||
static void ignore_return_value(int ignored) {}
|
||||
|
||||
static const char* decode() {
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dst_buffer,
|
||||
.len = DST_BUFFER_SIZE,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = hello_ptr,
|
||||
.len = hello_len,
|
||||
}),
|
||||
.meta = ((wuffs_base__io_buffer_meta){
|
||||
.wi = hello_len,
|
||||
.ri = 0,
|
||||
.pos = 0,
|
||||
.closed = true,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer dst;
|
||||
dst.data.ptr = dst_buffer;
|
||||
dst.data.len = DST_BUFFER_SIZE;
|
||||
dst.meta.wi = 0;
|
||||
dst.meta.ri = 0;
|
||||
dst.meta.pos = 0;
|
||||
dst.meta.closed = false;
|
||||
|
||||
wuffs_base__io_buffer src;
|
||||
src.data.ptr = src_ptr;
|
||||
src.data.len = src_len;
|
||||
src.meta.wi = src_len;
|
||||
src.meta.ri = 0;
|
||||
src.meta.pos = 0;
|
||||
src.meta.closed = true;
|
||||
|
||||
wuffs_base__io_writer dst_writer = wuffs_base__io_buffer__writer(&dst);
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
|
||||
wuffs_gzip__decoder* dec = calloc(sizeof__wuffs_gzip__decoder(), 1);
|
||||
wuffs_gzip__decoder* dec =
|
||||
(wuffs_gzip__decoder*)(calloc(sizeof__wuffs_gzip__decoder(), 1));
|
||||
if (!dec) {
|
||||
return "out of memory";
|
||||
}
|
||||
@@ -109,11 +108,9 @@ static const char* decode() {
|
||||
free(dec);
|
||||
return status;
|
||||
}
|
||||
status = wuffs_gzip__decoder__decode_io_writer(dec, dst_writer, src_reader,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer,
|
||||
.len = WORK_BUFFER_SIZE,
|
||||
}));
|
||||
status = wuffs_gzip__decoder__decode_io_writer(
|
||||
dec, dst_writer, src_reader,
|
||||
wuffs_base__make_slice_u8(work_buffer, WORK_BUFFER_SIZE));
|
||||
if (status) {
|
||||
free(dec);
|
||||
return status;
|
||||
|
||||
+16
-16
@@ -91,18 +91,21 @@ static const char* decode() {
|
||||
return status;
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dst_buffer,
|
||||
.len = DST_BUFFER_SIZE,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = src_buffer,
|
||||
.len = SRC_BUFFER_SIZE,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer dst;
|
||||
dst.data.ptr = dst_buffer;
|
||||
dst.data.len = DST_BUFFER_SIZE;
|
||||
dst.meta.wi = 0;
|
||||
dst.meta.ri = 0;
|
||||
dst.meta.pos = 0;
|
||||
dst.meta.closed = false;
|
||||
|
||||
wuffs_base__io_buffer src;
|
||||
src.data.ptr = src_buffer;
|
||||
src.data.len = SRC_BUFFER_SIZE;
|
||||
src.meta.wi = 0;
|
||||
src.meta.ri = 0;
|
||||
src.meta.pos = 0;
|
||||
src.meta.closed = false;
|
||||
|
||||
while (true) {
|
||||
const int stdin_fd = 0;
|
||||
@@ -123,10 +126,7 @@ static const char* decode() {
|
||||
status = wuffs_gzip__decoder__decode_io_writer(
|
||||
&dec, wuffs_base__io_buffer__writer(&dst),
|
||||
wuffs_base__io_buffer__reader(&src),
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer,
|
||||
.len = WORK_BUFFER_SIZE,
|
||||
}));
|
||||
wuffs_base__make_slice_u8(work_buffer, WORK_BUFFER_SIZE));
|
||||
|
||||
if (dst.meta.wi) {
|
||||
// TODO: handle EINTR and other write errors; see "man 2 write".
|
||||
|
||||
@@ -134,6 +134,13 @@ typedef struct {
|
||||
uint8_t private_impl;
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__make_empty_struct() {
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
@@ -367,18 +374,47 @@ typedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;
|
||||
typedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;
|
||||
typedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__make_slice_u8(uint8_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u8 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u16 //
|
||||
wuffs_base__make_slice_u16(uint16_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u16 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u32 //
|
||||
wuffs_base__make_slice_u32(uint32_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u32 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u64 //
|
||||
wuffs_base__make_slice_u64(uint64_t* ptr, size_t len) {
|
||||
wuffs_base__slice_u64 ret;
|
||||
ret.ptr = ptr;
|
||||
ret.len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// wuffs_base__slice_u8__subslice_i returns s[i:].
|
||||
//
|
||||
// It returns an empty slice if i is out of bounds.
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {
|
||||
if ((i <= SIZE_MAX) && (i <= s.len)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = s.ptr + i,
|
||||
.len = s.len - i,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(s.ptr + i, s.len - i);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// wuffs_base__slice_u8__subslice_j returns s[:j].
|
||||
@@ -387,12 +423,9 @@ wuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {
|
||||
if ((j <= SIZE_MAX) && (j <= s.len)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = s.ptr,
|
||||
.len = j,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(s.ptr, j);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// wuffs_base__slice_u8__subslice_ij returns s[i:j].
|
||||
@@ -403,12 +436,9 @@ wuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,
|
||||
uint64_t i,
|
||||
uint64_t j) {
|
||||
if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = s.ptr + i,
|
||||
.len = j - i,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(s.ptr + i, j - i);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -419,6 +449,11 @@ wuffs_base__acknowledge_potentially_unused_functions__core_public()
|
||||
|
||||
static inline void
|
||||
wuffs_base__acknowledge_potentially_unused_functions__core_public() {
|
||||
(void)(wuffs_base__make_empty_struct);
|
||||
(void)(wuffs_base__make_slice_u16);
|
||||
(void)(wuffs_base__make_slice_u32);
|
||||
(void)(wuffs_base__make_slice_u64);
|
||||
(void)(wuffs_base__make_slice_u8);
|
||||
(void)(wuffs_base__slice_u8__subslice_i);
|
||||
(void)(wuffs_base__slice_u8__subslice_ij);
|
||||
(void)(wuffs_base__slice_u8__subslice_j);
|
||||
@@ -1296,15 +1331,19 @@ wuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) {
|
||||
|
||||
static inline wuffs_base__io_reader //
|
||||
wuffs_base__io_buffer__reader(wuffs_base__io_buffer* buf) {
|
||||
wuffs_base__io_reader ret = ((wuffs_base__io_reader){.private_impl = {0}});
|
||||
wuffs_base__io_reader ret;
|
||||
ret.private_impl.buf = buf;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__io_writer //
|
||||
wuffs_base__io_buffer__writer(wuffs_base__io_buffer* buf) {
|
||||
wuffs_base__io_writer ret = ((wuffs_base__io_writer){.private_impl = {0}});
|
||||
wuffs_base__io_writer ret;
|
||||
ret.private_impl.buf = buf;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1382,13 +1421,10 @@ wuffs_base__malloc_slice_u8(void* (*malloc_func)(size_t), uint64_t num_u8) {
|
||||
if (malloc_func && (num_u8 <= (SIZE_MAX / sizeof(uint8_t)))) {
|
||||
void* p = (*malloc_func)(num_u8 * sizeof(uint8_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = (uint8_t*)(p),
|
||||
.len = num_u8,
|
||||
});
|
||||
return wuffs_base__make_slice_u8((uint8_t*)(p), num_u8);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u16 //
|
||||
@@ -1396,13 +1432,10 @@ wuffs_base__malloc_slice_u16(void* (*malloc_func)(size_t), uint64_t num_u16) {
|
||||
if (malloc_func && (num_u16 <= (SIZE_MAX / sizeof(uint16_t)))) {
|
||||
void* p = (*malloc_func)(num_u16 * sizeof(uint16_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u16){
|
||||
.ptr = (uint16_t*)(p),
|
||||
.len = num_u16,
|
||||
});
|
||||
return wuffs_base__make_slice_u16((uint16_t*)(p), num_u16);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u16){0});
|
||||
return wuffs_base__make_slice_u16(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u32 //
|
||||
@@ -1410,13 +1443,10 @@ wuffs_base__malloc_slice_u32(void* (*malloc_func)(size_t), uint64_t num_u32) {
|
||||
if (malloc_func && (num_u32 <= (SIZE_MAX / sizeof(uint32_t)))) {
|
||||
void* p = (*malloc_func)(num_u32 * sizeof(uint32_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u32){
|
||||
.ptr = (uint32_t*)(p),
|
||||
.len = num_u32,
|
||||
});
|
||||
return wuffs_base__make_slice_u32((uint32_t*)(p), num_u32);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u32){0});
|
||||
return wuffs_base__make_slice_u32(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u64 //
|
||||
@@ -1424,13 +1454,10 @@ wuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) {
|
||||
if (malloc_func && (num_u64 <= (SIZE_MAX / sizeof(uint64_t)))) {
|
||||
void* p = (*malloc_func)(num_u64 * sizeof(uint64_t));
|
||||
if (p) {
|
||||
return ((wuffs_base__slice_u64){
|
||||
.ptr = (uint64_t*)(p),
|
||||
.len = num_u64,
|
||||
});
|
||||
return wuffs_base__make_slice_u64((uint64_t*)(p), num_u64);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u64){0});
|
||||
return wuffs_base__make_slice_u64(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -1801,17 +1828,20 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__pixel_config){
|
||||
.private_impl = {0},
|
||||
});
|
||||
|
||||
c->private_impl.pixfmt = 0;
|
||||
c->private_impl.pixsub = 0;
|
||||
c->private_impl.width = 0;
|
||||
c->private_impl.height = 0;
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__pixel_config){
|
||||
.private_impl = {0},
|
||||
});
|
||||
c->private_impl.pixfmt = 0;
|
||||
c->private_impl.pixsub = 0;
|
||||
c->private_impl.width = 0;
|
||||
c->private_impl.height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1832,13 +1862,21 @@ wuffs_base__pixel_config__pixel_subsampling(wuffs_base__pixel_config* c) {
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__pixel_config__bounds(wuffs_base__pixel_config* c) {
|
||||
return c ? ((wuffs_base__rect_ie_u32){
|
||||
.min_incl_x = 0,
|
||||
.min_incl_y = 0,
|
||||
.max_excl_x = c->private_impl.width,
|
||||
.max_excl_y = c->private_impl.height,
|
||||
})
|
||||
: ((wuffs_base__rect_ie_u32){0});
|
||||
if (c) {
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = 0;
|
||||
ret.min_incl_y = 0;
|
||||
ret.max_excl_x = c->private_impl.width;
|
||||
ret.max_excl_y = c->private_impl.height;
|
||||
return ret;
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = 0;
|
||||
ret.min_incl_y = 0;
|
||||
ret.max_excl_x = 0;
|
||||
ret.max_excl_y = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -1988,19 +2026,24 @@ wuffs_base__image_config__set(wuffs_base__image_config* c,
|
||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||
return;
|
||||
}
|
||||
*c = ((wuffs_base__image_config){
|
||||
.pixcfg = {.private_impl = {0}},
|
||||
.private_impl = {0},
|
||||
});
|
||||
|
||||
c->pixcfg.private_impl.pixfmt = 0;
|
||||
c->pixcfg.private_impl.pixsub = 0;
|
||||
c->pixcfg.private_impl.width = 0;
|
||||
c->pixcfg.private_impl.height = 0;
|
||||
c->private_impl.first_frame_io_position = 0;
|
||||
c->private_impl.first_frame_is_opaque = 0;
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__image_config__invalidate(wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){
|
||||
.pixcfg = {.private_impl = {0}},
|
||||
.private_impl = {0},
|
||||
});
|
||||
c->pixcfg.private_impl.pixfmt = 0;
|
||||
c->pixcfg.private_impl.pixsub = 0;
|
||||
c->pixcfg.private_impl.width = 0;
|
||||
c->pixcfg.private_impl.height = 0;
|
||||
c->private_impl.first_frame_io_position = 0;
|
||||
c->private_impl.first_frame_is_opaque = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2147,7 +2190,16 @@ wuffs_base__frame_config__update(wuffs_base__frame_config* c,
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {
|
||||
return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){0});
|
||||
if (c) {
|
||||
return c->private_impl.bounds;
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = 0;
|
||||
ret.min_incl_y = 0;
|
||||
ret.max_excl_x = 0;
|
||||
ret.max_excl_y = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -2345,13 +2397,10 @@ wuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* b) {
|
||||
wuffs_base__table_u8* tab =
|
||||
&b->private_impl.planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];
|
||||
if ((tab->width == 1024) && (tab->height == 1)) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = tab->ptr,
|
||||
.len = 1024,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(tab->ptr, 1024);
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format //
|
||||
@@ -2364,9 +2413,16 @@ wuffs_base__pixel_buffer__pixel_format(wuffs_base__pixel_buffer* b) {
|
||||
|
||||
static inline wuffs_base__table_u8 //
|
||||
wuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* b, uint32_t p) {
|
||||
return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))
|
||||
? b->private_impl.planes[p]
|
||||
: ((wuffs_base__table_u8){0});
|
||||
if (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX)) {
|
||||
return b->private_impl.planes[p];
|
||||
}
|
||||
|
||||
wuffs_base__table_u8 ret;
|
||||
ret.ptr = NULL;
|
||||
ret.width = 0;
|
||||
ret.height = 0;
|
||||
ret.stride = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -3851,7 +3907,7 @@ extern "C" {
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__ignore_status(wuffs_base__status z) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.
|
||||
@@ -3918,11 +3974,6 @@ wuffs_base__ignore_status(wuffs_base__status z) {
|
||||
// inline attribute to guide optimizations such as inlining, to avoid the
|
||||
// -Wunused-function warning, and we like to compile with -Wall -Werror.
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__return_empty_struct() {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
}
|
||||
|
||||
// ---------------- Numeric Types
|
||||
|
||||
static inline uint8_t //
|
||||
@@ -4252,19 +4303,16 @@ wuffs_base__slice_u8__copy_from_slice(wuffs_base__slice_u8 dst,
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {
|
||||
if (y < t.height) {
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = t.ptr + (t.stride * y),
|
||||
.len = t.width,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Slices and Tables (Utility)
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__utility__null_slice_u8() {
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -4291,7 +4339,6 @@ wuffs_base__acknowledge_potentially_unused_functions__core_private() {
|
||||
(void)(wuffs_base__load_u64be);
|
||||
(void)(wuffs_base__load_u64le);
|
||||
(void)(wuffs_base__load_u8be);
|
||||
(void)(wuffs_base__return_empty_struct);
|
||||
(void)(wuffs_base__slice_u8__copy_from_slice);
|
||||
(void)(wuffs_base__slice_u8__prefix);
|
||||
(void)(wuffs_base__slice_u8__suffix);
|
||||
@@ -4368,34 +4415,34 @@ wuffs_base__range_ie_u64__get_max_excl(const wuffs_base__range_ie_u64* r) {
|
||||
|
||||
static inline wuffs_base__range_ii_u32 //
|
||||
wuffs_base__utility__make_range_ii_u32(uint32_t min_incl, uint32_t max_incl) {
|
||||
return ((wuffs_base__range_ii_u32){
|
||||
.min_incl = min_incl,
|
||||
.max_incl = max_incl,
|
||||
});
|
||||
wuffs_base__range_ii_u32 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_incl = max_incl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__range_ie_u32 //
|
||||
wuffs_base__utility__make_range_ie_u32(uint32_t min_incl, uint32_t max_excl) {
|
||||
return ((wuffs_base__range_ie_u32){
|
||||
.min_incl = min_incl,
|
||||
.max_excl = max_excl,
|
||||
});
|
||||
wuffs_base__range_ie_u32 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_excl = max_excl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__range_ii_u64 //
|
||||
wuffs_base__utility__make_range_ii_u64(uint64_t min_incl, uint64_t max_incl) {
|
||||
return ((wuffs_base__range_ii_u64){
|
||||
.min_incl = min_incl,
|
||||
.max_incl = max_incl,
|
||||
});
|
||||
wuffs_base__range_ii_u64 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_incl = max_incl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__range_ie_u64 //
|
||||
wuffs_base__utility__make_range_ie_u64(uint64_t min_incl, uint64_t max_excl) {
|
||||
return ((wuffs_base__range_ie_u64){
|
||||
.min_incl = min_incl,
|
||||
.max_excl = max_excl,
|
||||
});
|
||||
wuffs_base__range_ie_u64 ret;
|
||||
ret.min_incl = min_incl;
|
||||
ret.max_excl = max_excl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__rect_ii_u32 //
|
||||
@@ -4403,12 +4450,12 @@ wuffs_base__utility__make_rect_ii_u32(uint32_t min_incl_x,
|
||||
uint32_t min_incl_y,
|
||||
uint32_t max_incl_x,
|
||||
uint32_t max_incl_y) {
|
||||
return ((wuffs_base__rect_ii_u32){
|
||||
.min_incl_x = min_incl_x,
|
||||
.min_incl_y = min_incl_y,
|
||||
.max_incl_x = max_incl_x,
|
||||
.max_incl_y = max_incl_y,
|
||||
});
|
||||
wuffs_base__rect_ii_u32 ret;
|
||||
ret.min_incl_x = min_incl_x;
|
||||
ret.min_incl_y = min_incl_y;
|
||||
ret.max_incl_x = max_incl_x;
|
||||
ret.max_incl_y = max_incl_y;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
@@ -4416,12 +4463,12 @@ wuffs_base__utility__make_rect_ie_u32(uint32_t min_incl_x,
|
||||
uint32_t min_incl_y,
|
||||
uint32_t max_excl_x,
|
||||
uint32_t max_excl_y) {
|
||||
return ((wuffs_base__rect_ie_u32){
|
||||
.min_incl_x = min_incl_x,
|
||||
.min_incl_y = min_incl_y,
|
||||
.max_excl_x = max_excl_x,
|
||||
.max_excl_y = max_excl_y,
|
||||
});
|
||||
wuffs_base__rect_ie_u32 ret;
|
||||
ret.min_incl_x = min_incl_x;
|
||||
ret.min_incl_y = min_incl_y;
|
||||
ret.max_excl_x = max_excl_x;
|
||||
ret.max_excl_y = max_excl_y;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -4639,7 +4686,10 @@ wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop_r = data.ptr;
|
||||
*ptr_io1_r = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
@@ -4649,13 +4699,19 @@ wuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,
|
||||
if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {
|
||||
o->private_impl.limit = iop_r + limit;
|
||||
}
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {
|
||||
o->private_impl.mark = mark;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
@@ -4663,12 +4719,9 @@ wuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {
|
||||
if (n <= ((size_t)(io1_r - *ptr_iop_r))) {
|
||||
uint8_t* p = *ptr_iop_r;
|
||||
*ptr_iop_r += n;
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = p,
|
||||
.len = n,
|
||||
});
|
||||
return wuffs_base__make_slice_u8(p, n);
|
||||
}
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
@@ -4688,25 +4741,51 @@ wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop_w = data.ptr;
|
||||
*ptr_io1_w = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {
|
||||
o->private_impl.mark = mark;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
|
||||
wuffs_base__empty_struct ret;
|
||||
ret.private_impl = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---------------- I/O (Utility)
|
||||
|
||||
static inline wuffs_base__io_buffer //
|
||||
wuffs_base__utility__null_io_buffer() {
|
||||
wuffs_base__io_buffer ret;
|
||||
ret.data.ptr = NULL;
|
||||
ret.data.len = 0;
|
||||
ret.meta.wi = 0;
|
||||
ret.meta.ri = 0;
|
||||
ret.meta.pos = 0;
|
||||
ret.meta.closed = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__io_reader //
|
||||
wuffs_base__utility__null_io_reader() {
|
||||
return ((wuffs_base__io_reader){.private_impl = {0}});
|
||||
wuffs_base__io_reader ret;
|
||||
ret.private_impl.buf = NULL;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__io_writer //
|
||||
wuffs_base__utility__null_io_writer() {
|
||||
return ((wuffs_base__io_writer){.private_impl = {0}});
|
||||
wuffs_base__io_writer ret;
|
||||
ret.private_impl.buf = NULL;
|
||||
ret.private_impl.mark = NULL;
|
||||
ret.private_impl.limit = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---------------- Bureaucracy re -Wunused-function
|
||||
@@ -4732,6 +4811,7 @@ wuffs_base__acknowledge_potentially_unused_functions__io_private() {
|
||||
(void)(wuffs_base__io_writer__is_valid);
|
||||
(void)(wuffs_base__io_writer__set);
|
||||
(void)(wuffs_base__io_writer__set_mark);
|
||||
(void)(wuffs_base__utility__null_io_buffer);
|
||||
(void)(wuffs_base__utility__null_io_reader);
|
||||
(void)(wuffs_base__utility__null_io_writer);
|
||||
}
|
||||
@@ -6366,11 +6446,11 @@ sizeof__wuffs_deflate__decoder() {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
||||
wuffs_deflate__decoder__workbuf_len(const wuffs_deflate__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(1, 1);
|
||||
@@ -6453,35 +6533,25 @@ wuffs_deflate__decoder__decode_io_writer(wuffs_deflate__decoder* self,
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
v_written = ((wuffs_base__slice_u8){
|
||||
.ptr = a_dst.private_impl.mark,
|
||||
.len = (size_t)(iop_a_dst - a_dst.private_impl.mark),
|
||||
});
|
||||
v_written = wuffs_base__make_slice_u8(
|
||||
a_dst.private_impl.mark,
|
||||
(size_t)(iop_a_dst - a_dst.private_impl.mark));
|
||||
if (((uint64_t)(v_written.len)) >= 32768) {
|
||||
v_written = wuffs_base__slice_u8__suffix(v_written, 32768);
|
||||
wuffs_base__slice_u8__copy_from_slice(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768),
|
||||
v_written);
|
||||
self->private_impl.f_history_index = 32768;
|
||||
} else {
|
||||
v_n_copied = wuffs_base__slice_u8__copy_from_slice(
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768),
|
||||
(self->private_impl.f_history_index & 32767)),
|
||||
v_written);
|
||||
if (v_n_copied < ((uint64_t)(v_written.len))) {
|
||||
v_written = wuffs_base__slice_u8__subslice_i(v_written, v_n_copied);
|
||||
v_n_copied = wuffs_base__slice_u8__copy_from_slice(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768),
|
||||
v_written);
|
||||
self->private_impl.f_history_index =
|
||||
(((uint32_t)((v_n_copied & 32767))) + 32768);
|
||||
@@ -7415,10 +7485,10 @@ label_0_continue:;
|
||||
(((uint64_t)(io1_a_src - iop_a_src)) >= 12)) {
|
||||
if (v_n_bits < 15) {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
} else {
|
||||
}
|
||||
@@ -7429,7 +7499,7 @@ label_0_continue:;
|
||||
if ((v_table_entry >> 31) != 0) {
|
||||
(wuffs_base__store_u8be(iop_a_dst,
|
||||
((uint8_t)(((v_table_entry >> 8) & 255)))),
|
||||
iop_a_dst += 1, wuffs_base__return_empty_struct());
|
||||
iop_a_dst += 1, wuffs_base__make_empty_struct());
|
||||
goto label_0_continue;
|
||||
} else if ((v_table_entry >> 30) != 0) {
|
||||
} else if ((v_table_entry >> 29) != 0) {
|
||||
@@ -7438,10 +7508,10 @@ label_0_continue:;
|
||||
} else if ((v_table_entry >> 28) != 0) {
|
||||
if (v_n_bits < 15) {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
} else {
|
||||
}
|
||||
@@ -7460,7 +7530,7 @@ label_0_continue:;
|
||||
if ((v_table_entry >> 31) != 0) {
|
||||
(wuffs_base__store_u8be(iop_a_dst,
|
||||
((uint8_t)(((v_table_entry >> 8) & 255)))),
|
||||
iop_a_dst += 1, wuffs_base__return_empty_struct());
|
||||
iop_a_dst += 1, wuffs_base__make_empty_struct());
|
||||
goto label_0_continue;
|
||||
} else if ((v_table_entry >> 30) != 0) {
|
||||
} else if ((v_table_entry >> 29) != 0) {
|
||||
@@ -7491,10 +7561,10 @@ label_0_continue:;
|
||||
if (v_table_entry_n_bits > 0) {
|
||||
if (v_n_bits < 15) {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
} else {
|
||||
}
|
||||
@@ -7509,10 +7579,10 @@ label_0_continue:;
|
||||
}
|
||||
if (v_n_bits < 15) {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
} else {
|
||||
}
|
||||
@@ -7523,10 +7593,10 @@ label_0_continue:;
|
||||
if ((v_table_entry >> 28) == 1) {
|
||||
if (v_n_bits < 15) {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
} else {
|
||||
}
|
||||
@@ -7557,10 +7627,10 @@ label_0_continue:;
|
||||
v_table_entry_n_bits = ((v_table_entry >> 4) & 15);
|
||||
if (v_n_bits < v_table_entry_n_bits) {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
}
|
||||
v_dist_minus_1 =
|
||||
@@ -7593,10 +7663,8 @@ label_0_continue:;
|
||||
v_n_copied = wuffs_base__io_writer__copy_n_from_slice(
|
||||
&iop_a_dst, io1_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history,
|
||||
32768),
|
||||
(v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
goto label_1_break;
|
||||
@@ -7604,10 +7672,7 @@ label_0_continue:;
|
||||
v_hlen -= v_n_copied;
|
||||
wuffs_base__io_writer__copy_n_from_slice(
|
||||
&iop_a_dst, io1_a_dst, v_hlen,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}));
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768));
|
||||
goto label_1_break;
|
||||
}
|
||||
label_1_break:;
|
||||
@@ -7631,7 +7696,7 @@ label_0_break:;
|
||||
while (v_n_bits >= 8) {
|
||||
v_n_bits -= 8;
|
||||
if (iop_a_src > io0_a_src) {
|
||||
(iop_a_src--, wuffs_base__return_empty_struct());
|
||||
(iop_a_src--, wuffs_base__make_empty_struct());
|
||||
} else {
|
||||
status = wuffs_deflate__error__internal_error_inconsistent_i_o;
|
||||
goto exit;
|
||||
@@ -7976,10 +8041,8 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
|
||||
v_n_copied = wuffs_base__io_writer__copy_n_from_slice(
|
||||
&iop_a_dst, io1_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history,
|
||||
32768),
|
||||
(v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
@@ -8001,10 +8064,8 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
|
||||
v_n_copied = wuffs_base__io_writer__copy_n_from_slice(
|
||||
&iop_a_dst, io1_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_history,
|
||||
.len = 32768,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history,
|
||||
32768),
|
||||
(v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
@@ -8173,18 +8234,18 @@ sizeof__wuffs_lzw__decoder() {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct //
|
||||
wuffs_lzw__decoder__set_literal_width(wuffs_lzw__decoder* self, uint32_t a_lw) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
if (a_lw < 2 || a_lw > 8) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
self->private_impl.f_set_literal_width_arg = a_lw;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func lzw.decoder.workbuf_len
|
||||
@@ -8192,11 +8253,11 @@ wuffs_lzw__decoder__set_literal_width(wuffs_lzw__decoder* self, uint32_t a_lw) {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
||||
wuffs_lzw__decoder__workbuf_len(const wuffs_lzw__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
@@ -8348,15 +8409,14 @@ wuffs_lzw__decoder__read_from(wuffs_lzw__decoder* self,
|
||||
if (v_n_bits < v_width) {
|
||||
if (((uint64_t)(io1_a_src - iop_a_src)) >= 4) {
|
||||
v_bits |= (wuffs_base__load_u32le(iop_a_src) << v_n_bits);
|
||||
(iop_a_src += ((31 - v_n_bits) >> 3),
|
||||
wuffs_base__return_empty_struct());
|
||||
(iop_a_src += ((31 - v_n_bits) >> 3), wuffs_base__make_empty_struct());
|
||||
v_n_bits |= 24;
|
||||
} else if (((uint64_t)(io1_a_src - iop_a_src)) <= 0) {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
goto label_0_break;
|
||||
} else {
|
||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
if (v_n_bits >= v_width) {
|
||||
} else if (((uint64_t)(io1_a_src - iop_a_src)) <= 0) {
|
||||
@@ -8365,7 +8425,7 @@ wuffs_lzw__decoder__read_from(wuffs_lzw__decoder* self,
|
||||
} else {
|
||||
v_bits |=
|
||||
(((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
v_n_bits += 8;
|
||||
if (v_n_bits < v_width) {
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
@@ -8475,7 +8535,7 @@ label_0_break:;
|
||||
while (v_n_bits >= 8) {
|
||||
v_n_bits -= 8;
|
||||
if (iop_a_src > io0_a_src) {
|
||||
(iop_a_src--, wuffs_base__return_empty_struct());
|
||||
(iop_a_src--, wuffs_base__make_empty_struct());
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
goto label_2_break;
|
||||
@@ -8494,7 +8554,7 @@ label_0_break:;
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
}
|
||||
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func lzw.decoder.write_to
|
||||
@@ -8537,10 +8597,7 @@ wuffs_lzw__decoder__write_to(wuffs_lzw__decoder* self,
|
||||
goto exit;
|
||||
}
|
||||
v_s = wuffs_base__slice_u8__subslice_ij(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_output,
|
||||
.len = 8199,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_output, 8199),
|
||||
self->private_impl.f_output_ri, self->private_impl.f_output_wi);
|
||||
v_n = wuffs_base__io_writer__copy_from_slice(&iop_a_dst, io1_a_dst, v_s);
|
||||
if (v_n == ((uint64_t)(v_s.len))) {
|
||||
@@ -8581,20 +8638,17 @@ exit:
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__slice_u8 //
|
||||
wuffs_lzw__decoder__flush(wuffs_lzw__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return ((wuffs_base__slice_u8){0});
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
wuffs_base__slice_u8 v_s = {0};
|
||||
|
||||
if (self->private_impl.f_output_ri <= self->private_impl.f_output_wi) {
|
||||
v_s = wuffs_base__slice_u8__subslice_ij(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_output,
|
||||
.len = 8199,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_output, 8199),
|
||||
self->private_impl.f_output_ri, self->private_impl.f_output_wi);
|
||||
}
|
||||
self->private_impl.f_output_ri = 0;
|
||||
@@ -8906,11 +8960,11 @@ wuffs_gif__decoder__num_decoded_frames(const wuffs_gif__decoder* self) {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32 //
|
||||
wuffs_gif__decoder__frame_dirty_rect(const wuffs_gif__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__rect_ie_u32){0});
|
||||
return wuffs_base__utility__make_rect_ie_u32(0, 0, 0, 0);
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return ((wuffs_base__rect_ie_u32){0});
|
||||
return wuffs_base__utility__make_rect_ie_u32(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_rect_ie_u32(
|
||||
@@ -8927,11 +8981,11 @@ wuffs_gif__decoder__frame_dirty_rect(const wuffs_gif__decoder* self) {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
||||
wuffs_gif__decoder__workbuf_len(const wuffs_gif__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(1, 1);
|
||||
@@ -8995,7 +9049,7 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
(memset(&self->private_impl.f_dirty_y, 0, sizeof(wuffs_base__range_ie_u32)),
|
||||
wuffs_base__return_empty_struct());
|
||||
wuffs_base__make_empty_struct());
|
||||
if (!self->private_impl.f_end_of_data) {
|
||||
if (self->private_impl.f_call_sequence == 0) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
@@ -9245,7 +9299,7 @@ wuffs_gif__decoder__reset_gc(wuffs_gif__decoder* self) {
|
||||
self->private_impl.f_gc_transparent_index = 0;
|
||||
self->private_impl.f_gc_disposal = 0;
|
||||
self->private_impl.f_gc_duration = 0;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.decode_up_to_id_part1
|
||||
@@ -10439,14 +10493,8 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
}
|
||||
} else if (self->private_impl.f_gc_has_transparent_index) {
|
||||
wuffs_base__slice_u8__copy_from_slice(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_palettes[1],
|
||||
.len = 1024,
|
||||
}),
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_palettes[0],
|
||||
.len = 1024,
|
||||
}));
|
||||
wuffs_base__make_slice_u8(self->private_data.f_palettes[1], 1024),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_palettes[0], 1024));
|
||||
} else {
|
||||
self->private_impl.f_which_palette = 0;
|
||||
}
|
||||
@@ -10466,20 +10514,16 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
}
|
||||
v_dst_palette = wuffs_base__pixel_buffer__palette(a_dst);
|
||||
if (((uint64_t)(v_dst_palette.len)) == 0) {
|
||||
v_dst_palette = ((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_dst_palette,
|
||||
.len = 1024,
|
||||
});
|
||||
v_dst_palette =
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024);
|
||||
}
|
||||
wuffs_base__pixel_swizzler__prepare(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__pixel_buffer__pixel_format(a_dst), v_dst_palette,
|
||||
1191444488,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data
|
||||
.f_palettes[self->private_impl.f_which_palette],
|
||||
.len = 1024,
|
||||
}));
|
||||
wuffs_base__make_slice_u8(
|
||||
self->private_data.f_palettes[self->private_impl.f_which_palette],
|
||||
1024));
|
||||
if (self->private_impl.f_previous_lzw_decode_ended_abruptly) {
|
||||
wuffs_base__ignore_status(wuffs_lzw__decoder__initialize(
|
||||
&self->private_data.f_lzw, sizeof(wuffs_lzw__decoder), WUFFS_VERSION,
|
||||
@@ -10538,11 +10582,9 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
bool v_need_block_size = false;
|
||||
uint64_t v_n_compressed = 0;
|
||||
wuffs_base__slice_u8 v_compressed = {0};
|
||||
wuffs_base__io_reader v_r = {.private_impl = {0}};
|
||||
wuffs_base__io_buffer u_r WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
.data = ((wuffs_base__slice_u8){0}),
|
||||
.meta = ((wuffs_base__io_buffer_meta){0}),
|
||||
};
|
||||
wuffs_base__io_reader v_r = wuffs_base__utility__null_io_reader();
|
||||
wuffs_base__io_buffer u_r WUFFS_BASE__POTENTIALLY_UNUSED =
|
||||
wuffs_base__utility__null_io_buffer();
|
||||
uint8_t* iop_v_r WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_v_r WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__status v_lzw_status = NULL;
|
||||
@@ -10611,10 +10653,8 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
wuffs_base__io_reader__take(&iop_a_src, io1_a_src, v_n_compressed);
|
||||
wuffs_base__slice_u8__copy_from_slice(
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_compressed,
|
||||
.len = 4096,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_compressed,
|
||||
4096),
|
||||
self->private_impl.f_compressed_wi),
|
||||
v_compressed);
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_compressed_wi,
|
||||
@@ -10628,7 +10668,7 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
goto label_1_break;
|
||||
}
|
||||
v_block_size = ((uint64_t)(wuffs_base__load_u8be(iop_a_src)));
|
||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
}
|
||||
label_1_break:;
|
||||
if (1 > ((uint64_t)(a_workbuf.len))) {
|
||||
@@ -10650,10 +10690,8 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
wuffs_base__io_reader__set(
|
||||
&v_r, &u_r, &iop_v_r, &io1_v_r,
|
||||
wuffs_base__slice_u8__subslice_ij(
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_compressed,
|
||||
.len = 4096,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_compressed,
|
||||
4096),
|
||||
self->private_impl.f_compressed_ri,
|
||||
self->private_impl.f_compressed_wi));
|
||||
{
|
||||
@@ -10804,10 +10842,7 @@ label_0_continue:;
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_packed(
|
||||
&self->private_impl.f_swizzler, v_dst,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = self->private_data.f_dst_palette,
|
||||
.len = 1024,
|
||||
}),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
v_src);
|
||||
wuffs_base__u64__sat_add_indirect(&v_src_ri, v_n);
|
||||
wuffs_base__u32__sat_add_indirect(&self->private_impl.f_dst_x,
|
||||
@@ -10971,14 +11006,14 @@ sizeof__wuffs_gzip__decoder() {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct //
|
||||
wuffs_gzip__decoder__set_ignore_checksum(wuffs_gzip__decoder* self, bool a_ic) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
self->private_impl.f_ignore_checksum = a_ic;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func gzip.decoder.workbuf_len
|
||||
@@ -10986,11 +11021,11 @@ wuffs_gzip__decoder__set_ignore_checksum(wuffs_gzip__decoder* self, bool a_ic) {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
||||
wuffs_gzip__decoder__workbuf_len(const wuffs_gzip__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(1, 1);
|
||||
@@ -11249,10 +11284,9 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
if (!self->private_impl.f_ignore_checksum) {
|
||||
v_checksum_got = wuffs_crc32__ieee_hasher__update(
|
||||
&self->private_data.f_checksum,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = a_dst.private_impl.mark,
|
||||
.len = (size_t)(iop_a_dst - a_dst.private_impl.mark),
|
||||
}));
|
||||
wuffs_base__make_slice_u8(
|
||||
a_dst.private_impl.mark,
|
||||
(size_t)(iop_a_dst - a_dst.private_impl.mark)));
|
||||
v_decoded_length_got += ((uint32_t)(
|
||||
(((uint64_t)(iop_a_dst - a_dst.private_impl.mark)) & 4294967295)));
|
||||
}
|
||||
@@ -11466,14 +11500,14 @@ sizeof__wuffs_zlib__decoder() {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct //
|
||||
wuffs_zlib__decoder__set_ignore_checksum(wuffs_zlib__decoder* self, bool a_ic) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
self->private_impl.f_ignore_checksum = a_ic;
|
||||
return ((wuffs_base__empty_struct){0});
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func zlib.decoder.workbuf_len
|
||||
@@ -11481,11 +11515,11 @@ wuffs_zlib__decoder__set_ignore_checksum(wuffs_zlib__decoder* self, bool a_ic) {
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
||||
wuffs_zlib__decoder__workbuf_len(const wuffs_zlib__decoder* self) {
|
||||
if (!self) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return ((wuffs_base__range_ii_u64){0});
|
||||
return wuffs_base__utility__make_range_ii_u64(0, 0);
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(1, 1);
|
||||
@@ -11629,10 +11663,9 @@ wuffs_zlib__decoder__decode_io_writer(wuffs_zlib__decoder* self,
|
||||
if (!self->private_impl.f_ignore_checksum) {
|
||||
v_checksum_got = wuffs_adler32__hasher__update(
|
||||
&self->private_data.f_checksum,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = a_dst.private_impl.mark,
|
||||
.len = (size_t)(iop_a_dst - a_dst.private_impl.mark),
|
||||
}));
|
||||
wuffs_base__make_slice_u8(
|
||||
a_dst.private_impl.mark,
|
||||
(size_t)(iop_a_dst - a_dst.private_impl.mark)));
|
||||
}
|
||||
if (wuffs_base__status__is_ok(v_status)) {
|
||||
goto label_0_break;
|
||||
|
||||
Reference in new issue
Block a user