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 46 # ifdef __MINGW64_VERSION_MAJOR 47 # include <winsock2.h> 52 OF_ASSUME_NONNULL_BEGIN
82 id _Nonnull right,
void *_Nullable context);
130 static OF_INLINE
OFRange OF_CONST_FUNC
133 OFRange range = { start, length };
145 static OF_INLINE
bool 163 static OF_INLINE
size_t 167 extern void OF_NO_RETURN_FUNC _OFThrowOutOfRangeException(
void);
168 _OFThrowOutOfRangeException();
181 static OF_INLINE
bool 184 return (location >= range.
location &&
265 static OF_INLINE
OFPoint OF_CONST_FUNC
280 static OF_INLINE
bool 283 if (point1.
x != point2.
x)
286 if (point1.
y != point2.
y)
311 static OF_INLINE
OFSize OF_CONST_FUNC
314 OFSize size = { width, height };
326 static OF_INLINE
bool 359 static OF_INLINE
OFRect OF_CONST_FUNC
377 static OF_INLINE
bool 460 static OF_INLINE
bool 463 if (vector1.
x != vector2.
x)
466 if (vector1.
y != vector2.
y)
469 if (vector1.
z != vector2.
z)
486 vector1.
z + vector2.
z);
500 vector1.
z - vector2.
z);
524 static OF_INLINE
float 527 return vector1.
x * vector2.
x + vector1.
y * vector2.
y +
528 vector1.
z * vector2.
z;
538 static OF_INLINE
float 586 static OF_INLINE
bool 589 if (vector1.
x != vector2.
x)
592 if (vector1.
y != vector2.
y)
595 if (vector1.
z != vector2.
z)
598 if (vector1.
w != vector2.
w)
615 vector1.
z + vector2.
z, vector1.
w + vector2.
w);
629 vector1.
z - vector2.
z, vector1.
w - vector2.
w);
643 vector.
z * scalar, vector.
w * scalar);
653 static OF_INLINE
float 656 return vector1.
x * vector2.
x + vector1.
y * vector2.
y +
657 vector1.
z * vector2.
z + vector1.
w * vector2.
w;
667 static OF_INLINE
float 681 static OF_INLINE
void 684 uint32_t tmp = (uint32_t)*hash;
699 static OF_INLINE
void 713 static OF_INLINE
void 716 uint32_t tmp = (uint32_t)*hash;
761 - (
unsigned long)
hash;
783 - (bool)isKindOfClass: (Class)class_;
792 - (bool)isMemberOfClass: (Class)class_;
801 - (bool)respondsToSelector: (
SEL)selector;
809 - (bool)conformsToProtocol: (
Protocol *)protocol;
817 - (nullable
IMP)methodForSelector: (
SEL)selector;
825 - (nullable id)performSelector: (
SEL)selector;
835 - (nullable id)performSelector: (
SEL)selector withObject: (nullable
id)object;
847 - (nullable id)performSelector: (
SEL)selector
848 withObject: (nullable
id)object1
849 withObject: (nullable
id)object2;
863 - (nullable id)performSelector: (
SEL)selector
864 withObject: (nullable
id)object1
865 withObject: (nullable
id)object2
866 withObject: (nullable
id)object3;
882 - (nullable id)performSelector: (
SEL)selector
883 withObject: (nullable
id)object1
884 withObject: (nullable
id)object2
885 withObject: (nullable
id)object3
886 withObject: (nullable
id)object4;
900 - (bool)isEqual: (nullable
id)object;
931 - (instancetype)
self;
957 #ifndef __clang_analyzer__ 960 Class _isa __attribute__((__unused__));
964 #ifdef OF_HAVE_CLASS_PROPERTIES 966 @property (
class, readonly, nonatomic) Class
class;
968 @property (
class, readonly, nonatomic, getter=
class) Class class_;
971 @property (
class, readonly, nullable, nonatomic) Class
superclass;
976 @property (readonly, nonatomic) Class
class;
978 @property (readonly, nonatomic, getter=
class) Class class_;
980 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class
superclass;
981 @property (readonly, nonatomic)
unsigned long hash;
982 @property (readonly, nonatomic)
unsigned int retainCount;
983 @property (readonly, nonatomic)
bool isProxy;
1047 + (instancetype)
alloc;
1070 + (bool)isSubclassOfClass: (Class)class_;
1086 + (bool)instancesRespondToSelector: (
SEL)selector;
1094 + (bool)conformsToProtocol: (
Protocol *)protocol;
1104 + (nullable
IMP)instanceMethodForSelector: (
SEL)selector;
1116 instanceMethodSignatureForSelector: (
SEL)selector;
1134 + (nullable
IMP)replaceClassMethod: (
SEL)selector
1135 withMethodFromClass: (Class)class_;
1145 + (nullable
IMP)replaceInstanceMethod: (
SEL)selector
1146 withMethodFromClass: (Class)class_;
1166 + (void)inheritMethodsFromClass: (Class)class_;
1176 + (bool)resolveClassMethod: (
SEL)selector;
1186 + (bool)resolveInstanceMethod: (
SEL)selector;
1229 - (instancetype)
init;
1255 - (void)performSelector: (
SEL)selector afterDelay: (
OFTimeInterval)delay;
1266 - (void)performSelector: (
SEL)selector
1267 withObject: (nullable
id)object
1281 - (void)performSelector: (
SEL)selector
1282 withObject: (nullable
id)object1
1283 withObject: (nullable
id)object2
1299 - (void)performSelector: (
SEL)selector
1300 withObject: (nullable
id)object1
1301 withObject: (nullable
id)object2
1302 withObject: (nullable
id)object3
1320 - (void)performSelector: (
SEL)selector
1321 withObject: (nullable
id)object1
1322 withObject: (nullable
id)object2
1323 withObject: (nullable
id)object3
1324 withObject: (nullable
id)object4
1327 #ifdef OF_HAVE_THREADS 1335 - (void)performSelector: (
SEL)selector
1337 waitUntilDone: (
bool)waitUntilDone;
1349 - (void)performSelector: (
SEL)selector
1351 withObject: (nullable
id)object
1352 waitUntilDone: (
bool)waitUntilDone;
1366 - (void)performSelector: (
SEL)selector
1368 withObject: (nullable
id)object1
1369 withObject: (nullable
id)object2
1370 waitUntilDone: (
bool)waitUntilDone;
1386 - (void)performSelector: (
SEL)selector
1388 withObject: (nullable
id)object1
1389 withObject: (nullable
id)object2
1390 withObject: (nullable
id)object3
1391 waitUntilDone: (
bool)waitUntilDone;
1409 - (void)performSelector: (
SEL)selector
1411 withObject: (nullable
id)object1
1412 withObject: (nullable
id)object2
1413 withObject: (nullable
id)object3
1414 withObject: (nullable
id)object4
1415 waitUntilDone: (
bool)waitUntilDone;
1423 - (void)performSelectorOnMainThread: (
SEL)selector
1424 waitUntilDone: (
bool)waitUntilDone;
1435 - (void)performSelectorOnMainThread: (
SEL)selector
1436 withObject: (nullable
id)object
1437 waitUntilDone: (
bool)waitUntilDone;
1450 - (void)performSelectorOnMainThread: (
SEL)selector
1451 withObject: (nullable
id)object1
1452 withObject: (nullable
id)object2
1453 waitUntilDone: (
bool)waitUntilDone;
1468 - (void)performSelectorOnMainThread: (
SEL)selector
1469 withObject: (nullable
id)object1
1470 withObject: (nullable
id)object2
1471 withObject: (nullable
id)object3
1472 waitUntilDone: (
bool)waitUntilDone;
1489 - (void)performSelectorOnMainThread: (
SEL)selector
1490 withObject: (nullable
id)object1
1491 withObject: (nullable
id)object2
1492 withObject: (nullable
id)object3
1493 withObject: (nullable
id)object4
1494 waitUntilDone: (
bool)waitUntilDone;
1504 - (void)performSelector: (
SEL)selector
1518 - (void)performSelector: (
SEL)selector
1520 withObject: (nullable
id)object
1535 - (void)performSelector: (
SEL)selector
1537 withObject: (nullable
id)object1
1538 withObject: (nullable
id)object2
1555 - (void)performSelector: (
SEL)selector
1557 withObject: (nullable
id)object1
1558 withObject: (nullable
id)object2
1559 withObject: (nullable
id)object3
1578 - (void)performSelector: (
SEL)selector
1580 withObject: (nullable
id)object1
1581 withObject: (nullable
id)object2
1582 withObject: (nullable
id)object3
1583 withObject: (nullable
id)object4
1598 - (nullable id)forwardingTargetForSelector: (
SEL)selector;
1609 - (void)doesNotRecognizeSelector: (
SEL)selector OF_NO_RETURN;
1682 extern void *_Nullable
OFAllocMemory(
size_t count,
size_t size)
1683 OF_MALLOC_FUNC OF_WARN_UNUSED_RESULT;
1700 OF_MALLOC_FUNC OF_WARN_UNUSED_RESULT;
1719 extern void *_Nullable
OFResizeMemory(
void *_Nullable pointer,
size_t count,
1720 size_t size) OF_WARN_UNUSED_RESULT;
1731 #ifdef OF_APPLE_RUNTIME 1734 extern id _Nullable objc_retain(
id _Nullable
object);
1735 extern id _Nullable objc_retainBlock(
id _Nullable block);
1736 extern id _Nullable objc_retainAutorelease(
id _Nullable
object);
1737 extern void objc_release(
id _Nullable
object);
1738 extern id _Nullable objc_autorelease(
id _Nullable
object);
1739 extern id _Nullable objc_autoreleaseReturnValue(
id _Nullable
object);
1740 extern id _Nullable objc_retainAutoreleaseReturnValue(
id _Nullable
object);
1741 extern id _Nullable objc_retainAutoreleasedReturnValue(
id _Nullable
object);
1742 extern id _Nullable objc_storeStrong(
id _Nullable *_Nonnull
object,
1743 id _Nullable value);
1744 extern id _Nullable objc_storeWeak(
id _Nullable *_Nonnull
object,
1745 id _Nullable value);
1746 extern id _Nullable objc_loadWeakRetained(
id _Nullable *_Nonnull
object);
1747 extern _Nullable
id objc_initWeak(
id _Nullable *_Nonnull
object,
1748 id _Nullable value);
1749 extern void objc_destroyWeak(
id _Nullable *_Nonnull
object);
1750 extern id _Nullable objc_loadWeak(
id _Nullable *_Nonnull
object);
1751 extern void objc_copyWeak(
id _Nullable *_Nonnull dest,
1752 id _Nullable *_Nonnull src);
1753 extern void objc_moveWeak(
id _Nullable *_Nonnull dest,
1754 id _Nullable *_Nonnull src);
1755 # ifdef OF_DECLARE_CONSTRUCT_INSTANCE 1757 void *_Nullable bytes);
1760 # ifdef OF_DECLARE_SET_ASSOCIATED_OBJECT 1769 const void *_Nonnull key,
id _Nullable value,
1772 const void *_Nonnull key);
1789 extern id OFAllocObject(Class class_,
size_t extraSize,
size_t extraAlignment,
1790 void *_Nullable *_Nullable extra);
1821 extern void OFHashInit(
unsigned long *_Nonnull hash);
1847 OF_ASSUME_NONNULL_END
1850 #import "OFObject+KeyValueCoding.h" float y
Definition: OFObject.h:255
static OF_INLINE bool OFEqualRects(OFRect rect1, OFRect rect2)
Returns whether the two rectangles are equal.
Definition: OFObject.h:378
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:472
void * objc_destructInstance(id object)
Destructs the specified object.
Definition: instance.m:131
id objc_constructInstance(Class class_, void *bytes)
Constructs an instance of the specified class in the specified array of bytes.
Definition: instance.m:115
static OF_INLINE OFVector3D OFMultiplyVector3D(OFVector3D vector, float scalar)
Multiplies the specified vector with a scalar.
Definition: OFObject.h:511
static OF_INLINE OFVector4D OFMultiplyVector4D(OFVector4D vector, float scalar)
Multiplies the specified vector with a scalar.
Definition: OFObject.h:640
float height
Definition: OFObject.h:301
Definition: OFObject.h:107
A protocol for comparing objects.
Definition: OFObject.h:1656
static OF_INLINE OFVector4D OFSubtractVectors4D(OFVector4D vector1, OFVector4D vector2)
Subtracts the second vector from the first vector.
Definition: OFObject.h:626
Definition: OFObject.h:70
void release()
Decreases the retain count.
id copy()
Copies the object.
static OF_INLINE OFSize OF_CONST_FUNC OFMakeSize(float width, float height)
Creates a new OFSize.
Definition: OFObject.h:312
The root class for all other classes inside ObjFW.
Definition: OFObject.h:954
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:131
void * OFAllocMemory(size_t count, size_t size) OF_MALLOC_FUNC
Allocates memory for the specified number of items of the specified size.
Definition: OFObject.m:101
Associate the object like a retained, nonatomic property.
Definition: ObjFWRT.h:187
A class for parsing type encodings and accessing them.
Definition: OFMethodSignature.h:32
void OFMethodNotFound(id self, SEL _cmd)
This function is called when a method is not found.
Definition: OFObject.m:412
static OF_INLINE void OFHashFinalize(unsigned long *hash)
Finalizes the specified hash.
Definition: OFObject.h:714
float y
Definition: OFObject.h:555
Definition: OFObject.h:68
OFString * description()
Returns a description for the class, which is usually the class name.
static OF_INLINE OFVector4D OFAddVectors4D(OFVector4D vector1, OFVector4D vector2)
Adds the two specified vectors.
Definition: OFObject.h:612
bool retainWeakReference()
Retain a weak reference to this object.
instancetype retain()
Increases the retain count.
size_t length
Definition: OFObject.h:120
static OF_INLINE OFPoint OF_CONST_FUNC OFMakePoint(float x, float y)
Creates a new OFPoint.
Definition: OFObject.h:266
float x
Definition: OFObject.h:430
float w
Definition: OFObject.h:559
static OF_INLINE size_t OFEndOfRange(OFRange range)
Returns the end of the range, which is its location + its length.
Definition: OFObject.h:164
static OF_INLINE void OFHashAddByte(unsigned long *hash, unsigned char byte)
Adds the specified byte to the hash.
Definition: OFObject.h:682
uint16_t OFRandom16(void)
Returns 16 bit or non-cryptographical randomness.
Definition: OFObject.m:190
Associate the object like an assigned property.
Definition: ObjFWRT.h:185
Associate the object like a copied, nonatomic property.
Definition: ObjFWRT.h:191
static OF_INLINE bool OFLocationInRange(size_t location, OFRange range)
Returns whether the specified location is in the specified range.
Definition: OFObject.h:182
Associate the object like a retained property.
Definition: ObjFWRT.h:189
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:66
static OF_INLINE OFRange OFUnionRange(OFRange range1, OFRange range2)
Returns the union of the two ranges if they are overlapping or adjacent, otherwise returns a range wi...
Definition: OFObject.h:224
A class for handling strings.
Definition: OFString.h:142
Associate the object like a copied property.
Definition: ObjFWRT.h:193
static OF_INLINE void OFHashAddHash(unsigned long *hash, unsigned long otherHash)
Adds the specified hash to the hash.
Definition: OFObject.h:700
static OF_INLINE OFVector4D OF_CONST_FUNC OFMakeVector4D(float x, float y, float z, float w)
Creates a new OFVector4D.
Definition: OFObject.h:572
A rectangle.
Definition: OFObject.h:343
id copy()
Returns the class.
Definition: OFObject.m:1326
static OF_INLINE float OFDotProductOfVectors4D(OFVector4D vector1, OFVector4D vector2)
Calculates the dot product of the two specified vectors.
Definition: OFObject.h:654
OFComparisonResult
A result of a comparison.
Definition: OFObject.h:64
float y
Definition: OFObject.h:432
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
A class which provides portable threads.
Definition: OFThread.h:65
void objc_removeAssociatedObjects(id object)
Removes all associated objects for the specified object.
Definition: association.m:251
instancetype autorelease()
Adds the object to the topmost autorelease pool of the thread's autorelease pool stack.
static OF_INLINE bool OFEqualVectors3D(OFVector3D vector1, OFVector3D vector2)
Returns whether the two vectors are equal.
Definition: OFObject.h:461
instancetype self()
Returns the receiver.
static OF_INLINE bool OFEqualVectors4D(OFVector4D vector1, OFVector4D vector2)
Returns whether the two vectors are equal.
Definition: OFObject.h:587
uint64_t OFRandom64(void)
Returns 64 bit or non-cryptographical randomness.
Definition: OFObject.m:246
unsigned int retainCount()
Returns the retain count.
void dealloc()
Deallocates the object.
Definition: OFObject.m:1270
OFSize size
Definition: OFObject.h:347
objc_associationPolicy
A policy for object association, see objc_setAssociatedObject.
Definition: ObjFWRT.h:183
Definition: OFObject.h:102
OFByteOrder
An enum for representing endianness.
Definition: OFObject.h:98
static const size_t OFNotFound
A special not found index.
Definition: OFObject.h:59
double OFTimeInterval
A time interval in seconds.
Definition: OFObject.h:244
instancetype init()
Initializes an already allocated object.
Definition: OFObject.m:671
static OF_INLINE OFRect OFIntersectionRect(OFRect rect1, OFRect rect2)
Returns the intersection of the two rectangles or a rectangle with x, y, width and height set to 0 if...
Definition: OFObject.h:398
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:511
OFString * className()
Returns the name of the class as a string.
static OF_INLINE OFVector3D OF_CONST_FUNC OFMakeVector3D(float x, float y, float z)
Creates a new OFVector3D.
Definition: OFObject.h:446
instancetype alloc()
Allocates memory for an instance of the class and sets up the memory pool for the object...
Definition: OFObject.m:515
void * OFAllocZeroedMemory(size_t count, size_t size) OF_MALLOC_FUNC
Allocates memory for the specified number of items of the specified size and initializes it with zero...
Definition: OFObject.m:119
static OF_INLINE float OFDistanceOfVectors4D(OFVector4D vector1, OFVector4D vector2)
Calculates the distance between two vectors.
Definition: OFObject.h:668
static OF_INLINE bool OFEqualPoints(OFPoint point1, OFPoint point2)
Returns whether the two points are equal.
Definition: OFObject.h:281
OFComparisonResult(^ OFComparator)(id left, id right)
A comparator to compare two objects.
Definition: OFObject.h:92
uint32_t OFRandom32(void)
Returns 32 bit or non-cryptographical randomness.
Definition: OFObject.m:220
static OF_INLINE float OFDistanceOfVectors3D(OFVector3D vector1, OFVector3D vector2)
Calculates the distance between two vectors.
Definition: OFObject.h:539
static OF_INLINE OFRect OF_CONST_FUNC OFMakeRect(float x, float y, float width, float height)
Creates a new OFRect.
Definition: OFObject.h:360
A size.
Definition: OFObject.h:297
static OF_INLINE OFVector3D OFSubtractVectors3D(OFVector3D vector1, OFVector3D vector2)
Subtracts the second vector from the first vector.
Definition: OFObject.h:497
A protocol for the creation of mutable copies.
Definition: OFObject.h:1639
static OF_INLINE OFRange OF_CONST_FUNC OFMakeRange(size_t start, size_t length)
Creates a new OFRange.
Definition: OFObject.h:131
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
A protocol for the creation of copies.
Definition: OFObject.h:1618
float z
Definition: OFObject.h:557
unsigned long hash()
Returns a hash for the object.
size_t location
Definition: OFObject.h:118
Class class()
Returns the class.
static OF_INLINE OFVector3D OFAddVectors3D(OFVector3D vector1, OFVector3D vector2)
Adds the two specified vectors.
Definition: OFObject.h:483
OFPoint origin
Definition: OFObject.h:345
id OFAllocObject(Class class_, size_t extraSize, size_t extraAlignment, void **extra)
Allocates a new object.
Definition: OFObject.m:432
static OF_INLINE bool OFEqualSizes(OFSize size1, OFSize size2)
Returns whether the two sizes are equal.
Definition: OFObject.h:327
static OF_INLINE OFRange OFIntersectionRange(OFRange range1, OFRange range2)
Returns the intersection of the two ranges or OFNotFound and length 0 if they don't intersect...
Definition: OFObject.h:197
float z
Definition: OFObject.h:434
const struct objc_protocol * Protocol
A protocol.
Definition: ObjFWRT.h:117
id(* IMP)(id object, SEL selector,...)
A method implementation.
Definition: ObjFWRT.h:146
float x
Definition: OFObject.h:253
id objc_getAssociatedObject(id object, const void *key)
Returns the associated object on the specified object for the specified key.
Definition: association.m:208
A vector in 3D space.
Definition: OFObject.h:428
static OF_INLINE float OFDotProductOfVectors3D(OFVector3D vector1, OFVector3D vector2)
Calculates the dot product of the two specified vectors.
Definition: OFObject.h:525
Definition: OFObject.h:100
static OF_INLINE bool OFEqualRanges(OFRange range1, OFRange range2)
Returns whether the two ranges are equal.
Definition: OFObject.h:146
void unload()
A method which is called when the class is unloaded from the runtime.
Definition: OFObject.m:507
A range.
Definition: OFObject.h:116
float width
Definition: OFObject.h:299
A vector in 4D space.
Definition: OFObject.h:551
void OFHashInit(unsigned long *hash)
Initializes the specified hash.
Definition: OFObject.m:276
float x
Definition: OFObject.h:553
OFComparisonResult(* OFCompareFunction)(id left, id right, void *context)
A function to compare two objects.
Definition: OFObject.h:81
A point in 2D space.
Definition: OFObject.h:251
nullable Class superclass()
Returns the superclass of the class.