Mercurial > jwe > qt-gui-with-push-parser
annotate qt-interpreter.cpp @ 7:04867eba6428
function objects and signals/slots for errors and results
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 May 2019 09:27:09 -0400 |
parents | 1b575145197e |
children | 1e5a1e15fa56 |
rev | line source |
---|---|
7
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
1 #include <iostream> |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 #include <sstream> |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 |
5
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
4 #include <QString> |
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
5 |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 #include "gui-main.h" |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 #include "interpreter.h" |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 #include "qt-interpreter.h" |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 #include <readline/readline.h> |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 #include <readline/history.h> |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 namespace calc |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 { |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 qt_interpreter::qt_interpreter (void) |
6
1b575145197e
interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
16 : m_interpreter () |
7
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
17 { |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
18 m_interpreter.set_error_handler ([this] (const char *msg) |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
19 { emit this->error_signal (msg); }); |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
20 |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
21 m_interpreter.set_result_handler ([this] (double value) |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
22 { emit this->result_ready (value); }); |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
6
diff
changeset
|
23 } |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 void qt_interpreter::execute (void) |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 { |
5
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
27 } |
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
28 |
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
29 void qt_interpreter::accept_input_line (const QString& line) |
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
30 { |
6
1b575145197e
interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
31 m_interpreter.parse_and_execute (line.toStdString ()); |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 } |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 } |