Commit fbc10cb8 authored by Eric Myhre's avatar Eric Myhre

Move minima/thunks to own file in gen.

This was triggered by an experiment about generating even more 'minima'
like this, such as a batch of helper structs which would hold all the
common "no, you can't do operation X on something of kind Y" methods.
However, that diff isn't here; and is probably going to turn out to be
abandoned, because after trying it out, I found that it was pretty hard
to do good error messages (which... was pretty central to the point)
with that approach.  So, more on those attempts later.
Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent 1392c36d
package gengo
import (
"io"
)
func emitMinima(f io.Writer) {
emitFileHeader(f)
// Iterator rejection thunks.
f.Write([]byte(`
type mapIteratorReject struct{ err error }
type listIteratorReject struct{ err error }
func (itr mapIteratorReject) Next() (ipld.Node, ipld.Node, error) { return nil, nil, itr.err }
func (itr mapIteratorReject) Done() bool { return false }
func (itr listIteratorReject) Next() (int, ipld.Node, error) { return -1, nil, itr.err }
func (itr listIteratorReject) Done() bool { return false }
`))
}
......@@ -36,18 +36,8 @@ func TestNuevo(t *testing.T) {
tg.EmitNodeMethodNodeBuilder(w)
}
f := openOrPanic("_test/thunks.go")
emitFileHeader(f)
doTemplate(`
type mapIteratorReject struct{ err error }
type listIteratorReject struct{ err error }
func (itr mapIteratorReject) Next() (ipld.Node, ipld.Node, error) { return nil, nil, itr.err }
func (itr mapIteratorReject) Done() bool { return false }
func (itr listIteratorReject) Next() (int, ipld.Node, error) { return -1, nil, itr.err }
func (itr listIteratorReject) Done() bool { return false }
`, f, nil)
f := openOrPanic("_test/minima.go")
emitMinima(f)
f = openOrPanic("_test/tStrang.go")
emitFileHeader(f)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment