Convert io_buffer_create to static io_buffer_t::create, make io_buffer_t constructor private

This commit is contained in:
Cheer Xiao 2013-01-15 17:07:30 +08:00
parent 0f443ef37b
commit 9057801c4b
4 changed files with 20 additions and 20 deletions

View file

@ -801,7 +801,7 @@ void exec(parser_t &parser, job_t *j)
if (p->next)
{
io_buffer.reset(io_buffer_create(0));
io_buffer.reset(io_buffer_t::create(0));
j->io.push_back(io_buffer);
}
@ -818,7 +818,7 @@ void exec(parser_t &parser, job_t *j)
{
if (p->next)
{
io_buffer.reset(io_buffer_create(0));
io_buffer.reset(io_buffer_t::create(0));
j->io.push_back(io_buffer);
}
@ -1409,7 +1409,7 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst)
is_subshell=1;
const shared_ptr<io_buffer_t> io_buffer(io_buffer_create(0));
const shared_ptr<io_buffer_t> io_buffer(io_buffer_t::create(0));
prev_status = proc_get_last_status();

2
io.cpp
View file

@ -130,7 +130,7 @@ void io_buffer_read(io_buffer_t *d)
}
io_buffer_t *io_buffer_create(bool is_input)
io_buffer_t *io_buffer_t::create(bool is_input)
{
bool success = true;
io_buffer_t *buffer_redirect = new io_buffer_t(is_input ? 0 : 1);

28
io.h
View file

@ -119,15 +119,15 @@ private:
/** buffer to save output in */
shared_ptr<std::vector<char> > out_buffer;
public:
virtual void print() const;
io_buffer_t(int f):
io_data_t(IO_BUFFER, f),
out_buffer()
{
}
public:
virtual void print() const;
~io_buffer_t();
/** Function to create the output buffer */
@ -162,6 +162,17 @@ public:
assert(out_buffer.get() != NULL);
return out_buffer->size();
}
/**
Create a IO_BUFFER type io redirection, complete with a pipe and a
vector<char> for output. The default file descriptor used is 1 for
output buffering and 0 for input buffering.
\param is_input set this parameter to zero if the buffer should be
used to buffer the output of a command, or non-zero to buffer the
input to a command.
*/
static io_buffer_t *create(bool is_input);
};
class io_chain_t : public std::vector<shared_ptr<io_data_t> >
@ -201,17 +212,6 @@ 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);
/**
Create a IO_BUFFER type io redirection, complete with a pipe and a
vector<char> for output. The default file descriptor used is 1 for
output buffering and 0 for input buffering.
\param is_input set this parameter to zero if the buffer should be
used to buffer the output of a command, or non-zero to buffer the
input to a command.
*/
io_buffer_t *io_buffer_create(bool is_input);
/**
Close output pipe, and read from input pipe until eof.
*/

View file

@ -1064,7 +1064,7 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector<c
is_quoted?L"-q":L"",
prefix_esc.c_str());
shared_ptr<io_buffer_t> in(io_buffer_create(true));
shared_ptr<io_buffer_t> in(io_buffer_t::create(true));
in->fd = 3;
escaped_separator = escape(COMPLETE_SEP_STR, 1);
@ -1133,7 +1133,7 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector<c
term_donate();
shared_ptr<io_buffer_t> out(io_buffer_create(false));
shared_ptr<io_buffer_t> out(io_buffer_t::create(false));
out->fd = 4;
parser_t &parser = parser_t::principal_parser();