Rename crc32.ieee to crc32.ieee_hasher

This commit is contained in:
Nigel Tao committed 2018-04-27 20:23:45 +10:00
1 parent 035b138cb1
commit eecdaba4e8
8 files changed
+46 -45

No files matched your search

+1 -1
View File
@@ -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"
}
+8 -8
View File
@@ -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,22 +1078,22 @@ 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,
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,
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
wuffs_base__slice_u8 a_x);
#ifdef __cplusplus
@@ -1566,7 +1566,7 @@ static const uint32_t wuffs_crc32__ieee_table[256] = {
// ---------------- Initializer Implementations
void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self,
uint32_t wuffs_version,
uint32_t for_internal_use_only) {
if (!self) {
@@ -1584,7 +1584,7 @@ void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
// ---------------- Function Implementations
uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self,
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
wuffs_base__slice_u8 a_x) {
if (!self) {
return 0;
+10 -9
View File
@@ -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,22 +1087,22 @@ 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,
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,
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
wuffs_base__slice_u8 a_x);
#ifdef __cplusplus
@@ -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,7 +1841,8 @@ 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_crc32__ieee_hasher__initialize(&self->private_impl.f_checksum,
WUFFS_VERSION,
WUFFS_BASE__ALREADY_ZEROED);
}
@@ -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,
+6 -6
View File
@@ -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,22 +1078,22 @@ 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,
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,
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
wuffs_base__slice_u8 a_x);
#ifdef __cplusplus
+7 -7
View File
@@ -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,22 +1087,22 @@ 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,
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,
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
wuffs_base__slice_u8 a_x);
#ifdef __cplusplus
@@ -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 {
+3 -3
View File
@@ -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) {
+1 -1
View File
@@ -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,
)
+10 -10
View File
@@ -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,10 +164,10 @@ 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){
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,
}));
@@ -188,10 +188,10 @@ 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){
wuffs_crc32__ieee_hasher__update(&checksum, ((wuffs_base__slice_u8){
.ptr = src->ptr + src->ri,
.len = src->wi - src->ri,
}));