49 lines
995 B
C++
49 lines
995 B
C++
/*
|
|
SPDX-License-Identifier: MIT
|
|
Copyright © 2024-2025 Amebis
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "common.hpp"
|
|
#include <IOKit/IOKitLib.h>
|
|
|
|
namespace macstd {
|
|
///
|
|
/// IOKit handle traits
|
|
///
|
|
template <typename T>
|
|
struct io_object_traits
|
|
{
|
|
static inline constexpr T invalid = 0;
|
|
|
|
///
|
|
/// Releases an object handle
|
|
///
|
|
/// \sa [IOObjectRelease function](https://developer.apple.com/documentation/iokit/1514627-ioobjectrelease)
|
|
///
|
|
static void free(T h) noexcept
|
|
{
|
|
IOObjectRelease(h);
|
|
}
|
|
|
|
private:
|
|
static T duplicate(T h);
|
|
};
|
|
|
|
///
|
|
/// IOKit handle traits
|
|
///
|
|
template <typename T>
|
|
using io_object = handle<T, io_object_traits<T>>;
|
|
|
|
using io_connect = io_object<io_connect_t>;
|
|
using io_enumerator = io_object<io_enumerator_t>;
|
|
using io_ident = io_object<io_ident_t>;
|
|
using io_iterator = io_object<io_iterator_t>;
|
|
using io_registry_entry = io_object<io_registry_entry_t>;
|
|
using io_service = io_object<io_service_t>;
|
|
using uext_object = io_object<uext_object_t>;
|
|
}
|
|
|