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;
493 - (
unsigned long)
hash;
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;
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;
775 + (instancetype)
alloc;
798 + (bool)isSubclassOfClass: (Class)class_;
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;
1410 extern void *_Nullable
OFAllocMemory(
size_t count,
size_t size)
1411 OF_WARN_UNUSED_RESULT;
1428 OF_WARN_UNUSED_RESULT;
1447 extern void *_Nullable
OFResizeMemory(
void *_Nullable pointer,
size_t count,
1448 size_t size) OF_WARN_UNUSED_RESULT;
1459 #ifdef OF_APPLE_RUNTIME 1464 void *_Nullable bytes);
1468 extern id OFAllocObject(Class class_,
size_t extraSize,
size_t extraAlignment,
1469 void *_Nullable *_Nullable extra);
1470 extern void OF_NO_RETURN_FUNC OFMethodNotFound(
id self,
SEL _cmd);
1477 extern void OFHashInit(
unsigned long *_Nonnull hash);
1503 OF_ASSUME_NONNULL_END
1506 #import "OFObject+KeyValueCoding.h" float y
Definition: OFObject.h:161
bool allowsWeakReference()
Returns whether the object allows a weak reference.
void load()
A method which is called once when the class is loaded into the runtime.
Definition: OFObject.m:395
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
float height
Definition: OFObject.h:207
Definition: OFObject.h:97
A protocol for comparing objects.
Definition: OFObject.h:1384
Definition: OFObject.h:60
void release()
Decreases the retain count.
id copy()
Copies the object.
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
A class for parsing type encodings and accessing them.
Definition: OFMethodSignature.h:28
float y
Definition: OFObject.h:356
Definition: OFObject.h:58
OFString * description()
Returns a description for the class, which is usually the class name.
bool retainWeakReference()
Retain a weak reference to this object.
instancetype retain()
Increases the retain count.
size_t length
Definition: OFObject.h:110
float x
Definition: OFObject.h:302
float w
Definition: OFObject.h:360
uint16_t OFRandom16(void)
Returns 16 bit or non-cryptographical randomness.
Definition: OFObject.m:178
id mutableCopy()
Creates a mutable copy of the object.
void OFFreeMemory(void *pointer)
Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.
Definition: OFObject.m:156
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...
Definition: OFObject.h:56
A class for handling strings.
Definition: OFString.h:134
A rectangle.
Definition: OFObject.h:249
id copy()
Returns the class.
Definition: OFObject.m:1291
OFComparisonResult
A result of a comparison.
Definition: OFObject.h:54
float y
Definition: OFObject.h:304
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 * OFAllocMemory(size_t count, size_t size)
Allocates memory for the specified number of items of the specified size.
Definition: OFObject.m:101
A class which provides portable threads.
Definition: OFThread.h:61
instancetype autorelease()
Adds the object to the topmost autorelease pool of the thread's autorelease pool stack.
instancetype self()
Returns the receiver.
uint64_t OFRandom64(void)
Returns 64 bit or non-cryptographical randomness.
Definition: OFObject.m:216
unsigned int retainCount()
Returns the retain count.
void dealloc()
Deallocates the object.
Definition: OFObject.m:1229
OFSize size
Definition: OFObject.h:253
Definition: OFObject.h:92
OFByteOrder
An enum for representing endianness.
Definition: OFObject.h:88
double OFTimeInterval
A time interval in seconds.
Definition: OFObject.h:150
instancetype init()
Initializes an already allocated object.
Definition: OFObject.m:586
bool isProxy()
Returns whether the object is a proxy object.
void initialize()
A method which is called the moment before the first call to the class is being made.
Definition: OFObject.m:434
OFString * className()
Returns the name of the class as a string.
instancetype alloc()
Allocates memory for an instance of the class and sets up the memory pool for the object...
Definition: OFObject.m:438
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
A size.
Definition: OFObject.h:203
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
A protocol for the creation of mutable copies.
Definition: OFObject.h:1367
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
A protocol for the creation of copies.
Definition: OFObject.h:1346
float z
Definition: OFObject.h:358
unsigned long hash()
Returns a hash for the object.
size_t location
Definition: OFObject.h:108
Class class()
Returns the class.
OFPoint origin
Definition: OFObject.h:251
float z
Definition: OFObject.h:306
const struct objc_protocol * Protocol
A protocol.
Definition: ObjFWRT.h:113
id(* IMP)(id object, SEL selector,...)
A method implementation.
Definition: ObjFWRT.h:142
float x
Definition: OFObject.h:159
A vector in 3D space.
Definition: OFObject.h:300
Definition: OFObject.h:90
void unload()
A method which is called when the class is unloaded from the runtime.
Definition: OFObject.m:430
A range.
Definition: OFObject.h:106
float width
Definition: OFObject.h:205
A vector in 4D space.
Definition: OFObject.h:352
void OFHashInit(unsigned long *hash)
Initializes the specified hash.
Definition: OFObject.m:236
float x
Definition: OFObject.h:354
OFComparisonResult(* OFCompareFunction)(id left, id right, void *context)
A function to compare two objects.
Definition: OFObject.h:71
A point in 2D space.
Definition: OFObject.h:157
nullable Class superclass()
Returns the superclass of the class.