ObjFW
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
ObjFWRT.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  objc_super
 A struct representing a call to super. More...
 

Macros

#define Nil   (Class _Null_unspecified)0
 A value representing no class.
 
#define nil   (id _Null_unspecified)0
 A value representing no object.
 
#define YES   true
 An Objective-C boolean representing true.
 
#define NO   false
 An Objective-C boolean representing false.
 

Typedefs

typedef const struct objc_selector * SEL
 A selector.
 
typedef const struct objc_method * Method
 A method.
 
typedef const struct objc_protocol * Protocol
 A protocol.
 
typedef const struct objc_ivar * Ivar
 An instance variable.
 
typedef const struct objc_property * objc_property_t
 A property.
 
typedef bool BOOL
 An Objective-C boolean. Either YES or NO.
 
typedef id(* IMP) (id object, SEL selector,...)
 A method implementation.
 
typedef void(* objc_uncaught_exception_handler) (id exception)
 A handler for uncaught exceptions.
 
typedef void(* objc_enumeration_mutation_handler) (id object)
 A handler for mutation during enumeration.
 

Enumerations

enum  objc_associationPolicy {
  OBJC_ASSOCIATION_ASSIGN = 0 , OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1 , OBJC_ASSOCIATION_RETAIN = OBJC_ASSOCIATION_RETAIN_NONATOMIC | 0x300 , OBJC_ASSOCIATION_COPY_NONATOMIC = 3 ,
  OBJC_ASSOCIATION_COPY = OBJC_ASSOCIATION_COPY_NONATOMIC | 0x300
}
 A policy for object association, see objc_setAssociatedObject. More...
 

Functions

SEL sel_registerName (const char *name)
 Registers a selector with the specified name with the runtime.
 
const char * sel_getName (SEL selector)
 Returns the name of the specified selector.
 
bool sel_isEqual (SEL selector1, SEL selector2)
 Checks two selectors for equality.
 
Class objc_allocateClassPair (Class superclass, const char *name, size_t extraBytes)
 Allocates a new class and its metaclass.
 
void objc_registerClassPair (Class class_)
 Registers an already allocated class pair.
 
unsigned int objc_getClassList (Class *buffer, unsigned int count)
 Gets the list of all classes known to the runtime.
 
Class * objc_copyClassList (unsigned int *length)
 Copies the list of all classes known to the runtime.
 
bool class_isMetaClass (Class class_)
 Returns whether the specified class is a metaclass.
 
const char * class_getName (Class class_)
 Returns the name of the specified class.
 
Class class_getSuperclass (Class class_)
 Returns the superclass of the specified class.
 
unsigned long class_getInstanceSize (Class class_)
 Returns the instance size of the specified class.
 
bool class_respondsToSelector (Class class_, SEL selector)
 Returns whether the specified class responds to the specified selector.
 
bool class_conformsToProtocol (Class class_, Protocol *protocol)
 Returns whether the specified class conforms to the specified protocol.
 
IMP class_getMethodImplementation (Class class_, SEL selector)
 Returns the class's method implementation for the specified selector.
 
IMP class_getMethodImplementation_stret (Class class_, SEL selector)
 Returns the class's method implementation for the specified selector.
 
Method class_getInstanceMethod (Class class_, SEL selector)
 Returns the class's instance method for the specified selector.
 
bool class_addMethod (Class class_, SEL selector, IMP implementation, const char *typeEncoding)
 Adds the specified method to the class.
 
IMP class_replaceMethod (Class class_, SEL selector, IMP implementation, const char *typeEncoding)
 Replaces or adds the specified method of the class.
 
Class object_getClass (id object)
 Returns the object's class.
 
Class object_setClass (id object, Class class_)
 Sets the object's class.
 
const char * object_getClassName (id object)
 Returns the object's class name.
 
const char * protocol_getName (Protocol *protocol)
 Returns the name of the specified protocol.
 
bool protocol_isEqual (Protocol *protocol1, Protocol *protocol2)
 Returns whether two protocols are equal.
 
bool protocol_conformsToProtocol (Protocol *protocol1, Protocol *protocol2)
 Returns whether the first protocol conforms to the second protocol.
 
Methodclass_copyMethodList (Class class_, unsigned int *outCount)
 Copies the method list of the specified class.
 
SEL method_getName (Method method)
 Returns the name of the specified method.
 
const char * method_getTypeEncoding (Method method)
 Returns the type encoding of the specified method.
 
Ivarclass_copyIvarList (Class class_, unsigned int *outCount)
 Copies the instance variable list of the specified class.
 
const char * ivar_getName (Ivar ivar)
 Returns the name of the specified instance variable.
 
const char * ivar_getTypeEncoding (Ivar ivar)
 Returns the type encoding of the specified instance variable.
 
ptrdiff_t ivar_getOffset (Ivar ivar)
 Returns the offset of the specified instance variable.
 
objc_property_tclass_copyPropertyList (Class class_, unsigned int *outCount)
 Copies the property list of the specified class.
 
const char * property_getName (objc_property_t property)
 Returns the name of the specified property.
 
char * property_copyAttributeValue (objc_property_t property, const char *name)
 Copies the specified attribute value.
 
void objc_deinit (void)
 Deinitializes the Objective-C runtime.
 
objc_uncaught_exception_handler objc_setUncaughtExceptionHandler (objc_uncaught_exception_handler handler)
 Sets the handler for uncaught exceptions.
 
void objc_setForwardHandler (IMP forward, IMP stretForward)
 Sets the forwarding handler for unimplemented methods.
 
void objc_setEnumerationMutationHandler (objc_enumeration_mutation_handler handler)
 Sets the handler for mutations during enumeration.
 
id objc_constructInstance (Class class_, void *bytes)
 Constructs an instance of the specified class in the specified array of bytes.
 
void * objc_destructInstance (id object)
 Destructs the specified object.
 
void *_Null_unspecified objc_autoreleasePoolPush (void)
 Creates a new autorelease pool and puts it on top of the stack of autorelease pools.
 
void objc_autoreleasePoolPop (void *_Null_unspecified pool)
 Drains the specified autorelease pool and all pools on top of it and removes it from the stack of autorelease pools.
 
id _objc_rootAutorelease (id object)
 Adds the specified object to the topmost autorelease pool.
 
void objc_setTaggedPointerSecret (uintptr_t secret)
 Sets the tagged pointer secret.
 
int objc_registerTaggedPointerClass (Class class_)
 Registers a class for tagged pointers.
 
bool object_isTaggedPointer (id object)
 Returns whether the specified object is a tagged pointer.
 
uintptr_t object_getTaggedPointerValue (id object)
 Returns the value of the specified tagged pointer.
 
id objc_createTaggedPointer (int class_, uintptr_t value)
 Creates a new tagged pointer.
 
void objc_setAssociatedObject (id object, const void *key, id value, objc_associationPolicy policy)
 Sets an associated object on the specified object for the specified key.
 
id objc_getAssociatedObject (id object, const void *key)
 Returns the associated object on the specified object for the specified key.
 
void objc_removeAssociatedObjects (id object)
 Removes all associated objects for the specified object.
 

Macro Definition Documentation

◆ NO

#define NO   false

An Objective-C boolean representing false.

Note
This is a legacy from before C had a boolean type. Prefer the standard C99 false instead!

◆ YES

#define YES   true

An Objective-C boolean representing true.

Note
This is a legacy from before C had a boolean type. Prefer the standard C99 true instead!

Typedef Documentation

◆ BOOL

typedef bool BOOL

An Objective-C boolean. Either YES or NO.

Note
This is a legacy from before C had a boolean type. Prefer the standard C99 bool instead!

◆ IMP

typedef id(* IMP) (id object, SEL selector,...)

A method implementation.

Parameters
objectThe messaged object
selectorThe selector sent

◆ Method

typedef const struct objc_method* Method

A method.

A method consists of a selector with a type encoding and an implementation.

◆ objc_enumeration_mutation_handler

typedef void(* objc_enumeration_mutation_handler) (id object)

A handler for mutation during enumeration.

Parameters
objectThe object that was mutated during enumeration

◆ objc_uncaught_exception_handler

typedef void(* objc_uncaught_exception_handler) (id exception)

A handler for uncaught exceptions.

Parameters
exceptionThe exception which was not caught.

◆ SEL

typedef const struct objc_selector* SEL

A selector.

A selector is the name of a method including the colons and an optional type encoding.

Enumeration Type Documentation

◆ objc_associationPolicy

A policy for object association, see objc_setAssociatedObject.

Enumerator
OBJC_ASSOCIATION_ASSIGN 

Associate the object like an assigned property.

OBJC_ASSOCIATION_RETAIN_NONATOMIC 

Associate the object like a retained, nonatomic property.

OBJC_ASSOCIATION_RETAIN 

Associate the object like a retained property.

OBJC_ASSOCIATION_COPY_NONATOMIC 

Associate the object like a copied, nonatomic property.

OBJC_ASSOCIATION_COPY 

Associate the object like a copied property.

Function Documentation

◆ _objc_rootAutorelease()

id _objc_rootAutorelease ( id object)
extern

Adds the specified object to the topmost autorelease pool.

This is only to be used to implement the autorelease method in a root class.

Parameters
objectThe object to add to the topmost autorelease pool
Returns
The autoreleased object

◆ class_addMethod()

bool class_addMethod ( Class class_,
SEL selector,
IMP implementation,
const char * typeEncoding )
extern

Adds the specified method to the class.

Parameters
class_The class to which to add the method
selectorThe selector for the method to add
implementationThe implementation of the method to add
typeEncodingThe type encoding of the method to add
Returns
Whether the specified method was added

◆ class_conformsToProtocol()

bool class_conformsToProtocol ( Class class_,
Protocol * protocol )
extern

Returns whether the specified class conforms to the specified protocol.

Parameters
class_The class which should be examined
protocolThe protocol for which conformance should be checked
Returns
Whether the specified class conforms to the specified protocol

◆ class_copyIvarList()

Ivar * class_copyIvarList ( Class class_,
unsigned int * outCount )
extern

Copies the instance variable list of the specified class.

Parameters
class_The class whose instance variable list should be copied
outCountAn optional pointer to an unsigned int that should be set to the number of instance variables returned
Returns
An array of instance variables, terminated by NULL. You need to call free() on it when done.

◆ class_copyMethodList()

Method * class_copyMethodList ( Class class_,
unsigned int * outCount )
extern

Copies the method list of the specified class.

Parameters
class_The class whose method list should be copied
outCountAn optional pointer to an unsigned int that should be set to the number of methods returned
Returns
An array of methods, terminated by NULL. You need to call free() on it when done.

◆ class_copyPropertyList()

objc_property_t * class_copyPropertyList ( Class class_,
unsigned int * outCount )
extern

Copies the property list of the specified class.

Parameters
class_The class whose property list should be copied
outCountAn optional pointer to an unsigned int that should be set to the number of properties returned
Returns
An array of properties, terminated by NULL. You need to call free() on it when done.

◆ class_getInstanceMethod()

Method class_getInstanceMethod ( Class class_,
SEL selector )
extern

Returns the class's instance method for the specified selector.

Parameters
class_The class whose instance method should be returned
selectorThe selector of the instance method to return
Returns
The class's instance method for the specified selector

◆ class_getInstanceSize()

unsigned long class_getInstanceSize ( Class class_)
extern

Returns the instance size of the specified class.

Parameters
class_The class whose instance size should be returned
Returns
The instance size of the specified class

◆ class_getMethodImplementation()

IMP class_getMethodImplementation ( Class class_,
SEL selector )
extern

Returns the class's method implementation for the specified selector.

Warning
If the method uses the struct return ABI, you need to use class_getMethodImplementation_stret instead! Depending on the ABI, small structs might not use the struct return ABI.
Parameters
class_The class whose method implementation should be returned
selectorThe selector for the method whose implementation should be returned
Returns
The class's method implementation for the specified selector

◆ class_getMethodImplementation_stret()

IMP class_getMethodImplementation_stret ( Class class_,
SEL selector )
extern

Returns the class's method implementation for the specified selector.

Warning
If the method does not use use the struct return ABI, you need to use class_getMethodImplementation instead! Depending on the ABI, small structs might not use the struct return ABI.
Parameters
class_The class whose method implementation should be returned
selectorThe selector for the method whose implementation should be returned
Returns
The class's method implementation for the specified selector

◆ class_getName()

const char * class_getName ( Class class_)
extern

Returns the name of the specified class.

Parameters
class_The class whose name should be returned
Returns
The name of the specified class

◆ class_getSuperclass()

Class class_getSuperclass ( Class class_)
extern

Returns the superclass of the specified class.

Parameters
class_The class whose superclass should be returned
Returns
The superclass of the specified class

◆ class_isMetaClass()

bool class_isMetaClass ( Class class_)
extern

Returns whether the specified class is a metaclass.

Parameters
class_The class which should be examined
Returns
Whether the specified class is a metaclass

◆ class_replaceMethod()

IMP class_replaceMethod ( Class class_,
SEL selector,
IMP implementation,
const char * typeEncoding )
extern

Replaces or adds the specified method of the class.

Parameters
class_The class to which to replace the method
selectorThe selector for the method to replace
implementationThe implementation of the method to replace
typeEncodingThe type encoding of the method to replace. Only used if the method does not exist yet.
Returns
The old implementation of the method

◆ class_respondsToSelector()

bool class_respondsToSelector ( Class class_,
SEL selector )
extern

Returns whether the specified class responds to the specified selector.

Parameters
class_The class which should be examined
selectorThe selector which should be checked
Returns
Whether the specified class responds to the specified selector

◆ ivar_getName()

const char * ivar_getName ( Ivar ivar)
extern

Returns the name of the specified instance variable.

Parameters
ivarThe instance variable whose name should be returned
Returns
The name of the specified instance variable

◆ ivar_getOffset()

ptrdiff_t ivar_getOffset ( Ivar ivar)
extern

Returns the offset of the specified instance variable.

Parameters
ivarThe instance variable whose offset should be returned
Returns
The offset of the specified instance variable

◆ ivar_getTypeEncoding()

const char * ivar_getTypeEncoding ( Ivar ivar)
extern

Returns the type encoding of the specified instance variable.

Parameters
ivarThe instance variable whose type encoding should be returned
Returns
The type encoding of the specified instance variable

◆ method_getName()

SEL method_getName ( Method method)
extern

Returns the name of the specified method.

Parameters
methodThe method whose name should be returned
Returns
The name of the specified method

◆ method_getTypeEncoding()

const char * method_getTypeEncoding ( Method method)
extern

Returns the type encoding of the specified method.

Parameters
methodThe method whose type encoding should be returned
Returns
The type encoding of the specified method

◆ objc_allocateClassPair()

Class objc_allocateClassPair ( Class superclass,
const char * name,
size_t extraBytes )
extern

Allocates a new class and its metaclass.

Parameters
superclassThe superclass for the new class
nameThe name for the new class
extraBytesExtra bytes to add to the instance size
Returns
A new, unregistered class pair

◆ objc_autoreleasePoolPop()

void objc_autoreleasePoolPop ( void *_Null_unspecified pool)
extern

Drains the specified autorelease pool and all pools on top of it and removes it from the stack of autorelease pools.

Parameters
poolThe pool which should be drained together with all pools on top of it

◆ objc_autoreleasePoolPush()

void *_Null_unspecified objc_autoreleasePoolPush ( void )
extern

Creates a new autorelease pool and puts it on top of the stack of autorelease pools.

Returns
A new autorelease pool, which is now on the top of the stack of autorelease pools

◆ objc_constructInstance()

id objc_constructInstance ( Class class_,
void * bytes )
extern

Constructs an instance of the specified class in the specified array of bytes.

Parameters
class_The class of which to construct an instance
bytesAn array of bytes of at least the length of the instance size. Must be properly aligned for the class.
Returns
The constructed instance

◆ objc_copyClassList()

Class * objc_copyClassList ( unsigned int * length)
extern

Copies the list of all classes known to the runtime.

This is like objc_getClassList, but allocates a buffer large enough for all classes.

Parameters
lengthAn optional pointer to an unsigned int that will be set to the number of classes returned
Returns
An array of classes, terminated by Nil. You need to call free() on it when done.

◆ objc_createTaggedPointer()

id objc_createTaggedPointer ( int class_,
uintptr_t value )
extern

Creates a new tagged pointer.

Parameters
class_The tag ID for the tagged pointer class to use
valueThe value the tagged pointer should have
Returns
A tagged pointer, or nil if it could not be created

◆ objc_deinit()

void objc_deinit ( void )
extern

Deinitializes the Objective-C runtime.

This frees all data structures used by the runtime, after which Objective-C can no longer be used inside the current process. This is only useful for debugging and tests.

◆ objc_destructInstance()

void * objc_destructInstance ( id object)
extern

Destructs the specified object.

Parameters
objectThe object to destruct
Returns
The array of bytes that was used to back the instance

◆ objc_getAssociatedObject()

id objc_getAssociatedObject ( id object,
const void * key )
extern

Returns the associated object on the specified object for the specified key.

Parameters
objectThe object on which to get the associated object
keyThe key of the association
Returns
The associated object on the specified object for the specified key

◆ objc_getClassList()

unsigned int objc_getClassList ( Class * buffer,
unsigned int count )
extern

Gets the list of all classes known to the runtime.

Parameters
bufferAn array of Class to write to. If the buffer does not have enough space, the result is truncated.
countThe number of classes for which there is space in buffer
Returns
The number of classes written

◆ objc_registerClassPair()

void objc_registerClassPair ( Class class_)
extern

Registers an already allocated class pair.

Parameters
class_The class pair to register

◆ objc_registerTaggedPointerClass()

int objc_registerTaggedPointerClass ( Class class_)
extern

Registers a class for tagged pointers.

Parameters
class_The class to register for tagged pointers
Returns
The tagged pointer ID for the registered class

◆ objc_removeAssociatedObjects()

void objc_removeAssociatedObjects ( id object)
extern

Removes all associated objects for the specified object.

Parameters
objectThe object on which to remove all associated objects

◆ objc_setAssociatedObject()

void objc_setAssociatedObject ( id object,
const void * key,
id value,
objc_associationPolicy policy )
extern

Sets an associated object on the specified object for the specified key.

Parameters
objectThe object on which to set an associated object
keyA unique pointer to use as the key for the association
valueThe object to associate with the specified object
policyThe association policy, see objc_associationPolicy

◆ objc_setEnumerationMutationHandler()

void objc_setEnumerationMutationHandler ( objc_enumeration_mutation_handler handler)
extern

Sets the handler for mutations during enumeration.

Parameters
handlerThe handler for mutations during enumeration

◆ objc_setForwardHandler()

void objc_setForwardHandler ( IMP forward,
IMP stretForward )
extern

Sets the forwarding handler for unimplemented methods.

Parameters
forwardThe forwarding handler for regular methods
stretForwardThe forwarding handler for methods using the struct return ABI

◆ objc_setTaggedPointerSecret()

void objc_setTaggedPointerSecret ( uintptr_t secret)
extern

Sets the tagged pointer secret.

Parameters
secretA secret, random value that will be used to XOR all tagged pointers with

◆ objc_setUncaughtExceptionHandler()

objc_uncaught_exception_handler objc_setUncaughtExceptionHandler ( objc_uncaught_exception_handler handler)
extern

Sets the handler for uncaught exceptions.

Parameters
handlerThe new handler for uncaught exceptions
Returns
The old handler for uncaught exceptions

◆ object_getClass()

Class object_getClass ( id object)
extern

Returns the object's class.

Parameters
objectThe object whose class should be returned
Returns
The object's class

◆ object_getClassName()

const char * object_getClassName ( id object)
extern

Returns the object's class name.

Parameters
objectThe object whose class name should be returned
Returns
The object's class name

◆ object_getTaggedPointerValue()

uintptr_t object_getTaggedPointerValue ( id object)
extern

Returns the value of the specified tagged pointer.

Parameters
objectThe object whose tagged pointer value should be returned
Returns
The tagged pointer value of the object

◆ object_isTaggedPointer()

bool object_isTaggedPointer ( id object)
extern

Returns whether the specified object is a tagged pointer.

Parameters
objectThe object to inspect
Returns
Whether the specified object is a tagged pointer

◆ object_setClass()

Class object_setClass ( id object,
Class class_ )
extern

Sets the object's class.

This can be used to swizzle an object's class.

Parameters
objectThe object whose class should be set
class_The new class for the object
Returns
The old class of the object

◆ property_copyAttributeValue()

char * property_copyAttributeValue ( objc_property_t property,
const char * name )
extern

Copies the specified attribute value.

Parameters
propertyThe property whose attribute value should be copied
nameThe name of the attribute value to copy
Returns
A copy of the attribute value. You need to call free() on it when done.

◆ property_getName()

const char * property_getName ( objc_property_t property)
extern

Returns the name of the specified property.

Parameters
propertyThe property whose name should be returned
Returns
The name of the specified property

◆ protocol_conformsToProtocol()

bool protocol_conformsToProtocol ( Protocol * protocol1,
Protocol * protocol2 )
extern

Returns whether the first protocol conforms to the second protocol.

Parameters
protocol1The first protocol
protocol2The second protocol
Returns
Whether the first protocol conforms to the second protocol

◆ protocol_getName()

const char * protocol_getName ( Protocol * protocol)
extern

Returns the name of the specified protocol.

Parameters
protocolThe protocol whose name should be returned
Returns
The name of the specified protocol

◆ protocol_isEqual()

bool protocol_isEqual ( Protocol * protocol1,
Protocol * protocol2 )
extern

Returns whether two protocols are equal.

Parameters
protocol1The first protocol
protocol2The second protocol
Returns
Whether the two protocols are equal

◆ sel_getName()

const char * sel_getName ( SEL selector)
extern

Returns the name of the specified selector.

Parameters
selectorThe selector whose name should be returned
Returns
The name of the specified selector

◆ sel_isEqual()

bool sel_isEqual ( SEL selector1,
SEL selector2 )
extern

Checks two selectors for equality.

Selectors are considered equal if they have the same name - any type encoding is ignored.

Parameters
selector1The first selector
selector2The second selector
Returns
Whether the two selectors are equal

◆ sel_registerName()

SEL sel_registerName ( const char * name)
extern

Registers a selector with the specified name with the runtime.

Parameters
nameThe name for the selector to register
Returns
The registered selector