16 #include "objfw-defs.h"
18 #ifndef __STDC_LIMIT_MACROS
19 # define __STDC_LIMIT_MACROS
21 #ifndef __STDC_CONSTANT_MACROS
22 # define __STDC_CONSTANT_MACROS
41 # ifdef __MINGW64_VERSION_MAJOR
42 # include <winsock2.h>
47 OF_ASSUME_NONNULL_BEGIN
72 id _Nonnull right,
void *_Nullable context);
120 static OF_INLINE
OFRange OF_CONST_FUNC
121 OFMakeRange(
size_t start,
size_t length)
123 OFRange range = { start, length };
135 static OF_INLINE
bool
171 static OF_INLINE
OFPoint OF_CONST_FUNC
172 OFMakePoint(
float x,
float y)
186 static OF_INLINE
bool
189 if (point1.
x != point2.
x)
192 if (point1.
y != point2.
y)
217 static OF_INLINE
OFSize OF_CONST_FUNC
218 OFMakeSize(
float width,
float height)
220 OFSize size = { width, height };
232 static OF_INLINE
bool
265 static OF_INLINE
OFRect OF_CONST_FUNC
266 OFMakeRect(
float x,
float y,
float width,
float height)
270 OFMakeSize(width, height)
283 static OF_INLINE
bool
289 if (!OFEqualSizes(rect1.
size, rect2.
size))
318 OFMakeVector3D(
float x,
float y,
float z)
332 static OF_INLINE
bool
335 if (vector1.
x != vector2.
x)
338 if (vector1.
y != vector2.
y)
341 if (vector1.
z != vector2.
z)
373 OFMakeVector4D(
float x,
float y,
float z,
float w)
387 static OF_INLINE
bool
390 if (vector1.
x != vector2.
x)
393 if (vector1.
y != vector2.
y)
396 if (vector1.
z != vector2.
z)
399 if (vector1.
w != vector2.
w)
411 static OF_INLINE
void
412 OFHashAddByte(
unsigned long *_Nonnull hash,
unsigned char byte)
414 uint32_t tmp = (uint32_t)*hash;
429 static OF_INLINE
void
430 OFHashAddHash(
unsigned long *_Nonnull hash,
unsigned long otherHash)
432 OFHashAddByte(hash, (otherHash >> 24) & 0xFF);
433 OFHashAddByte(hash, (otherHash >> 16) & 0xFF);
434 OFHashAddByte(hash, (otherHash >> 8) & 0xFF);
435 OFHashAddByte(hash, otherHash & 0xFF);
443 static OF_INLINE
void
444 OFHashFinalize(
unsigned long *_Nonnull hash)
446 uint32_t tmp = (uint32_t)*hash;
455 static const size_t OFNotFound = SIZE_MAX;
479 - (nullable Class)superclass;
493 - (
unsigned long)hash;
500 - (
unsigned int)retainCount;
515 - (bool)isKindOfClass: (Class)class_;
524 - (bool)isMemberOfClass: (Class)class_;
533 - (bool)respondsToSelector: (
SEL)selector;
541 - (bool)conformsToProtocol: (
Protocol *)protocol;
549 - (nullable
IMP)methodForSelector: (
SEL)selector;
557 - (nullable id)performSelector: (
SEL)selector;
567 - (nullable id)performSelector: (
SEL)selector withObject: (nullable
id)object;
579 - (nullable id)performSelector: (
SEL)selector
580 withObject: (nullable
id)object1
581 withObject: (nullable
id)object2;
595 - (nullable id)performSelector: (
SEL)selector
596 withObject: (nullable
id)object1
597 withObject: (nullable
id)object2
598 withObject: (nullable
id)object3;
614 - (nullable id)performSelector: (
SEL)selector
615 withObject: (nullable
id)object1
616 withObject: (nullable
id)object2
617 withObject: (nullable
id)object3
618 withObject: (nullable
id)object4;
632 - (bool)isEqual: (nullable
id)object;
663 - (instancetype)
self;
670 - (bool)allowsWeakReference;
689 #ifndef __clang_analyzer__
692 Class _isa __attribute__((__unused__));
696 #ifdef OF_HAVE_CLASS_PROPERTIES
698 @property (
class, readonly, nonatomic) Class
class;
700 @property (
class, readonly, nonatomic, getter=
class) Class class_;
703 @property (
class, readonly, nullable, nonatomic) Class superclass;
708 @property (readonly, nonatomic) Class
class;
710 @property (readonly, nonatomic, getter=
class) Class class_;
712 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class superclass;
713 @property (readonly, nonatomic)
unsigned long hash;
714 @property (readonly, nonatomic)
unsigned int retainCount;
715 @property (readonly, nonatomic)
bool isProxy;
716 @property (readonly, nonatomic)
bool allowsWeakReference;
775 + (instancetype)
alloc;
798 + (bool)isSubclassOfClass: (Class)class_;
805 + (nullable Class)superclass;
814 + (bool)instancesRespondToSelector: (
SEL)selector;
822 + (bool)conformsToProtocol: (
Protocol *)protocol;
832 + (nullable
IMP)instanceMethodForSelector: (
SEL)selector;
844 instanceMethodSignatureForSelector: (
SEL)selector;
862 + (nullable
IMP)replaceClassMethod: (
SEL)selector
863 withMethodFromClass: (Class)class_;
873 + (nullable
IMP)replaceInstanceMethod: (
SEL)selector
874 withMethodFromClass: (Class)class_;
894 + (void)inheritMethodsFromClass: (Class)class_;
904 + (bool)resolveClassMethod: (
SEL)selector;
914 + (bool)resolveInstanceMethod: (
SEL)selector;
957 - (instancetype)
init;
983 - (void)performSelector: (
SEL)selector afterDelay: (
OFTimeInterval)delay;
994 - (void)performSelector: (
SEL)selector
995 withObject: (nullable
id)object
1009 - (void)performSelector: (
SEL)selector
1010 withObject: (nullable
id)object1
1011 withObject: (nullable
id)object2
1027 - (void)performSelector: (
SEL)selector
1028 withObject: (nullable
id)object1
1029 withObject: (nullable
id)object2
1030 withObject: (nullable
id)object3
1048 - (void)performSelector: (
SEL)selector
1049 withObject: (nullable
id)object1
1050 withObject: (nullable
id)object2
1051 withObject: (nullable
id)object3
1052 withObject: (nullable
id)object4
1055 #ifdef OF_HAVE_THREADS
1063 - (void)performSelector: (
SEL)selector
1065 waitUntilDone: (
bool)waitUntilDone;
1077 - (void)performSelector: (
SEL)selector
1079 withObject: (nullable
id)object
1080 waitUntilDone: (
bool)waitUntilDone;
1094 - (void)performSelector: (
SEL)selector
1096 withObject: (nullable
id)object1
1097 withObject: (nullable
id)object2
1098 waitUntilDone: (
bool)waitUntilDone;
1114 - (void)performSelector: (
SEL)selector
1116 withObject: (nullable
id)object1
1117 withObject: (nullable
id)object2
1118 withObject: (nullable
id)object3
1119 waitUntilDone: (
bool)waitUntilDone;
1137 - (void)performSelector: (
SEL)selector
1139 withObject: (nullable
id)object1
1140 withObject: (nullable
id)object2
1141 withObject: (nullable
id)object3
1142 withObject: (nullable
id)object4
1143 waitUntilDone: (
bool)waitUntilDone;
1151 - (void)performSelectorOnMainThread: (
SEL)selector
1152 waitUntilDone: (
bool)waitUntilDone;
1163 - (void)performSelectorOnMainThread: (
SEL)selector
1164 withObject: (nullable
id)object
1165 waitUntilDone: (
bool)waitUntilDone;
1178 - (void)performSelectorOnMainThread: (
SEL)selector
1179 withObject: (nullable
id)object1
1180 withObject: (nullable
id)object2
1181 waitUntilDone: (
bool)waitUntilDone;
1196 - (void)performSelectorOnMainThread: (
SEL)selector
1197 withObject: (nullable
id)object1
1198 withObject: (nullable
id)object2
1199 withObject: (nullable
id)object3
1200 waitUntilDone: (
bool)waitUntilDone;
1217 - (void)performSelectorOnMainThread: (
SEL)selector
1218 withObject: (nullable
id)object1
1219 withObject: (nullable
id)object2
1220 withObject: (nullable
id)object3
1221 withObject: (nullable
id)object4
1222 waitUntilDone: (
bool)waitUntilDone;
1232 - (void)performSelector: (
SEL)selector
1246 - (void)performSelector: (
SEL)selector
1248 withObject: (nullable
id)object
1263 - (void)performSelector: (
SEL)selector
1265 withObject: (nullable
id)object1
1266 withObject: (nullable
id)object2
1283 - (void)performSelector: (
SEL)selector
1285 withObject: (nullable
id)object1
1286 withObject: (nullable
id)object2
1287 withObject: (nullable
id)object3
1306 - (void)performSelector: (
SEL)selector
1308 withObject: (nullable
id)object1
1309 withObject: (nullable
id)object2
1310 withObject: (nullable
id)object3
1311 withObject: (nullable
id)object4
1326 - (nullable id)forwardingTargetForSelector: (
SEL)selector;
1337 - (void)doesNotRecognizeSelector: (
SEL)selector OF_NO_RETURN;
1409 extern void *_Nullable
OFAllocMemory(
size_t count,
size_t size)
1410 OF_WARN_UNUSED_RESULT;
1427 OF_WARN_UNUSED_RESULT;
1446 extern void *_Nullable
OFResizeMemory(
void *_Nullable pointer,
size_t count,
1447 size_t size) OF_WARN_UNUSED_RESULT;
1458 #ifdef OF_APPLE_RUNTIME
1463 void *_Nullable bytes);
1467 extern id OFAllocObject(Class class_,
size_t extraSize,
size_t extraAlignment,
1468 void *_Nullable *_Nullable extra);
1469 extern void OF_NO_RETURN_FUNC OFMethodNotFound(
id self,
SEL _cmd);
1476 extern void OFHashInit(
unsigned long *_Nonnull hash);
1502 OF_ASSUME_NONNULL_END
1505 #import "OFObject+KeyValueCoding.h"
OFComparisonResult
A result of a comparison.
Definition: OFObject.h:54
@ OFOrderedAscending
Definition: OFObject.h:56
@ OFOrderedDescending
Definition: OFObject.h:60
@ OFOrderedSame
Definition: OFObject.h:58
void OFHashInit(unsigned long *hash)
Initializes the specified hash.
Definition: OFObject.m:236
OFComparisonResult(^ OFComparator)(id left, id right)
A comparator to compare two objects.
Definition: OFObject.h:82
uint32_t OFRandom32(void)
Returns 32 bit or non-cryptographical randomness.
Definition: OFObject.m:200
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:138
void OFFreeMemory(void *pointer)
Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.
Definition: OFObject.m:156
double OFTimeInterval
A time interval in seconds.
Definition: OFObject.h:150
void * OFAllocMemory(size_t count, size_t size)
Allocates memory for the specified number of items of the specified size.
Definition: OFObject.m:101
uint64_t OFRandom64(void)
Returns 64 bit or non-cryptographical randomness.
Definition: OFObject.m:216
OFByteOrder
An enum for representing endianess.
Definition: OFObject.h:88
@ OFByteOrderBigEndian
Definition: OFObject.h:90
@ OFByteOrderLittleEndian
Definition: OFObject.h:92
@ OFByteOrderNative
Definition: OFObject.h:97
uint16_t OFRandom16(void)
Returns 16 bit or non-cryptographical randomness.
Definition: OFObject.m:178
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:119
OFComparisonResult(* OFCompareFunction)(id left, id right, void *context)
A function to compare two objects.
Definition: OFObject.h:71
id(* IMP)(id object, SEL selector,...)
A method implemenation.
Definition: ObjFWRT.h:142
void *_Null_unspecified objc_autoreleasePoolPush(void)
Creates a new autorelease pool and puts it on top of the stack of autorelease pools.
Definition: autorelease.m:66
void * objc_destructInstance(id object)
Destructs the specified object.
Definition: instance.m:75
id objc_constructInstance(Class class_, void *bytes)
Constructs an instance of the specified class in the specified array of bytes.
Definition: instance.m:59
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:113
A class for parsing type encodings and accessing them.
Definition: OFMethodSignature.h:29
The root class for all other classes inside ObjFW.
Definition: OFObject.h:688
OFString * description
A description for the object.
Definition: OFObject.h:730
OFString * className
The name of the object's class.
Definition: OFObject.h:722
instancetype init()
Initializes an already allocated object.
Definition: OFObject.m:585
void dealloc()
Deallocates the object.
Definition: OFObject.m:1228
id copy()
Returns the class.
Definition: OFObject.m:1290
void unload()
A method which is called when the class is unloaded from the runtime.
Definition: OFObject.m:429
instancetype alloc()
Allocates memory for an instance of the class and sets up the memory pool for the object.
Definition: OFObject.m:437
void initialize()
A method which is called the moment before the first call to the class is being made.
Definition: OFObject.m:433
void load()
A method which is called once when the class is loaded into the runtime.
Definition: OFObject.m:394
A class for handling strings.
Definition: OFString.h:135
A class which provides portable threads.
Definition: OFThread.h:62
A protocol for comparing objects.
Definition: OFObject.h:1383
A protocol for the creation of copies.
Definition: OFObject.h:1346
id copy()
Copies the object.
A protocol for the creation of mutable copies.
Definition: OFObject.h:1367
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:157
float y
Definition: OFObject.h:161
float x
Definition: OFObject.h:159
A range.
Definition: OFObject.h:106
size_t length
Definition: OFObject.h:110
size_t location
Definition: OFObject.h:108
A rectangle.
Definition: OFObject.h:249
OFPoint origin
Definition: OFObject.h:251
OFSize size
Definition: OFObject.h:253
A size.
Definition: OFObject.h:203
float width
Definition: OFObject.h:205
float height
Definition: OFObject.h:207
A vector in 3D space.
Definition: OFObject.h:300
float x
Definition: OFObject.h:302
float y
Definition: OFObject.h:304
float z
Definition: OFObject.h:306
A vector in 4D space.
Definition: OFObject.h:352
float x
Definition: OFObject.h:354
float z
Definition: OFObject.h:358
float y
Definition: OFObject.h:356
float w
Definition: OFObject.h:360