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
46 # include <winsock2.h>
51 OF_ASSUME_NONNULL_BEGIN
76 id _Nonnull right,
void *_Nullable context);
124 static OF_INLINE
OFRange OF_CONST_FUNC
127 OFRange range = { start, length };
139 static OF_INLINE
bool
175 static OF_INLINE
OFPoint OF_CONST_FUNC
190 static OF_INLINE
bool
193 if (point1.
x != point2.
x)
196 if (point1.
y != point2.
y)
221 static OF_INLINE
OFSize OF_CONST_FUNC
224 OFSize size = { width, height };
236 static OF_INLINE
bool
269 static OF_INLINE
OFRect OF_CONST_FUNC
287 static OF_INLINE
bool
336 static OF_INLINE
bool
339 if (vector1.
x != vector2.
x)
342 if (vector1.
y != vector2.
y)
345 if (vector1.
z != vector2.
z)
391 static OF_INLINE
bool
394 if (vector1.
x != vector2.
x)
397 if (vector1.
y != vector2.
y)
400 if (vector1.
z != vector2.
z)
403 if (vector1.
w != vector2.
w)
415 static OF_INLINE
void
418 uint32_t tmp = (uint32_t)*hash;
433 static OF_INLINE
void
447 static OF_INLINE
void
450 uint32_t tmp = (uint32_t)*hash;
459 static 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;
667 - (instancetype)
self;
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;
783 + (instancetype)
alloc;
806 + (bool)isSubclassOfClass: (Class)class_;
813 + (nullable Class)superclass;
822 + (bool)instancesRespondToSelector: (
SEL)selector;
830 + (bool)conformsToProtocol: (
Protocol *)protocol;
840 + (nullable
IMP)instanceMethodForSelector: (
SEL)selector;
852 instanceMethodSignatureForSelector: (
SEL)selector;
870 + (nullable
IMP)replaceClassMethod: (
SEL)selector
871 withMethodFromClass: (Class)class_;
881 + (nullable
IMP)replaceInstanceMethod: (
SEL)selector
882 withMethodFromClass: (Class)class_;
902 + (void)inheritMethodsFromClass: (Class)class_;
912 + (bool)resolveClassMethod: (
SEL)selector;
922 + (bool)resolveInstanceMethod: (
SEL)selector;
965 - (instancetype)
init;
991 - (void)performSelector: (
SEL)selector afterDelay: (
OFTimeInterval)delay;
1002 - (void)performSelector: (
SEL)selector
1003 withObject: (nullable
id)object
1017 - (void)performSelector: (
SEL)selector
1018 withObject: (nullable
id)object1
1019 withObject: (nullable
id)object2
1035 - (void)performSelector: (
SEL)selector
1036 withObject: (nullable
id)object1
1037 withObject: (nullable
id)object2
1038 withObject: (nullable
id)object3
1056 - (void)performSelector: (
SEL)selector
1057 withObject: (nullable
id)object1
1058 withObject: (nullable
id)object2
1059 withObject: (nullable
id)object3
1060 withObject: (nullable
id)object4
1063 #ifdef OF_HAVE_THREADS
1071 - (void)performSelector: (
SEL)selector
1073 waitUntilDone: (
bool)waitUntilDone;
1085 - (void)performSelector: (
SEL)selector
1087 withObject: (nullable
id)object
1088 waitUntilDone: (
bool)waitUntilDone;
1102 - (void)performSelector: (
SEL)selector
1104 withObject: (nullable
id)object1
1105 withObject: (nullable
id)object2
1106 waitUntilDone: (
bool)waitUntilDone;
1122 - (void)performSelector: (
SEL)selector
1124 withObject: (nullable
id)object1
1125 withObject: (nullable
id)object2
1126 withObject: (nullable
id)object3
1127 waitUntilDone: (
bool)waitUntilDone;
1145 - (void)performSelector: (
SEL)selector
1147 withObject: (nullable
id)object1
1148 withObject: (nullable
id)object2
1149 withObject: (nullable
id)object3
1150 withObject: (nullable
id)object4
1151 waitUntilDone: (
bool)waitUntilDone;
1159 - (void)performSelectorOnMainThread: (
SEL)selector
1160 waitUntilDone: (
bool)waitUntilDone;
1171 - (void)performSelectorOnMainThread: (
SEL)selector
1172 withObject: (nullable
id)object
1173 waitUntilDone: (
bool)waitUntilDone;
1186 - (void)performSelectorOnMainThread: (
SEL)selector
1187 withObject: (nullable
id)object1
1188 withObject: (nullable
id)object2
1189 waitUntilDone: (
bool)waitUntilDone;
1204 - (void)performSelectorOnMainThread: (
SEL)selector
1205 withObject: (nullable
id)object1
1206 withObject: (nullable
id)object2
1207 withObject: (nullable
id)object3
1208 waitUntilDone: (
bool)waitUntilDone;
1225 - (void)performSelectorOnMainThread: (
SEL)selector
1226 withObject: (nullable
id)object1
1227 withObject: (nullable
id)object2
1228 withObject: (nullable
id)object3
1229 withObject: (nullable
id)object4
1230 waitUntilDone: (
bool)waitUntilDone;
1240 - (void)performSelector: (
SEL)selector
1254 - (void)performSelector: (
SEL)selector
1256 withObject: (nullable
id)object
1271 - (void)performSelector: (
SEL)selector
1273 withObject: (nullable
id)object1
1274 withObject: (nullable
id)object2
1291 - (void)performSelector: (
SEL)selector
1293 withObject: (nullable
id)object1
1294 withObject: (nullable
id)object2
1295 withObject: (nullable
id)object3
1314 - (void)performSelector: (
SEL)selector
1316 withObject: (nullable
id)object1
1317 withObject: (nullable
id)object2
1318 withObject: (nullable
id)object3
1319 withObject: (nullable
id)object4
1334 - (nullable id)forwardingTargetForSelector: (
SEL)selector;
1345 - (void)doesNotRecognizeSelector: (
SEL)selector OF_NO_RETURN;
1418 extern void *_Nullable
OFAllocMemory(
size_t count,
size_t size)
1419 OF_WARN_UNUSED_RESULT;
1436 OF_WARN_UNUSED_RESULT;
1455 extern void *_Nullable
OFResizeMemory(
void *_Nullable pointer,
size_t count,
1456 size_t size) OF_WARN_UNUSED_RESULT;
1467 #ifdef OF_APPLE_RUNTIME
1470 # ifdef OF_DECLARE_CONSTRUCT_INSTANCE
1472 void *_Nullable bytes);
1475 # ifdef OF_DECLARE_SET_ASSOCIATED_OBJECT
1484 const void *_Nonnull key,
id _Nullable value,
1487 const void *_Nonnull key);
1504 extern id OFAllocObject(Class class_,
size_t extraSize,
size_t extraAlignment,
1505 void *_Nullable *_Nullable extra);
1536 extern void OFHashInit(
unsigned long *_Nonnull hash);
1562 OF_ASSUME_NONNULL_END
1565 #import "OFObject+KeyValueCoding.h"
static OF_INLINE OFRect OF_CONST_FUNC OFMakeRect(float x, float y, float width, float height)
Creates a new OFRect.
Definition: OFObject.h:270
static OF_INLINE void OFHashFinalize(unsigned long *hash)
Finalizes the specified hash.
Definition: OFObject.h:448
static OF_INLINE void OFHashAddByte(unsigned long *hash, unsigned char byte)
Adds the specified byte to the hash.
Definition: OFObject.h:416
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:314
static OF_INLINE bool OFEqualVectors4D(OFVector4D vector1, OFVector4D vector2)
Returns whether the two vectors are equal.
Definition: OFObject.h:392
OFComparisonResult(^ OFComparator)(id left, id right)
A comparator to compare two objects.
Definition: OFObject.h:86
static OF_INLINE bool OFEqualRanges(OFRange range1, OFRange range2)
Returns whether the two ranges are equal.
Definition: OFObject.h:140
static OF_INLINE void OFHashAddHash(unsigned long *hash, unsigned long otherHash)
Adds the specified hash to the hash.
Definition: OFObject.h:434
static OF_INLINE bool OFEqualSizes(OFSize size1, OFSize size2)
Returns whether the two sizes are equal.
Definition: OFObject.h:237
static OF_INLINE OFSize OF_CONST_FUNC OFMakeSize(float width, float height)
Creates a new OFSize.
Definition: OFObject.h:222
uint32_t OFRandom32(void)
Returns 32 bit or non-cryptographical randomness.
Definition: OFObject.m:258
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:149
void OFFreeMemory(void *pointer)
Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.
Definition: OFObject.m:167
double OFTimeInterval
A time interval in seconds.
Definition: OFObject.h:154
void * OFAllocMemory(size_t count, size_t size)
Allocates memory for the specified number of items of the specified size.
Definition: OFObject.m:112
uint64_t OFRandom64(void)
Returns 64 bit or non-cryptographical randomness.
Definition: OFObject.m:284
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
static OF_INLINE bool OFEqualVectors3D(OFVector3D vector1, OFVector3D vector2)
Returns whether the two vectors are equal.
Definition: OFObject.h:337
id OFAllocObject(Class class_, size_t extraSize, size_t extraAlignment, void **extra)
Allocates a new object.
Definition: OFObject.m:408
uint16_t OFRandom16(void)
Returns 16 bit or non-cryptographical randomness.
Definition: OFObject.m:228
static OF_INLINE bool OFEqualPoints(OFPoint point1, OFPoint point2)
Returns whether the two points are equal.
Definition: OFObject.h:191
static OF_INLINE bool OFEqualRects(OFRect rect1, OFRect rect2)
Returns whether the two rectangles are equal.
Definition: OFObject.h:288
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:130
OFComparisonResult(* OFCompareFunction)(id left, id right, void *context)
A function to compare two objects.
Definition: OFObject.h:75
static OF_INLINE OFVector4D OF_CONST_FUNC OFMakeVector4D(float x, float y, float z, float w)
Creates a new OFVector4D.
Definition: OFObject.h:377
void OFMethodNotFound(id self, SEL _cmd)
This function is called when a method is not found.
Definition: OFObject.m:388
static OF_INLINE OFPoint OF_CONST_FUNC OFMakePoint(float x, float y)
Creates a new OFPoint.
Definition: OFObject.h:176
static OF_INLINE OFRange OF_CONST_FUNC OFMakeRange(size_t start, size_t length)
Creates a new OFRange.
Definition: OFObject.h:125
static OF_INLINE OFVector3D OF_CONST_FUNC OFMakeVector3D(float x, float y, float z)
Creates a new OFVector3D.
Definition: OFObject.h:322
id(* IMP)(id object, SEL selector,...)
A method implementation.
Definition: ObjFWRT.h:146
void *_Null_unspecified objc_autoreleasePoolPush(void)
Creates a new autorelease pool and puts it on top of the stack of autorelease pools.
Definition: autorelease-foundation.m:37
void objc_removeAssociatedObjects(id object)
Removes all associated objects for the specified object.
Definition: association.m:228
void * objc_destructInstance(id object)
Destructs the specified object.
Definition: instance.m:83
id objc_constructInstance(Class class_, void *bytes)
Constructs an instance of the specified class in the specified array of bytes.
Definition: instance.m:67
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.
Definition: association.m:116
id objc_getAssociatedObject(id object, const void *key)
Returns the associated object on the specified object for the specified key.
Definition: association.m:186
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 aut...
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:696
void dealloc()
Deallocates the object.
Definition: OFObject.m:1339
id copy()
Returns the class.
Definition: OFObject.m:1407
void unload()
A method which is called when the class is unloaded from the runtime.
Definition: OFObject.m:540
instancetype alloc()
Allocates memory for an instance of the class and sets up the memory pool for the object.
Definition: OFObject.m:548
void initialize()
A method which is called the moment before the first call to the class is being made.
Definition: OFObject.m:544
void load()
A method which is called once when the class is loaded into the runtime.
Definition: OFObject.m:505
A class for handling strings.
Definition: OFString.h:143
A class which provides portable threads.
Definition: OFThread.h:66
A protocol for comparing objects.
Definition: OFObject.h:1392
A protocol for the creation of copies.
Definition: OFObject.h:1354
id copy()
Copies the object.
A protocol for the creation of mutable copies.
Definition: OFObject.h:1375
id mutableCopy()
Creates a mutable copy of the object.
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