ObjFW
|
#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. More... | |
#define | NO false |
An Objective-C boolean representing false. More... | |
Typedefs | |
typedef struct objc_class * | Class |
A pointer to a class. | |
typedef struct objc_object * | id |
A pointer to any object. | |
typedef const struct objc_selector * | SEL |
A selector. More... | |
typedef const struct objc_method * | Method |
A method. More... | |
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. More... | |
typedef id _Nullable(* | IMP) (id _Nonnull object, SEL _Nonnull selector,...) |
A method implemenation. More... | |
typedef void(* | objc_uncaught_exception_handler_t) (id _Nullable exception) |
A handler for uncaught exceptions. More... | |
typedef void(* | objc_enumeration_mutation_handler_t) (id _Nonnull object) |
A handler for mutation during enumeration. More... | |
Functions | |
SEL _Nonnull | sel_registerName (const char *_Nonnull name) |
Registers a selector with the specified name with the runtime. More... | |
const char *_Nonnull | sel_getName (SEL _Nonnull selector) |
Returns the name of the specified selector. More... | |
bool | sel_isEqual (SEL _Nonnull selector1, SEL _Nonnull selector2) |
Checks two selectors for equality. More... | |
Class _Nonnull | objc_allocateClassPair (Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes) |
Allocates a new class and its metaclass. More... | |
void | objc_registerClassPair (Class _Nonnull class_) |
Registers an already allocated class pair. More... | |
unsigned int | objc_getClassList (Class _Nonnull *_Nullable buffer, unsigned int count) |
Gets the list of all classes known to the runtime. More... | |
Class _Nonnull *_Nonnull | objc_copyClassList (unsigned int *_Nullable length) |
Copies the list of all classes known to the runtime. More... | |
bool | class_isMetaClass (Class _Nullable class_) |
Returns whether the specified class is a metaclass. More... | |
const char *_Nullable | class_getName (Class _Nullable class_) |
Returns the name of the specified class. More... | |
Class _Nullable | class_getSuperclass (Class _Nullable class_) |
Returns the superclass of the specified class. More... | |
unsigned long | class_getInstanceSize (Class _Nullable class_) |
Returns the instance size of the specified class. More... | |
bool | class_respondsToSelector (Class _Nullable class_, SEL _Nonnull selector) |
Returns whether the specified class responds to the specified selector. More... | |
bool | class_conformsToProtocol (Class _Nullable class_, Protocol *_Nonnull protocol) |
Returns whether the specified class conforms to the specified protocol. More... | |
IMP _Nullable | class_getMethodImplementation (Class _Nullable class_, SEL _Nonnull selector) |
Returns the class's method implementation for the specified selector. More... | |
IMP _Nullable | class_getMethodImplementation_stret (Class _Nullable class_, SEL _Nonnull selector) |
Returns the class's method implementation for the specified selector. More... | |
Method _Nullable | class_getInstanceMethod (Class _Nullable class_, SEL _Nonnull selector) |
Returns the class's instance method for the specified selector. More... | |
bool | class_addMethod (Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding) |
Adds the specified method to the class. More... | |
IMP _Nullable | class_replaceMethod (Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding) |
Replaces or adds the specified method of the class. More... | |
Class _Nullable | object_getClass (id _Nullable object) |
Returns the object's class. More... | |
Class _Nullable | object_setClass (id _Nullable object, Class _Nonnull class_) |
Sets the object's class. More... | |
const char *_Nullable | object_getClassName (id _Nullable object) |
Returns the object's class name. More... | |
const char *_Nonnull | protocol_getName (Protocol *_Nonnull protocol) |
Returns the name of the specified protocol. More... | |
bool | protocol_isEqual (Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2) |
Returns whether two protocols are equal. More... | |
bool | protocol_conformsToProtocol (Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2) |
Returns whether the first protocol conforms to the second protocol. More... | |
Method _Nullable *_Nullable | class_copyMethodList (Class _Nullable class_, unsigned int *_Nullable outCount) |
Copies the method list of the specified class. More... | |
SEL _Nonnull | method_getName (Method _Nonnull method) |
Returns the name of the specified method. More... | |
const char *_Nullable | method_getTypeEncoding (Method _Nonnull method) |
Returns the type encoding of the specified method. More... | |
Ivar _Nullable *_Nullable | class_copyIvarList (Class _Nullable class_, unsigned int *_Nullable outCount) |
Copies the instance variable list of the specified class. More... | |
const char *_Nonnull | ivar_getName (Ivar _Nonnull ivar) |
Returns the name of the specified instance variable. More... | |
const char *_Nonnull | ivar_getTypeEncoding (Ivar _Nonnull ivar) |
Returns the type encoding of the specified instance variable. More... | |
ptrdiff_t | ivar_getOffset (Ivar _Nonnull ivar) |
Returns the offset of the specified instance variable. More... | |
objc_property_t _Nullable *_Nullable | class_copyPropertyList (Class _Nullable class_, unsigned int *_Nullable outCount) |
Copies the property list of the specified class. More... | |
const char *_Nonnull | property_getName (objc_property_t _Nonnull property) |
Returns the name of the specified property. More... | |
char *_Nullable | property_copyAttributeValue (objc_property_t _Nonnull property, const char *_Nonnull name) |
Copies the specified attribute value. More... | |
void | objc_exit (void) |
Exits the Objective-C runtime. More... | |
_Nullable objc_uncaught_exception_handler_t | objc_setUncaughtExceptionHandler (objc_uncaught_exception_handler_t _Nullable handler) |
Sets the handler for uncaught exceptions. More... | |
void | objc_setForwardHandler (IMP _Nullable forward, IMP _Nullable stretForward) |
Sets the forwarding handler for unimplemented methods. More... | |
void | objc_setEnumerationMutationHandler (objc_enumeration_mutation_handler_t _Nullable handler) |
Sets the handler for mutations during enumeration. More... | |
id _Nullable | objc_constructInstance (Class _Nullable class_, void *_Nullable bytes) |
Constructs an instance of the specified class in the specified array of bytes. More... | |
void *_Nullable | objc_destructInstance (id _Nullable object) |
Destructs the specified object. More... | |
void *_Null_unspecified | objc_autoreleasePoolPush (void) |
Creates a new autorelease pool and puts it on top of the stack of autorelease pools. More... | |
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. More... | |
id _Nullable | _objc_rootAutorelease (id _Nullable object) |
Adds the specified object to the topmost autorelease pool. More... | |
void | objc_setTaggedPointerSecret (uintptr_t secret) |
Sets the tagged pointer secret. More... | |
int | objc_registerTaggedPointerClass (Class _Nonnull class) |
Registers a class for tagged pointers. More... | |
bool | object_isTaggedPointer (id _Nullable object) |
Returns whether the specified object is a tagged pointer. More... | |
uintptr_t | object_getTaggedPointerValue (id _Nonnull object) |
Returns the value of the specified tagged pointer. More... | |
id _Nullable | objc_createTaggedPointer (int class, uintptr_t value) |
Creates a new tagged pointer. More... | |
#define NO false |
An Objective-C boolean representing false.
#define YES true |
An Objective-C boolean representing true.
typedef bool BOOL |
A method implemenation.
object | The messaged object |
selector | The selector sent |
typedef const struct objc_method* Method |
A method.
A method consists of a selector with a type encoding and an implementation.
typedef void(* objc_enumeration_mutation_handler_t) (id _Nonnull object) |
A handler for mutation during enumeration.
object | The object that was mutated during enumeration |
typedef void(* objc_uncaught_exception_handler_t) (id _Nullable exception) |
A handler for uncaught exceptions.
exception | The exception which was not caught. |
typedef const struct objc_selector* SEL |
A selector.
A selector is the name of a method including the colons and an optional type encoding.
Adds the specified object to the topmost autorelease pool.
This is only to be used to implement the autorelease
method in a root class.
object | The object to add to the topmost autorelease pool |
bool class_addMethod | ( | Class _Nonnull | class_, |
SEL _Nonnull | selector, | ||
IMP _Nonnull | implementation, | ||
const char *_Nullable | typeEncoding | ||
) |
Adds the specified method to the class.
class_ | The class to which to add the method |
selector | The selector for the method to add |
implementation | The implementation of the method to add |
typeEncoding | The type encoding of the method to add |
Returns whether the specified class conforms to the specified protocol.
class_ | The class which should be examined |
protocol | The protocol for which conformance should be checked |
Ivar _Nullable* _Nullable class_copyIvarList | ( | Class _Nullable | class_, |
unsigned int *_Nullable | outCount | ||
) |
Copies the instance variable list of the specified class.
class_ | The class whose instance variable list should be copied |
outCount | An optional pointer to an unsigned int that should be set to the number of instance variables returned |
NULL
. You need to call free()
on it when done. Method _Nullable* _Nullable class_copyMethodList | ( | Class _Nullable | class_, |
unsigned int *_Nullable | outCount | ||
) |
Copies the method list of the specified class.
class_ | The class whose method list should be copied |
outCount | An optional pointer to an unsigned int that should be set to the number of methods returned |
NULL
. You need to call free()
on it when done. objc_property_t _Nullable* _Nullable class_copyPropertyList | ( | Class _Nullable | class_, |
unsigned int *_Nullable | outCount | ||
) |
Copies the property list of the specified class.
class_ | The class whose property list should be copied |
outCount | An optional pointer to an unsigned int that should be set to the number of properties returned |
NULL
. You need to call free()
on it when done. Returns the class's instance method for the specified selector.
class_ | The class whose instance method should be returned |
selector | The selector of the instance method to return |
unsigned long class_getInstanceSize | ( | Class _Nullable | class_ | ) |
Returns the instance size of the specified class.
class_ | The class whose instance size should be returned |
Returns the class's method implementation for the specified selector.
class_ | The class whose method implementation should be returned |
selector | The selector for the method whose implementation should be returned |
Returns the class's method implementation for the specified selector.
class_ | The class whose method implementation should be returned |
selector | The selector for the method whose implementation should be returned |
const char* _Nullable class_getName | ( | Class _Nullable | class_ | ) |
Returns the name of the specified class.
class_ | The class whose name should be returned |
Returns the superclass of the specified class.
class_ | The class whose superclass should be returned |
bool class_isMetaClass | ( | Class _Nullable | class_ | ) |
Returns whether the specified class is a metaclass.
class_ | The class which should be examined |
IMP _Nullable class_replaceMethod | ( | Class _Nonnull | class_, |
SEL _Nonnull | selector, | ||
IMP _Nonnull | implementation, | ||
const char *_Nullable | typeEncoding | ||
) |
Replaces or adds the specified method of the class.
class_ | The class to which to replace the method |
selector | The selector for the method to replace |
implementation | The implementation of the method to replace |
typeEncoding | The type encoding of the method to replace. Only used if the method does not exist yet. |
Returns whether the specified class responds to the specified selector.
class_ | The class which should be examined |
selector | The selector which should be checked |
const char* _Nonnull ivar_getName | ( | Ivar _Nonnull | ivar | ) |
Returns the name of the specified instance variable.
ivar | The instance variable whose name should be returned |
ptrdiff_t ivar_getOffset | ( | Ivar _Nonnull | ivar | ) |
Returns the offset of the specified instance variable.
ivar | The instance variable whose offset should be returned |
const char* _Nonnull ivar_getTypeEncoding | ( | Ivar _Nonnull | ivar | ) |
Returns the type encoding of the specified instance variable.
ivar | The instance variable whose type encoding should be returned |
Returns the name of the specified method.
method | The method whose name should be returned |
const char* _Nullable method_getTypeEncoding | ( | Method _Nonnull | method | ) |
Returns the type encoding of the specified method.
method | The method whose type encoding should be returned |
Class _Nonnull objc_allocateClassPair | ( | Class _Nullable | superclass, |
const char *_Nonnull | name, | ||
size_t | extraBytes | ||
) |
Allocates a new class and its metaclass.
superclass | The superclass for the new class |
name | The name for the new class |
extraBytes | Extra bytes to add to the instance size |
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.
pool | The pool which should be drained together with all pools on top of it |
void* _Null_unspecified objc_autoreleasePoolPush | ( | void | ) |
Creates a new autorelease pool and puts it on top of the stack of autorelease pools.
Constructs an instance of the specified class in the specified array of bytes.
class_ | The class of which to construct an instance |
bytes | An array of bytes of at least the length of the instance size. Must be properly aligned for the class. |
Class _Nonnull* _Nonnull objc_copyClassList | ( | unsigned int *_Nullable | length | ) |
Copies the list of all classes known to the runtime.
This is like objc_getClassList, but allocates a buffer large enough for all classes.
length | An optional pointer to an unsigned int that will be set to the number of classes returned |
Nil
. You need to call free()
on it when done. id _Nullable objc_createTaggedPointer | ( | int | class, |
uintptr_t | value | ||
) |
Creates a new tagged pointer.
class | The tag ID for the tagged pointer class to use |
value | The value the tagged pointer should have |
nil
if it could not be created void* _Nullable objc_destructInstance | ( | id _Nullable | object | ) |
Destructs the specified object.
object | The object to destruct |
void objc_exit | ( | void | ) |
Exits 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.
unsigned int objc_getClassList | ( | Class _Nonnull *_Nullable | buffer, |
unsigned int | count | ||
) |
Gets the list of all classes known to the runtime.
buffer | An array of Class to write to. If the buffer does not have enough space, the result is truncated. |
count | The number of classes for which there is space in buffer |
void objc_registerClassPair | ( | Class _Nonnull | class_ | ) |
Registers an already allocated class pair.
class_ | The class pair to register |
int objc_registerTaggedPointerClass | ( | Class _Nonnull | class | ) |
Registers a class for tagged pointers.
class | The class to register for tagged pointers |
void objc_setEnumerationMutationHandler | ( | objc_enumeration_mutation_handler_t _Nullable | handler | ) |
Sets the handler for mutations during enumeration.
handler | The handler for mutations during enumeration |
Sets the forwarding handler for unimplemented methods.
forward | The forwarding handler for regular methods |
stretForward | The forwarding handler for methods using the struct return ABI |
void objc_setTaggedPointerSecret | ( | uintptr_t | secret | ) |
Sets the tagged pointer secret.
secret | A secret, random value that will be used to XOR all tagged pointers with |
_Nullable objc_uncaught_exception_handler_t objc_setUncaughtExceptionHandler | ( | objc_uncaught_exception_handler_t _Nullable | handler | ) |
Sets the handler for uncaught exceptions.
handler | The new handler for uncaught exceptions |
Returns the object's class.
object | The object whose class should be returned |
const char* _Nullable object_getClassName | ( | id _Nullable | object | ) |
Returns the object's class name.
object | The object whose class name should be returned |
uintptr_t object_getTaggedPointerValue | ( | id _Nonnull | object | ) |
Returns the value of the specified tagged pointer.
object | The object whose tagged pointer value should be returned |
bool object_isTaggedPointer | ( | id _Nullable | object | ) |
Returns whether the specified object is a tagged pointer.
object | The object to inspect |
Sets the object's class.
This can be used to swizzle an object's class.
object | The object whose class should be set |
class_ | The new class for the object |
char* _Nullable property_copyAttributeValue | ( | objc_property_t _Nonnull | property, |
const char *_Nonnull | name | ||
) |
Copies the specified attribute value.
property | The property whose attribute value should be copied |
name | The name of the attribute value to copy |
free()
on it when done. const char* _Nonnull property_getName | ( | objc_property_t _Nonnull | property | ) |
Returns the name of the specified property.
property | The property whose name should be returned |
Returns whether the first protocol conforms to the second protocol.
protocol1 | The first protocol |
protocol2 | The second protocol |
const char* _Nonnull protocol_getName | ( | Protocol *_Nonnull | protocol | ) |
Returns the name of the specified protocol.
protocol | The protocol whose name should be returned |
Returns whether two protocols are equal.
protocol1 | The first protocol |
protocol2 | The second protocol |
const char* _Nonnull sel_getName | ( | SEL _Nonnull | selector | ) |
Returns the name of the specified selector.
selector | The selector whose name should be returned |
Checks two selectors for equality.
Selectors are considered equal if they have the same name - any type encoding is ignored.
selector1 | The first selector |
selector2 | The second selector |
SEL _Nonnull sel_registerName | ( | const char *_Nonnull | name | ) |
Registers a selector with the specified name with the runtime.
name | The name for the selector to register |