ObjFW  Check-in [b1ef40944b]

Overview
Comment:Key Value Coding: Check type encoding for NULL
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b1ef40944b075be9887a7da3b0d98a0a8ba9db60ce98423e2b0a5ad2170d2c4c
User & Date: js on 2016-06-05 13:41:38
Other Links: manifest | tags
Context
2016-06-05
13:56
Add tests for Key Value Coding check-in: eb42896514 user: js tags: trunk
13:41
Key Value Coding: Check type encoding for NULL check-in: b1ef40944b user: js tags: trunk
13:32
configure: Use -Wobjc-missing-property-synthesis check-in: 9a0fd366ad user: js tags: trunk
Changes

Modified src/OFObject+KeyValueCoding.m from [8b1cd7f8e8] to [b460000a1a].

43
44
45
46
47
48
49



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




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







>
>
>







43
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 '@':
		ret = [self performSelector: selector];
		break;
#define CASE(encoding, type, method)					  \
	case encoding:							  \
		{							  \
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

	selector = sel_registerName(name);

	free(name);

	typeEncoding = [self typeEncodingForSelector: selector];

	if (nextType(&typeEncoding) != 'v' || nextType(&typeEncoding) != '@' ||
	    nextType(&typeEncoding) != ':') {
		[self    setValue: value
		  forUndefinedKey: key];
		return;
	}

	valueType = nextType(&typeEncoding);








|
|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

	selector = sel_registerName(name);

	free(name);

	typeEncoding = [self typeEncodingForSelector: selector];

	if (typeEncoding == NULL || nextType(&typeEncoding) != 'v' ||
	    nextType(&typeEncoding) != '@' || nextType(&typeEncoding) != ':') {
		[self    setValue: value
		  forUndefinedKey: key];
		return;
	}

	valueType = nextType(&typeEncoding);