mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Add wuffs_base__status__is_complete
This commit is contained in:
1 parent
73ed2eece1
commit
8c6cc80b57
3 files changed
+34
-1
No files matched your search
@@ -106,10 +106,26 @@ typedef struct {
|
|||||||
//
|
//
|
||||||
// Status strings are statically allocated and should never be free'd. They can
|
// Status strings are statically allocated and should never be free'd. They can
|
||||||
// be compared by the == operator and not just by strcmp.
|
// be compared by the == operator and not just by strcmp.
|
||||||
|
//
|
||||||
|
// Statuses come in four categories:
|
||||||
|
// - OK: the request was completed, successfully.
|
||||||
|
// - Warnings: the request was completed, unsuccessfully.
|
||||||
|
// - Suspensions: the request was not completed, but can be re-tried.
|
||||||
|
// - Errors: the request was not completed, permanently.
|
||||||
|
//
|
||||||
|
// When a function returns an incomplete status, a suspension means that that
|
||||||
|
// function should be called again within a new context, such as after flushing
|
||||||
|
// or re-filling an I/O buffer. An error means that an irrecoverable failure
|
||||||
|
// state was reached.
|
||||||
typedef const char* wuffs_base__status;
|
typedef const char* wuffs_base__status;
|
||||||
|
|
||||||
// !! INSERT wuffs_base__status names.
|
// !! INSERT wuffs_base__status names.
|
||||||
|
|
||||||
|
static inline bool //
|
||||||
|
wuffs_base__status__is_complete(wuffs_base__status z) {
|
||||||
|
return (z == NULL) || ((*z != '$') && (*z != '?'));
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_error(wuffs_base__status z) {
|
wuffs_base__status__is_error(wuffs_base__status z) {
|
||||||
return z && (*z == '?');
|
return z && (*z == '?');
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ const baseBasePublicH = "" +
|
|||||||
"nt.com/nothings/stb/master/docs/stb_howto.txt\n#ifdef WUFFS_CONFIG__STATIC_FUNCTIONS\n#define WUFFS_BASE__MAYBE_STATIC static\n#else\n#define WUFFS_BASE__MAYBE_STATIC\n#endif\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n#define WUFFS_BASE__WARN_UNUSED_RESULT\n#endif\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n " +
|
"nt.com/nothings/stb/master/docs/stb_howto.txt\n#ifdef WUFFS_CONFIG__STATIC_FUNCTIONS\n#define WUFFS_BASE__MAYBE_STATIC static\n#else\n#define WUFFS_BASE__MAYBE_STATIC\n#endif\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n#define WUFFS_BASE__WARN_UNUSED_RESULT\n#endif\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n " +
|
||||||
"//\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" +
|
"//\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" +
|
||||||
"" +
|
"" +
|
||||||
"// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '?');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '?');\n}\n\n" +
|
"// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\n//\n// Statuses come in four categories:\n// - OK: the request was completed, successfully.\n// - Warnings: the request was completed, unsuccessfully.\n// - Suspensions: the request was not completed, but can be re-tried.\n// - Errors: the request was not completed, permanently.\n//\n// When a function returns an incomplete status, a suspension means that that\n// function should be called again within a new context, such as after flushing\n// or re-filling an I/O buffer. An error means that an irrecoverable failure\n// state was reached.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_bas" +
|
||||||
|
"e__status names.\n\nstatic inline bool //\nwuffs_base__status__is_complete(wuffs_base__status z) {\n return (z == NULL) || ((*z != '$') && (*z != '?'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '?');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '?');\n}\n\n" +
|
||||||
"" +
|
"" +
|
||||||
"// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" +
|
"// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" +
|
||||||
"" +
|
"" +
|
||||||
|
|||||||
@@ -130,6 +130,17 @@ typedef struct {
|
|||||||
//
|
//
|
||||||
// Status strings are statically allocated and should never be free'd. They can
|
// Status strings are statically allocated and should never be free'd. They can
|
||||||
// be compared by the == operator and not just by strcmp.
|
// be compared by the == operator and not just by strcmp.
|
||||||
|
//
|
||||||
|
// Statuses come in four categories:
|
||||||
|
// - OK: the request was completed, successfully.
|
||||||
|
// - Warnings: the request was completed, unsuccessfully.
|
||||||
|
// - Suspensions: the request was not completed, but can be re-tried.
|
||||||
|
// - Errors: the request was not completed, permanently.
|
||||||
|
//
|
||||||
|
// When a function returns an incomplete status, a suspension means that that
|
||||||
|
// function should be called again within a new context, such as after flushing
|
||||||
|
// or re-filling an I/O buffer. An error means that an irrecoverable failure
|
||||||
|
// state was reached.
|
||||||
typedef const char* wuffs_base__status;
|
typedef const char* wuffs_base__status;
|
||||||
|
|
||||||
extern const char* wuffs_base__warning__end_of_data;
|
extern const char* wuffs_base__warning__end_of_data;
|
||||||
@@ -148,6 +159,11 @@ extern const char* wuffs_base__error__check_wuffs_version_not_applicable;
|
|||||||
extern const char* wuffs_base__error__check_wuffs_version_missing;
|
extern const char* wuffs_base__error__check_wuffs_version_missing;
|
||||||
extern const char* wuffs_base__error__disabled_by_previous_error;
|
extern const char* wuffs_base__error__disabled_by_previous_error;
|
||||||
|
|
||||||
|
static inline bool //
|
||||||
|
wuffs_base__status__is_complete(wuffs_base__status z) {
|
||||||
|
return (z == NULL) || ((*z != '$') && (*z != '?'));
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_error(wuffs_base__status z) {
|
wuffs_base__status__is_error(wuffs_base__status z) {
|
||||||
return z && (*z == '?');
|
return z && (*z == '?');
|
||||||
|
|||||||
Reference in new issue
Block a user