mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-31 03:18:43 -06:00
The test for this does the following: 1. The generated code is checked in 2. Running the test regenerates the generated code 3. Then the test.go is compiled and run This also adds a smoke test for the codegen which just makes sure that we do not fail when we try to generate code. Fixes #90
73 lines
1.7 KiB
Cheetah
73 lines
1.7 KiB
Cheetah
// {{.StructName}}
|
|
|
|
type {{.StructName}} struct {
|
|
l types.List
|
|
}
|
|
|
|
type {{.StructName}}IterCallback (func (p {{.ElemName}}) (stop bool))
|
|
|
|
func New{{.StructName}}() {{.StructName}} {
|
|
return {{.StructName}}{types.NewList()}
|
|
}
|
|
|
|
func {{.StructName}}FromVal(p types.Value) {{.StructName}} {
|
|
return {{.StructName}}{p.(types.List)}
|
|
}
|
|
|
|
func (l {{.StructName}}) NomsValue() types.List {
|
|
return l.l
|
|
}
|
|
|
|
func (l {{.StructName}}) Equals(p {{.StructName}}) bool {
|
|
return l.l.Equals(p.l)
|
|
}
|
|
|
|
func (l {{.StructName}}) Ref() ref.Ref {
|
|
return l.l.Ref()
|
|
}
|
|
|
|
func (l {{.StructName}}) Len() uint64 {
|
|
return l.l.Len()
|
|
}
|
|
|
|
func (l {{.StructName}}) Empty() bool {
|
|
return l.Len() == uint64(0)
|
|
}
|
|
|
|
func (l {{.StructName}}) Get(idx uint64) {{.ElemName}} {
|
|
return {{fromVal .ElemName}}(l.l.Get(idx))
|
|
}
|
|
|
|
func (l {{.StructName}}) Slice(idx uint64, end uint64) {{.StructName}} {
|
|
return {{.StructName}}{l.l.Slice(idx, end)}
|
|
}
|
|
|
|
func (l {{.StructName}}) Set(idx uint64, v {{.ElemName}}) {{.StructName}} {
|
|
return {{.StructName}}{l.l.Set(idx, v{{toVal .ElemName}})}
|
|
}
|
|
|
|
func (l {{.StructName}}) Append(v ...{{.ElemName}}) {{.StructName}} {
|
|
return {{.StructName}}{l.l.Append(l.fromElemSlice(v)...)}
|
|
}
|
|
|
|
func (l {{.StructName}}) Insert(idx uint64, v ...{{.ElemName}}) {{.StructName}} {
|
|
return {{.StructName}}{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
|
}
|
|
|
|
func (l {{.StructName}}) Remove(idx uint64, end uint64) {{.StructName}} {
|
|
return {{.StructName}}{l.l.Remove(idx, end)}
|
|
}
|
|
|
|
func (l {{.StructName}}) RemoveAt(idx uint64) {{.StructName}} {
|
|
return {{.StructName}}{(l.l.RemoveAt(idx))}
|
|
}
|
|
|
|
func (l {{.StructName}}) fromElemSlice(p []{{.ElemName}}) []types.Value {
|
|
r := make([]types.Value, len(p))
|
|
for i, v := range p {
|
|
r[i] = v{{toVal .ElemName}}
|
|
}
|
|
return r
|
|
}
|
|
|