lots of work on determinism in the linux driver.

This commit is contained in:
2022-02-18 03:59:21 -05:00
parent 6a6d2c7f75
commit ba1e923b5a
10 changed files with 175 additions and 110 deletions

View File

@@ -132,20 +132,6 @@ public:
//
std::string error() const { return error_; }
// True if the channel is in readline mode.
//
// Stdio always starts with this enabled, other channels always start
// with this disabled.
//
bool readline_enabled() const { return readline_enabled_; }
// Put the channel into readline mode.
//
// Caution: the channel better be coming from a raw tty, otherwise,
// this is going to produce weird results.
//
void set_readline(bool enabled);
// Set the prompt for readline mode.
//
void set_prompt(const std::string &prompt);
@@ -164,10 +150,11 @@ private:
//
void feed_readline(int nbytes, const char *bytes);
void peek_outgoing(int *nbytes, const char **bytes);
void peek_outgoing(int *nbytes, const char **bytes) const;
void sent_outgoing(int nbytes);
void erase_command();
void echo_command();
void pump_readline();
private:
static const int READLINE_MAX=512;
@@ -177,9 +164,9 @@ private:
std::shared_ptr<StreamBuffer> sb_in_;
std::shared_ptr<StreamBuffer> sb_out_;
// In readline mode, we inject tty echoes into the output stream.
// If this is stdio, we inject tty echoes into the output stream.
// This buffer holds the users output interleaved with the tty echoes.
// In non-readline mode, this is just another pointer to sb_out.
// In any other channel, this is just another pointer to sb_out.
std::shared_ptr<StreamBuffer> sb_drvout_;
int port_;
@@ -188,13 +175,12 @@ private:
std::string target_;
bool stop_driver_;
// Readline stuff.
// Readline stuff. Only used on channel 0 (stdio).
std::string desired_command_;
std::string current_command_;
std::string desired_prompt_;
std::string current_prompt_;
char readline_lastc_;
bool readline_enabled_;
friend class DrivenEngine;
};
@@ -374,8 +360,7 @@ public:
// Set the lua source code. The driver is expected to read the lua source
// code and store it (using this function) once before invoking
//
void drv_add_lua_source(const char *fn, const char *data);
void drv_set_lua_source(util::LuaSourcePtr source);
void drv_add_lua_source(std::string_view fn, std::string_view data);
// Invoke the init or update event.
//