1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

AK: Rename adopt() to adopt_ref()

This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
This commit is contained in:
Andreas Kling 2021-04-23 16:46:57 +02:00
parent b3db01e20e
commit b91c49364d
228 changed files with 461 additions and 461 deletions

View file

@ -829,7 +829,7 @@ RefPtr<Value> CloseFdRedirection::run(RefPtr<Shell>)
{
Command command;
command.position = position();
command.redirections.append(adopt(*new CloseRedirection(m_fd)));
command.redirections.append(adopt_ref(*new CloseRedirection(m_fd)));
return create<CommandValue>(move(command));
}
@ -3249,7 +3249,7 @@ ListValue::ListValue(Vector<String> values)
return;
m_contained_values.ensure_capacity(values.size());
for (auto& str : values)
m_contained_values.append(adopt(*new StringValue(move(str))));
m_contained_values.append(adopt_ref(*new StringValue(move(str))));
}
NonnullRefPtr<Value> Value::with_slices(NonnullRefPtr<Slice> slice) const&
@ -3447,7 +3447,7 @@ Vector<String> TildeValue::resolve_as_list(RefPtr<Shell> shell)
Result<NonnullRefPtr<Rewiring>, String> CloseRedirection::apply() const
{
return adopt(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseNew));
return adopt_ref(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseNew));
}
CloseRedirection::~CloseRedirection()
@ -3462,7 +3462,7 @@ Result<NonnullRefPtr<Rewiring>, String> PathRedirection::apply() const
dbgln("open() failed for '{}' with {}", path, error);
return error;
}
return adopt(*new Rewiring(fd, my_fd, Rewiring::Close::Old));
return adopt_ref(*new Rewiring(fd, my_fd, Rewiring::Close::Old));
};
switch (direction) {
case AST::PathRedirection::WriteAppend:

View file

@ -24,13 +24,13 @@ namespace Shell::AST {
template<typename T, typename... Args>
static inline NonnullRefPtr<T> create(Args... args)
{
return adopt(*new T(args...));
return adopt_ref(*new T(args...));
}
template<typename T>
static inline NonnullRefPtr<T> create(std::initializer_list<NonnullRefPtr<Value>> arg)
{
return adopt(*new T(arg));
return adopt_ref(*new T(arg));
}
struct HighlightMetadata {
@ -122,7 +122,7 @@ struct PathRedirection : public Redirection {
static NonnullRefPtr<PathRedirection> create(String path, int fd, decltype(direction) direction)
{
return adopt(*new PathRedirection(move(path), fd, direction));
return adopt_ref(*new PathRedirection(move(path), fd, direction));
}
virtual Result<NonnullRefPtr<Rewiring>, String> apply() const override;
@ -143,19 +143,19 @@ struct FdRedirection : public Redirection {
public:
static NonnullRefPtr<FdRedirection> create(int old_fd, int new_fd, Rewiring::Close close)
{
return adopt(*new FdRedirection(old_fd, new_fd, close));
return adopt_ref(*new FdRedirection(old_fd, new_fd, close));
}
static NonnullRefPtr<FdRedirection> create(int old_fd, int new_fd, FdRedirection* pipe_end, Rewiring::Close close)
{
return adopt(*new FdRedirection(old_fd, new_fd, pipe_end, close));
return adopt_ref(*new FdRedirection(old_fd, new_fd, pipe_end, close));
}
virtual ~FdRedirection();
virtual Result<NonnullRefPtr<Rewiring>, String> apply() const override
{
return adopt(*new Rewiring(old_fd, new_fd, other_pipe_end, action));
return adopt_ref(*new Rewiring(old_fd, new_fd, other_pipe_end, action));
}
int old_fd { -1 };

View file

@ -767,7 +767,7 @@ int Shell::builtin_shift(int argc, const char** argv)
}
if (!argv_->is_list())
argv_ = adopt(*new AST::ListValue({ argv_.release_nonnull() }));
argv_ = adopt_ref(*new AST::ListValue({ argv_.release_nonnull() }));
auto& values = static_cast<AST::ListValue*>(argv_.ptr())->values();
if ((size_t)count > values.size()) {

View file

@ -27,7 +27,7 @@ struct LocalFrame;
class Job : public RefCounted<Job> {
public:
static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt(*new Job(pid, pgid, move(cmd), job_id, move(command))); }
static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt_ref(*new Job(pid, pgid, move(cmd), job_id, move(command))); }
~Job()
{

View file

@ -84,7 +84,7 @@ bool Parser::expect(const StringView& expected)
template<typename A, typename... Args>
NonnullRefPtr<A> Parser::create(Args... args)
{
return adopt(*new A(AST::Position { m_rule_start_offsets.last(), m_offset, m_rule_start_lines.last(), line() }, args...));
return adopt_ref(*new A(AST::Position { m_rule_start_offsets.last(), m_offset, m_rule_start_lines.last(), line() }, args...));
}
[[nodiscard]] OwnPtr<Parser::ScopedOffset> Parser::push_start()

View file

@ -297,9 +297,9 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands
subcommand_ast = ast->command();
}
auto subcommand_nonnull = subcommand_ast.release_nonnull();
NonnullRefPtr<AST::Node> substitute = adopt(*new AST::Join(subcommand_nonnull->position(),
NonnullRefPtr<AST::Node> substitute = adopt_ref(*new AST::Join(subcommand_nonnull->position(),
subcommand_nonnull,
adopt(*new AST::CommandLiteral(subcommand_nonnull->position(), command))));
adopt_ref(*new AST::CommandLiteral(subcommand_nonnull->position(), command))));
auto res = substitute->run(*this);
for (auto& subst_command : res->resolve_as_commands(*this)) {
if (!subst_command.argv.is_empty() && subst_command.argv.first() == argv0) // Disallow an alias resolving to itself.
@ -356,7 +356,7 @@ RefPtr<AST::Value> Shell::lookup_local_variable(const String& name)
RefPtr<AST::Value> Shell::get_argument(size_t index)
{
if (index == 0)
return adopt(*new AST::StringValue(current_script));
return adopt_ref(*new AST::StringValue(current_script));
--index;
if (auto argv = lookup_local_variable("ARGV")) {
@ -452,12 +452,12 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
size_t index = 0;
for (auto& arg : function.arguments) {
++index;
set_local_variable(arg, adopt(*new AST::StringValue(command.argv[index])), true);
set_local_variable(arg, adopt_ref(*new AST::StringValue(command.argv[index])), true);
}
auto argv = command.argv;
argv.take_first();
set_local_variable("ARGV", adopt(*new AST::ListValue(move(argv))), true);
set_local_variable("ARGV", adopt_ref(*new AST::ListValue(move(argv))), true);
Core::EventLoop loop;
setup_signals();
@ -910,8 +910,8 @@ void Shell::run_tail(const AST::Command& invoking_command, const AST::NodeWithAc
}
auto node = next_in_chain.node;
if (!invoking_command.should_wait)
node = adopt(static_cast<AST::Node&>(*new AST::Background(next_in_chain.node->position(), move(node))));
adopt(static_cast<AST::Node&>(*new AST::Execute(next_in_chain.node->position(), move(node))))->run(*this);
node = adopt_ref(static_cast<AST::Node&>(*new AST::Background(next_in_chain.node->position(), move(node))));
adopt_ref(static_cast<AST::Node&>(*new AST::Execute(next_in_chain.node->position(), move(node))))->run(*this);
};
switch (next_in_chain.action) {
case AST::NodeWithAction::And:

View file

@ -163,7 +163,7 @@ int main(int argc, char** argv)
Vector<String> args;
for (auto* arg : script_args)
args.empend(arg);
shell->set_local_variable("ARGV", adopt(*new Shell::AST::ListValue(move(args))));
shell->set_local_variable("ARGV", adopt_ref(*new Shell::AST::ListValue(move(args))));
}
if (command_to_run) {