15#include "../oxr_logger.h"
108 oxr_handle_destroyer destroy,
121 oxr_handle_destroyer destroy,
159 oxr_handle_destroyer destroy,
174 oxr_handle_destroyer destroy,
220#define OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT) \
221 oxr_handle_allocate_and_init(LOG, sizeof(*OUT), DEBUG, DESTROY, PARENT, (void **)&OUT)
237#define OXR_ALLOCATE_HANDLE_PARENT(LOG, OUT, DEBUG, DESTROY, PARENT) \
238 oxr_handle_parent_allocate_and_init(LOG, sizeof(*OUT), DEBUG, DESTROY, PARENT, (void **)&OUT)
241#define ASSERT_HANDLE_TYPE(OUT, TYPE, HANDLE_TYPE) \
243 static_assert(offsetof(XRT_TYPEOF(*OUT), handle) == 0, \
244 "OUT must have a field 'handle' of type struct oxr_handle_base"); \
245 static_assert(sizeof(((XRT_TYPEOF(*OUT) *)0)->handle) == sizeof(HANDLE_TYPE), \
246 "OUT must have a field 'handle' of type struct oxr_handle_base"); \
250#define ASSERT_HANDLE_TYPE(OUT, TYPE, HANDLE_TYPE) \
269#define OXR_ALLOCATE_HANDLE_OR_RETURN(LOG, OUT, DEBUG, DESTROY, PARENT) \
272 ASSERT_HANDLE_TYPE(OUT, typeof(*OUT), struct oxr_handle_base); \
273 XrResult allocResult = OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT); \
274 if (allocResult != XR_SUCCESS) { \
275 return allocResult; \
293#define OXR_ALLOCATE_HANDLE_PARENT_OR_RETURN(LOG, OUT, DEBUG, DESTROY, PARENT) \
296 ASSERT_HANDLE_TYPE(OUT, typeof(*OUT), struct oxr_handle_parent_base); \
297 XrResult allocResult = OXR_ALLOCATE_HANDLE_PARENT(LOG, OUT, DEBUG, DESTROY, PARENT); \
298 if (allocResult != XR_SUCCESS) { \
299 return allocResult; \
oxr_handle_state
State of a handle base, to reduce likelihood of going "boom" on out-of-order destruction or other uns...
Definition oxr_handle_base.h:44
@ OXR_HANDLE_STATE_DESTROYED
State after successful oxr_handle_destroy.
Definition oxr_handle_base.h:52
@ OXR_HANDLE_STATE_LIVE
State after successful oxr_handle_init.
Definition oxr_handle_base.h:49
@ OXR_HANDLE_STATE_UNINITIALIZED
State during/before oxr_handle_init, or after failure.
Definition oxr_handle_base.h:46
A dynamic array of handles.
Manages an array of handles, does not have a init function but must be zero initialized where it is d...
Definition oxr_handle_array.h:21
A single OpenXR handle, which is a child of a parent handle holder, if any.
Definition oxr_handle_base.h:62
XrResult oxr_handle_allocate_and_init(struct oxr_logger *log, size_t size, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_parent_base *parent, void **out)
Allocate some memory for use as a handle, and initialize it as a handle.
uint64_t debug
Magic (per-handle-type) value for debugging.
Definition oxr_handle_base.h:64
enum oxr_handle_state state
Current handle state.
Definition oxr_handle_base.h:74
struct oxr_handle_parent_base * parent
Pointer to this object's parent handle holder, if any.
Definition oxr_handle_base.h:69
XrResult(* oxr_handle_destroyer)(struct oxr_logger *log, struct oxr_handle_base *hb)
Function pointer type for a handle destruction function.
Definition oxr_handle_base.h:35
oxr_handle_destroyer destroy
Destroy the object this handle refers to.
Definition oxr_handle_base.h:79
XrResult oxr_handle_init(struct oxr_logger *log, struct oxr_handle_base *hb, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_parent_base *parent)
Initialize a handle, and if a parent is specified, update its child list to include this handle.
Used to hold diverse child handles and ensure orderly destruction.
Definition oxr_handle_base.h:88
XrResult oxr_handle_parent_init(struct oxr_logger *log, struct oxr_handle_parent_base *hpb, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_parent_base *parent)
Initialize a handle holder, and if a parent is specified, update its child list to include this handl...
struct oxr_handle_array children
Array of children, if any.
Definition oxr_handle_base.h:94
XrResult oxr_handle_parent_allocate_and_init(struct oxr_logger *log, size_t size, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_parent_base *parent, void **out)
Allocate some memory for use as a handle holder, and initialize it as a handle holder.
Logger struct that lives on the stack, one for each call client call.
Definition oxr_logger.h:44