Files
jak-project/common/repl/nrepl/ReplClient.cpp
T
Tyler Wilding 00ac12094e goalc/repl: cleanup of goalc/REPL code and some QoL improvements (#2104)
- lets you split up your `startup.gc` file into two sections
  - one that runs on initial startup / reloads
  - the other that runs when you listen to a target
- allows for customization of the keybinds added a month or so ago
- removes a useless flag (--startup-cmd) and marks others for
deprecation.
- added another help prompt that lists all the keybinds and what they do

Co-authored-by: water <awaterford111445@gmail.com>
2023-01-07 11:24:02 -05:00

37 lines
841 B
C++

// clang-format off
#include "ReplClient.h"
#include "common/cross_sockets/XSocket.h"
#include "common/versions.h"
#include "third-party/fmt/core.h"
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinSock2.h>
#include <WS2tcpip.h>
#endif
// clang-format on
void ReplClient::eval(std::string form) {
if (!is_connected()) {
return;
}
// TODO - split this up into two writes
u32 dataLength = form.length();
ReplServerHeader header = {dataLength, ReplServerMessageType::EVAL};
auto const ptr = reinterpret_cast<char*>(&header);
std::vector<char> buffer(ptr, ptr + sizeof header);
buffer.insert(buffer.end(), form.begin(), form.end());
int result = write_to_socket(client_socket, buffer.data(), buffer.size());
if (result == -1) {
// TODO - log
disconnect();
}
}