Inverted control flow, engine as library

This commit is contained in:
2021-10-04 17:45:18 -04:00
parent e0fdb2d42f
commit bc22dc89af
15 changed files with 387 additions and 136 deletions

View File

@@ -111,6 +111,19 @@ void StreamBuffer::clear() {
lua_reader_size_ = 0;
}
std::string StreamBuffer::readline() {
char *p = read_cursor_;
while ((p < write_cursor_) && (*p != '\n')) p++;
if (p == write_cursor_) {
return "";
} else {
p++;
std::string result(read_cursor_, p - read_cursor_);
read_cursor_ = p;
return result;
}
}
// These routines return true if you can losslessly cast the
// specified value to the specified type.