Add "PUFFS" to "ERROR_BAD_PUFFS_VERSION".

This commit is contained in:
Nigel Tao committed 2017-07-13 11:34:36 +10:00
1 parent a3302ff1e5
commit 4302619eba
6 files changed
+20 -20

No files matched your search

+5 -5
View File
@@ -83,7 +83,7 @@ const (
var builtInStatuses = [...]string{ var builtInStatuses = [...]string{
"status ok", "status ok",
"error bad version", "error bad puffs version",
"error bad receiver", "error bad receiver",
"error bad argument", "error bad argument",
"error constructor not called", "error constructor not called",
@@ -426,9 +426,9 @@ func (g *gen) gatherStatuses(n *a.Status) error {
func (g *gen) writeStruct(n *a.Struct) error { func (g *gen) writeStruct(n *a.Struct) error {
// For API/ABI compatibility, the very first field in the struct's // 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 constructor callee
// set "self->private_impl.status = etc_error_bad_version;" regardless of // set "self->private_impl.status = etc_error_bad_puffs_version;"
// the sizeof(*self) struct reserved by the caller and even if the caller // regardless of the sizeof(*self) struct reserved by the caller and even
// and callee were built with different versions. // if the caller and callee were built with different versions.
structName := n.Name().String(g.tm) structName := n.Name().String(g.tm)
g.writes("typedef struct {\n") g.writes("typedef struct {\n")
g.writes("// Do not access the private_impl's fields directly. There is no API/ABI\n") g.writes("// Do not access the private_impl's fields directly. There is no API/ABI\n")
@@ -529,7 +529,7 @@ func (g *gen) writeCtorImpl(n *a.Struct) error {
if ctor { if ctor {
g.printf("if (puffs_version != PUFFS_VERSION) {\n") g.printf("if (puffs_version != PUFFS_VERSION) {\n")
g.printf("self->private_impl.status = PUFFS_%s_ERROR_BAD_VERSION;\n", g.PKGNAME) g.printf("self->private_impl.status = PUFFS_%s_ERROR_BAD_PUFFS_VERSION;\n", g.PKGNAME)
g.printf("return;\n") g.printf("return;\n")
g.printf("}\n") g.printf("}\n")
+3 -3
View File
@@ -91,7 +91,7 @@ typedef int32_t puffs_flate_status;
#define puffs_flate_packageid 967230 // 0x000ec23e #define puffs_flate_packageid 967230 // 0x000ec23e
#define PUFFS_FLATE_STATUS_OK 0 // 0x00000000 #define PUFFS_FLATE_STATUS_OK 0 // 0x00000000
#define PUFFS_FLATE_ERROR_BAD_VERSION -2147483647 // 0x80000001 #define PUFFS_FLATE_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001
#define PUFFS_FLATE_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_FLATE_ERROR_BAD_RECEIVER -2147483646 // 0x80000002
#define PUFFS_FLATE_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 #define PUFFS_FLATE_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003
#define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004
@@ -212,7 +212,7 @@ bool puffs_flate_status_is_error(puffs_flate_status s) {
const char* puffs_flate_status_strings0[9] = { const char* puffs_flate_status_strings0[9] = {
"flate: ok", "flate: ok",
"flate: bad version", "flate: bad puffs version",
"flate: bad receiver", "flate: bad receiver",
"flate: bad argument", "flate: bad argument",
"flate: constructor not called", "flate: constructor not called",
@@ -274,7 +274,7 @@ void puffs_flate_decoder_constructor(puffs_flate_decoder* self,
return; return;
} }
if (puffs_version != PUFFS_VERSION) { if (puffs_version != PUFFS_VERSION) {
self->private_impl.status = PUFFS_FLATE_ERROR_BAD_VERSION; self->private_impl.status = PUFFS_FLATE_ERROR_BAD_PUFFS_VERSION;
return; return;
} }
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) { if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
+4 -4
View File
@@ -91,7 +91,7 @@ typedef int32_t puffs_gif_status;
#define puffs_gif_packageid 1017222 // 0x000f8586 #define puffs_gif_packageid 1017222 // 0x000f8586
#define PUFFS_GIF_STATUS_OK 0 // 0x00000000 #define PUFFS_GIF_STATUS_OK 0 // 0x00000000
#define PUFFS_GIF_ERROR_BAD_VERSION -2147483647 // 0x80000001 #define PUFFS_GIF_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001
#define PUFFS_GIF_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_GIF_ERROR_BAD_RECEIVER -2147483646 // 0x80000002
#define PUFFS_GIF_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 #define PUFFS_GIF_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003
#define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004
@@ -282,7 +282,7 @@ bool puffs_gif_status_is_error(puffs_gif_status s) {
const char* puffs_gif_status_strings0[9] = { const char* puffs_gif_status_strings0[9] = {
"gif: ok", "gif: ok",
"gif: bad version", "gif: bad puffs version",
"gif: bad receiver", "gif: bad receiver",
"gif: bad argument", "gif: bad argument",
"gif: constructor not called", "gif: constructor not called",
@@ -359,7 +359,7 @@ void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self,
return; return;
} }
if (puffs_version != PUFFS_VERSION) { if (puffs_version != PUFFS_VERSION) {
self->private_impl.status = PUFFS_GIF_ERROR_BAD_VERSION; self->private_impl.status = PUFFS_GIF_ERROR_BAD_PUFFS_VERSION;
return; return;
} }
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) { if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
@@ -382,7 +382,7 @@ void puffs_gif_decoder_constructor(puffs_gif_decoder* self,
return; return;
} }
if (puffs_version != PUFFS_VERSION) { if (puffs_version != PUFFS_VERSION) {
self->private_impl.status = PUFFS_GIF_ERROR_BAD_VERSION; self->private_impl.status = PUFFS_GIF_ERROR_BAD_PUFFS_VERSION;
return; return;
} }
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) { if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
+1 -1
View File
@@ -91,7 +91,7 @@ typedef int32_t puffs_flate_status;
#define puffs_flate_packageid 967230 // 0x000ec23e #define puffs_flate_packageid 967230 // 0x000ec23e
#define PUFFS_FLATE_STATUS_OK 0 // 0x00000000 #define PUFFS_FLATE_STATUS_OK 0 // 0x00000000
#define PUFFS_FLATE_ERROR_BAD_VERSION -2147483647 // 0x80000001 #define PUFFS_FLATE_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001
#define PUFFS_FLATE_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_FLATE_ERROR_BAD_RECEIVER -2147483646 // 0x80000002
#define PUFFS_FLATE_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 #define PUFFS_FLATE_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003
#define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004
+1 -1
View File
@@ -91,7 +91,7 @@ typedef int32_t puffs_gif_status;
#define puffs_gif_packageid 1017222 // 0x000f8586 #define puffs_gif_packageid 1017222 // 0x000f8586
#define PUFFS_GIF_STATUS_OK 0 // 0x00000000 #define PUFFS_GIF_STATUS_OK 0 // 0x00000000
#define PUFFS_GIF_ERROR_BAD_VERSION -2147483647 // 0x80000001 #define PUFFS_GIF_ERROR_BAD_PUFFS_VERSION -2147483647 // 0x80000001
#define PUFFS_GIF_ERROR_BAD_RECEIVER -2147483646 // 0x80000002 #define PUFFS_GIF_ERROR_BAD_RECEIVER -2147483646 // 0x80000002
#define PUFFS_GIF_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 #define PUFFS_GIF_ERROR_BAD_ARGUMENT -2147483645 // 0x80000003
#define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004 #define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004
+6 -6
View File
@@ -86,9 +86,9 @@ void test_basic_puffs_version_bad() {
proc_funcname = __func__; proc_funcname = __func__;
puffs_gif_lzw_decoder dec; puffs_gif_lzw_decoder dec;
puffs_gif_lzw_decoder_constructor(&dec, 0, 0); // 0 is not PUFFS_VERSION. puffs_gif_lzw_decoder_constructor(&dec, 0, 0); // 0 is not PUFFS_VERSION.
if (dec.private_impl.status != PUFFS_GIF_ERROR_BAD_VERSION) { if (dec.private_impl.status != PUFFS_GIF_ERROR_BAD_PUFFS_VERSION) {
FAIL("status: got %d, want %d", dec.private_impl.status, FAIL("status: got %d, want %d", dec.private_impl.status,
PUFFS_GIF_ERROR_BAD_VERSION); PUFFS_GIF_ERROR_BAD_PUFFS_VERSION);
goto cleanup0; goto cleanup0;
} }
cleanup0: cleanup0:
@@ -118,8 +118,8 @@ void test_basic_status_is_error() {
FAIL("is_error(OK) returned true"); FAIL("is_error(OK) returned true");
return; return;
} }
if (!puffs_gif_status_is_error(PUFFS_GIF_ERROR_BAD_VERSION)) { if (!puffs_gif_status_is_error(PUFFS_GIF_ERROR_BAD_PUFFS_VERSION)) {
FAIL("is_error(BAD_VERSION) returned false"); FAIL("is_error(BAD_PUFFS_VERSION) returned false");
return; return;
} }
if (puffs_gif_status_is_error(PUFFS_GIF_SUSPENSION_SHORT_WRITE)) { if (puffs_gif_status_is_error(PUFFS_GIF_SUSPENSION_SHORT_WRITE)) {
@@ -140,8 +140,8 @@ void test_basic_status_strings() {
FAIL("got \"%s\", want \"%s\"", s0, t0); FAIL("got \"%s\", want \"%s\"", s0, t0);
return; return;
} }
const char* s1 = puffs_gif_status_string(PUFFS_GIF_ERROR_BAD_VERSION); const char* s1 = puffs_gif_status_string(PUFFS_GIF_ERROR_BAD_PUFFS_VERSION);
const char* t1 = "gif: bad version"; const char* t1 = "gif: bad puffs version";
if (strcmp(s1, t1)) { if (strcmp(s1, t1)) {
FAIL("got \"%s\", want \"%s\"", s1, t1); FAIL("got \"%s\", want \"%s\"", s1, t1);
return; return;