IOHIDTransactionElement.c [plain text]
#include <CoreFoundation/CFRuntime.h>
#include "IOHIDTransactionElement.h"
static IOHIDTransactionElementRef __IOHIDTransactionElementCreatePrivate(CFAllocatorRef allocator, CFAllocatorContext * context __unused);
static void __IOHIDTransactionElementRelease( CFTypeRef object );
typedef struct __IOHIDTransactionElement
{
CFRuntimeBase cfBase;
IOHIDElementRef element;
IOHIDValueRef value;
IOHIDValueRef defaultValue;
uint8_t state;
} __IOHIDTransactionElement, *__IOHIDTransactionElementRef;
static const CFRuntimeClass __IOHIDTransactionElementClass = {
0, "IOHIDElement", NULL, NULL, __IOHIDTransactionElementRelease, NULL, NULL, NULL, NULL, NULL, NULL, };
static dispatch_once_t __transactionElementTypeInit = 0;
static CFTypeID __kIOHIDTransactionElementTypeID = _kCFRuntimeNotATypeID;
IOHIDTransactionElementRef __IOHIDTransactionElementCreatePrivate(CFAllocatorRef allocator, CFAllocatorContext * context __unused)
{
IOHIDTransactionElementRef element = NULL;
void * offset = NULL;
uint32_t size;
size = sizeof(__IOHIDTransactionElement) - sizeof(CFRuntimeBase);
element = (IOHIDTransactionElementRef)_CFRuntimeCreateInstance(allocator, IOHIDTransactionElementGetTypeID(), size, NULL);
if (!element)
return NULL;
offset = element;
bzero(offset + sizeof(CFRuntimeBase), size);
return element;
}
void __IOHIDTransactionElementRelease( CFTypeRef object )
{
IOHIDTransactionElementRef element = ( IOHIDTransactionElementRef ) object;
if (element->element) CFRelease(element->element);
if (element->value) CFRelease(element->value);
if (element->defaultValue) CFRelease(element->defaultValue);
}
CFTypeID IOHIDTransactionElementGetTypeID(void)
{
if ( __kIOHIDTransactionElementTypeID == _kCFRuntimeNotATypeID ) {
dispatch_once(&__transactionElementTypeInit, ^{
__kIOHIDTransactionElementTypeID = _CFRuntimeRegisterClass(&__IOHIDTransactionElementClass);
});
}
return __kIOHIDTransactionElementTypeID;
}
IOHIDTransactionElementRef IOHIDTransactionElementCreate(CFAllocatorRef allocator, IOHIDElementRef element, IOOptionBits options __unused)
{
if ( !element )
return NULL;
IOHIDTransactionElementRef transElement = __IOHIDTransactionElementCreatePrivate(allocator, NULL);
if ( transElement )
transElement->element = (IOHIDElementRef)CFRetain(element);
return transElement;
}
IOHIDElementRef IOHIDTransactionElementGetElement(IOHIDTransactionElementRef element)
{
return element->element;
}
void IOHIDTransactionElementSetDefaultValue(IOHIDTransactionElementRef element, IOHIDValueRef value)
{
if (element->defaultValue) CFRelease(element->defaultValue);
element->defaultValue = value ? (IOHIDValueRef)CFRetain(value) : NULL;
}
IOHIDValueRef IOHIDTransactionElementGetDefaultValue(IOHIDTransactionElementRef element)
{
return element->defaultValue;
}
void IOHIDTransactionElementSetValue(IOHIDTransactionElementRef element, IOHIDValueRef value)
{
if (element->value) CFRelease(element->value);
element->value = value ? (IOHIDValueRef)CFRetain(value) : NULL;
}
IOHIDValueRef IOHIDTransactionElementGetValue(IOHIDTransactionElementRef element)
{
return element->value;
}