mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +01:00
Make wuffs_base__status a struct
This commit is contained in:
1 parent
c50f16e58b
commit
e6db7f6a40
24 files changed
+677
-499
No files matched your search
@@ -55,9 +55,9 @@ wuffs_base__ignore_status(wuffs_base__status z) {
|
||||
case n:;
|
||||
|
||||
#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \
|
||||
if (!status) { \
|
||||
if (!status.repr) { \
|
||||
goto ok; \
|
||||
} else if (*status != '$') { \
|
||||
} else if (*status.repr != '$') { \
|
||||
goto exit; \
|
||||
} \
|
||||
coro_susp_point = n; \
|
||||
@@ -417,6 +417,6 @@ wuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {
|
||||
return wuffs_base__make_slice_u8(NULL, 0);
|
||||
}
|
||||
|
||||
// ---------------- Slices and Tables (Utility)
|
||||
// ---------------- Slices and Tables (Utility)
|
||||
|
||||
#define wuffs_base__utility__empty_slice_u8 wuffs_base__empty_slice_u8
|
||||
@@ -135,51 +135,99 @@ typedef struct {
|
||||
// --------
|
||||
|
||||
// See https://github.com/google/wuffs/blob/master/doc/note/statuses.md
|
||||
typedef const char* wuffs_base__status;
|
||||
typedef struct {
|
||||
const char* repr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline bool is_complete() const;
|
||||
inline bool is_error() const;
|
||||
inline bool is_ok() const;
|
||||
inline bool is_suspension() const;
|
||||
inline bool is_warning() const;
|
||||
inline const char* message() const;
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_base__status;
|
||||
|
||||
// !! INSERT wuffs_base__status names.
|
||||
|
||||
static inline wuffs_base__status //
|
||||
wuffs_base__make_status(const char* repr) {
|
||||
return repr;
|
||||
wuffs_base__status z;
|
||||
z.repr = repr;
|
||||
return z;
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__status__is_complete(wuffs_base__status z) {
|
||||
return (z == NULL) || ((*z != '$') && (*z != '#'));
|
||||
wuffs_base__status__is_complete(const wuffs_base__status* z) {
|
||||
return (z->repr == NULL) || ((*z->repr != '$') && (*z->repr != '#'));
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__status__is_error(wuffs_base__status z) {
|
||||
return z && (*z == '#');
|
||||
wuffs_base__status__is_error(const wuffs_base__status* z) {
|
||||
return z->repr && (*z->repr == '#');
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__status__is_ok(wuffs_base__status z) {
|
||||
return z == NULL;
|
||||
wuffs_base__status__is_ok(const wuffs_base__status* z) {
|
||||
return z->repr == NULL;
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__status__is_suspension(wuffs_base__status z) {
|
||||
return z && (*z == '$');
|
||||
wuffs_base__status__is_suspension(const wuffs_base__status* z) {
|
||||
return z->repr && (*z->repr == '$');
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__status__is_warning(wuffs_base__status z) {
|
||||
return z && (*z != '$') && (*z != '#');
|
||||
wuffs_base__status__is_warning(const wuffs_base__status* z) {
|
||||
return z->repr && (*z->repr != '$') && (*z->repr != '#');
|
||||
}
|
||||
|
||||
// wuffs_base__status__message strips the leading '$', '#' or '@'.
|
||||
static inline const char* //
|
||||
wuffs_base__status__message(wuffs_base__status z) {
|
||||
if (z) {
|
||||
if ((*z == '$') || (*z == '#') || (*z == '@')) {
|
||||
return z + 1;
|
||||
wuffs_base__status__message(const wuffs_base__status* z) {
|
||||
if (z->repr) {
|
||||
if ((*z->repr == '$') || (*z->repr == '#') || (*z->repr == '@')) {
|
||||
return z->repr + 1;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
return z->repr;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline bool //
|
||||
wuffs_base__status::is_complete() const {
|
||||
return wuffs_base__status__is_complete(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
wuffs_base__status::is_error() const {
|
||||
return wuffs_base__status__is_error(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
wuffs_base__status::is_ok() const {
|
||||
return wuffs_base__status__is_ok(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
wuffs_base__status::is_suspension() const {
|
||||
return wuffs_base__status__is_suspension(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
wuffs_base__status::is_warning() const {
|
||||
return wuffs_base__status__is_warning(this);
|
||||
}
|
||||
|
||||
inline const char* //
|
||||
wuffs_base__status::message() const {
|
||||
return wuffs_base__status__message(this);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
// --------
|
||||
|
||||
// FourCC constants.
|
||||
|
||||
@@ -1053,7 +1053,7 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
|
||||
b.printf("wuffs_base__status z = %s%s__initialize("+
|
||||
"&self->private_data.%s%s, sizeof(self->private_data.%s%s), WUFFS_VERSION, initialize_flags);\n",
|
||||
prefix, qid[1].Str(g.tm), fPrefix, f.Name().Str(g.tm), fPrefix, f.Name().Str(g.tm))
|
||||
b.printf("if (z) { return z; }\n")
|
||||
b.printf("if (z.repr) { return z; }\n")
|
||||
b.printf("}\n")
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ const baseImageImplC = "" +
|
||||
|
||||
const baseCorePrivateH = "" +
|
||||
"static inline wuffs_base__empty_struct //\nwuffs_base__ignore_status(wuffs_base__status z) {\n return wuffs_base__make_empty_struct();\n}\n\n// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.\n// It's not foolproof, given C doesn't automatically zero memory before use,\n// but it should catch 99.99% of cases.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"wuffs\").\n#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)\n\n// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable\n// error was previously encountered.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"disabled\").\n#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)\n\n// Denote intentional fallthroughs for -Wimplicit-fallthrough.\n//\n// The order matters here. Clang also defines \"__GNUC__\".\n#if defined(__clang__) && defined(__cplusplus) && (__cplusplus >= 201103L)\n#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]\n#elif !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 7)\n#define WUFFS_BAS" +
|
||||
"E__FALLTHROUGH __attribute__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use trivial macros instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status) { \\\n goto ok; \\\n } else if (*status != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point" +
|
||||
"E__FALLTHROUGH __attribute__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use trivial macros instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status.repr) { \\\n goto ok; \\\n } else if (*status.repr != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point" +
|
||||
" = n; \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKELY(expr) (expr)\n#endif\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\n" +
|
||||
"" +
|
||||
"// ---------------- Numeric Types\n\nstatic inline uint8_t //\nwuffs_base__load_u8be(uint8_t* p) {\n return p[0];\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16be(uint8_t* p) {\n return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16le(uint8_t* p) {\n return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]" +
|
||||
@@ -55,7 +55,7 @@ const baseCorePrivateH = "" +
|
||||
"// ---------------- Slices and Tables\n\n// wuffs_base__slice_u8__prefix returns up to the first up_to bytes of s.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__prefix(wuffs_base__slice_u8 s, uint64_t up_to) {\n if ((uint64_t)(s.len) > up_to) {\n s.len = up_to;\n }\n return s;\n}\n\n// wuffs_base__slice_u8__suffix returns up to the last up_to bytes of s.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__suffix(wuffs_base__slice_u8 s, uint64_t up_to) {\n if ((uint64_t)(s.len) > up_to) {\n s.ptr += (uint64_t)(s.len) - up_to;\n s.len = up_to;\n }\n return s;\n}\n\n// wuffs_base__slice_u8__copy_from_slice calls memmove(dst.ptr, src.ptr, len)\n// where len is the minimum of dst.len and src.len.\n//\n// Passing a wuffs_base__slice_u8 with all fields NULL or zero (a valid, empty\n// slice) is valid and results in a no-op.\nstatic inline uint64_t //\nwuffs_base__slice_u8__copy_from_slice(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t len = dst.l" +
|
||||
"en < src.len ? dst.len : src.len;\n if (len > 0) {\n memmove(dst.ptr, src.ptr, len);\n }\n return len;\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {\n if (y < t.height) {\n return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n" +
|
||||
"// --------\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {\n if (y < t.height) {\n return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n " +
|
||||
"" +
|
||||
"// ---------------- Slices and Tables (Utility)\n\n#define wuffs_base__utility__empty_slice_u8 wuffs_base__empty_slice_u8\n" +
|
||||
""
|
||||
@@ -69,8 +69,9 @@ const baseCorePublicH = "" +
|
||||
"// --------\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\nstatic inline wuffs_base__empty_struct //\nwuffs_base__make_empty_struct() {\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\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// See https://github.com/google/wuffs/blob/master/doc/note/statuses.md\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline wuffs_base__status //\nwuffs_base__make_status(const char* repr) {\n return repr;\n}\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// wuffs_base__status__message strips the leading '$', '#' or '@'.\nstatic inline const char* //\nwuffs_base__status__message(wuffs_base__status z) {\n if (z) {\n if ((*z == '$') || (*z " +
|
||||
"== '#') || (*z == '@')) {\n return z + 1;\n }\n }\n return z;\n}\n\n" +
|
||||
"// --------\n\n// See https://github.com/google/wuffs/blob/master/doc/note/statuses.md\ntypedef struct {\n const char* repr;\n\n#ifdef __cplusplus\n inline bool is_complete() const;\n inline bool is_error() const;\n inline bool is_ok() const;\n inline bool is_suspension() const;\n inline bool is_warning() const;\n inline const char* message() const;\n#endif // __cplusplus\n\n} wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline wuffs_base__status //\nwuffs_base__make_status(const char* repr) {\n wuffs_base__status z;\n z.repr = repr;\n return z;\n}\n\nstatic inline bool //\nwuffs_base__status__is_complete(const wuffs_base__status* z) {\n return (z->repr == NULL) || ((*z->repr != '$') && (*z->repr != '#'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(const wuffs_base__status* z) {\n return z->repr && (*z->repr == '#');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(const wuffs_base__status* z) {\n return z->repr == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(c" +
|
||||
"onst wuffs_base__status* z) {\n return z->repr && (*z->repr == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(const wuffs_base__status* z) {\n return z->repr && (*z->repr != '$') && (*z->repr != '#');\n}\n\n// wuffs_base__status__message strips the leading '$', '#' or '@'.\nstatic inline const char* //\nwuffs_base__status__message(const wuffs_base__status* z) {\n if (z->repr) {\n if ((*z->repr == '$') || (*z->repr == '#') || (*z->repr == '@')) {\n return z->repr + 1;\n }\n }\n return z->repr;\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__status::is_complete() const {\n return wuffs_base__status__is_complete(this);\n}\n\ninline bool //\nwuffs_base__status::is_error() const {\n return wuffs_base__status__is_error(this);\n}\n\ninline bool //\nwuffs_base__status::is_ok() const {\n return wuffs_base__status__is_ok(this);\n}\n\ninline bool //\nwuffs_base__status::is_suspension() const {\n return wuffs_base__status__is_suspension(this);\n}\n\ninline bool //\nwuffs_base__status::is_warning() const {\n re" +
|
||||
"turn wuffs_base__status__is_warning(this);\n}\n\ninline const char* //\nwuffs_base__status::message() const {\n return wuffs_base__status__message(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// FourCC constants.\n\n// !! INSERT FourCCs.\n\n" +
|
||||
"" +
|
||||
|
||||
+10
-2
@@ -276,14 +276,24 @@ func (g *gen) writeExprBinaryOp(b *buffer, n *a.Expr, depth uint32) error {
|
||||
if err := g.writeExpr(b, n.LHS().AsExpr(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
if g.hasRepr(n.LHS().AsExpr()) {
|
||||
b.writes(".repr")
|
||||
}
|
||||
b.writes(opName)
|
||||
if err := g.writeExpr(b, n.RHS().AsExpr(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
if g.hasRepr(n.RHS().AsExpr()) {
|
||||
b.writes(".repr")
|
||||
}
|
||||
b.writeb(')')
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) hasRepr(n *a.Expr) bool {
|
||||
return n.MType().IsStatus()
|
||||
}
|
||||
|
||||
func (g *gen) writeExprAs(b *buffer, lhs *a.Expr, rhs *a.TypeExpr, depth uint32) error {
|
||||
b.writes("((")
|
||||
// TODO: watch for passing an array type to writeCTypeName? In C, an array
|
||||
@@ -325,8 +335,6 @@ func (g *gen) writeExprUserDefinedCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
recvTyp, addr := recv.MType(), "&"
|
||||
if p := recvTyp.Decorator(); p == t.IDNptr || p == t.IDPtr {
|
||||
recvTyp, addr = recvTyp.Inner(), ""
|
||||
} else if recvTyp.IsStatus() {
|
||||
addr = ""
|
||||
}
|
||||
if recvTyp.Decorator() != 0 {
|
||||
return fmt.Errorf("cannot generate user-defined method call %q for receiver type %q",
|
||||
|
||||
@@ -371,11 +371,11 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
||||
b.writes("goto suspend;suspend:") // The goto avoids the "unused label" warning.
|
||||
|
||||
b.printf("self->private_impl.%s%s[0] = "+
|
||||
"wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;\n",
|
||||
"wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;\n",
|
||||
pPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
||||
if g.currFunk.astFunc.Public() {
|
||||
b.printf("self->private_impl.active_coroutine = "+
|
||||
"wuffs_base__status__is_suspension(status) ? %d : 0;\n", g.currFunk.coroID)
|
||||
"wuffs_base__status__is_suspension(&status) ? %d : 0;\n", g.currFunk.coroID)
|
||||
}
|
||||
if err := g.writeResumeSuspend(b, &g.currFunk, true); err != nil {
|
||||
return err
|
||||
@@ -406,7 +406,7 @@ func (g *gen) writeFuncImplEpilogue(b *buffer) error {
|
||||
(g.currFunk.returnsStatus && (len(g.currFunk.derivedVars) > 0)) {
|
||||
|
||||
if g.currFunk.astFunc.Public() {
|
||||
b.writes("if (wuffs_base__status__is_error(status)) { " +
|
||||
b.writes("if (wuffs_base__status__is_error(&status)) { " +
|
||||
"self->private_impl.magic = WUFFS_BASE__DISABLED; }\n")
|
||||
}
|
||||
b.writes("return status;\n")
|
||||
|
||||
@@ -162,7 +162,7 @@ func (g *gen) writeStatementAssign0(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
}
|
||||
|
||||
if op != t.IDEqQuestion && rhs.Effect().Coroutine() {
|
||||
b.writes("if (status) { goto suspend; }\n")
|
||||
b.writes("if (status.repr) { goto suspend; }\n")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,8 +464,8 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
||||
} else {
|
||||
g.currFunk.hasGotoOK = true
|
||||
// TODO: the "goto exit"s can be "goto ok".
|
||||
b.writes("if (wuffs_base__status__is_error(status)) { goto exit; }" +
|
||||
"else if (wuffs_base__status__is_suspension(status)) { " +
|
||||
b.writes("if (wuffs_base__status__is_error(&status)) { goto exit; }" +
|
||||
"else if (wuffs_base__status__is_suspension(&status)) { " +
|
||||
"status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension); goto exit; } goto ok;")
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user