#include <functional>
#ifdef BINDGEN
#include "go_handle.hpp"
#include "pan.h"
#else
#include "pan/go_handle.hpp"
#include "pan/pan.h"
#endif
namespace Pan
{
bool GoHandle::operator!=(const GoHandle &other) const
{ return handle != other.handle; }
bool GoHandle::operator==(const GoHandle &other) const
{ return handle == other.handle; }
std::uintptr_t *GoHandle::resetAndGetAddressOf()
{
reset();
return &handle;
}
void GoHandle::reset(std::uintptr_t newHandle)
{
reset();
handle = newHandle;
}
std::uintptr_t GoHandle::release() noexcept
{
std::uintptr_t tmp = handle;
handle = INVALID_HANDLE;
return tmp;
}
const std::uintptr_t *const GoHandle::getAddressOf() const { return &handle; }
std::uintptr_t GoHandle::get() const noexcept { return handle; }
bool GoHandle::isValid() const { return handle != INVALID_HANDLE; }
GoHandle::operator bool() const { return handle != INVALID_HANDLE; }
GoHandle GoHandle::duplicate()
{
return GoHandle::Duplicate(handle);
}
GoHandle::~GoHandle() { reset(); }
GoHandle &GoHandle::operator=(GoHandle &&other)
{
swap(*this, other);
return *this;
}
GoHandle::GoHandle() : handle() {}
GoHandle::GoHandle(GoHandle &&other)
{
swap(*this, other);
}
GoHandle::GoHandle(std::uintptr_t h)
: handle(h)
{
}
void swap(GoHandle &a, GoHandle &b)
{
std::swap(a.handle, b.handle);
}
GoHandle::GoHandle(const GoHandle &other)
: handle(PanDuplicateHandle(other.handle))
{
}
GoHandle &GoHandle::operator=(const GoHandle &other)
{
if (other != *this)
handle = PanDuplicateHandle(other.handle);
return *this;
}
GoHandle GoHandle::Duplicate(std::uintptr_t handle)
{
return GoHandle(PanDuplicateHandle(handle));
}
void GoHandle::reset()
{
if (handle != PAN_INVALID_HANDLE)
{
PanDeleteHandle(handle);
handle = PAN_INVALID_HANDLE;
}
}
}