Runtime Utilities

## Detailed Description

Examples:
  Creating a CF opaque type (EXUInt32)

Warning
  The CFRuntime functions are not thread-safe.

## Data Structures

struct | CFRuntimeClass
struct | CFRuntimeBase
struct | __CFRuntimeBase._flags

## Macros

#define | INIT_CFRUNTIME_BASE(...) { 0, 0, { 1, 0, 0 } }
#define | CF_HAS_INIT_STATIC_INSTANCE 1

## Enumerations

enum | { _kCFRuntimeNotATypeID = 0 }
enum | { _kCFRuntimeScannedObject = (1UL<<0) , _kCFRuntimeResourcefulObject = (1UL<<2) , _kCFRuntimeCustomRefCount = (1UL<<3) }

## Functions

CFTypeID | _CFRuntimeRegisterClass (const CFRuntimeClass *const cls)
const CFRuntimeClass * | _CFRuntimeGetClassWithTypeID (CFTypeID typeID)
void | _CFRuntimeUnregisterClassWithTypeID (CFTypeID typeID)
CFTypeRef | _CFRuntimeCreateInstance (CFAllocatorRef allocator, CFTypeID typeID, CFIndex extraBytes, unsigned char *category)
void | _CFRuntimeSetInstanceTypeID (CFTypeRef cf, CFTypeID typeID)
void | _CFRuntimeInitStaticInstance (void *memory, CFTypeID typeID)

## Garbage Collection

Garbage Collection is not supported. All macros and functions relating to GC return false or NULL, but are provided for compatibility.
Boolean | kCFUseCollectableAllocator
Boolean(* | __CFObjCIsCollectable )(void *)
#define | CF_USING_COLLECTABLE_MEMORY (kCFUseCollectableAllocator)
#define | CF_IS_COLLECTABLE_ALLOCATOR(allocator) 0
#define | CF_IS_COLLECTABLE(obj) 0

## Data Structure Documentation

## __CFRuntimeBase

struct __CFRuntimeBase

Data Fields
void * | _isa | The Objective-C class for this object. Used for the Objective-C bridge. For internal use only.
SInt16 | _typeID |
struct __CFRuntimeBase._flags | _flags |

## __CFRuntimeBase._flags

struct __CFRuntimeBase._flags

Data Fields
SInt16 | ro: 1 |
SInt16 | reserved: 7 |
SInt16 | info: 8 |

## Function Documentation

## _CFRuntimeRegisterClass()

CFTypeID _CFRuntimeRegisterClass | ( | const CFRuntimeClass *const | cls | ) |

Registers a new CF class with the runtime. This function locks the class table and so is thread-safe.

Parameters

  cls | A constant CFRuntimeClass.

Returns
  The next available CFTypeID or _kCFRuntimeNotATypeID if none are available.

See also
  _CFRuntimeUnregisterClassWithTypeID()

Examples
  EXUInt32.c.

## _CFRuntimeGetClassWithTypeID()

const CFRuntimeClass * _CFRuntimeGetClassWithTypeID | ( | CFTypeID | typeID | ) |

Gets the class structure associated with the typeID.

Parameters

  typeID | A CFTypeID to look up.

Returns
  The CFRuntimeClass for the typeID

## _CFRuntimeUnregisterClassWithTypeID()

void _CFRuntimeUnregisterClassWithTypeID | ( | CFTypeID | typeID | ) |

Unregisters a class.

Parameters

  typeID | The CFTypeID to unregister.

See also
  _CFRuntimeRegisterClass()

Warning
  This function is not thread-safe.

## _CFRuntimeCreateInstance()

CFTypeRef _CFRuntimeCreateInstance | ( | CFAllocatorRef | allocator,
|  | CFTypeID | typeID,
|  | CFIndex | extraBytes,
|  | unsigned char * | category
| ) |  |

Creates a new CF type instance.

Parameters

  allocator | The CFAllocatorRef to use or NULL for the default allocator.
  typeID | The CFTypeID of the class.
  extraBytes | The amount of extra bytes over a CFRuntimeBase type needed by this instance.
  category | Currently unused, use NULL.

Returns
  A newly allocated object.

See also
  CFRetain()
  CFRelease()

Examples
  EXUInt32.c.

## _CFRuntimeSetInstanceTypeID()

void _CFRuntimeSetInstanceTypeID | ( | CFTypeRef | cf,
|  | CFTypeID | typeID
| ) |  |

Set the CFTypeID for an instance.

Parameters

  cf | The object instance to set the type ID.
  typeID | The new CFTypeID.

## _CFRuntimeInitStaticInstance()

void _CFRuntimeInitStaticInstance | ( | void * | memory,
|  | CFTypeID | typeID
| ) |  |

Initializes a static CF object instance.

Parameters

  memory | A pointer to a static CF object instance.
  typeID | The CFTypeID of the instance.