ObjFW  Diff

Differences From Artifact [234e32b5ef]:

To Artifact [1e751e9c03]:


18
19
20
21
22
23
24

25



26
27
28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
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
18
19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60
61
62
63
64














+
-
+
+
+









-
+














-
+











-
-
-
-
-
-
-

#include <string.h>

#import "runtime.h"
#import "runtime-private.h"

@implementation Protocol
@end
- (BOOL)_isImplementedByClass: (Class)cls

BOOL
class_conformsToProtocol(Class cls, Protocol *p)
{
	struct objc_protocol_list *pl;
	struct objc_category **cats;
	long i, j;

	objc_global_mutex_lock();

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

	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, name)) {
				if (!strcmp(pl->list[j]->name, p->name)) {
					objc_global_mutex_unlock();
					return YES;
				}
			}
		}
	}

	objc_global_mutex_unlock();

	return NO;
}
@end

BOOL
class_conformsToProtocol(Class cls, Protocol *p)
{
	return [p _isImplementedByClass: cls];
}