Changeset View
Changeset View
Standalone View
Standalone View
src/backends/julia/juliaexpression.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | This program is free software; you can redistribute it and/or | ||||
3 | modify it under the terms of the GNU General Public License | ||||
4 | as published by the Free Software Foundation; either version 2 | ||||
5 | of the License, or (at your option) any later version. | ||||
6 | | ||||
7 | This program is distributed in the hope that it will be useful, | ||||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
10 | GNU General Public License for more details. | ||||
11 | | ||||
12 | You should have received a copy of the GNU General Public License | ||||
13 | along with this program; if not, write to the Free Software | ||||
14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
15 | Boston, MA 02110-1301, USA. | ||||
16 | | ||||
17 | --- | ||||
18 | Copyright (C) 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com> | ||||
19 | */ | ||||
20 | #include "juliaexpression.h" | ||||
21 | | ||||
22 | #include "juliasession.h" | ||||
23 | #include "textresult.h" | ||||
24 | | ||||
25 | JuliaExpression::JuliaExpression(Cantor::Session *session) | ||||
26 | : Cantor::Expression(session) | ||||
27 | { | ||||
28 | } | ||||
29 | | ||||
30 | void JuliaExpression::evaluate() | ||||
31 | { | ||||
32 | setStatus(Cantor::Expression::Computing); | ||||
33 | dynamic_cast<JuliaSession *>(session())->runExpression(this); | ||||
34 | } | ||||
35 | | ||||
36 | void JuliaExpression::finalize() | ||||
37 | { | ||||
38 | auto juliaSession = dynamic_cast<JuliaSession *>(session()); | ||||
39 | setErrorMessage( | ||||
40 | juliaSession->getError() | ||||
41 | .replace(QLatin1String("\n"), QLatin1String("<br>")) | ||||
42 | ); | ||||
43 | if (juliaSession->getWasException()) { | ||||
44 | setStatus(Cantor::Expression::Error); | ||||
45 | } else { | ||||
46 | setResult(new Cantor::TextResult(juliaSession->getOutput())); | ||||
47 | setStatus(Cantor::Expression::Done); | ||||
48 | } | ||||
49 | } | ||||
50 | | ||||
51 | void JuliaExpression::interrupt() | ||||
52 | { | ||||
53 | setStatus(Cantor::Expression::Interrupted); | ||||
54 | } | ||||
55 | | ||||
56 | #include "juliaexpression.moc" |