ObjFW  Diff

Differences From Artifact [fcc7bff050]:

To Artifact [0c9f7f6c34]:


1
2
3
4

5
6
7
8
9
10
11
1



2
3
4
5
6
7
8
9

-
-
-
+







/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019, 2020
 *   Jonathan Schleifer <js@nil.im>
 * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
 *
 * 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.
 *
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
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







-
+
-
-
+
-
-

















-
+
-







		otherValue = of_alloc(1, size);
	} @catch (id e) {
		free(value);
		@throw e;
	}

	@try {
		[self getValue: value
		[self getValue: value size: size];
			  size: size];
		[object getValue: otherValue
		[object getValue: otherValue size: size];
			    size: size];

		ret = (memcmp(value, otherValue, size) == 0);
	} @finally {
		free(value);
		free(otherValue);
	}

	return ret;
}

- (unsigned long)hash
{
	size_t size = of_sizeof_type_encoding(self.objCType);
	unsigned char *value;
	uint32_t hash;

	value = of_alloc(1, size);
	@try {
		[self getValue: value
		[self getValue: value size: size];
			  size: size];

		OF_HASH_INIT(hash);

		for (size_t i = 0; i < size; i++)
			OF_HASH_ADD(hash, value[i]);

		OF_HASH_FINALIZE(hash);
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
293

294
295
296
297
298
299
300
301
302
303

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318

319
320
321
322
323
324
325
326
230
231
232
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

293

294
295
296
297
298
299
300







-
+
-







-
-
+
-
-






-
-
+
-
-






-
-
+
-
-






-
-
+
-
-






-
-
+
-
-






-
-
+
-
-












-
+
-







}

- (const char *)objCType
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
	    size: (size_t)size
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void *)pointerValue
{
	void *ret;

	[self getValue: &ret
	[self getValue: &ret size: sizeof(ret)];
		  size: sizeof(ret)];

	return ret;
}

- (id)nonretainedObjectValue
{
	id ret;

	[self getValue: &ret
	[self getValue: &ret size: sizeof(ret)];
		  size: sizeof(ret)];

	return ret;
}

- (of_range_t)rangeValue
{
	of_range_t ret;

	[self getValue: &ret
	[self getValue: &ret size: sizeof(ret)];
		  size: sizeof(ret)];

	return ret;
}

- (of_point_t)pointValue
{
	of_point_t ret;

	[self getValue: &ret
	[self getValue: &ret size: sizeof(ret)];
		  size: sizeof(ret)];

	return ret;
}

- (of_dimension_t)dimensionValue
{
	of_dimension_t ret;

	[self getValue: &ret
	[self getValue: &ret size: sizeof(ret)];
		  size: sizeof(ret)];

	return ret;
}

- (of_rectangle_t)rectangleValue
{
	of_rectangle_t ret;

	[self getValue: &ret
	[self getValue: &ret size: sizeof(ret)];
		  size: sizeof(ret)];

	return ret;
}

- (OFString *)description
{
	OFMutableString *ret =
	    [OFMutableString stringWithString: @"<OFValue: "];
	size_t size = of_sizeof_type_encoding(self.objCType);
	unsigned char *value;

	value = of_alloc(1, size);
	@try {
		[self getValue: value
		[self getValue: value size: size];
			  size: size];

		for (size_t i = 0; i < size; i++) {
			if (i > 0)
				[ret appendString: @" "];

			[ret appendFormat: @"%02x", value[i]];
		}