picofuse-objc

Modules | Classes | Macros | Typedefs | Functions
Objective-C Runtime

Objective-C runtime, providing class introspection, protocols and resolution of selectors to the methods. More...

Collaboration diagram for Objective-C Runtime:

Modules

 Foundation Framework
 Foundational classes and types.
 
 Application Framework
 An application, and the run loop which dispatches its events on one or more cores.
 
 Graphics Framework
 Displays, which the application redraws when they've changed, and drawing on them.
 
 Devices Framework
 A class for each device, named after it: displays, such as SDLWindow, DRMDisplay, Pimoroni's boards and packs and Waveshare's e-paper HATs, which are NXDisplays, and inputs, such as LinuxInput, which send NXKeyEvents and NXMoveEvents.
 
 Network Framework
 It includes the Application framework, which it builds on.
 

Classes

protocol  <ObjectProtocol>
 Protocol for objects. More...
 
class  Object
 The root class of all Objective-C classes. More...
 
class  Protocol
 Protocol class definition. More...
 

Macros

#define objc_assert(condition)
 Asserts that a condition is true. More...
 
#define OBJC_SYNC_CAPACITY   32
 Maximum number of objects which can be locked at any one time, by all threads together. More...
 
#define nil   ((id)0)
 A null object pointer.
 
#define Nil   ((Class)0)
 A null class pointer.
 
#define YES   true
 The Boolean value true.
 
#define NO   false
 The Boolean value false.
 
#define OBJC_ROOT_CLASS
 A macro to declare a class as a root class. More...
 
#define OBJC_UNUSED
 A macro to declare a method parameter is unused. More...
 
#define OBJC_REQUIRES_NIL_TERMINATION
 A macro to indicate that a method requires a nil-terminated list of arguments. More...
 

Typedefs

typedef struct objc_object * id
 A pointer to an instance of a class.
 
typedef const struct objc_selector * SEL
 A pointer to a method selector.
 
typedef struct objc_class * Class
 A pointer to a class definition.
 
typedef id(* IMP) (id, SEL,...)
 A pointer to a method implementation.
 
typedef struct objc_method * Method
 A pointer to a method.
 
typedef struct objc_protocol objc_protocol_t
 An instance of a protocol.
 
typedef bool BOOL
 A Boolean value.
 

Functions

int objc_sync_enter (id obj)
 Acquire a lock on the specified object for thread synchronization. More...
 
int objc_sync_exit (id obj)
 Release a lock on the specified object. More...
 
Class objc_lookupClass (const char *name)
 Looks up a class by name. More...
 
size_t objc_getClassList (Class *classes, size_t count)
 Returns the classes which are registered. More...
 
const char * class_getName (Class cls)
 Returns the name of a class. More...
 
const char * object_getClassName (id obj)
 Returns the name of an object's class. More...
 
Class object_getClass (id object)
 Returns the class of an object. More...
 
void object_setClass (id object, Class cls)
 Sets the class of an object. More...
 
BOOL object_respondsToSelector (id object, SEL sel)
 Checks if an instance's class responds to a selector. More...
 
const char * object_getMethodTypes (id object, SEL sel)
 Returns the types of a method's result and arguments. More...
 
Class object_getSuperclass (id obj)
 Returns the superclass of an object. More...
 
Class class_getSuperclass (Class cls)
 Returns the superclass of a class. More...
 
BOOL object_isKindOfClass (id object, Class cls)
 Checks if an instance class matches, or subclass of another class. More...
 
size_t class_getInstanceSize (Class cls)
 Returns the size of an instance of a class. More...
 
BOOL class_metaclassRespondsToSelector (Class cls, SEL sel)
 Checks if a class object responds to a selector. More...
 
BOOL class_respondsToSelector (Class cls, SEL sel)
 Checks if an instance of a class responds to a selector. More...
 
IMP objc_msg_lookup (id receiver, SEL selector)
 Finds the implementation of a method, as when a message is sent. More...
 
void objc_enumerationMutation (id object)
 Panics, as a collection changed while a for...in loop went through it. More...
 
const char * sel_getName (SEL sel)
 Returns the name of a selector. More...
 
const char * proto_getName (objc_protocol_t *protocol)
 Returns the name of a protocol. More...
 
BOOL proto_conformsTo (objc_protocol_t *protocol, objc_protocol_t *otherProtocol)
 Checks if a protocol conforms to another protocol. More...
 
BOOL class_conformsTo (Class cls, objc_protocol_t *otherProtocol)
 Checks if a class conforms to a protocol. More...
 

Detailed Description

Objective-C runtime, providing class introspection, protocols and resolution of selectors to the methods.

Macro Definition Documentation

◆ objc_assert

#define objc_assert (   condition)
Value:
if (!(condition)) { \
sys_panicf("ASSERT FAIL: %s", #condition); \
}

Asserts that a condition is true.

Parameters
conditionThe condition to check.

If the DEBUG macro is defined, this macro will check the given condition. If the condition is false, it will call panicf with an assertion failure message, including the condition, file name, and line number. If DEBUG is not defined, this macro does nothing.

Definition at line 29 of file assert.h.

◆ OBJC_REQUIRES_NIL_TERMINATION

#define OBJC_REQUIRES_NIL_TERMINATION

A macro to indicate that a method requires a nil-terminated list of arguments.

This macro is used in method declarations to specify that the method accepts a variable number of arguments that must be terminated with nil.

Definition at line 109 of file runtime.h.

◆ OBJC_ROOT_CLASS

#define OBJC_ROOT_CLASS

A macro to declare a class as a root class.

This macro uses the objc_root_class attribute if it is available, which allows a class to be defined without a superclass.

Definition at line 83 of file runtime.h.

◆ OBJC_SYNC_CAPACITY

#define OBJC_SYNC_CAPACITY   32

Maximum number of objects which can be locked at any one time, by all threads together.

Exceeding it panics.

Definition at line 19 of file mutex.h.

◆ OBJC_UNUSED

#define OBJC_UNUSED

A macro to declare a method parameter is unused.

This macro uses the unused attribute if it is available, which allows a method parameter to be marked as unused.

Definition at line 97 of file runtime.h.

Function Documentation

◆ class_conformsTo()

BOOL class_conformsTo ( Class  cls,
objc_protocol_t *  otherProtocol 
)

Checks if a class conforms to a protocol.

Parameters
clsThe class to test for conformance.
otherProtocolThe protocol to check conformance against.
Returns
YES if methods of a cls conforms to otherProtocol, NO otherwise.

◆ class_getInstanceSize()

size_t class_getInstanceSize ( Class  cls)

Returns the size of an instance of a class.

Parameters
clsThe class to inspect.
Returns
The size of an instance of the class in bytes, or 0 if the class is Nil.

◆ class_getName()

const char* class_getName ( Class  cls)

Returns the name of a class.

Parameters
clsThe class to inspect.
Returns
A C-string containing the name of the class, or NULL if cls is Nil.

◆ class_getSuperclass()

Class class_getSuperclass ( Class  cls)

Returns the superclass of a class.

Parameters
clsThe class to inspect.
Returns
The superclass of the class, or Nil if it is a root class.

◆ class_metaclassRespondsToSelector()

BOOL class_metaclassRespondsToSelector ( Class  cls,
SEL  sel 
)

Checks if a class object responds to a selector.

Parameters
clsThe class to inspect.
selThe selector to check.
Returns
YES if the class responds to the selector, NO otherwise.

◆ class_respondsToSelector()

BOOL class_respondsToSelector ( Class  cls,
SEL  sel 
)

Checks if an instance of a class responds to a selector.

Parameters
clsThe class to inspect.
selThe selector to check.
Returns
YES if instances of the class respond to the selector, NO otherwise.

◆ objc_enumerationMutation()

void objc_enumerationMutation ( id  object)

Panics, as a collection changed while a for...in loop went through it.

Parameters
objectThe collection.

The compiler calls this, when the count of changes which the collection gave the loop isn't what it was.

◆ objc_getClassList()

size_t objc_getClassList ( Class *  classes,
size_t  count 
)

Returns the classes which are registered.

Parameters
classesA buffer for the classes, or NULL to only count them.
countThe number of classes the buffer has room for.
Returns
The number of classes, which may be more than count, in which case only count of them are in the buffer. Each class is resolved, as when it's looked up by name.

◆ objc_lookupClass()

Class objc_lookupClass ( const char *  name)

Looks up a class by name.

Parameters
nameThe name of the class to look up.
Returns
The class object, or Nil if the class is not found.

◆ objc_msg_lookup()

IMP objc_msg_lookup ( id  receiver,
SEL  selector 
)

Finds the implementation of a method, as when a message is sent.

Parameters
receiverThe object or class which would receive the message.
selectorThe selector for the message.
Returns
The implementation, which has to be cast to a function with the method's own arguments and return type to be called. Panics if there's no such method.

◆ objc_sync_enter()

int objc_sync_enter ( id  obj)

Acquire a lock on the specified object for thread synchronization.

Parameters
objThe object to lock. Nothing is done if it's nil.
Returns
0 on success, or a non-zero error code on failure.

If another thread holds the lock, this blocks until it's released. A thread can lock an object again which it has already locked, as long as it unlocks it as many times.

◆ objc_sync_exit()

int objc_sync_exit ( id  obj)

Release a lock on the specified object.

Parameters
objThe object to unlock. Must be the same object passed to objc_sync_enter().
Returns
0 on success, or a non-zero error code if the current thread doesn't hold the lock.

◆ object_getClass()

Class object_getClass ( id  object)

Returns the class of an object.

Parameters
objectThe object to inspect.
Returns
The class of the object, or Nil if the object is nil.

◆ object_getClassName()

const char* object_getClassName ( id  obj)

Returns the name of an object's class.

Parameters
objThe object to inspect.
Returns
A C-string containing the name of the object's class, or NULL if obj is nil.

◆ object_getMethodTypes()

const char* object_getMethodTypes ( id  object,
SEL  sel 
)

Returns the types of a method's result and arguments.

Parameters
objectThe object or class which has the method.
selThe selector for the method.
Returns
The type encoding, or NULL if there's no such method.

◆ object_getSuperclass()

Class object_getSuperclass ( id  obj)

Returns the superclass of an object.

Parameters
objThe object to inspect.
Returns
The superclass of the object, or Nil if it is a root class.

◆ object_isKindOfClass()

BOOL object_isKindOfClass ( id  object,
Class  cls 
)

Checks if an instance class matches, or subclass of another class.

Parameters
objectThe object to inspect.
clsThe class to compare against.
Returns
YES if object class matches or is a subclass of cls, NO otherwise.

◆ object_respondsToSelector()

BOOL object_respondsToSelector ( id  object,
SEL  sel 
)

Checks if an instance's class responds to a selector.

Parameters
objectThe object to inspect.
selThe selector to check.
Returns
YES if instances of the class respond to the selector, NO otherwise.

◆ object_setClass()

void object_setClass ( id  object,
Class  cls 
)

Sets the class of an object.

Parameters
objectThe object to modify.
clsThe new class for the object.

◆ proto_conformsTo()

BOOL proto_conformsTo ( objc_protocol_t *  protocol,
objc_protocol_t *  otherProtocol 
)

Checks if a protocol conforms to another protocol.

Parameters
protocolThe protocol to test for conformance.
otherProtocolThe protocol to check conformance against.
Returns
YES if protocol conforms to otherProtocol, NO otherwise.

◆ proto_getName()

const char* proto_getName ( objc_protocol_t *  protocol)

Returns the name of a protocol.

Parameters
protocolThe protocol to inspect.
Returns
A C-string containing the name of the protocol, or NULL if protocol is NULL.

◆ sel_getName()

const char* sel_getName ( SEL  sel)

Returns the name of a selector.

Parameters
selThe selector to inspect.
Returns
A C-string representing the selector's name.