mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 00:47:56 +01:00
Allow referring to types from used packages
This commit is contained in:
1 parent
df4539f6ff
commit
0a32c01014
5 files changed
+24
-1
No files matched your search
@@ -562,7 +562,21 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fallback {
|
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++ {
|
for i := 0; i < numPointers; i++ {
|
||||||
|
|||||||
@@ -401,6 +401,8 @@ typedef struct {
|
|||||||
wuffs_zlib__status status;
|
wuffs_zlib__status status;
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
|
||||||
|
wuffs_flate__flate_decoder f_flate;
|
||||||
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_zlib__decoder;
|
} wuffs_zlib__decoder;
|
||||||
|
|
||||||
|
|||||||
@@ -401,6 +401,8 @@ typedef struct {
|
|||||||
wuffs_zlib__status status;
|
wuffs_zlib__status status;
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
|
||||||
|
wuffs_flate__flate_decoder f_flate;
|
||||||
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_zlib__decoder;
|
} wuffs_zlib__decoder;
|
||||||
|
|
||||||
|
|||||||
@@ -1115,6 +1115,10 @@ swtch:
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
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")
|
return fmt.Errorf("check: unrecognized node for tcheckTypeExpr")
|
||||||
}
|
}
|
||||||
n.Node().SetTypeChecked()
|
n.Node().SetTypeChecked()
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ packageid "zlib"
|
|||||||
use "std/flate"
|
use "std/flate"
|
||||||
|
|
||||||
pub struct decoder?(
|
pub struct decoder?(
|
||||||
|
flate flate.flate_decoder,
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user