Skip to content

Commit

Permalink
Use standard pointers for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan63 committed Mar 30, 2024
1 parent 9723c9e commit 179ce1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
21 changes: 11 additions & 10 deletions src/hx/libs/asys/libuv/system/LibuvChildProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
#include "LibuvChildProcess.h"

hx::asys::libuv::system::LibuvChildProcess::LibuvChildProcess()
: request(std::move(std::make_unique<uv_process_t>()))
, options(std::move(std::make_unique<uv_process_options_t>()))
: request(new uv_process_t())
, options(new uv_process_options_t())
, arguments(new std::vector<char*>())
, environment(new std::vector<char*>())
, containers(new std::vector<uv_stdio_container_t>(3))
, currentExitCode(new std::optional<int64_t>())
, exitCallback(null())
, closeCallback(null())
, containers(3)
{
hx::GCSetFinalizer(this, [](hx::Object* obj) -> void {
reinterpret_cast<LibuvChildProcess*>(obj)->~LibuvChildProcess();
});
HX_OBJ_WB_NEW_MARKED_OBJECT(this);
}

hx::asys::Pid hx::asys::libuv::system::LibuvChildProcess::pid()
Expand Down Expand Up @@ -69,7 +70,7 @@ void hx::asys::libuv::system::LibuvChildProcess::sendSignal(hx::EnumBase signal,
}

auto result = 0;
if ((result = uv_process_kill(request.get(), signum)) < 0)
if ((result = uv_process_kill(request, signum)) < 0)
{
cbFailure(hx::asys::libuv::uv_err_to_enum(result));
}
Expand All @@ -81,9 +82,9 @@ void hx::asys::libuv::system::LibuvChildProcess::sendSignal(hx::EnumBase signal,

void hx::asys::libuv::system::LibuvChildProcess::exitCode(Dynamic cbSuccess, Dynamic cbFailure)
{
if (currentExitCode.has_value())
if (currentExitCode->has_value())
{
cbSuccess(static_cast<int>(currentExitCode.value()));
cbSuccess(static_cast<int>(currentExitCode->value()));
}
else
{
Expand All @@ -95,7 +96,7 @@ void hx::asys::libuv::system::LibuvChildProcess::close(Dynamic cbSuccess, Dynami
{
closeCallback = cbSuccess.mPtr;

uv_close(reinterpret_cast<uv_handle_t*>(request.get()), [](uv_handle_t* handle) {
uv_close(reinterpret_cast<uv_handle_t*>(request), [](uv_handle_t* handle) {
auto gcZone = hx::AutoGCZone();
auto process = std::unique_ptr<hx::RootedObject<hx::asys::libuv::system::LibuvChildProcess>>(reinterpret_cast<hx::RootedObject<hx::asys::libuv::system::LibuvChildProcess>*>(handle->data));
auto callback = Dynamic(process->rooted->closeCallback);
Expand Down
12 changes: 6 additions & 6 deletions src/hx/libs/asys/libuv/system/LibuvChildProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace hx::asys::libuv::system
class LibuvChildProcess final : public hx::asys::system::ChildProcess_obj
{
public:
std::unique_ptr<uv_process_t> request;
std::unique_ptr<uv_process_options_t> options;
std::vector<char*> arguments;
std::vector<char*> environment;
std::vector<uv_stdio_container_t> containers;
std::optional<int64_t> currentExitCode;
uv_process_t* request;
uv_process_options_t* options;
std::vector<char*>* arguments;
std::vector<char*>* environment;
std::vector<uv_stdio_container_t>* containers;
std::optional<int64_t>* currentExitCode;

Dynamic exitCallback;
Dynamic closeCallback;
Expand Down

0 comments on commit 179ce1c

Please sign in to comment.