diff --git a/cmd/wuffs-c/internal/cgen/expr.go b/cmd/wuffs-c/internal/cgen/expr.go index 18b6b771..7f0eba58 100644 --- a/cmd/wuffs-c/internal/cgen/expr.go +++ b/cmd/wuffs-c/internal/cgen/expr.go @@ -562,7 +562,21 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var } } if fallback { - b.printf("%s%s", g.pkgPrefix, innermost.Name().Str(g.tm)) + prefix := g.pkgPrefix + if otherPkgID := innermost.Decorator(); otherPkgID != 0 { + otherPkg := g.tm.ByID(otherPkgID) + // TODO: map the "flate" in "flate.decoder" to the "flate" in `use + // "std/flate"`, and use the latter "flate". + // + // This is pretty academic at the moment, since they're the same + // "flate", but in the future, we might be able to rename used + // packages, e.g. `use "foo/bar" as "baz"`, so "baz.qux" would map + // to generating "wuffs_bar__qux". + // + // TODO: sanitize or validate otherPkg, e.g. that it's ASCII only? + prefix = "wuffs_" + otherPkg + "__" + } + b.printf("%s%s", prefix, innermost.Name().Str(g.tm)) } for i := 0; i < numPointers; i++ { diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 2ba83479..f75d9540 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -401,6 +401,8 @@ typedef struct { wuffs_zlib__status status; uint32_t magic; + wuffs_flate__flate_decoder f_flate; + } private_impl; } wuffs_zlib__decoder; diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 221f2f64..c2e5a7c8 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -401,6 +401,8 @@ typedef struct { wuffs_zlib__status status; uint32_t magic; + wuffs_flate__flate_decoder f_flate; + } private_impl; } wuffs_zlib__decoder; diff --git a/lang/check/type.go b/lang/check/type.go index b8671130..b7971654 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -1115,6 +1115,10 @@ swtch: } default: + // TODO: don't hard-code flate.flate_decoder as an acceptable type. + if q.tm.ByID(n.Decorator()) == "flate" && q.tm.ByID(n.Name()) == "flate_decoder" { + break + } return fmt.Errorf("check: unrecognized node for tcheckTypeExpr") } n.Node().SetTypeChecked() diff --git a/std/zlib/decode_zlib.wuffs b/std/zlib/decode_zlib.wuffs index 90e07bea..895a2e9a 100644 --- a/std/zlib/decode_zlib.wuffs +++ b/std/zlib/decode_zlib.wuffs @@ -17,4 +17,5 @@ packageid "zlib" use "std/flate" pub struct decoder?( + flate flate.flate_decoder, )