ObjFW  Diff

Differences From Artifact [08642a6afa]:

To Artifact [f4fafd457a]:


44
45
46
47
48
49
50
51




52





















53
54
55
56
57
58
59
@implementation OFObject (KeyValueCoding)
- (id)valueForKey: (OFString*)key
{
	SEL selector = sel_registerName([key UTF8String]);
	const char *typeEncoding = [self typeEncodingForSelector: selector];
	id ret;

	if (typeEncoding == NULL)




		return [self valueForUndefinedKey: key];






















	switch (nextType(&typeEncoding)) {
	case '@':
	case '#':
		ret = [self performSelector: selector];
		break;
#define CASE(encoding, type, method)					  \







|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







44
45
46
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
82
83
84
@implementation OFObject (KeyValueCoding)
- (id)valueForKey: (OFString*)key
{
	SEL selector = sel_registerName([key UTF8String]);
	const char *typeEncoding = [self typeEncodingForSelector: selector];
	id ret;

	if (typeEncoding == NULL) {
		size_t keyLength;
		char *name;

		if ((keyLength = [key UTF8StringLength]) < 1)
			return [self valueForUndefinedKey: key];

		if ((name = malloc(keyLength + 3)) == NULL)
			@throw [OFOutOfMemoryException
			    exceptionWithRequestedSize: keyLength + 3];

		memcpy(name, "is", 2);
		memcpy(name + 2, [key UTF8String], keyLength);
		name[keyLength + 2] = '\0';

		name[2] = toupper(name[2]);

		selector = sel_registerName(name);

		free(name);

		typeEncoding = [self typeEncodingForSelector: selector];

		if (typeEncoding == NULL ||
		    *typeEncoding == '@' || *typeEncoding == '#')
			return [self valueForUndefinedKey: key];
	}

	switch (nextType(&typeEncoding)) {
	case '@':
	case '#':
		ret = [self performSelector: selector];
		break;
#define CASE(encoding, type, method)					  \