github.com/ipld/go-ipld-prime@v0.21.0/schema/gen/go/genInt.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 type intGenerator struct { 11 AdjCfg *AdjunctCfg 12 mixins.IntTraits 13 PkgName string 14 Type *schema.TypeInt 15 } 16 17 func (intGenerator) IsRepr() bool { return false } // hint used in some generalized templates. 18 19 // --- native content and specializations ---> 20 21 func (g intGenerator) EmitNativeType(w io.Writer) { 22 emitNativeType_scalar(w, g.AdjCfg, g) 23 } 24 func (g intGenerator) EmitNativeAccessors(w io.Writer) { 25 emitNativeAccessors_scalar(w, g.AdjCfg, g) 26 } 27 func (g intGenerator) EmitNativeBuilder(w io.Writer) { 28 emitNativeBuilder_scalar(w, g.AdjCfg, g) 29 } 30 31 func (g intGenerator) EmitNativeMaybe(w io.Writer) { 32 emitNativeMaybe(w, g.AdjCfg, g) 33 } 34 35 // --- type info ---> 36 37 func (g intGenerator) EmitTypeConst(w io.Writer) { 38 doTemplate(` 39 // TODO EmitTypeConst 40 `, w, g.AdjCfg, g) 41 } 42 43 // --- TypedNode interface satisfaction ---> 44 45 func (g intGenerator) EmitTypedNodeMethodType(w io.Writer) { 46 doTemplate(` 47 func ({{ .Type | TypeSymbol }}) Type() schema.Type { 48 return nil /*TODO:typelit*/ 49 } 50 `, w, g.AdjCfg, g) 51 } 52 53 func (g intGenerator) EmitTypedNodeMethodRepresentation(w io.Writer) { 54 emitTypicalTypedNodeMethodRepresentation(w, g.AdjCfg, g) 55 } 56 57 // --- Node interface satisfaction ---> 58 59 func (g intGenerator) EmitNodeType(w io.Writer) { 60 // No additional types needed. Methods all attach to the native type. 61 } 62 func (g intGenerator) EmitNodeTypeAssertions(w io.Writer) { 63 emitNodeTypeAssertions_typical(w, g.AdjCfg, g) 64 } 65 func (g intGenerator) EmitNodeMethodAsInt(w io.Writer) { 66 emitNodeMethodAsKind_scalar(w, g.AdjCfg, g) 67 } 68 func (g intGenerator) EmitNodeMethodPrototype(w io.Writer) { 69 emitNodeMethodPrototype_typical(w, g.AdjCfg, g) 70 } 71 func (g intGenerator) EmitNodePrototypeType(w io.Writer) { 72 emitNodePrototypeType_typical(w, g.AdjCfg, g) 73 } 74 75 // --- NodeBuilder and NodeAssembler ---> 76 77 func (g intGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator { 78 return intBuilderGenerator{ 79 g.AdjCfg, 80 mixins.IntAssemblerTraits{ 81 PkgName: g.PkgName, 82 TypeName: g.TypeName, 83 AppliedPrefix: "_" + g.AdjCfg.TypeSymbol(g.Type) + "__", 84 }, 85 g.PkgName, 86 g.Type, 87 } 88 } 89 90 type intBuilderGenerator struct { 91 AdjCfg *AdjunctCfg 92 mixins.IntAssemblerTraits 93 PkgName string 94 Type *schema.TypeInt 95 } 96 97 func (intBuilderGenerator) IsRepr() bool { return false } // hint used in some generalized templates. 98 99 func (g intBuilderGenerator) EmitNodeBuilderType(w io.Writer) { 100 emitEmitNodeBuilderType_typical(w, g.AdjCfg, g) 101 } 102 func (g intBuilderGenerator) EmitNodeBuilderMethods(w io.Writer) { 103 emitNodeBuilderMethods_typical(w, g.AdjCfg, g) 104 } 105 func (g intBuilderGenerator) EmitNodeAssemblerType(w io.Writer) { 106 emitNodeAssemblerType_scalar(w, g.AdjCfg, g) 107 } 108 func (g intBuilderGenerator) EmitNodeAssemblerMethodAssignNull(w io.Writer) { 109 emitNodeAssemblerMethodAssignNull_scalar(w, g.AdjCfg, g) 110 } 111 func (g intBuilderGenerator) EmitNodeAssemblerMethodAssignInt(w io.Writer) { 112 emitNodeAssemblerMethodAssignKind_scalar(w, g.AdjCfg, g) 113 } 114 func (g intBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) { 115 emitNodeAssemblerMethodAssignNode_scalar(w, g.AdjCfg, g) 116 } 117 func (g intBuilderGenerator) EmitNodeAssemblerOtherBits(w io.Writer) { 118 // Nothing needed here for int kinds. 119 }