Overview
Comment: | of_rectangle_t -> OFRect |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | new-naming-convention |
Files: | files | file ages | folders |
SHA3-256: |
dec9721b359528ea7e6689a2bafc3c59 |
User & Date: | js on 2021-04-17 01:19:44 |
Other Links: | branch diff | manifest | tags |
Context
2021-04-17
| ||
01:24 | OF_NOT_FOUND -> OFNotFound check-in: 83dc0fe6e5 user: js tags: new-naming-convention | |
01:19 | of_rectangle_t -> OFRect check-in: dec9721b35 user: js tags: new-naming-convention | |
01:10 | of_dimension_t -> OFSize check-in: 8a7353b219 user: js tags: new-naming-convention | |
Changes
Modified src/Makefile from [dbf0faa04b] to [45115139e9].
︙ | ︙ | |||
190 191 192 193 194 195 196 | OFMutableMapTableSet.m \ OFMutableUTF8String.m \ OFNonretainedObjectValue.m \ OFPointValue.m \ OFPointerValue.m \ OFRangeCharacterSet.m \ OFRangeValue.m \ | | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | OFMutableMapTableSet.m \ OFMutableUTF8String.m \ OFNonretainedObjectValue.m \ OFPointValue.m \ OFPointerValue.m \ OFRangeCharacterSet.m \ OFRangeValue.m \ OFRectValue.m \ OFSandbox.m \ OFSizeValue.m \ OFSubarray.m \ OFUTF8String.m \ ${LIBBASES_M} \ ${RUNTIME_AUTORELEASE_M} \ ${RUNTIME_INSTANCE_M} |
︙ | ︙ |
Modified src/OFNumber.h from [c1e91a3a26] to [6fc4bc7a5d].
︙ | ︙ | |||
128 129 130 131 132 133 134 | + (instancetype)valueWithBytes: (const void *)bytes objCType: (const char *)objCType OF_UNAVAILABLE; + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE; + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE; + (instancetype)valueWithRange: (OFRange)range OF_UNAVAILABLE; + (instancetype)valueWithPoint: (OFPoint)point OF_UNAVAILABLE; + (instancetype)valueWithSize: (OFSize)size OF_UNAVAILABLE; | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | + (instancetype)valueWithBytes: (const void *)bytes objCType: (const char *)objCType OF_UNAVAILABLE; + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE; + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE; + (instancetype)valueWithRange: (OFRange)range OF_UNAVAILABLE; + (instancetype)valueWithPoint: (OFPoint)point OF_UNAVAILABLE; + (instancetype)valueWithSize: (OFSize)size OF_UNAVAILABLE; + (instancetype)valueWithRect: (OFRect)rect OF_UNAVAILABLE; #endif /** * @brief Creates a new OFNumber with the specified `bool`. * * @param value The `bool` value which the OFNumber should contain * @return A new autoreleased OFNumber |
︙ | ︙ |
Modified src/OFObject.h from [43c18460ed] to [ad55e4debc].
︙ | ︙ | |||
233 234 235 236 237 238 239 | if (size1.height != size2.height) return false; return true; } /** | | | | | | | | | | | | | | | | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | if (size1.height != size2.height) return false; return true; } /** * @struct OFRect OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ struct OF_BOXABLE OFRect { /** The point from where the rectangle originates */ OFPoint origin; /** The size of the rectangle */ OFSize size; }; typedef struct OFRect OFRect; /** * @brief Creates a new OFRect. * * @param x The x coordinate of the top left corner of the rectangle * @param y The y coordinate of the top left corner of the rectangle * @param width The width of the rectangle * @param height The height of the rectangle * @return An OFRect with the specified origin and size */ static OF_INLINE OFRect OF_CONST_FUNC OFMakeRect(float x, float y, float width, float height) { OFRect rect = { OFMakePoint(x, y), OFMakeSize(width, height) }; return rect; } /** * @brief Returns whether the two rectangles are equal. * * @param rect1 The first rectangle for the comparison * @param rect2 The second rectangle for the comparison * @return Whether the two rectangles are equal */ static OF_INLINE bool OFEqualRects(OFRect rect1, OFRect rect2) { if (!OFEqualPoints(rect1.origin, rect2.origin)) return false; if (!OFEqualSizes(rect1.size, rect2.size)) return false; return true; } #ifdef __OBJC__ @class OFMethodSignature; |
︙ | ︙ |
Renamed and modified src/OFRectangleValue.h [6cb58bb467] to src/OFRectValue.h [57204033f6].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFRectValue: OFValue { OFRect _rect; } - (instancetype)initWithRect: (OFRect)rect; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFRectangleValue.m [7e7907dbd9] to src/OFRectValue.m [15e6c7cc85].
︙ | ︙ | |||
9 10 11 12 13 14 15 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | | | | | | | | | | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFRectValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfRangeException.h" @implementation OFRectValue @synthesize rectValue = _rect; - (instancetype)initWithRect: (OFRect)rect { self = [super init]; _rect = rect; return self; } - (const char *)objCType { return @encode(OFRect); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_rect)) @throw [OFOutOfRangeException exception]; memcpy(value, &_rect, sizeof(_rect)); } - (OFString *)description { return [OFString stringWithFormat: @"<OFValue: OFRect { %f, %f, %f, %f }>", _rect.origin.x, _rect.origin.y, _rect.size.width, _rect.size.height]; } @end |
Modified src/OFValue.h from [2987cd37b8] to [df3acd707a].
︙ | ︙ | |||
64 65 66 67 68 69 70 | * @brief The value as an OFSize. * * If the value is not OFSize-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) OFSize sizeValue; /** | | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | * @brief The value as an OFSize. * * If the value is not OFSize-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) OFSize sizeValue; /** * @brief The value as a OFRect. * * If the value is not OFRect-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) OFRect rectValue; /** * @brief Creates a new, autorelease OFValue with the specified bytes of the * specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value |
︙ | ︙ | |||
131 132 133 134 135 136 137 | */ + (instancetype)valueWithSize: (OFSize)size; /** * @brief Creates a new, autoreleased OFValue containing the specified * rectangle. * | | | | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | */ + (instancetype)valueWithSize: (OFSize)size; /** * @brief Creates a new, autoreleased OFValue containing the specified * rectangle. * * @param rect The rectangle the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRect: (OFRect)rect; /** * @brief Initializes an already allocated OFValue with the specified bytes of * the specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value |
︙ | ︙ |
Modified src/OFValue.m from [c62f9e27d2] to [712005bdcf].
︙ | ︙ | |||
16 17 18 19 20 21 22 | #import "OFValue.h" #import "OFBytesValue.h" #import "OFMethodSignature.h" #import "OFNonretainedObjectValue.h" #import "OFPointValue.h" #import "OFPointerValue.h" #import "OFRangeValue.h" | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFValue.h" #import "OFBytesValue.h" #import "OFMethodSignature.h" #import "OFNonretainedObjectValue.h" #import "OFPointValue.h" #import "OFPointerValue.h" #import "OFRangeValue.h" #import "OFRectValue.h" #import "OFSizeValue.h" #import "OFString.h" #import "OFOutOfMemoryException.h" @implementation OFValue + (instancetype)alloc |
︙ | ︙ | |||
64 65 66 67 68 69 70 | } + (instancetype)valueWithSize: (OFSize)size { return [[[OFSizeValue alloc] initWithSize: size] autorelease]; } | | | < | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | } + (instancetype)valueWithSize: (OFSize)size { return [[[OFSizeValue alloc] initWithSize: size] autorelease]; } + (instancetype)valueWithRect: (OFRect)rect { return [[[OFRectValue alloc] initWithRect: rect] autorelease]; } - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { OF_INVALID_INIT_METHOD } |
︙ | ︙ | |||
189 190 191 192 193 194 195 | - (OFSize)sizeValue { OFSize ret; [self getValue: &ret size: sizeof(ret)]; return ret; } | | | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | - (OFSize)sizeValue { OFSize ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFRect)rectValue { OFRect ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { OFMutableString *ret = |
︙ | ︙ |
Modified tests/OFValueTests.m from [30f9ae95fb] to [8235c5a687].
︙ | ︙ | |||
24 25 26 27 28 29 30 | @implementation TestsAppDelegate (OFValueTests) - (void)valueTests { void *pool = objc_autoreleasePoolPush(); OFRange range = OFMakeRange(1, 64), range2; OFPoint point = OFMakePoint(1.5f, 3.0f), point2; OFSize size = OFMakeSize(4.5f, 5.0f), size2; | | < | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | @implementation TestsAppDelegate (OFValueTests) - (void)valueTests { void *pool = objc_autoreleasePoolPush(); OFRange range = OFMakeRange(1, 64), range2; OFPoint point = OFMakePoint(1.5f, 3.0f), point2; OFSize size = OFMakeSize(4.5f, 5.0f), size2; OFRect rect = OFMakeRect(1.5f, 3.0f, 4.5f, 6.0f), rect2; OFValue *value; void *pointer = &value; TEST(@"+[valueWithBytes:objCType:]", (value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)])) |
︙ | ︙ | |||
126 127 128 129 130 131 132 | OFEqualSizes(size2, size)) EXPECT_EXCEPTION(@"-[sizeValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] sizeValue]) | | | | | | | | | | | | | | < | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | OFEqualSizes(size2, size)) EXPECT_EXCEPTION(@"-[sizeValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] sizeValue]) TEST(@"+[valueWithRect:]", (value = [OFValue valueWithRect: rect])) TEST(@"-[rectValue]", OFEqualRects(value.rectValue, rect) && (value = [OFValue valueWithBytes: &rect objCType: @encode(OFRect)]) && OFEqualRects(value.rectValue, rect)) TEST(@"-[getValue:size:] for OFRectValue", (value = [OFValue valueWithRect: rect]) && R([value getValue: &rect2 size: sizeof(rect2)]) && OFEqualRects(rect2, rect)) EXPECT_EXCEPTION(@"-[rectValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] rectValue]) TEST(@"-[isEqual:]", [[OFValue valueWithRect: rect] isEqual: [OFValue valueWithBytes: &rect objCType: @encode(OFRect)]] && ![[OFValue valueWithBytes: "a" objCType: @encode(signed char)] isEqual: [OFValue valueWithBytes: "a" objCType: @encode(unsigned char)]] && ![[OFValue valueWithBytes: "a" objCType: @encode(char)] isEqual: [OFValue valueWithBytes: "b" objCType: @encode(char)]]) objc_autoreleasePoolPop(pool); } @end |