Overview
Comment: | OFValue: Add support for ranges |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
cb1891cca19cc583d67aec91c7ae1f18 |
User & Date: | js on 2018-01-21 03:28:28 |
Other Links: | manifest | tags |
Context
2018-01-21
| ||
11:33 | OFIntrospection: Fix a typo check-in: a20995ef75 user: js tags: trunk | |
03:28 | OFValue: Add support for ranges check-in: cb1891cca1 user: js tags: trunk | |
03:12 | OFValue: Add -[description] check-in: 854435fa91 user: js tags: trunk | |
Changes
Modified src/Makefile from [ab44d84097] to [dc5b918af2].
︙ | |||
170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | + | 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} \ |
︙ |
Modified src/OFValue.h from [be3d51a96b] to [159b58341b].
︙ | |||
29 30 31 32 33 34 35 | 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 59 60 | - + - + + + + + + + + | * @brief The ObjC type encoding of the value. */ @property (readonly, nonatomic) const char *objCType; /*! * @brief The value as a pointer to void. * |
︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | + + + + + + + + | * collections without retaining them. * * @param object The object the OFValue should contain without retaining it * @return A new, autoreleased OFValue */ + (instancetype)valueWithNonretainedObject: (id)object; /*! * @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 |
︙ | |||
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | + + + + + + + + + | * collections without retaining them. * * @param object The object the OFValue should contain without retaining it * @return An initialized OFValue */ - (instancetype)initWithNonretainedObject: (id)object; /*! * @brief Initializes an already allocated OFValue containing the specified * 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 |
︙ |
Modified src/OFValue.m from [4262daaa9f] to [09ba4acbc4].
︙ | |||
17 18 19 20 21 22 23 24 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | + - | #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" |
︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | + + + + + | } - (instancetype)initWithNonretainedObject: (id)object { return (id)[[OFValue_nonretainedObject alloc] 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]; |
︙ | |||
79 80 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 | 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 | + + + + + + + + + + | return [[[self alloc] initWithPointer: pointer] autorelease]; } + (instancetype)valueWithNonretainedObject: (id)object { 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; |
︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | + + + + + + + + + + | return ret; } - (id)nonretainedObjectValue { id ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_range_t)rangeValue { of_range_t ret; [self getValue: &ret size: sizeof(ret)]; return ret; } |
︙ |
Added src/OFValue_range.h version [0f534c342c].
|
Added src/OFValue_range.m version [53afdf9eb3].
|
Modified tests/OFValueTests.m from [1e0dc03201] to [f2ecc9e780].
︙ | |||
75 76 77 78 79 80 81 82 83 84 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | + + + + + + + + + + + + + + + | objCType: @encode(id)] pointerValue] == pointer) EXPECT_EXCEPTION(@"-[nonretainedObjectValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] nonretainedObjectValue]) TEST(@"+[valueWithRange:]", (value = [OFValue valueWithRange: range])) TEST(@"-[rangeValue]", R(range = [value rangeValue]) && memcmp(&range, &range2, sizeof(of_range_t)) == 0 && R(range = [[OFValue valueWithBytes: &range objCType: @encode(of_range_t)] rangeValue]) && memcmp(&range, &range2, sizeof(of_range_t)) == 0) EXPECT_EXCEPTION(@"-[rangeValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" objCType: @encode(char)] rangeValue]) [pool drain]; } @end |