ObjFW  Check-in [2fab0339e4]

Overview
Comment:Check if protocol responds to protocol.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | runtime
Files: files | file ages | folders
SHA3-256: 2fab0339e44a6acdb6bbbcc04dcea61bd812a7a5041735ebe2f67dd3ec564415
User & Date: js on 2012-04-08 20:00:26
Other Links: branch diff | manifest | tags
Context
2012-04-18
17:26
Remove unnecessary interface. check-in: 1bf4571d60 user: js tags: runtime
2012-04-08
20:00
Check if protocol responds to protocol. check-in: 2fab0339e4 user: js tags: runtime
15:03
Return Nil for incomplete classes. check-in: 0e35ae63a5 user: js tags: runtime
Changes

Modified src/runtime/protocol.m from [9f39113692] to [c72a2fb5f7].

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
85
86
87
88
89
90
91
BOOL
class_conformsToProtocol(Class cls, Protocol *p)
{
	struct objc_protocol_list *pl;
	struct objc_category **cats;
	long i, j;

	for (pl = cls->protocols; pl != NULL; pl = pl->next) {
		for (i = 0; i < pl->count; i++) {
			if (!strcmp(pl->list[i]->name, p->name))
				return YES;
		}
	}

	objc_global_mutex_lock();

	if ((cats = objc_categories_for_class(cls)) == NULL) {
		objc_global_mutex_unlock();
		return NO;
	}

	for (i = 0; cats[i] != NULL; i++) {
		for (pl = cats[i]->protocols; pl != NULL; pl = pl->next) {
			for (j = 0; j < pl->count; j++) {

				if (!strcmp(pl->list[j]->name, p->name)) {
					objc_global_mutex_unlock();
					return YES;
				}
			}
		}
	}

	objc_global_mutex_unlock();

	return NO;
}







|
|
|

<
<











>
|











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
85
86
87
88
89
90
BOOL
class_conformsToProtocol(Class cls, Protocol *p)
{
	struct objc_protocol_list *pl;
	struct objc_category **cats;
	long i, j;

	for (pl = cls->protocols; pl != NULL; pl = pl->next)
		for (i = 0; i < pl->count; i++)
			if (protocol_conformsToProtocol(pl->list[i], p))
				return YES;



	objc_global_mutex_lock();

	if ((cats = objc_categories_for_class(cls)) == NULL) {
		objc_global_mutex_unlock();
		return NO;
	}

	for (i = 0; cats[i] != NULL; i++) {
		for (pl = cats[i]->protocols; pl != NULL; pl = pl->next) {
			for (j = 0; j < pl->count; j++) {
				if (protocol_conformsToProtocol(
				    pl->list[j], p)) {
					objc_global_mutex_unlock();
					return YES;
				}
			}
		}
	}

	objc_global_mutex_unlock();

	return NO;
}