2021-11-01 03:31:24 -07:00
|
|
|
#include "codon.h"
|
2021-11-05 15:26:32 -07:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <fcntl.h>
|
2021-11-01 03:31:24 -07:00
|
|
|
#include <iostream>
|
|
|
|
#include <nlohmann/json.hpp>
|
2021-11-05 15:26:32 -07:00
|
|
|
#include <unistd.h>
|
2021-11-01 03:31:24 -07:00
|
|
|
#include <xeus/xhelper.hpp>
|
|
|
|
|
|
|
|
using std::move;
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace nl = nlohmann;
|
|
|
|
|
|
|
|
namespace codon {
|
|
|
|
|
|
|
|
nl::json CodonJupyter::execute_request_impl(int execution_counter, const string &code,
|
|
|
|
bool silent, bool store_history,
|
|
|
|
nl::json user_expressions,
|
|
|
|
bool allow_stdin) {
|
2021-11-05 15:26:32 -07:00
|
|
|
auto err = jit->exec(code);
|
2021-11-01 03:31:24 -07:00
|
|
|
nl::json pub_data;
|
|
|
|
pub_data["text/plain"] = "Hello World !!";
|
|
|
|
publish_execution_result(execution_counter, move(pub_data), nl::json::object());
|
|
|
|
// publish_execution_error("TypeError", "123", {"!@#$", "*(*"});
|
|
|
|
return xeus::create_successful_reply();
|
|
|
|
}
|
|
|
|
|
2021-11-05 15:26:32 -07:00
|
|
|
void CodonJupyter::configure_impl() {
|
|
|
|
jit = std::make_unique<codon::jit::JIT>("");
|
|
|
|
llvm::cantFail(jit->init());
|
|
|
|
}
|
2021-11-01 03:31:24 -07:00
|
|
|
|
|
|
|
nl::json CodonJupyter::complete_request_impl(const string &code, int cursor_pos) {
|
|
|
|
return xeus::create_complete_reply({}, cursor_pos, cursor_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
nl::json CodonJupyter::inspect_request_impl(const string &code, int cursor_pos,
|
|
|
|
int detail_level) {
|
|
|
|
return xeus::create_inspect_reply();
|
|
|
|
}
|
|
|
|
|
|
|
|
nl::json CodonJupyter::is_complete_request_impl(const string &code) {
|
|
|
|
return xeus::create_is_complete_reply("complete");
|
|
|
|
}
|
|
|
|
|
|
|
|
nl::json CodonJupyter::kernel_info_request_impl() {
|
|
|
|
return xeus::create_info_reply("", "codon_kernel", "0.1.0", "python", "3.7",
|
|
|
|
"text/x-python", ".seq");
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodonJupyter::shutdown_request_impl() {}
|
|
|
|
|
|
|
|
} // namespace codon
|