ObjFW
OFObject.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2025 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "objfw-defs.h"
21 
22 #ifndef __STDC_LIMIT_MACROS
23 # define __STDC_LIMIT_MACROS
24 #endif
25 #ifndef __STDC_CONSTANT_MACROS
26 # define __STDC_CONSTANT_MACROS
27 #endif
28 
29 #include <stddef.h>
30 #include <stdint.h>
31 #include <stdbool.h>
32 #include <limits.h>
33 
34 #include "macros.h"
35 
36 #import "OFOnce.h"
37 
38 /*
39  * Some versions of MinGW require <winsock2.h> to be included before
40  * <windows.h>. Do this here to make sure this is always done in the correct
41  * order, even if another header includes just <windows.h>.
42  */
43 #ifdef __MINGW32__
44 # include <_mingw.h>
45 # ifdef __MINGW64_VERSION_MAJOR
46 # include <winsock2.h>
47 # include <windows.h>
48 # endif
49 #endif
50 
51 OF_ASSUME_NONNULL_BEGIN
52 
58 typedef enum {
66 
75 typedef OFComparisonResult (*OFCompareFunction)(id _Nonnull left,
76  id _Nonnull right, void *_Nullable context);
77 
78 #ifdef OF_HAVE_BLOCKS
86 typedef OFComparisonResult (^OFComparator)(id _Nonnull left, id _Nonnull right);
87 #endif
88 
92 typedef enum {
98 #ifdef OF_BIG_ENDIAN
100 #else
102 #endif
104 
110 typedef struct OF_BOXABLE OFRange {
112  size_t location;
114  size_t length;
115 } OFRange;
116 
124 static OF_INLINE OFRange OF_CONST_FUNC
125 OFMakeRange(size_t start, size_t length)
126 {
127  OFRange range = { start, length };
128 
129  return range;
130 }
131 
139 static OF_INLINE bool
141 {
142  if (range1.location != range2.location)
143  return false;
144 
145  if (range1.length != range2.length)
146  return false;
147 
148  return true;
149 }
150 
154 typedef double OFTimeInterval;
155 
161 typedef struct OF_BOXABLE OFPoint {
163  float x;
165  float y;
166 } OFPoint;
167 
175 static OF_INLINE OFPoint OF_CONST_FUNC
176 OFMakePoint(float x, float y)
177 {
178  OFPoint point = { x, y };
179 
180  return point;
181 }
182 
190 static OF_INLINE bool
192 {
193  if (point1.x != point2.x)
194  return false;
195 
196  if (point1.y != point2.y)
197  return false;
198 
199  return true;
200 }
201 
207 typedef struct OF_BOXABLE OFSize {
209  float width;
211  float height;
212 } OFSize;
213 
221 static OF_INLINE OFSize OF_CONST_FUNC
222 OFMakeSize(float width, float height)
223 {
224  OFSize size = { width, height };
225 
226  return size;
227 }
228 
236 static OF_INLINE bool
238 {
239  if (size1.width != size2.width)
240  return false;
241 
242  if (size1.height != size2.height)
243  return false;
244 
245  return true;
246 }
247 
253 typedef struct OF_BOXABLE OFRect {
258 } OFRect;
259 
269 static OF_INLINE OFRect OF_CONST_FUNC
270 OFMakeRect(float x, float y, float width, float height)
271 {
272  OFRect rect = {
273  OFMakePoint(x, y),
274  OFMakeSize(width, height)
275  };
276 
277  return rect;
278 }
279 
287 static OF_INLINE bool
289 {
290  if (!OFEqualPoints(rect1.origin, rect2.origin))
291  return false;
292 
293  if (!OFEqualSizes(rect1.size, rect2.size))
294  return false;
295 
296  return true;
297 }
298 
304 typedef struct OF_BOXABLE OFVector3D {
306  float x;
308  float y;
310  float z;
311 } OFVector3D;
312 
321 static OF_INLINE OFVector3D OF_CONST_FUNC
322 OFMakeVector3D(float x, float y, float z)
323 {
324  OFVector3D vector = { x, y, z };
325 
326  return vector;
327 }
328 
336 static OF_INLINE bool
338 {
339  if (vector1.x != vector2.x)
340  return false;
341 
342  if (vector1.y != vector2.y)
343  return false;
344 
345  if (vector1.z != vector2.z)
346  return false;
347 
348  return true;
349 }
350 
356 typedef struct OF_BOXABLE OFVector4D {
358  float x;
360  float y;
362  float z;
364  float w;
365 } OFVector4D;
366 
376 static OF_INLINE OFVector4D OF_CONST_FUNC
377 OFMakeVector4D(float x, float y, float z, float w)
378 {
379  OFVector4D vector = { x, y, z, w };
380 
381  return vector;
382 }
383 
391 static OF_INLINE bool
393 {
394  if (vector1.x != vector2.x)
395  return false;
396 
397  if (vector1.y != vector2.y)
398  return false;
399 
400  if (vector1.z != vector2.z)
401  return false;
402 
403  if (vector1.w != vector2.w)
404  return false;
405 
406  return true;
407 }
408 
415 static OF_INLINE void
416 OFHashAddByte(unsigned long *_Nonnull hash, unsigned char byte)
417 {
418  uint32_t tmp = (uint32_t)*hash;
419 
420  tmp += byte;
421  tmp += tmp << 10;
422  tmp ^= tmp >> 6;
423 
424  *hash = tmp;
425 }
426 
433 static OF_INLINE void
434 OFHashAddHash(unsigned long *_Nonnull hash, unsigned long otherHash)
435 {
436  OFHashAddByte(hash, (otherHash >> 24) & 0xFF);
437  OFHashAddByte(hash, (otherHash >> 16) & 0xFF);
438  OFHashAddByte(hash, (otherHash >> 8) & 0xFF);
439  OFHashAddByte(hash, otherHash & 0xFF);
440 }
441 
447 static OF_INLINE void
448 OFHashFinalize(unsigned long *_Nonnull hash)
449 {
450  uint32_t tmp = (uint32_t)*hash;
451 
452  tmp += tmp << 3;
453  tmp ^= tmp >> 11;
454  tmp += tmp << 15;
455 
456  *hash = tmp;
457 }
458 
459 static const size_t OFNotFound = SIZE_MAX;
460 
461 @class OFMethodSignature;
462 @class OFString;
463 @class OFThread;
464 
470 @protocol OFObject
476 - (Class)class;
477 
483 - (nullable Class)superclass;
484 
497 - (unsigned long)hash;
498 
504 - (unsigned int)retainCount;
505 
511 - (bool)isProxy;
512 
519 - (bool)isKindOfClass: (Class)class_;
520 
528 - (bool)isMemberOfClass: (Class)class_;
529 
537 - (bool)respondsToSelector: (SEL)selector;
538 
545 - (bool)conformsToProtocol: (Protocol *)protocol;
546 
553 - (nullable IMP)methodForSelector: (SEL)selector;
554 
561 - (nullable id)performSelector: (SEL)selector;
562 
571 - (nullable id)performSelector: (SEL)selector withObject: (nullable id)object;
572 
583 - (nullable id)performSelector: (SEL)selector
584  withObject: (nullable id)object1
585  withObject: (nullable id)object2;
586 
599 - (nullable id)performSelector: (SEL)selector
600  withObject: (nullable id)object1
601  withObject: (nullable id)object2
602  withObject: (nullable id)object3;
603 
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;
623 
636 - (bool)isEqual: (nullable id)object;
637 
644 - (instancetype)retain;
645 
652 - (void)release;
653 
660 - (instancetype)autorelease;
661 
667 - (instancetype)self;
668 
674 - (bool)allowsWeakReference;
675 
681 - (bool)retainWeakReference;
682 @end
683 
689 OF_ROOT_CLASS
690 @interface OFObject <OFObject>
691 {
692 @private
693 #ifndef __clang_analyzer__
694  Class _isa;
695 #else
696  Class _isa __attribute__((__unused__));
697 #endif
698 }
699 
700 #ifdef OF_HAVE_CLASS_PROPERTIES
701 # ifndef __cplusplus
702 @property (class, readonly, nonatomic) Class class;
703 # else
704 @property (class, readonly, nonatomic, getter=class) Class class_;
705 # endif
706 @property (class, readonly, nonatomic) OFString *className;
707 @property (class, readonly, nullable, nonatomic) Class superclass;
708 @property (class, readonly, nonatomic) OFString *description;
709 #endif
710 
711 #ifndef __cplusplus
712 @property (readonly, nonatomic) Class class;
713 #else
714 @property (readonly, nonatomic, getter=class) Class class_;
715 #endif
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;
721 
725 @property (readonly, nonatomic) OFString *className;
726 
733 @property (readonly, nonatomic) OFString *description;
734 
746 + (void)load;
747 
759 + (void)unload;
760 
770 + (void)initialize;
771 
783 + (instancetype)alloc;
784 
790 + (Class)class;
791 
797 + (OFString *)className;
798 
806 + (bool)isSubclassOfClass: (Class)class_;
807 
813 + (nullable Class)superclass;
814 
822 + (bool)instancesRespondToSelector: (SEL)selector;
823 
830 + (bool)conformsToProtocol: (Protocol *)protocol;
831 
840 + (nullable IMP)instanceMethodForSelector: (SEL)selector;
841 
851 + (nullable OFMethodSignature *)
852  instanceMethodSignatureForSelector: (SEL)selector;
853 
861 + (OFString *)description;
862 
870 + (nullable IMP)replaceClassMethod: (SEL)selector
871  withMethodFromClass: (Class)class_;
872 
881 + (nullable IMP)replaceInstanceMethod: (SEL)selector
882  withMethodFromClass: (Class)class_;
883 
902 + (void)inheritMethodsFromClass: (Class)class_;
903 
912 + (bool)resolveClassMethod: (SEL)selector;
913 
922 + (bool)resolveInstanceMethod: (SEL)selector;
923 
932 + (id)copy;
933 
965 - (instancetype)init;
966 
974 - (nullable OFMethodSignature *)methodSignatureForSelector: (SEL)selector;
975 
983 - (void)dealloc;
984 
991 - (void)performSelector: (SEL)selector afterDelay: (OFTimeInterval)delay;
992 
1002 - (void)performSelector: (SEL)selector
1003  withObject: (nullable id)object
1004  afterDelay: (OFTimeInterval)delay;
1005 
1017 - (void)performSelector: (SEL)selector
1018  withObject: (nullable id)object1
1019  withObject: (nullable id)object2
1020  afterDelay: (OFTimeInterval)delay;
1021 
1035 - (void)performSelector: (SEL)selector
1036  withObject: (nullable id)object1
1037  withObject: (nullable id)object2
1038  withObject: (nullable id)object3
1039  afterDelay: (OFTimeInterval)delay;
1040 
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
1061  afterDelay: (OFTimeInterval)delay;
1062 
1063 #ifdef OF_HAVE_THREADS
1071 - (void)performSelector: (SEL)selector
1072  onThread: (OFThread *)thread
1073  waitUntilDone: (bool)waitUntilDone;
1074 
1085 - (void)performSelector: (SEL)selector
1086  onThread: (OFThread *)thread
1087  withObject: (nullable id)object
1088  waitUntilDone: (bool)waitUntilDone;
1089 
1102 - (void)performSelector: (SEL)selector
1103  onThread: (OFThread *)thread
1104  withObject: (nullable id)object1
1105  withObject: (nullable id)object2
1106  waitUntilDone: (bool)waitUntilDone;
1107 
1122 - (void)performSelector: (SEL)selector
1123  onThread: (OFThread *)thread
1124  withObject: (nullable id)object1
1125  withObject: (nullable id)object2
1126  withObject: (nullable id)object3
1127  waitUntilDone: (bool)waitUntilDone;
1128 
1145 - (void)performSelector: (SEL)selector
1146  onThread: (OFThread *)thread
1147  withObject: (nullable id)object1
1148  withObject: (nullable id)object2
1149  withObject: (nullable id)object3
1150  withObject: (nullable id)object4
1151  waitUntilDone: (bool)waitUntilDone;
1152 
1159 - (void)performSelectorOnMainThread: (SEL)selector
1160  waitUntilDone: (bool)waitUntilDone;
1161 
1171 - (void)performSelectorOnMainThread: (SEL)selector
1172  withObject: (nullable id)object
1173  waitUntilDone: (bool)waitUntilDone;
1174 
1186 - (void)performSelectorOnMainThread: (SEL)selector
1187  withObject: (nullable id)object1
1188  withObject: (nullable id)object2
1189  waitUntilDone: (bool)waitUntilDone;
1190 
1204 - (void)performSelectorOnMainThread: (SEL)selector
1205  withObject: (nullable id)object1
1206  withObject: (nullable id)object2
1207  withObject: (nullable id)object3
1208  waitUntilDone: (bool)waitUntilDone;
1209 
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;
1231 
1240 - (void)performSelector: (SEL)selector
1241  onThread: (OFThread *)thread
1242  afterDelay: (OFTimeInterval)delay;
1243 
1254 - (void)performSelector: (SEL)selector
1255  onThread: (OFThread *)thread
1256  withObject: (nullable id)object
1257  afterDelay: (OFTimeInterval)delay;
1258 
1271 - (void)performSelector: (SEL)selector
1272  onThread: (OFThread *)thread
1273  withObject: (nullable id)object1
1274  withObject: (nullable id)object2
1275  afterDelay: (OFTimeInterval)delay;
1276 
1291 - (void)performSelector: (SEL)selector
1292  onThread: (OFThread *)thread
1293  withObject: (nullable id)object1
1294  withObject: (nullable id)object2
1295  withObject: (nullable id)object3
1296  afterDelay: (OFTimeInterval)delay;
1297 
1314 - (void)performSelector: (SEL)selector
1315  onThread: (OFThread *)thread
1316  withObject: (nullable id)object1
1317  withObject: (nullable id)object2
1318  withObject: (nullable id)object3
1319  withObject: (nullable id)object4
1320  afterDelay: (OFTimeInterval)delay;
1321 #endif
1322 
1334 - (nullable id)forwardingTargetForSelector: (SEL)selector;
1335 
1345 - (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN;
1346 @end
1347 
1353 @protocol OFCopying
1363 - (id)copy;
1364 @end
1365 
1374 @protocol OFMutableCopying
1380 - (id)mutableCopy;
1381 @end
1382 
1391 @protocol OFComparing
1398 - (OFComparisonResult)compare: (id <OFComparing>)object;
1399 @end
1400 
1401 #ifdef __cplusplus
1402 extern "C" {
1403 #endif
1418 extern void *_Nullable OFAllocMemory(size_t count, size_t size)
1419  OF_WARN_UNUSED_RESULT;
1420 
1435 extern void *_Nullable OFAllocZeroedMemory(size_t count, size_t size)
1436  OF_WARN_UNUSED_RESULT;
1437 
1455 extern void *_Nullable OFResizeMemory(void *_Nullable pointer, size_t count,
1456  size_t size) OF_WARN_UNUSED_RESULT;
1457 
1465 extern void OFFreeMemory(void *_Nullable pointer);
1466 
1467 #ifdef OF_APPLE_RUNTIME
1468 extern void *_Null_unspecified objc_autoreleasePoolPush(void);
1469 extern void objc_autoreleasePoolPop(void *_Null_unspecified pool);
1470 # ifdef OF_DECLARE_CONSTRUCT_INSTANCE
1471 extern id _Nullable objc_constructInstance(Class _Nullable class_,
1472  void *_Nullable bytes);
1473 extern void *_Nullable objc_destructInstance(id _Nullable object);
1474 # endif
1475 # ifdef OF_DECLARE_SET_ASSOCIATED_OBJECT
1476 typedef enum objc_associationPolicy {
1483 extern void objc_setAssociatedObject(id _Nonnull object,
1484  const void *_Nonnull key, id _Nullable value,
1485  objc_associationPolicy policy);
1486 extern id _Nullable objc_getAssociatedObject(id _Nonnull object,
1487  const void *_Nonnull key);
1488 extern void objc_removeAssociatedObjects(id _Nonnull object);
1489 # endif
1490 #endif
1491 
1504 extern id OFAllocObject(Class class_, size_t extraSize, size_t extraAlignment,
1505  void *_Nullable *_Nullable extra);
1506 
1529 extern void OF_NO_RETURN_FUNC OFMethodNotFound(id self, SEL _cmd);
1530 
1536 extern void OFHashInit(unsigned long *_Nonnull hash);
1537 
1543 extern uint16_t OFRandom16(void);
1544 
1550 extern uint32_t OFRandom32(void);
1551 
1557 extern uint64_t OFRandom64(void);
1558 #ifdef __cplusplus
1559 }
1560 #endif
1561 
1562 OF_ASSUME_NONNULL_END
1563 
1564 #import "OFBlock.h"
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