mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Allow table base.u8 as a type
This commit is contained in:
1 parent
2301c763c3
commit
eda326726a
10 files changed
+60
-27
No files matched your search
@@ -314,6 +314,17 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var
|
||||
}
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C", n.Str(g.tm))
|
||||
}
|
||||
if n.IsTableType() {
|
||||
o := n.Inner()
|
||||
if o.Decorator() == 0 && o.QID() == (t.QID{t.IDBase, t.IDU8}) && !o.IsRefined() {
|
||||
b.writes("wuffs_base__table_u8")
|
||||
b.writeb(' ')
|
||||
b.writes(varNamePrefix)
|
||||
b.writes(varName)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C", n.Str(g.tm))
|
||||
}
|
||||
|
||||
// maxNumPointers is an arbitrary implementation restriction.
|
||||
const maxNumPointers = 16
|
||||
|
||||
@@ -399,6 +399,9 @@ func (g *gen) writeStatementVar(b *buffer, n *a.Var, depth uint32) error {
|
||||
} else if nTyp.IsSliceType() {
|
||||
// TODO: don't assume that the slice is a slice of base.u8.
|
||||
b.printf("((wuffs_base__slice_u8){})")
|
||||
} else if nTyp.IsTableType() {
|
||||
// TODO: don't assume that the table is a table of base.u8.
|
||||
b.printf("((wuffs_base__table_u8){})")
|
||||
} else if nTyp.IsIOType() {
|
||||
s := "reader"
|
||||
if nTyp.QID()[1] == t.IDIOWriter {
|
||||
|
||||
@@ -285,6 +285,9 @@ func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool, initBoolTyp
|
||||
case t.IDSlice:
|
||||
// TODO: don't assume that the slice is a slice of base.u8.
|
||||
rhs = "wuffs_base__slice_u8"
|
||||
case t.IDTable:
|
||||
// TODO: don't assume that the table is a table of base.u8.
|
||||
rhs = "wuffs_base__table_u8"
|
||||
}
|
||||
if rhs != "" {
|
||||
b.printf("%s = ((%s){});\n", local, rhs)
|
||||
|
||||
Reference in new issue
Block a user