mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Let ? methods return OK even without suspending
This commit is contained in:
1 parent
865275db75
commit
00203e564f
4 files changed
+17
-11
No files matched your search
@@ -40,6 +40,7 @@ type funk struct {
|
||||
public bool
|
||||
suspendible bool
|
||||
usesScratch bool
|
||||
hasGotoOK bool
|
||||
shortReads []string
|
||||
}
|
||||
|
||||
@@ -133,6 +134,8 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
|
||||
b.writex(k.bBody)
|
||||
if k.suspendible && k.coroSuspPoint > 0 {
|
||||
b.writex(k.bBodySuspend)
|
||||
} else if k.hasGotoOK {
|
||||
b.writes("\ngoto ok;ok:\n") // The goto avoids the "unused label" warning.
|
||||
}
|
||||
b.writex(k.bFooter)
|
||||
b.writes("}\n\n")
|
||||
@@ -274,14 +277,12 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
||||
// We've reached the end of the function body. Reset the coroutine
|
||||
// suspension point so that the next call to this function starts at
|
||||
// the top.
|
||||
b.writes("\ngoto ok;\n") // Avoid the "unused label" warning.
|
||||
b.writes("ok:\n")
|
||||
b.writes("\ngoto ok;ok:") // The goto avoids the "unused label" warning.
|
||||
b.printf("self->private_impl.%s%s[0].coro_susp_point = 0;\n",
|
||||
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
||||
b.writes("goto exit; }\n\n") // Close the coroutine switch.
|
||||
|
||||
b.writes("goto suspend;\n") // Avoid the "unused label" warning.
|
||||
b.writes("suspend:\n")
|
||||
b.writes("goto suspend;suspend:") // The goto avoids the "unused label" warning.
|
||||
|
||||
b.printf("self->private_impl.%s%s[0].coro_susp_point = coro_susp_point;\n",
|
||||
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
||||
@@ -295,8 +296,7 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
||||
|
||||
func (g *gen) writeFuncImplFooter(b *buffer) error {
|
||||
if g.currFunk.suspendible {
|
||||
b.writes("goto exit;\n") // Avoid the "unused label" warning.
|
||||
b.writes("exit:")
|
||||
b.writes("goto exit;exit:") // The goto avoids the "unused label" warning.
|
||||
|
||||
for _, o := range g.currFunk.astFunc.In().Fields() {
|
||||
o := o.Field()
|
||||
|
||||
@@ -348,8 +348,10 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
||||
case t.IDError:
|
||||
b.writes("goto exit;")
|
||||
case t.IDStatus:
|
||||
g.currFunk.hasGotoOK = true
|
||||
b.writes("goto ok;")
|
||||
default:
|
||||
g.currFunk.hasGotoOK = true
|
||||
b.printf("if (status == 0) { goto ok; } else if (status > 0) { "+
|
||||
"status = %sERROR_CANNOT_RETURN_A_SUSPENSION; } goto exit;", g.PKGPREFIX)
|
||||
}
|
||||
|
||||
+6
-2
@@ -3628,9 +3628,13 @@ static wuffs_gif__status wuffs_gif__decoder__copy_to_image_buffer(
|
||||
v_dst = wuffs_base__table_u8__linearize(v_tab);
|
||||
if (((uint64_t)(v_dst.len)) == 0) {
|
||||
}
|
||||
} else {
|
||||
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
||||
status = WUFFS_GIF__STATUS_OK;
|
||||
goto ok;
|
||||
}
|
||||
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
return status;
|
||||
|
||||
@@ -505,8 +505,8 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
if dst.length() == 0 {
|
||||
// TODO.
|
||||
}
|
||||
} else {
|
||||
dst = tab.row(y:this.dst_y)
|
||||
// TODO.
|
||||
return
|
||||
}
|
||||
|
||||
dst = tab.row(y:this.dst_y)
|
||||
}
|
||||
Reference in new issue
Block a user