github.com/ipld/go-ipld-prime@v0.21.0/schema/gen/go/genStringReprString.go (about) 1 package gengo 2 3 import ( 4 "io" 5 6 "github.com/ipld/go-ipld-prime/schema" 7 "github.com/ipld/go-ipld-prime/schema/gen/go/mixins" 8 ) 9 10 var _ TypeGenerator = &stringReprStringGenerator{} 11 12 func NewStringReprStringGenerator(pkgName string, typ *schema.TypeString, adjCfg *AdjunctCfg) TypeGenerator { 13 return stringReprStringGenerator{ 14 stringGenerator{ 15 adjCfg, 16 mixins.StringTraits{ 17 PkgName: pkgName, 18 TypeName: string(typ.Name()), 19 TypeSymbol: adjCfg.TypeSymbol(typ), 20 }, 21 pkgName, 22 typ, 23 }, 24 } 25 } 26 27 type stringReprStringGenerator struct { 28 stringGenerator 29 } 30 31 func (g stringReprStringGenerator) GetRepresentationNodeGen() NodeGenerator { 32 return stringReprStringReprGenerator{ 33 g.AdjCfg, 34 g.Type, 35 } 36 } 37 38 type stringReprStringReprGenerator struct { 39 AdjCfg *AdjunctCfg 40 Type *schema.TypeString 41 } 42 43 func (g stringReprStringReprGenerator) EmitNodeType(w io.Writer) { 44 // Since this is a "natural" representation... there's just a type alias here. 45 // No new functions are necessary. 46 doTemplate(` 47 type _{{ .Type | TypeSymbol }}__Repr = _{{ .Type | TypeSymbol }} 48 `, w, g.AdjCfg, g) 49 } 50 func (g stringReprStringReprGenerator) EmitNodeTypeAssertions(w io.Writer) { 51 doTemplate(` 52 var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} 53 `, w, g.AdjCfg, g) 54 } 55 func (stringReprStringReprGenerator) EmitNodeMethodKind(io.Writer) {} 56 func (stringReprStringReprGenerator) EmitNodeMethodLookupByString(io.Writer) {} 57 func (stringReprStringReprGenerator) EmitNodeMethodLookupByNode(io.Writer) {} 58 func (stringReprStringReprGenerator) EmitNodeMethodLookupByIndex(io.Writer) {} 59 func (stringReprStringReprGenerator) EmitNodeMethodLookupBySegment(io.Writer) {} 60 func (stringReprStringReprGenerator) EmitNodeMethodMapIterator(io.Writer) {} 61 func (stringReprStringReprGenerator) EmitNodeMethodListIterator(io.Writer) {} 62 func (stringReprStringReprGenerator) EmitNodeMethodLength(io.Writer) {} 63 func (stringReprStringReprGenerator) EmitNodeMethodIsAbsent(io.Writer) {} 64 func (stringReprStringReprGenerator) EmitNodeMethodIsNull(io.Writer) {} 65 func (stringReprStringReprGenerator) EmitNodeMethodAsBool(io.Writer) {} 66 func (stringReprStringReprGenerator) EmitNodeMethodAsInt(io.Writer) {} 67 func (stringReprStringReprGenerator) EmitNodeMethodAsFloat(io.Writer) {} 68 func (stringReprStringReprGenerator) EmitNodeMethodAsString(io.Writer) {} 69 func (stringReprStringReprGenerator) EmitNodeMethodAsBytes(io.Writer) {} 70 func (stringReprStringReprGenerator) EmitNodeMethodAsLink(io.Writer) {} 71 func (stringReprStringReprGenerator) EmitNodeMethodPrototype(io.Writer) {} 72 func (g stringReprStringReprGenerator) EmitNodePrototypeType(w io.Writer) { 73 // Since this is a "natural" representation... there's just a type alias here. 74 // No new functions are necessary. 75 doTemplate(` 76 type _{{ .Type | TypeSymbol }}__ReprPrototype = _{{ .Type | TypeSymbol }}__Prototype 77 `, w, g.AdjCfg, g) 78 } 79 func (g stringReprStringReprGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator { 80 return stringReprStringReprBuilderGenerator(g) 81 } 82 83 type stringReprStringReprBuilderGenerator struct { 84 AdjCfg *AdjunctCfg 85 Type *schema.TypeString 86 } 87 88 func (stringReprStringReprBuilderGenerator) EmitNodeBuilderType(io.Writer) {} 89 func (g stringReprStringReprBuilderGenerator) EmitNodeBuilderMethods(w io.Writer) {} 90 func (g stringReprStringReprBuilderGenerator) EmitNodeAssemblerType(w io.Writer) { 91 // Since this is a "natural" representation... there's just a type alias here. 92 // No new functions are necessary. 93 doTemplate(` 94 type _{{ .Type | TypeSymbol }}__ReprAssembler = _{{ .Type | TypeSymbol }}__Assembler 95 `, w, g.AdjCfg, g) 96 } 97 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(io.Writer) {} 98 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(io.Writer) {} 99 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignNull(io.Writer) {} 100 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignBool(io.Writer) {} 101 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignInt(io.Writer) {} 102 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignFloat(io.Writer) {} 103 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignString(io.Writer) {} 104 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(io.Writer) {} 105 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignLink(io.Writer) {} 106 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(io.Writer) {} 107 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerMethodPrototype(io.Writer) {} 108 func (stringReprStringReprBuilderGenerator) EmitNodeAssemblerOtherBits(io.Writer) {}