Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Jul 10, 2024
1 parent 036b436 commit 46be1e0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 78 deletions.
10 changes: 5 additions & 5 deletions include/xeus-octave/xinterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class xoctave_interpreter : public xeus::xinterpreter
void configure_impl() override;

void execute_request_impl(
send_reply_callback cb,
int execution_counter,
const std::string& code,
xeus::execute_request_config config,
nl::json user_expressions
send_reply_callback cb,
int execution_counter,
const std::string& code,
xeus::execute_request_config config,
nl::json user_expressions
) override;

nl::json complete_request_impl(std::string const& code, int cursor_pos) override;
Expand Down
121 changes: 53 additions & 68 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include <string_view>

#ifdef __GNUC__
#include <stdio.h>
#include <execinfo.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#endif
Expand All @@ -43,22 +43,24 @@
#ifdef __GNUC__
void handler(int sig)
{
void* array[10];
// get void*'s for all entries on the stack
int size = backtrace(array, 10);
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, STDERR_FILENO);
exit(1);
void* array[10];
// get void*'s for all entries on the stack
int size = backtrace(array, 10);
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, STDERR_FILENO);
exit(1);
}
#endif

std::unique_ptr<xeus::xlogger> make_file_logger(xeus::xlogger::level log_level) {
auto logfile = std::getenv("JUPYTER_LOGFILE");
if (logfile == nullptr) {
return nullptr;
}
return xeus::make_file_logger(log_level, logfile);
std::unique_ptr<xeus::xlogger> make_file_logger(xeus::xlogger::level log_level)
{
auto logfile = std::getenv("JUPYTER_LOGFILE");
if (logfile == nullptr)
{
return nullptr;
}
return xeus::make_file_logger(log_level, logfile);
}

int main(int argc, char* argv[])
Expand All @@ -82,10 +84,10 @@ int main(int argc, char* argv[])
}
#endif

// Registering SIGSEGV handler
// Registering SIGSEGV handler
#ifdef __GNUC__
std::clog << "registering handler for SIGSEGV" << std::endl;
signal(SIGSEGV, handler);
std::clog << "registering handler for SIGSEGV" << std::endl;
signal(SIGSEGV, handler);
#endif

std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();
Expand All @@ -98,57 +100,40 @@ int main(int argc, char* argv[])

if (!connection_filename.empty())
{
xeus::xconfiguration config = xeus::load_configuration(connection_filename);

std::cout << "Instantiating kernel" << std::endl;
auto kernel = xeus::xkernel(
/* config= */ std::move(config),
/* user_name= */ xeus::get_user_name(),
/* context= */ std::move(context),
/* interpreter= */ std::move(interpreter),
/* sbuilder= */ xeus::make_xserver_default,
/* history_manager= */ std::move(hist),
/* logger= */ std::move(logger)
);

std::cout <<
"Starting xoctave kernel...\n\n"
"If you want to connect to this kernel from an other client, you can use"
" the " + connection_filename + " file."
<< std::endl;
kernel.start();
}
else
{
auto kernel = xeus::xkernel(
/* user_name= */ xeus::get_user_name(),
/* context= */ std::move(context),
/* interpreter= */ std::move(interpreter),
/* sbuilder= */ xeus::make_xserver_default
);

std::cout << "Getting config" << std::endl;
const auto& config = kernel.get_config();
std::cout << xeus::get_start_message(config);
// std::cout <<
// "Starting xoctave kernel...\n\n"
// "If you want to connect to this kernel from an other client, just copy"
// " and paste the following content inside of a `kernel.json` file. And then run for example:\n\n"
// "# jupyter console --existing kernel.json\n\n"
// "kernel.json\n```\n{\n"
// " \"transport\": \"" + config.m_transport + "\",\n"
// " \"ip\": \"" + config.m_ip + "\",\n"
// " \"control_port\": " + config.m_control_port + ",\n"
// " \"shell_port\": " + config.m_shell_port + ",\n"
// " \"stdin_port\": " + config.m_stdin_port + ",\n"
// " \"iopub_port\": " + config.m_iopub_port + ",\n"
// " \"hb_port\": " + config.m_hb_port + ",\n"
// " \"signature_scheme\": \"" + config.m_signature_scheme + "\",\n"
// " \"key\": \"" + config.m_key + "\"\n"
// "}\n```"
// << std::endl;
kernel.start();
}
xeus::xconfiguration config = xeus::load_configuration(connection_filename);

std::cout << "Instantiating kernel" << std::endl;
auto kernel = xeus::xkernel(
/* config= */ std::move(config),
/* user_name= */ xeus::get_user_name(),
/* context= */ std::move(context),
/* interpreter= */ std::move(interpreter),
/* sbuilder= */ xeus::make_xserver_default,
/* history_manager= */ std::move(hist),
/* logger= */ std::move(logger)
);

std::cout <<
"Starting xoctave kernel...\n\n"
"If you want to connect to this kernel from an other client, you can use"
" the " + connection_filename + " file."
<< std::endl;
kernel.start();
}
else
{
auto kernel = xeus::xkernel(
/* user_name= */ xeus::get_user_name(),
/* context= */ std::move(context),
/* interpreter= */ std::move(interpreter),
/* sbuilder= */ xeus::make_xserver_default
);

std::cout << "Getting config" << std::endl;
const auto& config = kernel.get_config();
std::cout << xeus::get_start_message(config);
kernel.start();
}

return 0;
}
10 changes: 5 additions & 5 deletions src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@ void fix_parse_error(std::string& evalue, std::string const& code, int line, int
} // namespace

void xoctave_interpreter::execute_request_impl(
send_reply_callback cb,
int execution_count,
const std::string& code,
xeus::execute_request_config config,
nl::json /*user_expressions*/
send_reply_callback cb,
int execution_count,
const std::string& code,
xeus::execute_request_config config,
nl::json /*user_expressions*/
)
{
class parser : public oc::parser
Expand Down

0 comments on commit 46be1e0

Please sign in to comment.