From 65c4efbe8b6a97c4a1090c57fa48546c0a92e7a4 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 21 Jul 2017 10:14:59 +1000 Subject: [PATCH] Add a placeholder huffman_decoder struct. --- cmd/puffs-gen-c/main.go | 2 +- gen/c/std/flate.c | 13 +++++++++++++ gen/h/std/flate.h | 13 +++++++++++++ std/flate/decode_flate.puffs | 4 ++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cmd/puffs-gen-c/main.go b/cmd/puffs-gen-c/main.go index b30c8364..940f8b02 100644 --- a/cmd/puffs-gen-c/main.go +++ b/cmd/puffs-gen-c/main.go @@ -749,7 +749,7 @@ func (g *gen) writeCTypeName(n *a.TypeExpr, varNamePrefix string, varName string } } if fallback { - g.printf("%s%s", g.pkgPrefix, n.Name().String(g.tm)) + g.printf("%s%s", g.pkgPrefix, innermost.Name().String(g.tm)) } for i := 0; i < numPointers; i++ { diff --git a/gen/c/std/flate.c b/gen/c/std/flate.c index 6d259a3d..8a37e3f7 100644 --- a/gen/c/std/flate.c +++ b/gen/c/std/flate.c @@ -121,6 +121,18 @@ const char* puffs_flate_status_string(puffs_flate_status s); // ---------------- Structs +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 + // puffs_flate_huffman_decoder_etc functions. + // + // In C++, these fields would be "private", but C does not support that. + // + // It is a struct, not a struct*, so that it can be stack allocated. + struct { + } private_impl; +} puffs_flate_huffman_decoder; + 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 @@ -136,6 +148,7 @@ typedef struct { uint32_t f_bits; uint32_t f_n_bits; + puffs_flate_huffman_decoder f_huff[2]; uint8_t f_code_lengths[19]; uint32_t f_wip0; uint32_t f_wip1; diff --git a/gen/h/std/flate.h b/gen/h/std/flate.h index 0a4bb963..2707bced 100644 --- a/gen/h/std/flate.h +++ b/gen/h/std/flate.h @@ -121,6 +121,18 @@ const char* puffs_flate_status_string(puffs_flate_status s); // ---------------- Structs +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 + // puffs_flate_huffman_decoder_etc functions. + // + // In C++, these fields would be "private", but C does not support that. + // + // It is a struct, not a struct*, so that it can be stack allocated. + struct { + } private_impl; +} puffs_flate_huffman_decoder; + 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 @@ -136,6 +148,7 @@ typedef struct { uint32_t f_bits; uint32_t f_n_bits; + puffs_flate_huffman_decoder f_huff[2]; uint8_t f_code_lengths[19]; uint32_t f_wip0; uint32_t f_wip1; diff --git a/std/flate/decode_flate.puffs b/std/flate/decode_flate.puffs index 0518dae0..f190c995 100644 --- a/std/flate/decode_flate.puffs +++ b/std/flate/decode_flate.puffs @@ -19,6 +19,7 @@ pub struct decoder?( bits u32, n_bits u32, + huff[2] huffman_decoder, code_lengths[19] u8[..7], // These temporary fields are used to debug work-in-progress code. @@ -120,3 +121,6 @@ pri func decoder.decode_dynamic?(dst writer1, src reader1)() { this.bits = bits this.n_bits = n_bits } + +pri struct huffman_decoder( +)