#pragma once
#include <cstdint>
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
namespace Pan {
class GoHandle;
void swap(GoHandle &a, GoHandle &b);
class GoHandle
{
public:
static constexpr std::uintptr_t INVALID_HANDLE = 0;
GoHandle();
explicit GoHandle(std::uintptr_t h);
DLLEXPORT
GoHandle(const GoHandle &other);
GoHandle(GoHandle &&other);
DLLEXPORT
GoHandle& operator=(const GoHandle &other);
GoHandle& operator=(GoHandle &&other);
~GoHandle();
DLLEXPORT
static GoHandle Duplicate(std::uintptr_t handle);
GoHandle duplicate();
bool operator==(const GoHandle &other) const;
bool operator!=(const GoHandle &other) const;
bool operator<(const GoHandle &other) const
{ return handle < other.handle; }
bool operator<=(const GoHandle &other) const
{ return handle <= other.handle; }
bool operator>(const GoHandle &other) const
{ return handle > other.handle; }
bool operator>=(const GoHandle &other) const
{ return handle >= other.handle; }
operator bool() const;
bool isValid() const;
std::uintptr_t get() const noexcept;
const std::uintptr_t *const getAddressOf() const;
std::uintptr_t* resetAndGetAddressOf();
void reset(std::uintptr_t newHandle);
DLLEXPORT
void reset();
std::uintptr_t release() noexcept;
friend void swap(GoHandle &a, GoHandle &b);
private:
std::uintptr_t handle = INVALID_HANDLE;
};
}
#ifndef BUILDING_RUST
#endif