-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfunctions.go
61 lines (47 loc) · 1.19 KB
/
functions.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
package generate
import (
"github.com/pekim/jennifer/jen"
)
type Functions []*Function
func (ff Functions) init(ns *Namespace, namePrefix string) {
for _, function := range ff {
function.init(ns, nil, namePrefix)
}
}
func (ff Functions) versionList() Versions {
var versions Versions
for _, f := range ff {
if f.Version != "" {
versions = append(versions, VersionNew(f.Version))
}
}
return versions
}
func (ff Functions) entities() []Generatable {
var generatables []Generatable
for _, function := range ff {
generatables = append(generatables, function)
}
return generatables
}
func (ff Functions) forCIdentifier(cidentifier string) *Function {
for _, function := range ff {
if function.CIdentifier == cidentifier {
return function
}
}
return nil
}
func (ff Functions) mergeAddenda(addenda Functions) {
for _, addendaFunction := range addenda {
if function := ff.forCIdentifier(addendaFunction.CIdentifier); function != nil {
function.mergeAddenda(addendaFunction)
}
}
}
func (ff Functions) generate(g *jen.Group, version *Version) {
for _, fn := range ff {
fn.generate(g, version)
}
}
func (ff Functions) generateDocs(ns *Namespace, typeName string) {}