28
28
#include " xinput.hpp"
29
29
#include " xinspect.hpp"
30
30
#include " xmagics/os.hpp"
31
+ #include " xmime_internal.hpp"
31
32
#include " xparser.hpp"
32
33
#include " xsystem.hpp"
33
34
@@ -128,7 +129,7 @@ __get_cxx_version ()
128
129
129
130
void interpreter::execute_request_impl (
130
131
send_reply_callback cb,
131
- int /* execution_count */ ,
132
+ int execution_counter ,
132
133
const std::string& code,
133
134
xeus::execute_request_config config,
134
135
nl::json /* user_expressions*/
@@ -153,7 +154,9 @@ __get_cxx_version ()
153
154
auto errorlevel = 0 ;
154
155
std::string ename;
155
156
std::string evalue;
156
- bool compilation_result = false ;
157
+ // bool compilation_result = false;
158
+ intptr_t output_value;
159
+ bool hadError = false ;
157
160
158
161
// If silent is set to true, temporarily dismiss all std::cerr and
159
162
// std::cout outputs resulting from `process_code`.
@@ -174,7 +177,7 @@ __get_cxx_version ()
174
177
try
175
178
{
176
179
StreamRedirectRAII R (err);
177
- compilation_result = Cpp::Process (code.c_str ());
180
+ output_value = Cpp::Evaluate (code.c_str (), &hadError );
178
181
}
179
182
catch (std::exception & e)
180
183
{
@@ -188,7 +191,7 @@ __get_cxx_version ()
188
191
ename = " Error: " ;
189
192
}
190
193
191
- if (compilation_result )
194
+ if (hadError )
192
195
{
193
196
errorlevel = 1 ;
194
197
ename = " Error: " ;
@@ -233,15 +236,12 @@ __get_cxx_version ()
233
236
}
234
237
else
235
238
{
236
- /*
237
- // Publish a mime bundle for the last return value if
238
- // the semicolon was omitted.
239
- if (!config.silent && output.hasValue() && trim(code).back() != ';')
240
- {
241
- nl::json pub_data = mime_repr(output);
242
- publish_execution_result(execution_counter, std::move(pub_data), nl::json::object());
243
- }
244
- */
239
+ // Publish a mime bundle for the last return value if
240
+ // the semicolon was omitted.
241
+ if (!config.silent && !hadError && trim (code).back () != ' ;' ) {
242
+ nl::json pub_data = mime_repr (output_value);
243
+ publish_execution_result (execution_counter, std::move (pub_data), nl::json::object ());
244
+ }
245
245
// Compose execute_reply message.
246
246
kernel_res[" status" ] = " ok" ;
247
247
kernel_res[" payload" ] = nl::json::array ();
0 commit comments