-
Notifications
You must be signed in to change notification settings - Fork 36
Initial merge with xeus-clang-repl - Capture outputs #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JohanMabille
merged 50 commits into
compiler-research:main
from
alexander-penev:MergeXeusClangReplMini
Apr 19, 2024
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
f806a62
Initial merge with xeus-clang-repl
alexander-penev 206b3de
Update kernel.json.in
alexander-penev c56bee2
Update kernel.json.in
alexander-penev 30b1eeb
Update kernel.json.in
alexander-penev b52b514
Update main.cpp
alexander-penev a96818e
Update CMakeLists.txt
alexander-penev f0f188c
Update CMakeLists.txt
alexander-penev 3f5349e
Update CMakeLists.txt
alexander-penev aef6ae5
Delete src/xmagics/pythonexec.cpp
alexander-penev ce859d9
Delete src/xmagics/pythonexec.hpp
alexander-penev 7bcbbb8
Update xinterpreter.cpp
alexander-penev 089d4a5
Update pytest.ini
alexander-penev 6dc91c5
Update xinterpreter.cpp
alexander-penev 733a979
Update xinterpreter.cpp
alexander-penev b0678a3
Update xinterpreter.cpp
alexander-penev 86f53dc
Update main.yml
alexander-penev 57c468f
Update main.yml
alexander-penev f2f99e8
Update xinterpreter.cpp
alexander-penev d9deba6
Update xinterpreter.cpp
alexander-penev f1e5a1e
Update xinterpreter.cpp
alexander-penev 568cd82
Update main.yml
alexander-penev 9dfcb52
Restore original
alexander-penev 576347b
Restore original 1
alexander-penev c6b13cc
Restore original 2
alexander-penev 7cdd306
Update xinterpreter.cpp
alexander-penev 829a844
Update environment.yml
alexander-penev 22af61d
Fix error messages formatting
alexander-penev b2ea844
Add more tests
alexander-penev 14f6d6d
Add more tests
alexander-penev 90a980c
Disable some tests
alexander-penev 770871c
Debug 1
alexander-penev 67f3b77
Debug 2
alexander-penev 0492fe9
Debug 3
alexander-penev f2b1432
Debug 4
alexander-penev 26f2929
Debug 5
alexander-penev 7cb5381
Debug 6
alexander-penev f719d9c
Debug 7
alexander-penev 721f778
Debug 8
alexander-penev 085efd2
Debug 8
alexander-penev 4a4444d
Cleanup
alexander-penev d68f4cd
Update main.yml
alexander-penev c8a02b8
Update test_xcpp_kernel.py
alexander-penev be05220
Update test_xcpp_kernel.py
alexander-penev 388ed38
Update xinterpreter.cpp
alexander-penev 71ec37a
Update xinterpreter.cpp
alexander-penev 71931e6
Clean
alexander-penev dec3301
Update src/xinterpreter.cpp
alexander-penev c01b67f
Apply suggestions from code review
alexander-penev 7a8cf17
Update xinterpreter.cpp
alexander-penev 28367af
Fix
alexander-penev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ name: xeus-cpp | |
channels: | ||
- conda-forge | ||
dependencies: | ||
- xeus-cpp=0.0.1 | ||
- xeus-cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,19 @@ using namespace std::placeholders; | |
|
||
namespace xcpp | ||
{ | ||
struct StreamRedirectRAII { | ||
std::string &err; | ||
StreamRedirectRAII(std::string &e) : err(e) { | ||
Cpp::BeginStdStreamCapture(Cpp::kStdErr); | ||
Cpp::BeginStdStreamCapture(Cpp::kStdOut); | ||
} | ||
~StreamRedirectRAII() { | ||
std::string out = Cpp::EndStdStreamCapture(); | ||
err = Cpp::EndStdStreamCapture(); | ||
std::cout << out; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably print out where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's address that in a separate PR. |
||
} | ||
}; | ||
|
||
void interpreter::configure_impl() | ||
{ | ||
xeus::register_interpreter(this); | ||
|
@@ -153,28 +166,32 @@ __get_cxx_version () | |
std::cerr.rdbuf(&null); | ||
} | ||
|
||
std::string err; | ||
|
||
// Attempt normal evaluation | ||
try | ||
{ | ||
StreamRedirectRAII R(err); | ||
compilation_result = Cpp::Process(code.c_str()); | ||
} | ||
catch (std::exception& e) | ||
{ | ||
errorlevel = 1; | ||
ename = "Standard Exception :"; | ||
ename = "Standard Exception: "; | ||
evalue = e.what(); | ||
} | ||
catch (...) | ||
{ | ||
errorlevel = 1; | ||
ename = "Error :"; | ||
ename = "Error: "; | ||
} | ||
|
||
if (compilation_result) | ||
{ | ||
errorlevel = 1; | ||
ename = "Error :"; | ||
evalue = "Compilation error!"; | ||
ename = "Error: "; | ||
evalue = "Compilation error! " + err; | ||
std::cerr << err; | ||
} | ||
|
||
// Flush streams | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.