ObjFW  Diff

Differences From Artifact [358230f36d]:

To Artifact [d066bfb20d]:


103
104
105
106
107
108
109














110
111
112
113
114
115
116
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+







}

+ (instancetype)valueWithRect: (OFRect)rect
{
	return [[[OFValue alloc] initWithBytes: &rect
				      objCType: @encode(OFRect)] autorelease];
}

+ (instancetype)valueWithVector3D: (OFVector3D)vector3D
{
	return [[[OFValue alloc]
	    initWithBytes: &vector3D
		 objCType: @encode(OFVector3D)] autorelease];
}

+ (instancetype)valueWithVector4D: (OFVector4D)vector4D
{
	return [[[OFValue alloc]
	    initWithBytes: &vector4D
		 objCType: @encode(OFVector4D)] autorelease];
}

- (instancetype)initWithBytes: (const void *)bytes
		     objCType: (const char *)objCType
{
	if ([self isMemberOfClass: [OFValue class]]) {
		@try {
			[self doesNotRecognizeSelector: _cmd];
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+








- (OFRect)rectValue
{
	OFRect ret;
	[self getValue: &ret size: sizeof(ret)];
	return ret;
}

- (OFVector3D)vector3DValue
{
	OFVector3D ret;
	[self getValue: &ret size: sizeof(ret)];
	return ret;
}

- (OFVector4D)vector4DValue
{
	OFVector4D ret;
	[self getValue: &ret size: sizeof(ret)];
	return ret;
}

- (OFString *)description
{
	const char *objCType = self.objCType;
	OFMutableString *ret;
	size_t size;
	unsigned char *value;
282
283
284
285
286
287
288















289
290
291
292
293
294
295
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	    strcmp(objCType, @encode(const OFRect)) == 0) {
		OFRect rectValue;
		[self getValue: &rectValue size: sizeof(rectValue)];
		return [OFString stringWithFormat:
		    @"<OFValue: OFRect { %g, %g, %g, %g }>",
		    rectValue.origin.x, rectValue.origin.y,
		    rectValue.size.width, rectValue.size.height];
	} else if (strcmp(objCType, @encode(OFVector3D)) == 0 ||
	    strcmp(objCType, @encode(const OFVector3D)) == 0) {
		OFVector3D vector3DValue;
		[self getValue: &vector3DValue size: sizeof(vector3DValue)];
		return [OFString stringWithFormat:
		    @"<OFValue: OFVector3D { %g, %g, %g }>",
		    vector3DValue.x, vector3DValue.y, vector3DValue.z];
	} else if (strcmp(objCType, @encode(OFVector4D)) == 0 ||
	    strcmp(objCType, @encode(const OFVector4D)) == 0) {
		OFVector4D vector4DValue;
		[self getValue: &vector4DValue size: sizeof(vector4DValue)];
		return [OFString stringWithFormat:
		    @"<OFValue: OFVector4D { %g, %g, %g, %g }>",
		    vector4DValue.x, vector4DValue.y, vector4DValue.z,
		    vector4DValue.w];
	}

	ret = [OFMutableString stringWithString: @"<OFValue: "];
	size = OFSizeOfTypeEncoding(objCType);
	value = OFAllocMemory(1, size);
	@try {
		[self getValue: value size: size];