示例#1
0
// 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()
}
示例#2
0
// 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()
}
示例#3
0
func unlockInterpreter(pipes *plumbing.Pipes) {
	select {
	case r := <-pipes.FromInterpreter():
		switch r.Type {
		case plumbing.ReadyP:
			pipes.ToInterpreter() <- &plumbing.Frontend{
				Type: plumbing.ReadyT,
			}
		}
	}
}
示例#4
0
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,
	}
}
示例#5
0
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)
}
示例#6
0
func launchGUI(pipes *plumbing.Pipes, guiAppName string) {
	driver := graphic.GUI(guiAppName)
	frontend.New(pipes.FromInterpreter(), pipes.ToInterpreter(), driver)
	driver.Loop()
}