package mixins import ( "io" ld "gitlab.dms3.io/ld/go-ld-prime" ) type ListTraits struct { PkgName string TypeName string // see doc in kindTraitsGenerator TypeSymbol string // see doc in kindTraitsGenerator } func (ListTraits) Kind() ld.Kind { return ld.Kind_List } func (g ListTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` func ({{ .TypeSymbol }}) Kind() ld.Kind { return ld.Kind_List } `, w, g) } func (g ListTraits) EmitNodeMethodLookupByString(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodLookupByString(w) } func (g ListTraits) EmitNodeMethodLookupBySegment(w io.Writer) { doTemplate(` func (n {{ .TypeSymbol }}) LookupBySegment(seg ld.PathSegment) (ld.Node, error) { i, err := seg.Index() if err != nil { return nil, ld.ErrInvalidSegmentForList{TypeName: "{{ .PkgName }}.{{ .TypeName }}", TroubleSegment: seg, Reason: err} } return n.LookupByIndex(i) } `, w, g) } func (g ListTraits) EmitNodeMethodMapIterator(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodMapIterator(w) } func (g ListTraits) EmitNodeMethodIsAbsent(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodIsAbsent(w) } func (g ListTraits) EmitNodeMethodIsNull(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodIsNull(w) } func (g ListTraits) EmitNodeMethodAsBool(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodAsBool(w) } func (g ListTraits) EmitNodeMethodAsInt(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodAsInt(w) } func (g ListTraits) EmitNodeMethodAsFloat(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodAsFloat(w) } func (g ListTraits) EmitNodeMethodAsString(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodAsString(w) } func (g ListTraits) EmitNodeMethodAsBytes(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodAsBytes(w) } func (g ListTraits) EmitNodeMethodAsLink(w io.Writer) { kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_List}.emitNodeMethodAsLink(w) } type ListAssemblerTraits struct { PkgName string TypeName string // see doc in kindAssemblerTraitsGenerator AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } func (ListAssemblerTraits) Kind() ld.Kind { return ld.Kind_List } func (g ListAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodBeginMap(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignNull(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignBool(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignInt(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignFloat(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignString(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignBytes(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodAssignLink(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_List}.emitNodeAssemblerMethodPrototype(w) }