-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalias.go
64 lines (49 loc) · 1.19 KB
/
alias.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package generate
import (
"fmt"
"github.com/pekim/jennifer/jen"
)
type Alias struct {
Namespace *Namespace
Name string `xml:"name,attr"`
Blacklist bool `xml:"blacklist,attr"`
CType string `xml:"type,attr"`
Type *Type `xml:"type"`
Doc *Doc `xml:"doc"`
goName string
}
func (a *Alias) init(ns *Namespace) {
a.Namespace = ns
//a.goName = MakeExportedGoName(a.Name)
a.goName = a.Name
if a.Type != nil {
a.Type.init(ns)
}
}
func (a Alias) version() string {
return ""
}
func (a *Alias) blacklisted() (bool, string) {
return a.Blacklist, a.CType
}
func (a *Alias) supported() (supported bool, reason string) {
if a.Type == nil {
return false, "alias has no param type"
}
if a.Type.generator == nil {
return false, fmt.Sprintf("alias has no type generator for %s, %s", a.Type.Name, a.Type.CType)
}
return true, ""
}
func (a *Alias) mergeAddenda(addenda *Alias) {
a.Blacklist = addenda.Blacklist
}
func (a *Alias) generate(g *jen.Group, version *Version) {
if !supportedByVersion(a, version) {
return
}
g.Commentf("%s is a representation of the C alias %s.", a.Name, a.CType)
g.Type()
a.Type.generator.generateDeclaration(g, a.goName)
g.Line()
}