mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Clean up the io_chain_t interface
This commit is contained in:
parent
371f67f1b5
commit
b00f039489
4 changed files with 12 additions and 18 deletions
|
@ -1106,7 +1106,7 @@ static int exec_subshell_internal(const wcstring &cmd, parser_t &parser, wcstrin
|
|||
io_buffer_t::create(STDOUT_FILENO, io_chain_t(), is_subcmd ? read_byte_limit : 0));
|
||||
if (io_buffer.get() != NULL) {
|
||||
parser_t &parser = parser_t::principal_parser();
|
||||
if (parser.eval(cmd, io_chain_t(io_buffer), SUBST) == 0) {
|
||||
if (parser.eval(cmd, io_chain_t{io_buffer}, SUBST) == 0) {
|
||||
subcommand_status = proc_get_last_status();
|
||||
}
|
||||
|
||||
|
|
|
@ -920,7 +920,7 @@ static void test_parser() {
|
|||
|
||||
static void test_1_cancellation(const wchar_t *src) {
|
||||
shared_ptr<io_buffer_t> out_buff(io_buffer_t::create(STDOUT_FILENO, io_chain_t()));
|
||||
const io_chain_t io_chain(out_buff);
|
||||
const io_chain_t io_chain{out_buff};
|
||||
pthread_t thread = pthread_self();
|
||||
double delay = 0.25 /* seconds */;
|
||||
iothread_perform([=]() {
|
||||
|
|
17
src/io.cpp
17
src/io.cpp
|
@ -120,15 +120,15 @@ void io_chain_t::remove(const shared_ptr<const io_data_t> &element) {
|
|||
}
|
||||
}
|
||||
|
||||
void io_chain_t::push_back(const shared_ptr<io_data_t> &element) {
|
||||
void io_chain_t::push_back(shared_ptr<io_data_t> element) {
|
||||
// Ensure we never push back NULL.
|
||||
assert(element.get() != NULL);
|
||||
std::vector<shared_ptr<io_data_t> >::push_back(element);
|
||||
assert(element.get() != nullptr);
|
||||
std::vector<shared_ptr<io_data_t> >::push_back(std::move(element));
|
||||
}
|
||||
|
||||
void io_chain_t::push_front(const shared_ptr<io_data_t> &element) {
|
||||
assert(element.get() != NULL);
|
||||
this->insert(this->begin(), element);
|
||||
void io_chain_t::push_front(shared_ptr<io_data_t> element) {
|
||||
assert(element.get() != nullptr);
|
||||
this->insert(this->begin(), std::move(element));
|
||||
}
|
||||
|
||||
void io_chain_t::append(const io_chain_t &chain) {
|
||||
|
@ -253,8 +253,3 @@ shared_ptr<const io_data_t> io_chain_get(const io_chain_t &src, int fd) {
|
|||
}
|
||||
|
||||
shared_ptr<io_data_t> io_chain_get(io_chain_t &src, int fd) { return src.get_io_for_fd(fd); }
|
||||
|
||||
io_chain_t::io_chain_t(const shared_ptr<io_data_t> &data)
|
||||
: std::vector<shared_ptr<io_data_t> >(1, data) {}
|
||||
|
||||
io_chain_t::io_chain_t() : std::vector<shared_ptr<io_data_t> >() {}
|
||||
|
|
9
src/io.h
9
src/io.h
|
@ -270,14 +270,13 @@ class io_buffer_t : public io_pipe_t {
|
|||
size_t buffer_limit = 0);
|
||||
};
|
||||
|
||||
class io_chain_t : public std::vector<shared_ptr<io_data_t> > {
|
||||
class io_chain_t : public std::vector<shared_ptr<io_data_t>> {
|
||||
public:
|
||||
io_chain_t();
|
||||
explicit io_chain_t(const shared_ptr<io_data_t> &);
|
||||
using std::vector<shared_ptr<io_data_t>>::vector;
|
||||
|
||||
void remove(const shared_ptr<const io_data_t> &element);
|
||||
void push_back(const shared_ptr<io_data_t> &element);
|
||||
void push_front(const shared_ptr<io_data_t> &element);
|
||||
void push_back(shared_ptr<io_data_t> element);
|
||||
void push_front(shared_ptr<io_data_t> element);
|
||||
void append(const io_chain_t &chain);
|
||||
|
||||
shared_ptr<const io_data_t> get_io_for_fd(int fd) const;
|
||||
|
|
Loading…
Reference in a new issue