bytesGenMixin.go 4.68 KB
Newer Older
Eric Myhre's avatar
Eric Myhre committed
1 2 3 4 5
package mixins

import (
	"io"

6
	ld "gitlab.dms3.io/ld/go-ld-prime"
Eric Myhre's avatar
Eric Myhre committed
7 8 9 10 11 12 13 14
)

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

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

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

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