diff --git a/cmd/wuffs-c/internal/cgen/expr.go b/cmd/wuffs-c/internal/cgen/expr.go index d19a4543..b14ace7e 100644 --- a/cmd/wuffs-c/internal/cgen/expr.go +++ b/cmd/wuffs-c/internal/cgen/expr.go @@ -315,7 +315,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare } if isThatMethod(g.tm, n, g.tm.ByName("update"), 1) { // TODO: don't hard-code the class name or this.checksum. - class := "wuffs_crc32__ieee" + class := "wuffs_crc32__ieee_hasher" if g.pkgName == "zlib" { class = "wuffs_adler32__hasher" } diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index fe36c096..f554a0e2 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -1066,7 +1066,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s); typedef struct { // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_crc32__ieee__etc functions. + // wuffs_crc32__ieee_hasher__etc functions. // // In C++, these fields would be "private", but C does not support that. // @@ -1078,23 +1078,23 @@ typedef struct { uint32_t f_state; } private_impl; -} wuffs_crc32__ieee; +} wuffs_crc32__ieee_hasher; // ---------------- Public Initializer Prototypes -// wuffs_crc32__ieee__initialize is an initializer function. +// wuffs_crc32__ieee_hasher__initialize is an initializer function. // -// It should be called before any other wuffs_crc32__ieee__* function. +// It should be called before any other wuffs_crc32__ieee_hasher__* function. // // Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only. -void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self, - uint32_t wuffs_version, - uint32_t for_internal_use_only); +void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self, + uint32_t wuffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes -uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self, - wuffs_base__slice_u8 a_x); +uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, + wuffs_base__slice_u8 a_x); #ifdef __cplusplus } // extern "C" @@ -1566,9 +1566,9 @@ static const uint32_t wuffs_crc32__ieee_table[256] = { // ---------------- Initializer Implementations -void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self, - uint32_t wuffs_version, - uint32_t for_internal_use_only) { +void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self, + uint32_t wuffs_version, + uint32_t for_internal_use_only) { if (!self) { return; } @@ -1584,8 +1584,8 @@ void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self, // ---------------- Function Implementations -uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self, - wuffs_base__slice_u8 a_x) { +uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, + wuffs_base__slice_u8 a_x) { if (!self) { return 0; } diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 0dba2c59..2383f8df 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -1075,7 +1075,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s); typedef struct { // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_crc32__ieee__etc functions. + // wuffs_crc32__ieee_hasher__etc functions. // // In C++, these fields would be "private", but C does not support that. // @@ -1087,23 +1087,23 @@ typedef struct { uint32_t f_state; } private_impl; -} wuffs_crc32__ieee; +} wuffs_crc32__ieee_hasher; // ---------------- Public Initializer Prototypes -// wuffs_crc32__ieee__initialize is an initializer function. +// wuffs_crc32__ieee_hasher__initialize is an initializer function. // -// It should be called before any other wuffs_crc32__ieee__* function. +// It should be called before any other wuffs_crc32__ieee_hasher__* function. // // Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only. -void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self, - uint32_t wuffs_version, - uint32_t for_internal_use_only); +void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self, + uint32_t wuffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes -uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self, - wuffs_base__slice_u8 a_x); +uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, + wuffs_base__slice_u8 a_x); #ifdef __cplusplus } // extern "C" @@ -1354,7 +1354,7 @@ typedef struct { uint32_t magic; wuffs_deflate__decoder f_flate; - wuffs_crc32__ieee f_checksum; + wuffs_crc32__ieee_hasher f_checksum; bool f_ignore_checksum; struct { @@ -1841,8 +1841,9 @@ void wuffs_gzip__decoder__initialize(wuffs_gzip__decoder* self, self->private_impl.magic = WUFFS_BASE__MAGIC; wuffs_deflate__decoder__initialize(&self->private_impl.f_flate, WUFFS_VERSION, WUFFS_BASE__ALREADY_ZEROED); - wuffs_crc32__ieee__initialize(&self->private_impl.f_checksum, WUFFS_VERSION, - WUFFS_BASE__ALREADY_ZEROED); + wuffs_crc32__ieee_hasher__initialize(&self->private_impl.f_checksum, + WUFFS_VERSION, + WUFFS_BASE__ALREADY_ZEROED); } // ---------------- Function Implementations @@ -2103,7 +2104,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self, v_z = t_8; } if (!self->private_impl.f_ignore_checksum) { - v_checksum_got = wuffs_crc32__ieee__update( + v_checksum_got = wuffs_crc32__ieee_hasher__update( &self->private_impl.f_checksum, ((wuffs_base__slice_u8){ .ptr = a_dst.private_impl.mark, diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index 22068ea8..39701c5f 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -1066,7 +1066,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s); typedef struct { // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_crc32__ieee__etc functions. + // wuffs_crc32__ieee_hasher__etc functions. // // In C++, these fields would be "private", but C does not support that. // @@ -1078,23 +1078,23 @@ typedef struct { uint32_t f_state; } private_impl; -} wuffs_crc32__ieee; +} wuffs_crc32__ieee_hasher; // ---------------- Public Initializer Prototypes -// wuffs_crc32__ieee__initialize is an initializer function. +// wuffs_crc32__ieee_hasher__initialize is an initializer function. // -// It should be called before any other wuffs_crc32__ieee__* function. +// It should be called before any other wuffs_crc32__ieee_hasher__* function. // // Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only. -void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self, - uint32_t wuffs_version, - uint32_t for_internal_use_only); +void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self, + uint32_t wuffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes -uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self, - wuffs_base__slice_u8 a_x); +uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, + wuffs_base__slice_u8 a_x); #ifdef __cplusplus } // extern "C" diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index c8a9724d..0907af26 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -1075,7 +1075,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s); typedef struct { // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_crc32__ieee__etc functions. + // wuffs_crc32__ieee_hasher__etc functions. // // In C++, these fields would be "private", but C does not support that. // @@ -1087,23 +1087,23 @@ typedef struct { uint32_t f_state; } private_impl; -} wuffs_crc32__ieee; +} wuffs_crc32__ieee_hasher; // ---------------- Public Initializer Prototypes -// wuffs_crc32__ieee__initialize is an initializer function. +// wuffs_crc32__ieee_hasher__initialize is an initializer function. // -// It should be called before any other wuffs_crc32__ieee__* function. +// It should be called before any other wuffs_crc32__ieee_hasher__* function. // // Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only. -void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self, - uint32_t wuffs_version, - uint32_t for_internal_use_only); +void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self, + uint32_t wuffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes -uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self, - wuffs_base__slice_u8 a_x); +uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, + wuffs_base__slice_u8 a_x); #ifdef __cplusplus } // extern "C" @@ -1354,7 +1354,7 @@ typedef struct { uint32_t magic; wuffs_deflate__decoder f_flate; - wuffs_crc32__ieee f_checksum; + wuffs_crc32__ieee_hasher f_checksum; bool f_ignore_checksum; struct { diff --git a/std/crc32/common_crc32.wuffs b/std/crc32/common_crc32.wuffs index 527d4860..741361d0 100644 --- a/std/crc32/common_crc32.wuffs +++ b/std/crc32/common_crc32.wuffs @@ -14,8 +14,8 @@ packageid "crc3" -// TODO: drop the '?' but still generate wuffs_crc32__ieee__initialize? -pub struct ieee?( +// TODO: drop the '?' but still generate wuffs_crc32__ieee_hasher__initialize? +pub struct ieee_hasher?( state base.u32, ) @@ -24,7 +24,7 @@ pub struct ieee?( // TODO: should it be ? instead of ! because it's public, and might need a way // to signal "initializer not called"? Should the return type, in the generated // C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"? -pub func ieee.update(x slice base.u8)(checksum base.u32) { +pub func ieee_hasher.update(x slice base.u8)(checksum base.u32) { var s base.u32 = 0xFFFFFFFF ^ this.state iterate[1](p ptr base.u8:in.x) { diff --git a/std/gzip/decode_gzip.wuffs b/std/gzip/decode_gzip.wuffs index 99464e7a..5fdf5240 100644 --- a/std/gzip/decode_gzip.wuffs +++ b/std/gzip/decode_gzip.wuffs @@ -24,7 +24,7 @@ pub error "invalid gzip encoding flags" pub struct decoder?( flate deflate.decoder, - checksum crc32.ieee, + checksum crc32.ieee_hasher, ignore_checksum base.bool, ) diff --git a/test/c/std/crc32.c b/test/c/std/crc32.c index fcacf5fa..d6f5e1a5 100644 --- a/test/c/std/crc32.c +++ b/test/c/std/crc32.c @@ -105,8 +105,8 @@ void test_wuffs_crc32_ieee_golden() { int j; for (j = 0; j < 2; j++) { - wuffs_crc32__ieee checksum; - wuffs_crc32__ieee__initialize(&checksum, WUFFS_VERSION, 0); + wuffs_crc32__ieee_hasher checksum; + wuffs_crc32__ieee_hasher__initialize(&checksum, WUFFS_VERSION, 0); uint32_t got; size_t num_fragments = 0; @@ -120,7 +120,7 @@ void test_wuffs_crc32_ieee_golden() { if ((j > 0) && (data.len > limit)) { data.len = limit; } - got = wuffs_crc32__ieee__update(&checksum, data); + got = wuffs_crc32__ieee_hasher__update(&checksum, data); num_fragments++; num_bytes += data.len; } while (num_bytes < src.wi); @@ -164,13 +164,13 @@ void test_wuffs_crc32_ieee_pi() { int i; for (i = 0; i < 64; i++) { - wuffs_crc32__ieee checksum; - wuffs_crc32__ieee__initialize(&checksum, WUFFS_VERSION, 0); - uint32_t got = - wuffs_crc32__ieee__update(&checksum, ((wuffs_base__slice_u8){ - .ptr = (uint8_t*)(digits), - .len = i, - })); + wuffs_crc32__ieee_hasher checksum; + wuffs_crc32__ieee_hasher__initialize(&checksum, WUFFS_VERSION, 0); + uint32_t got = wuffs_crc32__ieee_hasher__update( + &checksum, ((wuffs_base__slice_u8){ + .ptr = (uint8_t*)(digits), + .len = i, + })); if (got != wants[i]) { FAIL("i=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32 "\n", i, got, wants[i]); @@ -188,13 +188,13 @@ const char* wuffs_bench_crc32_ieee(wuffs_base__io_buffer* dst, uint64_t wlimit, uint64_t rlimit) { // TODO: don't ignore wlimit and rlimit. - wuffs_crc32__ieee checksum; - wuffs_crc32__ieee__initialize(&checksum, WUFFS_VERSION, 0); + wuffs_crc32__ieee_hasher checksum; + wuffs_crc32__ieee_hasher__initialize(&checksum, WUFFS_VERSION, 0); global_wuffs_crc32_unused_u32 = - wuffs_crc32__ieee__update(&checksum, ((wuffs_base__slice_u8){ - .ptr = src->ptr + src->ri, - .len = src->wi - src->ri, - })); + wuffs_crc32__ieee_hasher__update(&checksum, ((wuffs_base__slice_u8){ + .ptr = src->ptr + src->ri, + .len = src->wi - src->ri, + })); src->ri = src->wi; return NULL; }