stringGenMixin.go 4.73 KB
Newer Older
1 2 3 4 5
package mixins

import (
	"io"

6
	ld "gitlab.dms3.io/ld/go-ld-prime"
7 8 9 10 11 12 13 14
)

type StringTraits struct {
	PkgName    string
	TypeName   string // see doc in kindTraitsGenerator
	TypeSymbol string // see doc in kindTraitsGenerator
}

15 16
func (StringTraits) Kind() ld.Kind {
	return ld.Kind_String
Eric Myhre's avatar
Eric Myhre committed
17
}
18
func (g StringTraits) EmitNodeMethodKind(w io.Writer) {
19
	doTemplate(`
20 21
		func ({{ .TypeSymbol }}) Kind() ld.Kind {
			return ld.Kind_String
22 23 24
		}
	`, w, g)
}
25
func (g StringTraits) EmitNodeMethodLookupByString(w io.Writer) {
26
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodLookupByString(w)
27
}
28
func (g StringTraits) EmitNodeMethodLookupByNode(w io.Writer) {
29
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodLookupByNode(w)
30
}
31
func (g StringTraits) EmitNodeMethodLookupByIndex(w io.Writer) {
32
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodLookupByIndex(w)
33
}
34
func (g StringTraits) EmitNodeMethodLookupBySegment(w io.Writer) {
35
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodLookupBySegment(w)
36 37
}
func (g StringTraits) EmitNodeMethodMapIterator(w io.Writer) {
38
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodMapIterator(w)
39 40
}
func (g StringTraits) EmitNodeMethodListIterator(w io.Writer) {
41
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodListIterator(w)
42 43
}
func (g StringTraits) EmitNodeMethodLength(w io.Writer) {
44
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodLength(w)
45
}
46
func (g StringTraits) EmitNodeMethodIsAbsent(w io.Writer) {
47
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodIsAbsent(w)
48 49
}
func (g StringTraits) EmitNodeMethodIsNull(w io.Writer) {
50
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodIsNull(w)
51 52
}
func (g StringTraits) EmitNodeMethodAsBool(w io.Writer) {
53
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodAsBool(w)
54 55
}
func (g StringTraits) EmitNodeMethodAsInt(w io.Writer) {
56
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodAsInt(w)
57 58
}
func (g StringTraits) EmitNodeMethodAsFloat(w io.Writer) {
59
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodAsFloat(w)
60 61
}
func (g StringTraits) EmitNodeMethodAsBytes(w io.Writer) {
62
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodAsBytes(w)
63 64
}
func (g StringTraits) EmitNodeMethodAsLink(w io.Writer) {
65
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_String}.emitNodeMethodAsLink(w)
66
}
67 68 69 70 71 72 73

type StringAssemblerTraits struct {
	PkgName       string
	TypeName      string // see doc in kindAssemblerTraitsGenerator
	AppliedPrefix string // see doc in kindAssemblerTraitsGenerator
}

74 75
func (StringAssemblerTraits) Kind() ld.Kind {
	return ld.Kind_String
76
}
77
func (g StringAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) {
78
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodBeginMap(w)
79 80
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) {
81
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodBeginList(w)
82 83
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
84
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodAssignNull(w)
85 86
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) {
87
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodAssignBool(w)
88 89
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) {
90
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodAssignInt(w)
91 92
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) {
93
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodAssignFloat(w)
94 95
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) {
96
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodAssignBytes(w)
97 98
}
func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) {
99
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodAssignLink(w)
100
}
101
func (g StringAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) {
102
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_String}.emitNodeAssemblerMethodPrototype(w)
103
}