mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
Shell: Correct FdRedirection inheriting from two RefCounted bases
Also add missing calls to `adopt()`.
This commit is contained in:
parent
12af65c1c9
commit
1d08cab9ab
5 changed files with 32 additions and 22 deletions
29
Shell/AST.h
29
Shell/AST.h
|
@ -48,10 +48,11 @@ struct Position {
|
|||
bool contains(size_t offset) const { return start_offset <= offset && offset <= end_offset; }
|
||||
};
|
||||
|
||||
struct FdRedirection;
|
||||
struct Rewiring : public RefCounted<Rewiring> {
|
||||
int source_fd { -1 };
|
||||
int dest_fd { -1 };
|
||||
Rewiring* other_pipe_end { nullptr };
|
||||
FdRedirection* other_pipe_end { nullptr };
|
||||
enum class Close {
|
||||
None,
|
||||
Source,
|
||||
|
@ -67,7 +68,7 @@ struct Rewiring : public RefCounted<Rewiring> {
|
|||
{
|
||||
}
|
||||
|
||||
Rewiring(int source, int dest, Rewiring* other_end, Close close)
|
||||
Rewiring(int source, int dest, FdRedirection* other_end, Close close)
|
||||
: source_fd(source)
|
||||
, dest_fd(dest)
|
||||
, other_pipe_end(other_end)
|
||||
|
@ -121,20 +122,30 @@ private:
|
|||
virtual bool is_path_redirection() const override { return true; }
|
||||
};
|
||||
|
||||
struct FdRedirection : public Redirection
|
||||
, public Rewiring {
|
||||
|
||||
virtual Result<RefPtr<Rewiring>, String> apply() const override { return static_cast<RefPtr<Rewiring>>(this); }
|
||||
struct FdRedirection : public Redirection {
|
||||
virtual Result<RefPtr<Rewiring>, String> apply() const override
|
||||
{
|
||||
return RefPtr<Rewiring>(adopt(*new Rewiring(source_fd, dest_fd, other_pipe_end, action)));
|
||||
}
|
||||
virtual ~FdRedirection();
|
||||
FdRedirection(int source, int dest, Rewiring::Close close)
|
||||
: Rewiring(source, dest, close)
|
||||
: FdRedirection(source, dest, nullptr, close)
|
||||
{
|
||||
}
|
||||
FdRedirection(int source, int dest, Rewiring* pipe_end, Rewiring::Close close)
|
||||
: Rewiring(source, dest, pipe_end, close)
|
||||
|
||||
FdRedirection(int source, int dest, FdRedirection* pipe_end, Rewiring::Close close)
|
||||
: source_fd(source)
|
||||
, dest_fd(dest)
|
||||
, other_pipe_end(pipe_end)
|
||||
, action(close)
|
||||
{
|
||||
}
|
||||
|
||||
int source_fd { -1 };
|
||||
int dest_fd { -1 };
|
||||
FdRedirection* other_pipe_end { nullptr };
|
||||
Rewiring::Close action { Rewiring::Close::None };
|
||||
|
||||
private:
|
||||
virtual bool is_fd_redirection() const override { return true; }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue