mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add "PUFFS" to "ERROR_BAD_PUFFS_VERSION".
This commit is contained in:
1 parent
a3302ff1e5
commit
4302619eba
6 files changed
+20
-20
No files matched your search
@@ -83,7 +83,7 @@ const (
|
||||
|
||||
var builtInStatuses = [...]string{
|
||||
"status ok",
|
||||
"error bad version",
|
||||
"error bad puffs version",
|
||||
"error bad receiver",
|
||||
"error bad argument",
|
||||
"error constructor not called",
|
||||
@@ -426,9 +426,9 @@ func (g *gen) gatherStatuses(n *a.Status) error {
|
||||
func (g *gen) writeStruct(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
|
||||
// set "self->private_impl.status = etc_error_bad_version;" regardless of
|
||||
// the sizeof(*self) struct reserved by the caller and even if the caller
|
||||
// and callee were built with different versions.
|
||||
// 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.
|
||||
structName := n.Name().String(g.tm)
|
||||
g.writes("typedef struct {\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 {
|
||||
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("}\n")
|
||||
|
||||
|
||||
+3
-3
@@ -91,7 +91,7 @@ typedef int32_t puffs_flate_status;
|
||||
#define puffs_flate_packageid 967230 // 0x000ec23e
|
||||
|
||||
#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_ARGUMENT -2147483645 // 0x80000003
|
||||
#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] = {
|
||||
"flate: ok",
|
||||
"flate: bad version",
|
||||
"flate: bad puffs version",
|
||||
"flate: bad receiver",
|
||||
"flate: bad argument",
|
||||
"flate: constructor not called",
|
||||
@@ -274,7 +274,7 @@ void puffs_flate_decoder_constructor(puffs_flate_decoder* self,
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
|
||||
|
||||
+4
-4
@@ -91,7 +91,7 @@ typedef int32_t puffs_gif_status;
|
||||
#define puffs_gif_packageid 1017222 // 0x000f8586
|
||||
|
||||
#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_ARGUMENT -2147483645 // 0x80000003
|
||||
#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] = {
|
||||
"gif: ok",
|
||||
"gif: bad version",
|
||||
"gif: bad puffs version",
|
||||
"gif: bad receiver",
|
||||
"gif: bad argument",
|
||||
"gif: constructor not called",
|
||||
@@ -359,7 +359,7 @@ void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self,
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
|
||||
@@ -382,7 +382,7 @@ void puffs_gif_decoder_constructor(puffs_gif_decoder* self,
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ typedef int32_t puffs_flate_status;
|
||||
#define puffs_flate_packageid 967230 // 0x000ec23e
|
||||
|
||||
#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_ARGUMENT -2147483645 // 0x80000003
|
||||
#define PUFFS_FLATE_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ typedef int32_t puffs_gif_status;
|
||||
#define puffs_gif_packageid 1017222 // 0x000f8586
|
||||
|
||||
#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_ARGUMENT -2147483645 // 0x80000003
|
||||
#define PUFFS_GIF_ERROR_CONSTRUCTOR_NOT_CALLED -2147483644 // 0x80000004
|
||||
|
||||
+6
-6
@@ -86,9 +86,9 @@ 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.
|
||||
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,
|
||||
PUFFS_GIF_ERROR_BAD_VERSION);
|
||||
PUFFS_GIF_ERROR_BAD_PUFFS_VERSION);
|
||||
goto cleanup0;
|
||||
}
|
||||
cleanup0:
|
||||
@@ -118,8 +118,8 @@ void test_basic_status_is_error() {
|
||||
FAIL("is_error(OK) returned true");
|
||||
return;
|
||||
}
|
||||
if (!puffs_gif_status_is_error(PUFFS_GIF_ERROR_BAD_VERSION)) {
|
||||
FAIL("is_error(BAD_VERSION) returned false");
|
||||
if (!puffs_gif_status_is_error(PUFFS_GIF_ERROR_BAD_PUFFS_VERSION)) {
|
||||
FAIL("is_error(BAD_PUFFS_VERSION) returned false");
|
||||
return;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
const char* s1 = puffs_gif_status_string(PUFFS_GIF_ERROR_BAD_VERSION);
|
||||
const char* t1 = "gif: bad version";
|
||||
const char* s1 = puffs_gif_status_string(PUFFS_GIF_ERROR_BAD_PUFFS_VERSION);
|
||||
const char* t1 = "gif: bad puffs version";
|
||||
if (strcmp(s1, t1)) {
|
||||
FAIL("got \"%s\", want \"%s\"", s1, t1);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user