From a28dba7fd9f9e708daec88387d0d80c10ee5dcc9 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 30 Sep 2017 13:00:28 +1000 Subject: [PATCH] Rename C's foo_constructor to foo_initializer. --- cmd/puffs-c/internal/cgen/cgen.go | 38 +++++++++++----------- cmd/puffs-c/internal/cgen/func.go | 2 +- example/library/library.c | 2 +- example/peterface/peterface.c | 2 +- gen/c/std/flate.c | 52 ++++++++++++++--------------- gen/c/std/gif.c | 54 +++++++++++++++---------------- gen/h/std/flate.h | 20 ++++++------ gen/h/std/gif.h | 20 ++++++------ test/c/std/flate.c | 12 +++---- test/c/std/gif.c | 28 ++++++++-------- 10 files changed, 115 insertions(+), 115 deletions(-) diff --git a/cmd/puffs-c/internal/cgen/cgen.go b/cmd/puffs-c/internal/cgen/cgen.go index ad0ee63c..a400c913 100644 --- a/cmd/puffs-c/internal/cgen/cgen.go +++ b/cmd/puffs-c/internal/cgen/cgen.go @@ -88,7 +88,7 @@ var builtInStatuses = [...]string{ "error bad puffs version", "error bad receiver", "error bad argument", - "error constructor not called", + "error initializer not called", "error closed for writes", "error unexpected EOF", // Used if reading when closed == true. "suspension short read", // Used if reading when closed == false. @@ -266,10 +266,10 @@ func (g *gen) genHeader(b *buffer) error { } } - b.writes("// ---------------- Public Constructor and Destructor Prototypes\n\n") + b.writes("// ---------------- Public Initializer Prototypes\n\n") for _, n := range g.structList { if n.Public() { - if err := g.writeCtorPrototype(b, n); err != nil { + if err := g.writeInitializerPrototype(b, n); err != nil { return err } } @@ -331,10 +331,10 @@ func (g *gen) genImpl(b *buffer) error { return err } - b.writes("// ---------------- Private Constructor and Destructor Prototypes\n\n") + b.writes("// ---------------- Private Initializer Prototypes\n\n") for _, n := range g.structList { if !n.Public() { - if err := g.writeCtorPrototype(b, n); err != nil { + if err := g.writeInitializerPrototype(b, n); err != nil { return err } } @@ -345,21 +345,21 @@ func (g *gen) genImpl(b *buffer) error { return err } - b.writes("// ---------------- Constructor and Destructor Implementations\n\n") - b.writes("// PUFFS_MAGIC is a magic number to check that constructors are called. It's\n") + b.writes("// ---------------- Initializer Implementations\n\n") + b.writes("// PUFFS_MAGIC is a magic number to check that initializers are called. It's\n") b.writes("// not foolproof, given C doesn't automatically zero memory before use, but it\n") b.writes("// should catch 99.99% of cases.\n") b.writes("//\n") b.writes("// Its (non-zero) value is arbitrary, based on md5sum(\"puffs\").\n") b.writes("#define PUFFS_MAGIC (0xCB3699CCU)\n\n") - b.writes("// PUFFS_ALREADY_ZEROED is passed from a container struct's constructor to a\n") - b.writes("// containee struct's constructor when the container has already zeroed the\n") + b.writes("// PUFFS_ALREADY_ZEROED is passed from a container struct's initializer to a\n") + b.writes("// containee struct's initializer when the container has already zeroed the\n") b.writes("// containee's memory.\n") b.writes("//\n") b.writes("// Its (non-zero) value is arbitrary, based on md5sum(\"zeroed\").\n") b.writes("#define PUFFS_ALREADY_ZEROED (0x68602EF1U)\n\n") for _, n := range g.structList { - if err := g.writeCtorImpl(b, n); err != nil { + if err := g.writeInitializerImpl(b, n); err != nil { return err } } @@ -518,7 +518,7 @@ func (g *gen) writeConstList(b *buffer, n *a.Expr) error { func (g *gen) writeStruct(b *buffer, n *a.Struct) error { // For API/ABI compatibility, the very first field in the struct's - // private_impl must be the status code. This lets the constructor callee + // private_impl must be the status code. This lets the initializer callee // set "self->private_impl.status = etc_error_bad_puffs_version;" // regardless of the sizeof(*self) struct reserved by the caller and even // if the caller and callee were built with different versions. @@ -582,38 +582,38 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error { return nil } -func (g *gen) writeCtorSignature(b *buffer, n *a.Struct, public bool) error { +func (g *gen) writeInitializerSignature(b *buffer, n *a.Struct, public bool) error { structName := n.Name().String(g.tm) if public { - b.printf("// %s%s_constructor is a constructor function.\n", g.pkgPrefix, structName) + b.printf("// %s%s_initialize is an initializer function.\n", g.pkgPrefix, structName) b.printf("//\n") b.printf("// It should be called before any other %s%s_* function.\n", g.pkgPrefix, structName) b.printf("//\n") b.printf("// Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only.\n") } - b.printf("void %s%s_constructor(%s%s *self", g.pkgPrefix, structName, g.pkgPrefix, structName) + b.printf("void %s%s_initialize(%s%s *self", g.pkgPrefix, structName, g.pkgPrefix, structName) b.printf(", uint32_t puffs_version, uint32_t for_internal_use_only") b.printf(")") return nil } -func (g *gen) writeCtorPrototype(b *buffer, n *a.Struct) error { +func (g *gen) writeInitializerPrototype(b *buffer, n *a.Struct) error { if !n.Suspendible() { return nil } - if err := g.writeCtorSignature(b, n, n.Public()); err != nil { + if err := g.writeInitializerSignature(b, n, n.Public()); err != nil { return err } b.writes(";\n\n") return nil } -func (g *gen) writeCtorImpl(b *buffer, n *a.Struct) error { +func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error { if !n.Suspendible() { return nil } - if err := g.writeCtorSignature(b, n, false); err != nil { + if err := g.writeInitializerSignature(b, n, false); err != nil { return err } b.printf("{\n") @@ -647,7 +647,7 @@ func (g *gen) writeCtorImpl(b *buffer, n *a.Struct) error { if g.structMap[x.Name()] == nil { continue } - b.printf("%s%s_constructor(&self->private_impl.%s%s,"+ + b.printf("%s%s_initialize(&self->private_impl.%s%s,"+ "PUFFS_VERSION, PUFFS_ALREADY_ZEROED);\n", g.pkgPrefix, x.Name().String(g.tm), fPrefix, f.Name().String(g.tm)) } diff --git a/cmd/puffs-c/internal/cgen/func.go b/cmd/puffs-c/internal/cgen/func.go index 9ba4ef4c..1608d1c0 100644 --- a/cmd/puffs-c/internal/cgen/func.go +++ b/cmd/puffs-c/internal/cgen/func.go @@ -151,7 +151,7 @@ func (g *gen) writeFuncImplHeader(b *buffer) error { b.writes("}") b.printf("if (self->private_impl.magic != PUFFS_MAGIC) {"+ - "self->private_impl.status = %sERROR_CONSTRUCTOR_NOT_CALLED; }", g.PKGPREFIX) + "self->private_impl.status = %sERROR_INITIALIZER_NOT_CALLED; }", g.PKGPREFIX) b.writes("if (self->private_impl.status < 0) {") if g.currFunk.suspendible { diff --git a/example/library/library.c b/example/library/library.c index 637372b6..4f1618e1 100644 --- a/example/library/library.c +++ b/example/library/library.c @@ -54,7 +54,7 @@ static const char* decode(puffs_flate_decoder* dec) { int main(int argc, char** argv) { puffs_flate_decoder dec; - puffs_flate_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_flate_decoder_initialize(&dec, PUFFS_VERSION, 0); const char* status_msg = decode(&dec); int status = 0; diff --git a/example/peterface/peterface.c b/example/peterface/peterface.c index 17eaa3cd..b64f7598 100644 --- a/example/peterface/peterface.c +++ b/example/peterface/peterface.c @@ -70,7 +70,7 @@ int main(int argc, char** argv) { #endif puffs_gif_decoder dec; - puffs_gif_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_decoder_initialize(&dec, PUFFS_VERSION, 0); const char* status_msg = decode(&dec); int status = 0; diff --git a/gen/c/std/flate.c b/gen/c/std/flate.c index 1104a379..c2b0f5a1 100644 --- a/gen/c/std/flate.c +++ b/gen/c/std/flate.c @@ -108,7 +108,7 @@ typedef int32_t puffs_flate_status; #define PUFFS_FLATE_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001 #define PUFFS_FLATE_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_FLATE_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 +#define PUFFS_FLATE_ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_FLATE_ERROR_CLOSED_FOR_WRITES -2147483643 // 0x80000005 #define PUFFS_FLATE_ERROR_UNEXPECTED_EOF -2147483642 // 0x80000006 #define PUFFS_FLATE_SUSPENSION_SHORT_READ 7 // 0x00000007 @@ -250,25 +250,25 @@ typedef struct { } private_impl; } puffs_flate_zlib_decoder; -// ---------------- Public Constructor and Destructor Prototypes +// ---------------- Public Initializer Prototypes -// puffs_flate_decoder_constructor is a constructor function. +// puffs_flate_decoder_initialize is an initializer function. // // It should be called before any other puffs_flate_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_flate_decoder_constructor(puffs_flate_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_flate_decoder_initialize(puffs_flate_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); -// puffs_flate_zlib_decoder_constructor is a constructor function. +// puffs_flate_zlib_decoder_initialize is an initializer function. // // It should be called before any other puffs_flate_zlib_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_flate_zlib_decoder_constructor(puffs_flate_zlib_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_flate_zlib_decoder_initialize(puffs_flate_zlib_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes @@ -464,7 +464,7 @@ const char* puffs_flate_status_strings0[11] = { "flate: bad puffs version", "flate: bad receiver", "flate: bad argument", - "flate: constructor not called", + "flate: initializer not called", "flate: closed for writes", "flate: unexpected EOF", "flate: short read", @@ -552,7 +552,7 @@ static const uint32_t puffs_flate_dcode_magic_numbers[32] = { 541065680, 543162832, 134217728, 134217728, }; -// ---------------- Private Constructor and Destructor Prototypes +// ---------------- Private Initializer Prototypes // ---------------- Private Function Prototypes @@ -582,25 +582,25 @@ puffs_flate_status puffs_flate_decoder_init_huff(puffs_flate_decoder* self, uint32_t a_n_codes1, uint32_t a_base_symbol); -// ---------------- Constructor and Destructor Implementations +// ---------------- Initializer Implementations -// PUFFS_MAGIC is a magic number to check that constructors are called. It's +// PUFFS_MAGIC is a magic number to check that initializers are called. It's // not foolproof, given C doesn't automatically zero memory before use, but it // should catch 99.99% of cases. // // Its (non-zero) value is arbitrary, based on md5sum("puffs"). #define PUFFS_MAGIC (0xCB3699CCU) -// PUFFS_ALREADY_ZEROED is passed from a container struct's constructor to a -// containee struct's constructor when the container has already zeroed the +// PUFFS_ALREADY_ZEROED is passed from a container struct's initializer to a +// containee struct's initializer when the container has already zeroed the // containee's memory. // // Its (non-zero) value is arbitrary, based on md5sum("zeroed"). #define PUFFS_ALREADY_ZEROED (0x68602EF1U) -void puffs_flate_decoder_constructor(puffs_flate_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only) { +void puffs_flate_decoder_initialize(puffs_flate_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only) { if (!self) { return; } @@ -614,9 +614,9 @@ void puffs_flate_decoder_constructor(puffs_flate_decoder* self, self->private_impl.magic = PUFFS_MAGIC; } -void puffs_flate_zlib_decoder_constructor(puffs_flate_zlib_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only) { +void puffs_flate_zlib_decoder_initialize(puffs_flate_zlib_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only) { if (!self) { return; } @@ -628,8 +628,8 @@ void puffs_flate_zlib_decoder_constructor(puffs_flate_zlib_decoder* self, memset(self, 0, sizeof(*self)); } self->private_impl.magic = PUFFS_MAGIC; - puffs_flate_decoder_constructor(&self->private_impl.f_dec, PUFFS_VERSION, - PUFFS_ALREADY_ZEROED); + puffs_flate_decoder_initialize(&self->private_impl.f_dec, PUFFS_VERSION, + PUFFS_ALREADY_ZEROED); } // ---------------- Function Implementations @@ -641,7 +641,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self, return PUFFS_FLATE_ERROR_BAD_RECEIVER; } if (self->private_impl.magic != PUFFS_MAGIC) { - self->private_impl.status = PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED; + self->private_impl.status = PUFFS_FLATE_ERROR_INITIALIZER_NOT_CALLED; } if (self->private_impl.status < 0) { return self->private_impl.status; @@ -2032,7 +2032,7 @@ puffs_flate_status puffs_flate_zlib_decoder_decode( return PUFFS_FLATE_ERROR_BAD_RECEIVER; } if (self->private_impl.magic != PUFFS_MAGIC) { - self->private_impl.status = PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED; + self->private_impl.status = PUFFS_FLATE_ERROR_INITIALIZER_NOT_CALLED; } if (self->private_impl.status < 0) { return self->private_impl.status; diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index caed8927..694d0878 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -108,7 +108,7 @@ typedef int32_t puffs_gif_status; #define PUFFS_GIF_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001 #define PUFFS_GIF_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_GIF_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 +#define PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_GIF_ERROR_CLOSED_FOR_WRITES -2147483643 // 0x80000005 #define PUFFS_GIF_ERROR_UNEXPECTED_EOF -2147483642 // 0x80000006 #define PUFFS_GIF_SUSPENSION_SHORT_READ 7 // 0x00000007 @@ -218,25 +218,25 @@ typedef struct { } private_impl; } puffs_gif_decoder; -// ---------------- Public Constructor and Destructor Prototypes +// ---------------- Public Initializer Prototypes -// puffs_gif_lzw_decoder_constructor is a constructor function. +// puffs_gif_lzw_decoder_initialize is an initializer function. // // It should be called before any other puffs_gif_lzw_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_gif_lzw_decoder_initialize(puffs_gif_lzw_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); -// puffs_gif_decoder_constructor is a constructor function. +// puffs_gif_decoder_initialize is an initializer function. // // It should be called before any other puffs_gif_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_gif_decoder_constructor(puffs_gif_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_gif_decoder_initialize(puffs_gif_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes @@ -434,7 +434,7 @@ const char* puffs_gif_status_strings0[11] = { "gif: bad puffs version", "gif: bad receiver", "gif: bad argument", - "gif: constructor not called", + "gif: initializer not called", "gif: closed for writes", "gif: unexpected EOF", "gif: short read", @@ -472,7 +472,7 @@ const char* puffs_gif_status_string(puffs_gif_status s) { // ---------------- Private Consts -// ---------------- Private Constructor and Destructor Prototypes +// ---------------- Private Initializer Prototypes // ---------------- Private Function Prototypes @@ -489,25 +489,25 @@ puffs_gif_status puffs_gif_decoder_decode_id(puffs_gif_decoder* self, puffs_base_writer1 a_dst, puffs_base_reader1 a_src); -// ---------------- Constructor and Destructor Implementations +// ---------------- Initializer Implementations -// PUFFS_MAGIC is a magic number to check that constructors are called. It's +// PUFFS_MAGIC is a magic number to check that initializers are called. It's // not foolproof, given C doesn't automatically zero memory before use, but it // should catch 99.99% of cases. // // Its (non-zero) value is arbitrary, based on md5sum("puffs"). #define PUFFS_MAGIC (0xCB3699CCU) -// PUFFS_ALREADY_ZEROED is passed from a container struct's constructor to a -// containee struct's constructor when the container has already zeroed the +// PUFFS_ALREADY_ZEROED is passed from a container struct's initializer to a +// containee struct's initializer when the container has already zeroed the // containee's memory. // // Its (non-zero) value is arbitrary, based on md5sum("zeroed"). #define PUFFS_ALREADY_ZEROED (0x68602EF1U) -void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only) { +void puffs_gif_lzw_decoder_initialize(puffs_gif_lzw_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only) { if (!self) { return; } @@ -522,9 +522,9 @@ void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self, self->private_impl.f_literal_width = 8; } -void puffs_gif_decoder_constructor(puffs_gif_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only) { +void puffs_gif_decoder_initialize(puffs_gif_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only) { if (!self) { return; } @@ -536,8 +536,8 @@ void puffs_gif_decoder_constructor(puffs_gif_decoder* self, memset(self, 0, sizeof(*self)); } self->private_impl.magic = PUFFS_MAGIC; - puffs_gif_lzw_decoder_constructor(&self->private_impl.f_lzw, PUFFS_VERSION, - PUFFS_ALREADY_ZEROED); + puffs_gif_lzw_decoder_initialize(&self->private_impl.f_lzw, PUFFS_VERSION, + PUFFS_ALREADY_ZEROED); } // ---------------- Function Implementations @@ -549,7 +549,7 @@ puffs_gif_status puffs_gif_decoder_decode(puffs_gif_decoder* self, return PUFFS_GIF_ERROR_BAD_RECEIVER; } if (self->private_impl.magic != PUFFS_MAGIC) { - self->private_impl.status = PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED; + self->private_impl.status = PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED; } if (self->private_impl.status < 0) { return self->private_impl.status; @@ -1201,7 +1201,7 @@ void puffs_gif_lzw_decoder_set_literal_width(puffs_gif_lzw_decoder* self, return; } if (self->private_impl.magic != PUFFS_MAGIC) { - self->private_impl.status = PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED; + self->private_impl.status = PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED; } if (self->private_impl.status < 0) { return; @@ -1221,7 +1221,7 @@ puffs_gif_status puffs_gif_lzw_decoder_decode(puffs_gif_lzw_decoder* self, return PUFFS_GIF_ERROR_BAD_RECEIVER; } if (self->private_impl.magic != PUFFS_MAGIC) { - self->private_impl.status = PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED; + self->private_impl.status = PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED; } if (self->private_impl.status < 0) { return self->private_impl.status; diff --git a/gen/h/std/flate.h b/gen/h/std/flate.h index 1c446397..944b33ba 100644 --- a/gen/h/std/flate.h +++ b/gen/h/std/flate.h @@ -108,7 +108,7 @@ typedef int32_t puffs_flate_status; #define PUFFS_FLATE_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001 #define PUFFS_FLATE_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_FLATE_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 +#define PUFFS_FLATE_ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_FLATE_ERROR_CLOSED_FOR_WRITES -2147483643 // 0x80000005 #define PUFFS_FLATE_ERROR_UNEXPECTED_EOF -2147483642 // 0x80000006 #define PUFFS_FLATE_SUSPENSION_SHORT_READ 7 // 0x00000007 @@ -250,25 +250,25 @@ typedef struct { } private_impl; } puffs_flate_zlib_decoder; -// ---------------- Public Constructor and Destructor Prototypes +// ---------------- Public Initializer Prototypes -// puffs_flate_decoder_constructor is a constructor function. +// puffs_flate_decoder_initialize is an initializer function. // // It should be called before any other puffs_flate_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_flate_decoder_constructor(puffs_flate_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_flate_decoder_initialize(puffs_flate_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); -// puffs_flate_zlib_decoder_constructor is a constructor function. +// puffs_flate_zlib_decoder_initialize is an initializer function. // // It should be called before any other puffs_flate_zlib_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_flate_zlib_decoder_constructor(puffs_flate_zlib_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_flate_zlib_decoder_initialize(puffs_flate_zlib_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 5b54bc39..08129cb9 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -108,7 +108,7 @@ typedef int32_t puffs_gif_status; #define PUFFS_GIF_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001 #define PUFFS_GIF_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_GIF_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 +#define PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_GIF_ERROR_CLOSED_FOR_WRITES -2147483643 // 0x80000005 #define PUFFS_GIF_ERROR_UNEXPECTED_EOF -2147483642 // 0x80000006 #define PUFFS_GIF_SUSPENSION_SHORT_READ 7 // 0x00000007 @@ -218,25 +218,25 @@ typedef struct { } private_impl; } puffs_gif_decoder; -// ---------------- Public Constructor and Destructor Prototypes +// ---------------- Public Initializer Prototypes -// puffs_gif_lzw_decoder_constructor is a constructor function. +// puffs_gif_lzw_decoder_initialize is an initializer function. // // It should be called before any other puffs_gif_lzw_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_gif_lzw_decoder_initialize(puffs_gif_lzw_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); -// puffs_gif_decoder_constructor is a constructor function. +// puffs_gif_decoder_initialize is an initializer function. // // It should be called before any other puffs_gif_decoder_* function. // // Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only. -void puffs_gif_decoder_constructor(puffs_gif_decoder* self, - uint32_t puffs_version, - uint32_t for_internal_use_only); +void puffs_gif_decoder_initialize(puffs_gif_decoder* self, + uint32_t puffs_version, + uint32_t for_internal_use_only); // ---------------- Public Function Prototypes diff --git a/test/c/std/flate.c b/test/c/std/flate.c index 6dfb1134..f289fb44 100644 --- a/test/c/std/flate.c +++ b/test/c/std/flate.c @@ -104,7 +104,7 @@ golden_test zlib_pi_gt = { const char* puffs_flate_decode(puffs_base_buf1* dst, puffs_base_buf1* src) { puffs_flate_decoder dec; - puffs_flate_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_flate_decoder_initialize(&dec, PUFFS_VERSION, 0); puffs_base_writer1 dst_writer = {.buf = dst}; puffs_base_reader1 src_reader = {.buf = src}; puffs_flate_status s = @@ -117,7 +117,7 @@ const char* puffs_flate_decode(puffs_base_buf1* dst, puffs_base_buf1* src) { const char* puffs_zlib_decode(puffs_base_buf1* dst, puffs_base_buf1* src) { puffs_flate_zlib_decoder dec; - puffs_flate_zlib_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_flate_zlib_decoder_initialize(&dec, PUFFS_VERSION, 0); puffs_base_writer1 dst_writer = {.buf = dst}; puffs_base_reader1 src_reader = {.buf = src}; puffs_flate_status s = @@ -181,7 +181,7 @@ void test_puffs_flate_decode_split_src() { } got.wi = 0; - puffs_flate_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_flate_decoder_initialize(&dec, PUFFS_VERSION, 0); src.closed = false; src.ri = gt->src_offset0; @@ -230,7 +230,7 @@ bool do_test_puffs_flate_history(int i, got->ri = 0; got->wi = 0; - puffs_flate_decoder_constructor(dec, PUFFS_VERSION, 0); + puffs_flate_decoder_initialize(dec, PUFFS_VERSION, 0); puffs_base_writer1 dst_writer = {.buf = got}; puffs_base_reader1 src_reader = {.buf = src}; @@ -413,9 +413,9 @@ void test_puffs_flate_table_redirect() { // 2nd is the key in the second level table (variable bits). puffs_flate_decoder dec; - puffs_flate_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_flate_decoder_initialize(&dec, PUFFS_VERSION, 0); - // The constructor should zero out dec's fields, but to be paranoid, we zero + // The initializer should zero out dec's fields, but to be paranoid, we zero // it out explicitly. memset(&dec.private_impl.f_huffs[0], 0, sizeof(dec.private_impl.f_huffs[0])); diff --git a/test/c/std/gif.c b/test/c/std/gif.c index abd5e4d6..32990966 100644 --- a/test/c/std/gif.c +++ b/test/c/std/gif.c @@ -36,7 +36,7 @@ const char* proc_filename = "std/gif.c"; void test_basic_bad_argument_out_of_range() { proc_funcname = __func__; puffs_gif_lzw_decoder dec; - puffs_gif_lzw_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_lzw_decoder_initialize(&dec, PUFFS_VERSION, 0); // Setting to 8 is in the [2..8] range. puffs_gif_lzw_decoder_set_literal_width(&dec, 8); @@ -70,22 +70,22 @@ void test_basic_bad_receiver() { } } -void test_basic_constructor_not_called() { +void test_basic_initializer_not_called() { proc_funcname = __func__; puffs_gif_lzw_decoder dec = {{0}}; puffs_base_writer1 dst = {0}; puffs_base_reader1 src = {0}; puffs_gif_status status = puffs_gif_lzw_decoder_decode(&dec, dst, src); - if (status != PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED) { + if (status != PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED) { FAIL("status: got %d, want %d", status, - PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED); + PUFFS_GIF_ERROR_INITIALIZER_NOT_CALLED); } } void test_basic_puffs_version_bad() { proc_funcname = __func__; puffs_gif_lzw_decoder dec; - puffs_gif_lzw_decoder_constructor(&dec, 0, 0); // 0 is not PUFFS_VERSION. + puffs_gif_lzw_decoder_initialize(&dec, 0, 0); // 0 is not PUFFS_VERSION. if (dec.private_impl.status != PUFFS_GIF_ERROR_BAD_PUFFS_VERSION) { FAIL("status: got %d, want %d", dec.private_impl.status, PUFFS_GIF_ERROR_BAD_PUFFS_VERSION); @@ -96,7 +96,7 @@ void test_basic_puffs_version_bad() { void test_basic_puffs_version_good() { proc_funcname = __func__; puffs_gif_lzw_decoder dec; - puffs_gif_lzw_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_lzw_decoder_initialize(&dec, PUFFS_VERSION, 0); if (dec.private_impl.magic != PUFFS_MAGIC) { FAIL("magic: got %u, want %u", dec.private_impl.magic, PUFFS_MAGIC); return; @@ -163,10 +163,10 @@ void test_basic_status_strings() { } } -void test_basic_sub_struct_constructor() { +void test_basic_sub_struct_initializer() { proc_funcname = __func__; puffs_gif_decoder dec; - puffs_gif_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_decoder_initialize(&dec, PUFFS_VERSION, 0); if (dec.private_impl.magic != PUFFS_MAGIC) { FAIL("outer magic: got %u, want %u", dec.private_impl.magic, PUFFS_MAGIC); return; @@ -213,7 +213,7 @@ void test_puffs_gif_lzw_decode(const char* src_filename, } puffs_gif_lzw_decoder dec; - puffs_gif_lzw_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_lzw_decoder_initialize(&dec, PUFFS_VERSION, 0); puffs_gif_lzw_decoder_set_literal_width(&dec, literal_width); puffs_base_writer1 got_writer = {.buf = &got}; puffs_base_reader1 src_reader = {.buf = &src}; @@ -325,7 +325,7 @@ void bench_puffs_gif_lzw_decode(const char* filename, uint64_t reps) { dst.wi = 0; src.ri = 1; // Skip the literal width. puffs_gif_lzw_decoder dec; - puffs_gif_lzw_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_lzw_decoder_initialize(&dec, PUFFS_VERSION, 0); puffs_gif_status s = puffs_gif_lzw_decoder_decode(&dec, dst_writer, src_reader); if (s) { @@ -351,7 +351,7 @@ void bench_puffs_gif_lzw_decode_100k() { const char* puffs_gif_decode(puffs_base_buf1* dst, puffs_base_buf1* src) { puffs_gif_decoder dec; - puffs_gif_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_decoder_initialize(&dec, PUFFS_VERSION, 0); puffs_base_writer1 dst_writer = {.buf = dst}; puffs_base_reader1 src_reader = {.buf = src}; puffs_gif_status s = puffs_gif_decoder_decode(&dec, dst_writer, src_reader); @@ -374,7 +374,7 @@ void test_puffs_gif_decode(const char* filename, } puffs_gif_decoder dec; - puffs_gif_decoder_constructor(&dec, PUFFS_VERSION, 0); + puffs_gif_decoder_initialize(&dec, PUFFS_VERSION, 0); puffs_base_writer1 got_writer = {.buf = &got}; puffs_base_reader1 src_reader = {.buf = &src}; int num_iters = 0; @@ -640,12 +640,12 @@ proc tests[] = { // Basic Tests test_basic_bad_argument_out_of_range, // test_basic_bad_receiver, // - test_basic_constructor_not_called, // + test_basic_initializer_not_called, // test_basic_puffs_version_bad, // test_basic_puffs_version_good, // test_basic_status_is_error, // test_basic_status_strings, // - test_basic_sub_struct_constructor, // + test_basic_sub_struct_initializer, // // LZW Tests test_puffs_gif_lzw_decode_few_big_reads, //