Skip to content

Commit 79fe4f7

Browse files
committed
wit/bindgen: revert field names
1 parent 16743d2 commit 79fe4f7

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

wit/bindgen/generator.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ type generator struct {
9999
// which affects the generated Go package paths.
100100
versioned bool
101101

102-
// goPackages are Go goPackages indexed on Go package paths.
103-
goPackages map[string]*gen.Package
102+
// packages are Go packages indexed on Go package paths.
103+
packages map[string]*gen.Package
104104

105-
// ownerGoPackages map wit.TypeOwner (World, Interface) to Go packages.
106-
ownerGoPackages map[wit.TypeOwner]*gen.Package
105+
// witPackages map wit.TypeOwner (World, Interface) to Go packages.
106+
witPackages map[wit.TypeOwner]*gen.Package
107107

108108
// exportScopes map wit.TypeOwner to export scopes.
109109
exportScopes map[wit.TypeOwner]gen.Scope
@@ -135,13 +135,13 @@ type generator struct {
135135

136136
func newGenerator(res *wit.Resolve, opts ...Option) (*generator, error) {
137137
g := &generator{
138-
goPackages: make(map[string]*gen.Package),
139-
ownerGoPackages: make(map[wit.TypeOwner]*gen.Package),
140-
exportScopes: make(map[wit.TypeOwner]gen.Scope),
141-
moduleNames: make(map[wit.TypeOwner]string),
142-
shapes: make(map[typeUse]string),
143-
lowerFunctions: make(map[typeUse]function),
144-
liftFunctions: make(map[typeUse]function),
138+
packages: make(map[string]*gen.Package),
139+
witPackages: make(map[wit.TypeOwner]*gen.Package),
140+
exportScopes: make(map[wit.TypeOwner]gen.Scope),
141+
moduleNames: make(map[wit.TypeOwner]string),
142+
shapes: make(map[typeUse]string),
143+
lowerFunctions: make(map[typeUse]function),
144+
liftFunctions: make(map[typeUse]function),
145145
}
146146
for i := 0; i < 2; i++ {
147147
g.types[i] = make(map[*wit.TypeDef]*typeDecl)
@@ -182,11 +182,11 @@ func (g *generator) generate() ([]*gen.Package, error) {
182182
if err != nil {
183183
return nil, err
184184
}
185-
var goPackages []*gen.Package
186-
for _, path := range codec.SortedKeys(g.goPackages) {
187-
goPackages = append(goPackages, g.goPackages[path])
185+
var packages []*gen.Package
186+
for _, path := range codec.SortedKeys(g.packages) {
187+
packages = append(packages, g.packages[path])
188188
}
189-
return goPackages, nil
189+
return packages, nil
190190
}
191191

192192
func (g *generator) detectVersionedPackages() {
@@ -2288,7 +2288,7 @@ func (g *generator) cgoFileFor(owner wit.TypeOwner) *gen.File {
22882288
}
22892289

22902290
func (g *generator) goPackageFor(owner wit.TypeOwner) *gen.Package {
2291-
pkg := g.ownerGoPackages[owner]
2291+
pkg := g.witPackages[owner]
22922292
if pkg == nil {
22932293
panic(fmt.Sprintf("BUG: nil package for wit.TypeOwner %s (%T: %p)",
22942294
owner.WITPackage().Name.String(), owner, owner))
@@ -2324,7 +2324,7 @@ func (g *generator) defineGoPackage(w *wit.World, i *wit.Interface, name string)
23242324
}
23252325

23262326
// Don’t create the same package twice
2327-
pkg := g.ownerGoPackages[owner]
2327+
pkg := g.witPackages[owner]
23282328
if pkg != nil {
23292329
return pkg, nil
23302330
}
@@ -2357,8 +2357,8 @@ func (g *generator) defineGoPackage(w *wit.World, i *wit.Interface, name string)
23572357
}
23582358

23592359
pkg = gen.NewPackage(pkgPath + "#" + goName)
2360-
g.goPackages[pkg.Path] = pkg
2361-
g.ownerGoPackages[owner] = pkg
2360+
g.packages[pkg.Path] = pkg
2361+
g.witPackages[owner] = pkg
23622362
g.exportScopes[owner] = gen.NewScope(nil)
23632363
pkg.DeclareName("Exports")
23642364

0 commit comments

Comments
 (0)