Overview
Context
Changes
Modified src/OFConcreteNumber.h
from [c582a87f71]
to [fe80ae4102].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
|
20
21
22
23
24
25
26
27
28
29
30
31
|
-
+
|
@interface OFConcreteNumber: OFNumber
{
union {
double float_;
long long signed_;
unsigned long long unsigned_;
} _value;
const char *_typeEncoding;
char _typeEncoding;
}
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFConcreteNumber.m
from [9fe7ebb7d2]
to [f5ec3b05ca].
︙ | | |
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
167
168
169
170
171
172
173
174
175
176
177
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
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
167
168
169
170
171
172
173
174
175
176
177
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
}
- (instancetype)initWithBool: (bool)value
{
self = [super initWithBytes: &value objCType: @encode(bool)];
_value.unsigned_ = value;
_typeEncoding = @encode(bool);
_typeEncoding = *@encode(bool);
return self;
}
- (instancetype)initWithChar: (signed char)value
{
self = [super initWithBytes: &value objCType: @encode(signed char)];
_value.signed_ = value;
_typeEncoding = @encode(signed char);
_typeEncoding = *@encode(signed char);
return self;
}
- (instancetype)initWithShort: (short)value
{
self = [super initWithBytes: &value objCType: @encode(short)];
_value.signed_ = value;
_typeEncoding = @encode(short);
_typeEncoding = *@encode(short);
return self;
}
- (instancetype)initWithInt: (int)value
{
self = [super initWithBytes: &value objCType: @encode(int)];
_value.signed_ = value;
_typeEncoding = @encode(int);
_typeEncoding = *@encode(int);
return self;
}
- (instancetype)initWithLong: (long)value
{
self = [super initWithBytes: &value objCType: @encode(long)];
_value.signed_ = value;
_typeEncoding = @encode(long);
_typeEncoding = *@encode(long);
return self;
}
- (instancetype)initWithLongLong: (long long)value
{
self = [super initWithBytes: &value objCType: @encode(long long)];
_value.signed_ = value;
_typeEncoding = @encode(long long);
_typeEncoding = *@encode(long long);
return self;
}
- (instancetype)initWithUnsignedChar: (unsigned char)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned char)];
_value.unsigned_ = value;
_typeEncoding = @encode(unsigned long);
_typeEncoding = *@encode(unsigned long);
return self;
}
- (instancetype)initWithUnsignedShort: (unsigned short)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned short)];
_value.unsigned_ = value;
_typeEncoding = @encode(unsigned short);
_typeEncoding = *@encode(unsigned short);
return self;
}
- (instancetype)initWithUnsignedInt: (unsigned int)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned int)];
_value.unsigned_ = value;
_typeEncoding = @encode(unsigned int);
_typeEncoding = *@encode(unsigned int);
return self;
}
- (instancetype)initWithUnsignedLong: (unsigned long)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned long)];
_value.unsigned_ = value;
_typeEncoding = @encode(unsigned long);
_typeEncoding = *@encode(unsigned long);
return self;
}
- (instancetype)initWithUnsignedLongLong: (unsigned long long)value
{
self = [super initWithBytes: &value
objCType: @encode(unsigned long long)];
_value.unsigned_ = value;
_typeEncoding = @encode(unsigned long long);
_typeEncoding = *@encode(unsigned long long);
return self;
}
- (instancetype)initWithFloat: (float)value
{
self = [super initWithBytes: &value objCType: @encode(float)];
_value.float_ = value;
_typeEncoding = @encode(float);
_typeEncoding = *@encode(float);
return self;
}
- (instancetype)initWithDouble: (double)value
{
self = [super initWithBytes: &value objCType: @encode(double)];
_value.float_ = value;
_typeEncoding = @encode(double);
_typeEncoding = *@encode(double);
return self;
}
- (const char *)objCType
{
return _typeEncoding;
return &_typeEncoding;
}
- (long long)longLongValue
{
if (isFloat(self))
return _value.float_;
else if (isSigned(self))
|
︙ | | |
Modified src/OFConcreteValue.h
from [d86b034518]
to [50c02d8332].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
|
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteValue: OFValue
{
size_t _size;
void *_bytes;
const char *_objCType;
char *_objCType;
}
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFConcreteValue.m
from [023a457c93]
to [e87397b05a].
︙ | | |
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
|
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
58
|
+
-
+
-
+
|
* 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 "OFConcreteValue.h"
#import "OFMethodSignature.h"
#import "OFString.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteValue
@synthesize objCType = _objCType;
- (instancetype)initWithBytes: (const void *)bytes
objCType: (const char *)objCType
{
self = [super initWithBytes: bytes objCType: objCType];
@try {
_size = OFSizeOfTypeEncoding(objCType);
_objCType = objCType;
_objCType = OFStrDup(objCType);
_bytes = OFAllocMemory(1, _size);
memcpy(_bytes, bytes, _size);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
OFFreeMemory(_bytes);
OFFreeMemory(_objCType);
[super dealloc];
}
- (void)getValue: (void *)value size: (size_t)size
{
if (size != _size)
@throw [OFOutOfRangeException exception];
memcpy(value, _bytes, _size);
}
@end
|