20#include "objfw-defs.h"
22#ifndef __STDC_LIMIT_MACROS
23# define __STDC_LIMIT_MACROS
25#ifndef __STDC_CONSTANT_MACROS
26# define __STDC_CONSTANT_MACROS
45# ifdef __MINGW64_VERSION_MAJOR
51OF_ASSUME_NONNULL_BEGIN
76 id _Nonnull right,
void *_Nullable context);
124static OF_INLINE
OFRange OF_CONST_FUNC
125OFMakeRange(
size_t start,
size_t length)
127 OFRange range = { start, length };
175static OF_INLINE
OFPoint OF_CONST_FUNC
176OFMakePoint(
float x,
float y)
193 if (point1.
x != point2.
x)
196 if (point1.
y != point2.
y)
221static OF_INLINE
OFSize OF_CONST_FUNC
222OFMakeSize(
float width,
float height)
224 OFSize size = { width, height };
269static OF_INLINE
OFRect OF_CONST_FUNC
270OFMakeRect(
float x,
float y,
float width,
float height)
274 OFMakeSize(width, height)
293 if (!OFEqualSizes(rect1.
size, rect2.
size))
322OFMakeVector3D(
float x,
float y,
float z)
339 if (vector1.
x != vector2.
x)
342 if (vector1.
y != vector2.
y)
345 if (vector1.
z != vector2.
z)
377OFMakeVector4D(
float x,
float y,
float z,
float w)
394 if (vector1.
x != vector2.
x)
397 if (vector1.
y != vector2.
y)
400 if (vector1.
z != vector2.
z)
403 if (vector1.
w != vector2.
w)
416OFHashAddByte(
unsigned long *_Nonnull hash,
unsigned char byte)
418 uint32_t tmp = (uint32_t)*hash;
434OFHashAddHash(
unsigned long *_Nonnull hash,
unsigned long otherHash)
436 OFHashAddByte(hash, (otherHash >> 24) & 0xFF);
437 OFHashAddByte(hash, (otherHash >> 16) & 0xFF);
438 OFHashAddByte(hash, (otherHash >> 8) & 0xFF);
439 OFHashAddByte(hash, otherHash & 0xFF);
448OFHashFinalize(
unsigned long *_Nonnull hash)
450 uint32_t tmp = (uint32_t)*hash;
459static const size_t OFNotFound = SIZE_MAX;
483- (nullable Class)superclass;
497- (
unsigned long)hash;
504- (
unsigned int)retainCount;
519- (bool)isKindOfClass: (Class)class_;
528- (bool)isMemberOfClass: (Class)class_;
537- (bool)respondsToSelector: (
SEL)selector;
545- (bool)conformsToProtocol: (
Protocol *)protocol;
553- (nullable
IMP)methodForSelector: (
SEL)selector;
561- (nullable id)performSelector: (
SEL)selector;
571- (nullable id)performSelector: (
SEL)selector withObject: (nullable
id)object;
583- (nullable id)performSelector: (
SEL)selector
584 withObject: (nullable
id)object1
585 withObject: (nullable
id)object2;
599- (nullable id)performSelector: (
SEL)selector
600 withObject: (nullable
id)object1
601 withObject: (nullable
id)object2
602 withObject: (nullable
id)object3;
618- (nullable id)performSelector: (
SEL)selector
619 withObject: (nullable
id)object1
620 withObject: (nullable
id)object2
621 withObject: (nullable
id)object3
622 withObject: (nullable
id)object4;
636- (bool)isEqual: (nullable
id)object;
674- (bool)allowsWeakReference;
693#ifndef __clang_analyzer__
696 Class _isa __attribute__((__unused__));
700#ifdef OF_HAVE_CLASS_PROPERTIES
702@property (
class, readonly, nonatomic) Class
class;
704@property (
class, readonly, nonatomic, getter=
class) Class class_;
707@property (
class, readonly, nullable, nonatomic) Class superclass;
712@property (readonly, nonatomic) Class
class;
714@property (readonly, nonatomic, getter=
class) Class class_;
716@property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class superclass;
717@property (readonly, nonatomic)
unsigned long hash;
718@property (readonly, nonatomic)
unsigned int retainCount;
719@property (readonly, nonatomic)
bool isProxy;
720@property (readonly, nonatomic)
bool allowsWeakReference;
779+ (instancetype)
alloc;
802+ (bool)isSubclassOfClass: (Class)class_;
809+ (nullable Class)superclass;
818+ (bool)instancesRespondToSelector: (
SEL)selector;
826+ (bool)conformsToProtocol: (
Protocol *)protocol;
836+ (nullable
IMP)instanceMethodForSelector: (
SEL)selector;
848 instanceMethodSignatureForSelector: (
SEL)selector;
866+ (nullable
IMP)replaceClassMethod: (
SEL)selector
867 withMethodFromClass: (Class)class_;
877+ (nullable
IMP)replaceInstanceMethod: (
SEL)selector
878 withMethodFromClass: (Class)class_;
898+ (void)inheritMethodsFromClass: (Class)class_;
908+ (bool)resolveClassMethod: (
SEL)selector;
918+ (bool)resolveInstanceMethod: (
SEL)selector;
987- (void)performSelector: (
SEL)selector afterDelay: (
OFTimeInterval)delay;
998- (void)performSelector: (
SEL)selector
999 withObject: (nullable
id)object
1013- (void)performSelector: (
SEL)selector
1014 withObject: (nullable
id)object1
1015 withObject: (nullable
id)object2
1031- (void)performSelector: (
SEL)selector
1032 withObject: (nullable
id)object1
1033 withObject: (nullable
id)object2
1034 withObject: (nullable
id)object3
1052- (void)performSelector: (
SEL)selector
1053 withObject: (nullable
id)object1
1054 withObject: (nullable
id)object2
1055 withObject: (nullable
id)object3
1056 withObject: (nullable
id)object4
1059#ifdef OF_HAVE_THREADS
1067- (void)performSelector: (
SEL)selector
1069 waitUntilDone: (
bool)waitUntilDone;
1081- (void)performSelector: (
SEL)selector
1083 withObject: (nullable
id)object
1084 waitUntilDone: (
bool)waitUntilDone;
1098- (void)performSelector: (
SEL)selector
1100 withObject: (nullable
id)object1
1101 withObject: (nullable
id)object2
1102 waitUntilDone: (
bool)waitUntilDone;
1118- (void)performSelector: (
SEL)selector
1120 withObject: (nullable
id)object1
1121 withObject: (nullable
id)object2
1122 withObject: (nullable
id)object3
1123 waitUntilDone: (
bool)waitUntilDone;
1141- (void)performSelector: (
SEL)selector
1143 withObject: (nullable
id)object1
1144 withObject: (nullable
id)object2
1145 withObject: (nullable
id)object3
1146 withObject: (nullable
id)object4
1147 waitUntilDone: (
bool)waitUntilDone;
1155- (void)performSelectorOnMainThread: (
SEL)selector
1156 waitUntilDone: (
bool)waitUntilDone;
1167- (void)performSelectorOnMainThread: (
SEL)selector
1168 withObject: (nullable
id)object
1169 waitUntilDone: (
bool)waitUntilDone;
1182- (void)performSelectorOnMainThread: (
SEL)selector
1183 withObject: (nullable
id)object1
1184 withObject: (nullable
id)object2
1185 waitUntilDone: (
bool)waitUntilDone;
1200- (void)performSelectorOnMainThread: (
SEL)selector
1201 withObject: (nullable
id)object1
1202 withObject: (nullable
id)object2
1203 withObject: (nullable
id)object3
1204 waitUntilDone: (
bool)waitUntilDone;
1221- (void)performSelectorOnMainThread: (
SEL)selector
1222 withObject: (nullable
id)object1
1223 withObject: (nullable
id)object2
1224 withObject: (nullable
id)object3
1225 withObject: (nullable
id)object4
1226 waitUntilDone: (
bool)waitUntilDone;
1236- (void)performSelector: (
SEL)selector
1250- (void)performSelector: (
SEL)selector
1252 withObject: (nullable
id)object
1267- (void)performSelector: (
SEL)selector
1269 withObject: (nullable
id)object1
1270 withObject: (nullable
id)object2
1287- (void)performSelector: (
SEL)selector
1289 withObject: (nullable
id)object1
1290 withObject: (nullable
id)object2
1291 withObject: (nullable
id)object3
1310- (void)performSelector: (
SEL)selector
1312 withObject: (nullable
id)object1
1313 withObject: (nullable
id)object2
1314 withObject: (nullable
id)object3
1315 withObject: (nullable
id)object4
1330- (nullable id)forwardingTargetForSelector: (
SEL)selector;
1341- (void)doesNotRecognizeSelector: (
SEL)selector OF_NO_RETURN;
1370@protocol OFMutableCopying
1387@protocol OFComparing
1414extern void *_Nullable
OFAllocMemory(
size_t count,
size_t size)
1415 OF_WARN_UNUSED_RESULT;
1432 OF_WARN_UNUSED_RESULT;
1451extern void *_Nullable
OFResizeMemory(
void *_Nullable pointer,
size_t count,
1452 size_t size) OF_WARN_UNUSED_RESULT;
1463#ifdef OF_APPLE_RUNTIME
1464extern void *_Null_unspecified objc_autoreleasePoolPush(
void);
1465extern void objc_autoreleasePoolPop(
void *_Null_unspecified pool);
1467extern id _Nullable objc_constructInstance(Class _Nullable class_,
1468 void *_Nullable bytes);
1469extern void *_Nullable objc_destructInstance(
id _Nullable
object);
1477extern void objc_setAssociatedObject(
id _Nonnull
object,
1478 const void *_Nonnull key,
id _Nullable value,
1480extern id _Nullable objc_getAssociatedObject(
id _Nonnull
object,
1481 const void *_Nonnull key);
1482extern void objc_removeAssociatedObjects(
id _Nonnull
object);
1485extern id OFAllocObject(Class class_,
size_t extraSize,
size_t extraAlignment,
1486 void *_Nullable *_Nullable extra);
1487extern void OF_NO_RETURN_FUNC OFMethodNotFound(
id self,
SEL _cmd);
1494extern void OFHashInit(
unsigned long *_Nonnull hash);
1520OF_ASSUME_NONNULL_END
1523#import "OFObject+KeyValueCoding.h"
void * OFResizeMemory(void *pointer, size_t count, size_t size)
Resizes memory to the specified number of items of the specified size.
Definition: OFObject.m:145
void * OFAllocMemory(size_t count, size_t size)
Allocates memory for the specified number of items of the specified size.
Definition: OFObject.m:108
OFComparisonResult
A result of a comparison.
Definition: OFObject.h:58
@ OFOrderedAscending
Definition: OFObject.h:60
@ OFOrderedDescending
Definition: OFObject.h:64
@ OFOrderedSame
Definition: OFObject.h:62
void OFHashInit(unsigned long *hash)
Initializes the specified hash.
Definition: OFObject.m:270
OFComparisonResult(^ OFComparator)(id left, id right)
A comparator to compare two objects.
Definition: OFObject.h:86
uint32_t OFRandom32(void)
Returns 32 bit or non-cryptographical randomness.
Definition: OFObject.m:234
void OFFreeMemory(void *pointer)
Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.
Definition: OFObject.m:163
double OFTimeInterval
A time interval in seconds.
Definition: OFObject.h:154
uint64_t OFRandom64(void)
Returns 64 bit or non-cryptographical randomness.
Definition: OFObject.m:250
OFByteOrder
An enum for representing endianness.
Definition: OFObject.h:92
@ OFByteOrderBigEndian
Definition: OFObject.h:94
@ OFByteOrderLittleEndian
Definition: OFObject.h:96
@ OFByteOrderNative
Definition: OFObject.h:101
void * OFAllocZeroedMemory(size_t count, size_t size)
Allocates memory for the specified number of items of the specified size and initializes it with zero...
Definition: OFObject.m:126
uint16_t OFRandom16(void)
Returns 16 bit or non-cryptographical randomness.
Definition: OFObject.m:212
OFComparisonResult(* OFCompareFunction)(id left, id right, void *context)
A function to compare two objects.
Definition: OFObject.h:75
id(* IMP)(id object, SEL selector,...)
A method implementation.
Definition: ObjFWRT.h:146
const struct objc_protocol * Protocol
A protocol.
Definition: ObjFWRT.h:117
objc_associationPolicy
A policy for object association, see objc_setAssociatedObject.
Definition: ObjFWRT.h:183
@ OBJC_ASSOCIATION_RETAIN_NONATOMIC
Associate the object like a retained, nonatomic property.
Definition: ObjFWRT.h:187
@ OBJC_ASSOCIATION_COPY
Associate the object like a copied property.
Definition: ObjFWRT.h:193
@ OBJC_ASSOCIATION_RETAIN
Associate the object like a retained property.
Definition: ObjFWRT.h:189
@ OBJC_ASSOCIATION_ASSIGN
Associate the object like an assigned property.
Definition: ObjFWRT.h:185
@ OBJC_ASSOCIATION_COPY_NONATOMIC
Associate the object like a copied, nonatomic property.
Definition: ObjFWRT.h:191
A class for parsing type encodings and accessing them.
Definition: OFMethodSignature.h:33
The root class for all other classes inside ObjFW.
Definition: OFObject.h:692
OFString * description
A description for the object.
Definition: OFObject.h:734
OFString * className
The name of the object's class.
Definition: OFObject.h:726
instancetype init()
Initializes an already allocated object.
Definition: OFObject.m:652
void dealloc()
Deallocates the object.
Definition: OFObject.m:1295
id copy()
Returns the class.
Definition: OFObject.m:1363
void unload()
A method which is called when the class is unloaded from the runtime.
Definition: OFObject.m:496
instancetype alloc()
Allocates memory for an instance of the class and sets up the memory pool for the object.
Definition: OFObject.m:504
void initialize()
A method which is called the moment before the first call to the class is being made.
Definition: OFObject.m:500
void load()
A method which is called once when the class is loaded into the runtime.
Definition: OFObject.m:461
A class for handling strings.
Definition: OFString.h:139
A class which provides portable threads.
Definition: OFThread.h:66
instancetype autorelease()
Adds the object to the topmost autorelease pool of the thread's autorelease pool stack.
instancetype self()
Returns the receiver.
void release()
Decreases the retain count.
instancetype retain()
Increases the retain count.
bool retainWeakReference()
Retain a weak reference to this object.
A point in 2D space.
Definition: OFObject.h:161
float y
Definition: OFObject.h:165
float x
Definition: OFObject.h:163
A range.
Definition: OFObject.h:110
size_t length
Definition: OFObject.h:114
size_t location
Definition: OFObject.h:112
A rectangle.
Definition: OFObject.h:253
OFPoint origin
Definition: OFObject.h:255
OFSize size
Definition: OFObject.h:257
A size.
Definition: OFObject.h:207
float width
Definition: OFObject.h:209
float height
Definition: OFObject.h:211
A vector in 3D space.
Definition: OFObject.h:304
float x
Definition: OFObject.h:306
float y
Definition: OFObject.h:308
float z
Definition: OFObject.h:310
A vector in 4D space.
Definition: OFObject.h:356
float x
Definition: OFObject.h:358
float z
Definition: OFObject.h:362
float y
Definition: OFObject.h:360
float w
Definition: OFObject.h:364