// Read takes in a pair of channels for the interpreter, a reader stream and // reads the input file content. func Read(pipes *plumbing.Pipes, stream io.Reader) { input := &input{ receive: pipes.FromInterpreter(), send: pipes.ToInterpreter(), stream: stream, } input.read() }
// Write takes in a pair of channels for the interpreter, a writer stream and // writes JSON output. func Write(pipes *plumbing.Pipes, stream io.Writer) { output := &output{ receive: pipes.FromInterpreter(), send: pipes.ToInterpreter(), stream: stream, } output.write() }
func unlockInterpreter(pipes *plumbing.Pipes) { select { case r := <-pipes.FromInterpreter(): switch r.Type { case plumbing.ReadyP: pipes.ToInterpreter() <- &plumbing.Frontend{ Type: plumbing.ReadyT, } } } }
func fakeInterpreter(pipes *plumbing.Pipes) { receive := pipes.FromInterpreter() send := pipes.ToInterpreter() <-send q := *ast.NewQuestionNode("A question", "Q1", new(ast.ScalarQuestion), *new(scanner.Position)) receive <- &plumbing.Frontend{ Type: plumbing.UpdateQuestion, Identifier: q.Identifier(), Label: q.Label(), FieldType: q.Type(), Value: "No", } receive <- &plumbing.Frontend{ Type: plumbing.Flush, } }
func fakeInterpreter(pipes *plumbing.Pipes, expectedAnswers chan map[string]string) { receive := pipes.FromInterpreter() send := pipes.ToInterpreter() go func(receive chan *plumbing.Frontend) { for { receive <- &plumbing.Frontend{ Type: plumbing.Flush, } } }(receive) go func(send chan *plumbing.Frontend, expectedAnswers chan map[string]string) { for { r := <-send if r.Type == plumbing.Answers { expectedAnswers <- r.Answers } } }(send, expectedAnswers) }
func launchGUI(pipes *plumbing.Pipes, guiAppName string) { driver := graphic.GUI(guiAppName) frontend.New(pipes.FromInterpreter(), pipes.ToInterpreter(), driver) driver.Loop() }