28 void sexp_to_stream(SEXP, int32_t type,
bool include_reply =
false);
35 void sendReply(
char reply) {
if (!can_send_reply)
throw std::runtime_error(
"Cannot send a reply at this time, exiting"); can_send_reply =
false; stream.
write(reply); }
36 void allowSendReply() {
if (can_send_reply)
throw std::runtime_error(
"allowSendReply() called twice, exiting"); can_send_reply =
true; }
45 int32_t type = TYPEID<T>();
47 if (registry_sexp_from_stream.count(type) > 0 || registry_sexp_to_stream.count(type) > 0)
48 throw std::runtime_error(
"registerType(): type already registered");
51 T value = stream.
read<T>();
52 return Rcpp::wrap<T>(value);
55 registry_sexp_to_stream[type] = [type] (
RInsideServer &server, SEXP sexp,
bool include_reply) ->
void {
56 T value = Rcpp::as<T>(sexp);
RInsideCallbacks & Rcallbacks
RInsideServer(BinaryStream &stream, RInside &R, RInsideCallbacks &Rcallbacks)
void write(const char *buffer, size_t len)
static void registerDefaultTypes()
void sexp_to_stream(SEXP, int32_t type, bool include_reply=false)
static std::map< int32_t, std::function< SEXP(BinaryStream &)> > registry_sexp_from_stream
const char RIS_REPLY_VALUE
static void registerType()
static std::map< int32_t, std::function< void(RInsideServer &, SEXP, bool)> > registry_sexp_to_stream
void sendReply(char reply)
size_t read(char *buffer, size_t len)