Comment: | OFValue: Support for {point,dimension,rectangle}s |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2ca34d3de1a0c3453f551201a9f1fa43 |
User & Date: | js on 2018-01-21 12:18:59 |
Other Links: | manifest | tags |
2018-01-21
| ||
15:14 | Add test for -[OFValue isEqual:] check-in: 7edbe989ad user: js tags: trunk | |
12:18 | OFValue: Support for {point,dimension,rectangle}s check-in: 2ca34d3de1 user: js tags: trunk | |
11:33 | OFIntrospection: Fix a typo check-in: a20995ef75 user: js tags: trunk | |
Modified src/Makefile from [dc5b918af2] to [58756ea4bf].
︙ | ︙ | |||
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | OFMutableArray_adjacent.m \ OFMutableDictionary_hashtable.m \ OFMutableSet_hashtable.m \ OFMutableString_UTF8.m \ OFSet_hashtable.m \ OFString_UTF8.m \ OFValue_bytes.m \ OFValue_nonretainedObject.m \ OFValue_pointer.m \ OFValue_range.m \ ${AUTORELEASE_M} \ ${FOUNDATION_COMPAT_M} \ ${INSTANCE_M} SRCS_FILES += OFSettings_INIFile.m \ OFURLHandler_file.m SRCS_SOCKETS += OFKernelEventObserver.m \ ${OFKERNELEVENTOBSERVER_EPOLL_M} \ | > > > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | OFMutableArray_adjacent.m \ OFMutableDictionary_hashtable.m \ OFMutableSet_hashtable.m \ OFMutableString_UTF8.m \ OFSet_hashtable.m \ OFString_UTF8.m \ OFValue_bytes.m \ OFValue_dimension.m \ OFValue_nonretainedObject.m \ OFValue_point.m \ OFValue_pointer.m \ OFValue_range.m \ OFValue_rectangle.m \ ${AUTORELEASE_M} \ ${FOUNDATION_COMPAT_M} \ ${INSTANCE_M} SRCS_FILES += OFSettings_INIFile.m \ OFURLHandler_file.m SRCS_SOCKETS += OFKernelEventObserver.m \ ${OFKERNELEVENTOBSERVER_EPOLL_M} \ |
︙ | ︙ |
Modified src/OFObject.h from [2ac0a8962b] to [885fe09f8c].
︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | static OF_INLINE of_range_t OF_CONST_FUNC of_range(size_t start, size_t length) { of_range_t range = { start, length }; return range; } /*! * @brief A time interval in seconds. */ typedef double of_time_interval_t; /*! | > > > > > > > > > > > > > > > > > > > | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | static OF_INLINE of_range_t OF_CONST_FUNC of_range(size_t start, size_t length) { of_range_t range = { start, length }; return range; } /*! * @brief Returns whether the two ranges are equal. * * @param range1 The first range for the comparison * @param range2 The second range for the comparison * @return Whether the two ranges are equal */ static OF_INLINE bool of_range_equal(of_range_t range1, of_range_t range2) { if (range1.location != range2.location) return false; if (range1.length != range2.length) return false; return true; } /*! * @brief A time interval in seconds. */ typedef double of_time_interval_t; /*! |
︙ | ︙ | |||
125 126 127 128 129 130 131 132 133 134 135 136 137 138 | static OF_INLINE of_point_t OF_CONST_FUNC of_point(float x, float y) { of_point_t point = { x, y }; return point; } /*! * @struct of_dimension_t OFObject.h ObjFW/OFObject.h * * @brief A dimension. */ typedef struct OF_BOXABLE { | > > > > > > > > > > > > > > > > > > > | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | static OF_INLINE of_point_t OF_CONST_FUNC of_point(float x, float y) { of_point_t point = { x, y }; return point; } /*! * @brief Returns whether the two points are equal. * * @param point1 The first point for the comparison * @param point2 The second point for the comparison * @return Whether the two points are equal */ static OF_INLINE bool of_point_equal(of_point_t point1, of_point_t point2) { if (point1.x != point2.x) return false; if (point1.y != point2.y) return false; return true; } /*! * @struct of_dimension_t OFObject.h ObjFW/OFObject.h * * @brief A dimension. */ typedef struct OF_BOXABLE { |
︙ | ︙ | |||
152 153 154 155 156 157 158 159 160 161 162 163 164 165 | static OF_INLINE of_dimension_t OF_CONST_FUNC of_dimension(float width, float height) { of_dimension_t dimension = { width, height }; return dimension; } /*! * @struct of_rectangle_t OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ typedef struct OF_BOXABLE { | > > > > > > > > > > > > > > > > > > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | static OF_INLINE of_dimension_t OF_CONST_FUNC of_dimension(float width, float height) { of_dimension_t dimension = { width, height }; return dimension; } /*! * @brief Returns whether the two dimensions are equal. * * @param dimension1 The first dimension for the comparison * @param dimension2 The second dimension for the comparison * @return Whether the two dimensions are equal */ static OF_INLINE bool of_dimension_equal(of_dimension_t dimension1, of_dimension_t dimension2) { if (dimension1.width != dimension2.width) return false; if (dimension1.height != dimension2.height) return false; return true; } /*! * @struct of_rectangle_t OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ typedef struct OF_BOXABLE { |
︙ | ︙ | |||
184 185 186 187 188 189 190 191 192 193 194 195 196 197 | of_rectangle_t rectangle = { of_point(x, y), of_dimension(width, height) }; return rectangle; } @class OFMethodSignature; @class OFString; @class OFThread; /*! * @protocol OFObject OFObject.h ObjFW/OFObject.h | > > > > > > > > > > > > > > > > > > > | 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 | of_rectangle_t rectangle = { of_point(x, y), of_dimension(width, height) }; return rectangle; } /*! * @brief Returns whether the two rectangles are equal. * * @param rectangle1 The first rectangle for the comparison * @param rectangle2 The second rectangle for the comparison * @return Whether the two rectangles are equal */ static OF_INLINE bool of_rectangle_equal(of_rectangle_t rectangle1, of_rectangle_t rectangle2) { if (!of_point_equal(rectangle1.origin, rectangle2.origin)) return false; if (!of_dimension_equal(rectangle1.size, rectangle2.size)) return false; return true; } @class OFMethodSignature; @class OFString; @class OFThread; /*! * @protocol OFObject OFObject.h ObjFW/OFObject.h |
︙ | ︙ |
Modified src/OFValue.h from [159b58341b] to [9b9ae39ff5].
︙ | ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /*! * @brief The value as a range. * * If the value is not range-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) of_range_t rangeValue; /*! * @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 * @return A new, autoreleased OFValue | > > > > > > > > > > > > > > > > > > > > > | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /*! * @brief The value as a range. * * If the value is not range-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) of_range_t rangeValue; /*! * @brief The value as a point. * * If the value is not point-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) of_point_t pointValue; /*! * @brief The value as a dimension. * * If the value is not dimension-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) of_dimension_t dimensionValue; /*! * @brief The value as a rectangle. * * If the value is not rectangle-sized, @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) of_rectangle_t rectangleValue; /*! * @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 * @return A new, autoreleased OFValue |
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | * @brief Creates a new, autoreleased OFValue containing the specified range. * * @param range The range the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRange: (of_range_t)range; /*! * @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 * @return An initialized OFValue | > > > > > > > > > > > > > > > > > > > > > > > > > > | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | * @brief Creates a new, autoreleased OFValue containing the specified range. * * @param range The range the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRange: (of_range_t)range; /*! * @brief Creates a new, autoreleased OFValue containing the specified point. * * @param point The point the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithPoint: (of_point_t)point; /*! * @brief Creates a new, autoreleased OFValue containing the specified * dimension. * * @param dimension The dimension the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithDimension: (of_dimension_t)dimension; /*! * @brief Creates a new, autoreleased OFValue containing the specified * rectangle. * * @param rectangle The rectangle the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRectangle: (of_rectangle_t)rectangle; /*! * @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 * @return An initialized OFValue |
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 | * range. * * @param range The range the OFValue should contain * @return An initialized OFValue */ - (instancetype)initWithRange: (of_range_t)range; /*! * @brief Gets the value. * * If the specified size does not match, this raises an * @ref OFOutOfRangeException. * * @param value The buffer to copy the value into | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | * range. * * @param range The range the OFValue should contain * @return An initialized OFValue */ - (instancetype)initWithRange: (of_range_t)range; /*! * @brief Initializes an already allocated OFValue containing the specified * point. * * @param point The point the OFValue should contain * @return An initialized OFValue */ - (instancetype)initWithPoint: (of_point_t)point; /*! * @brief Initializes an already allocated OFValue containing the specified * dimension. * * @param dimension The dimension the OFValue should contain * @return An initialized OFValue */ - (instancetype)initWithDimension: (of_dimension_t)dimension; /*! * @brief Initializes an already allocated OFValue containing the specified * rectangle. * * @param rectangle The rectangle the OFValue should contain * @return An initialized OFValue */ - (instancetype)initWithRectangle: (of_rectangle_t)rectangle; /*! * @brief Gets the value. * * If the specified size does not match, this raises an * @ref OFOutOfRangeException. * * @param value The buffer to copy the value into |
︙ | ︙ |
Modified src/OFValue.m from [09ba4acbc4] to [b29dc94d62].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | * file. */ #import "OFValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFValue_bytes.h" #import "OFValue_nonretainedObject.h" #import "OFValue_pointer.h" #import "OFValue_range.h" #import "OFOutOfMemoryException.h" static struct { Class isa; } placeholder; | > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * file. */ #import "OFValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFValue_bytes.h" #import "OFValue_dimension.h" #import "OFValue_nonretainedObject.h" #import "OFValue_point.h" #import "OFValue_pointer.h" #import "OFValue_range.h" #import "OFValue_rectangle.h" #import "OFOutOfMemoryException.h" static struct { Class isa; } placeholder; |
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 | initWithNonretainedObject: object]; } - (instancetype)initWithRange: (of_range_t)range { return (id)[[OFValue_range alloc] initWithRange: range]; } @end @implementation OFValue + (void)initialize { if (self == [OFValue class]) placeholder.isa = [OFValue_placeholder class]; | > > > > > > > > > > > > > > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | initWithNonretainedObject: object]; } - (instancetype)initWithRange: (of_range_t)range { return (id)[[OFValue_range alloc] initWithRange: range]; } - (instancetype)initWithPoint: (of_point_t)point { return (id)[[OFValue_point alloc] initWithPoint: point]; } - (instancetype)initWithDimension: (of_dimension_t)dimension { return (id)[[OFValue_dimension alloc] initWithDimension: dimension]; } - (instancetype)initWithRectangle: (of_rectangle_t)rectangle { return (id)[[OFValue_rectangle alloc] initWithRectangle: rectangle]; } @end @implementation OFValue + (void)initialize { if (self == [OFValue class]) placeholder.isa = [OFValue_placeholder class]; |
︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | return [[[self alloc] initWithNonretainedObject: object] autorelease]; } + (instancetype)valueWithRange: (of_range_t)range { return [[[self alloc] initWithRange: range] autorelease]; } - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { OF_INVALID_INIT_METHOD } - (instancetype)initWithPointer: (const void *)pointer { OF_INVALID_INIT_METHOD } - (instancetype)initWithNonretainedObject: (id)object { OF_INVALID_INIT_METHOD } - (instancetype)initWithRange: (of_range_t)range { OF_INVALID_INIT_METHOD } - (bool)isEqual: (id)object { const char *objCType; size_t size; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 163 164 165 166 167 168 169 | return [[[self alloc] initWithNonretainedObject: object] autorelease]; } + (instancetype)valueWithRange: (of_range_t)range { return [[[self alloc] initWithRange: range] autorelease]; } + (instancetype)valueWithPoint: (of_point_t)point { return [[[self alloc] initWithPoint: point] autorelease]; } + (instancetype)valueWithDimension: (of_dimension_t)dimension { return [[[self alloc] initWithDimension: dimension] autorelease]; } + (instancetype)valueWithRectangle: (of_rectangle_t)rectangle { return [[[self alloc] initWithRectangle: rectangle] autorelease]; } - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { OF_INVALID_INIT_METHOD } - (instancetype)initWithPointer: (const void *)pointer { OF_INVALID_INIT_METHOD } - (instancetype)initWithNonretainedObject: (id)object { OF_INVALID_INIT_METHOD } - (instancetype)initWithRange: (of_range_t)range { OF_INVALID_INIT_METHOD } - (instancetype)initWithPoint: (of_point_t)point { OF_INVALID_INIT_METHOD } - (instancetype)initWithDimension: (of_dimension_t)dimension { OF_INVALID_INIT_METHOD } - (instancetype)initWithRectangle: (of_rectangle_t)rectangle { OF_INVALID_INIT_METHOD } - (bool)isEqual: (id)object { const char *objCType; size_t size; |
︙ | ︙ | |||
216 217 218 219 220 221 222 223 224 225 226 227 228 229 | return ret; } - (of_range_t)rangeValue { of_range_t ret; [self getValue: &ret size: sizeof(ret)]; return ret; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | return ret; } - (of_range_t)rangeValue { of_range_t ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_point_t)pointValue { of_point_t ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_dimension_t)dimensionValue { of_dimension_t ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_rectangle_t)rectangleValue { of_rectangle_t ret; [self getValue: &ret size: sizeof(ret)]; return ret; } |
︙ | ︙ |
Added src/OFValue_dimension.h version [bc97645412].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFValue_dimension: OFValue { of_dimension_t _dimension; } @end OF_ASSUME_NONNULL_END |
Added src/OFValue_dimension.m version [dd1f945a95].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 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 55 56 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFValue_dimension.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfRangeException.h" @implementation OFValue_dimension @synthesize dimensionValue = _dimension; - (instancetype)initWithDimension: (of_dimension_t)dimension { self = [super init]; _dimension = dimension; return self; } - (const char *)objCType { return @encode(of_dimension_t); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_dimension)) @throw [OFOutOfRangeException exception]; memcpy(value, &_dimension, sizeof(_dimension)); } - (OFString *)description { return [OFString stringWithFormat: @"<OFValue: of_dimension_t { %f, %f }>", _dimension.width, _dimension.height]; } @end |
Modified src/OFValue_nonretainedObject.m from [e080df1e1c] to [b5a2c6c06d].
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | { self = [super init]; _object = object; return self; } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_object)) @throw [OFOutOfRangeException exception]; | > > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | { self = [super init]; _object = object; return self; } - (const char *)objCType { return @encode(id); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_object)) @throw [OFOutOfRangeException exception]; |
︙ | ︙ |
Added src/OFValue_point.h version [69cc51d21e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFValue_point: OFValue { of_point_t _point; } @end OF_ASSUME_NONNULL_END |
Added src/OFValue_point.m version [a43b3b3688].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 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 55 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFValue_point.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfRangeException.h" @implementation OFValue_point @synthesize pointValue = _point; - (instancetype)initWithPoint: (of_point_t)point { self = [super init]; _point = point; return self; } - (const char *)objCType { return @encode(of_point_t); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_point)) @throw [OFOutOfRangeException exception]; memcpy(value, &_point, sizeof(_point)); } - (OFString *)description { return [OFString stringWithFormat: @"<OFValue: of_point_t { %f, %f }>", _point.x, _point.y]; } @end |
Modified src/OFValue_pointer.m from [46d3358a90] to [612ef456b8].
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | { self = [super init]; _pointer = (void *)pointer; return self; } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_pointer)) @throw [OFOutOfRangeException exception]; | > > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | { self = [super init]; _pointer = (void *)pointer; return self; } - (const char *)objCType { return @encode(void *); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_pointer)) @throw [OFOutOfRangeException exception]; |
︙ | ︙ |
Modified src/OFValue_range.m from [53afdf9eb3] to [d4b665299e].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | { self = [super init]; _range = range; return self; } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_range)) @throw [OFOutOfRangeException exception]; memcpy(value, &_range, sizeof(_range)); } - (OFString *)description { | > > > > > | > | | 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 55 56 | { self = [super init]; _range = range; return self; } - (const char *)objCType { return @encode(of_range_t); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_range)) @throw [OFOutOfRangeException exception]; memcpy(value, &_range, sizeof(_range)); } - (OFString *)description { return [OFString stringWithFormat: @"<OFValue: of_range_t { %zu, %zu }>", _range.location, _range.length]; } @end |
Added src/OFValue_rectangle.h version [11f38ea16f].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFValue_rectangle: OFValue { of_rectangle_t _rectangle; } @end OF_ASSUME_NONNULL_END |
Added src/OFValue_rectangle.m version [4103012342].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 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 55 56 57 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFValue_rectangle.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfRangeException.h" @implementation OFValue_rectangle @synthesize rectangleValue = _rectangle; - (instancetype)initWithRectangle: (of_rectangle_t)rectangle { self = [super init]; _rectangle = rectangle; return self; } - (const char *)objCType { return @encode(of_rectangle_t); } - (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_rectangle)) @throw [OFOutOfRangeException exception]; memcpy(value, &_rectangle, sizeof(_rectangle)); } - (OFString *)description { return [OFString stringWithFormat: @"<OFValue: of_rectangle_t { %f, %f, %f, %f }>", _rectangle.origin.x, _rectangle.origin.y, _rectangle.size.width, _rectangle.size.height]; } @end |
Modified tests/OFValueTests.m from [f2ecc9e780] to [2c898fcc53].
︙ | ︙ | |||
28 29 30 31 32 33 34 | static OFString *module = @"OFValue"; @implementation TestsAppDelegate (OFValueTests) - (void)valueTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; | | > > > < | | | 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 55 56 57 58 | static OFString *module = @"OFValue"; @implementation TestsAppDelegate (OFValueTests) - (void)valueTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; of_range_t range = of_range(1, 64), range2; of_point_t point = of_point(1.5, 3), point2; of_dimension_t dimension = of_dimension(4.5, 5), dimension2; of_rectangle_t rectangle = of_rectangle(1.5, 3, 4.5, 6), rectangle2; OFValue *value; void *pointer = &value; TEST(@"+[valueWithBytes:objCType:]", (value = [OFValue valueWithBytes: &range objCType: @encode(of_range_t)])) TEST(@"-[objCType]", strcmp([value objCType], @encode(of_range_t)) == 0) TEST(@"-[getValue:size:]", R([value getValue: &range2 size: sizeof(of_range_t)]) && of_range_equal(range2, range)) EXPECT_EXCEPTION(@"-[getValue:size:] with wrong size throws", OFOutOfRangeException, [value getValue: &range size: sizeof(of_range_t) - 1]) TEST(@"+[valueWithPointer:]", |
︙ | ︙ | |||
79 80 81 82 83 84 85 | [[OFValue valueWithBytes: "a" objCType: @encode(char)] nonretainedObjectValue]) TEST(@"+[valueWithRange:]", (value = [OFValue valueWithRange: range])) TEST(@"-[rangeValue]", | | < | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 163 164 165 166 | [[OFValue valueWithBytes: "a" objCType: @encode(char)] nonretainedObjectValue]) TEST(@"+[valueWithRange:]", (value = [OFValue valueWithRange: range])) TEST(@"-[rangeValue]", of_range_equal([value rangeValue], range) && (value = [OFValue valueWithBytes: &range objCType: @encode(of_range_t)]) && of_range_equal([value rangeValue], range)) TEST(@"-[getValue:size:] for OFValue_range", (value = [OFValue valueWithRange: range]) && R([value getValue: &range2 size: sizeof(range2)]) && of_range_equal(range2, range)) EXPECT_EXCEPTION(@"-[rangeValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] rangeValue]) TEST(@"+[valueWithPoint:]", (value = [OFValue valueWithPoint: point])) TEST(@"-[pointValue]", of_point_equal([value pointValue], point) && (value = [OFValue valueWithBytes: &point objCType: @encode(of_point_t)]) && of_point_equal([value pointValue], point)) TEST(@"-[getValue:size:] for OFValue_point", (value = [OFValue valueWithPoint: point]) && R([value getValue: &point2 size: sizeof(point2)]) && of_point_equal(point2, point)) EXPECT_EXCEPTION(@"-[pointValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] pointValue]) TEST(@"+[valueWithDimension:]", (value = [OFValue valueWithDimension: dimension])) TEST(@"-[dimensionValue]", of_dimension_equal([value dimensionValue], dimension) && (value = [OFValue valueWithBytes: &dimension objCType: @encode(of_dimension_t)]) && of_dimension_equal([value dimensionValue], dimension)) TEST(@"-[getValue:size:] for OFValue_dimension", (value = [OFValue valueWithDimension: dimension]) && R([value getValue: &dimension2 size: sizeof(dimension2)]) && of_dimension_equal(dimension2, dimension)) EXPECT_EXCEPTION(@"-[dimensionValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] dimensionValue]) TEST(@"+[valueWithRectangle:]", (value = [OFValue valueWithRectangle: rectangle])) TEST(@"-[rectangleValue]", of_rectangle_equal([value rectangleValue], rectangle) && (value = [OFValue valueWithBytes: &rectangle objCType: @encode(of_rectangle_t)]) && of_rectangle_equal([value rectangleValue], rectangle)) TEST(@"-[getValue:size:] for OFValue_rectangle", (value = [OFValue valueWithRectangle: rectangle]) && R([value getValue: &rectangle2 size: sizeof(rectangle2)]) && of_rectangle_equal(rectangle2, rectangle)) EXPECT_EXCEPTION(@"-[rectangleValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] rectangleValue]) [pool drain]; } @end |