ObjFW  Check-in [df24f80ab0]

Overview
Comment:Don't have any methods in Protocol.

Messaging protocols is deprecated and unreliable. Thus we shouldn't do
it in the runtime either.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | runtime
Files: files | file ages | folders
SHA3-256: df24f80ab0743aca75ff8193a956d78672abfc3a0ced810bded5b29b12c1edd2
User & Date: js on 2012-04-08 14:06:14
Other Links: branch diff | manifest | tags
Context
2012-04-08
14:07
Reduce locking in class_conformsToProtocol(). check-in: 10c3b59143 user: js tags: runtime
14:06
Don't have any methods in Protocol. check-in: df24f80ab0 user: js tags: runtime
2012-04-06
17:43
objc_abi_protocol_list does not exist anymore. check-in: 5b29d50e2e user: js tags: runtime
Changes

Modified src/runtime/protocol.m from [234e32b5ef] to [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

#include <string.h>

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

@implementation Protocol

- (BOOL)_isImplementedByClass: (Class)cls


{
	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)) {
				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)) {
					objc_global_mutex_unlock();
					return YES;
				}
			}
		}
	}

	objc_global_mutex_unlock();

	return NO;
}
@end

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







>
|
>
>









|














|











<
<
<
<
<
<
<
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
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, 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, p->name)) {
					objc_global_mutex_unlock();
					return YES;
				}
			}
		}
	}

	objc_global_mutex_unlock();

	return NO;
}







Modified src/runtime/runtime.h from [117a048a91] to [a7ea76e777].

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

typedef struct objc_class *Class;
typedef struct objc_object *id;
typedef const struct objc_selector *SEL;
typedef signed char BOOL;
typedef id (*IMP)(id, SEL, ...);

#ifdef __OBJC__
@interface Protocol
{
@private
	Class isa;
	const char *name;
	struct objc_protocol_list *protocol_list;
	struct objc_abi_method_description_list *instance_methods;
	struct objc_abi_method_description_list *class_methods;
}
@end
#else
typedef const void Protocol;
#endif

struct objc_class {
	Class isa;
	Class superclass;
	const char *name;
	unsigned long version;
	unsigned long info;
	unsigned long instance_size;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







20
21
22
23
24
25
26















27
28
29
30
31
32
33

typedef struct objc_class *Class;
typedef struct objc_object *id;
typedef const struct objc_selector *SEL;
typedef signed char BOOL;
typedef id (*IMP)(id, SEL, ...);
















struct objc_class {
	Class isa;
	Class superclass;
	const char *name;
	unsigned long version;
	unsigned long info;
	unsigned long instance_size;
86
87
88
89
90
91
92



















93
94
95
96
97
98
99
struct objc_category {
	const char *category_name;
	const char *class_name;
	struct objc_method_list *instance_methods;
	struct objc_method_list *class_methods;
	struct objc_protocol_list *protocols;
};




















struct objc_protocol_list {
	struct objc_protocol_list *next;
	long count;
	Protocol *list[1];
};








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
struct objc_category {
	const char *category_name;
	const char *class_name;
	struct objc_method_list *instance_methods;
	struct objc_method_list *class_methods;
	struct objc_protocol_list *protocols;
};

#ifdef __OBJC__
@interface Protocol
{
@public
#else
typedef struct {
#endif
	Class isa;
	const char *name;
	struct objc_protocol_list *protocol_list;
	struct objc_abi_method_description_list *instance_methods;
	struct objc_abi_method_description_list *class_methods;
#ifdef __OBJC__
}
@end
#else
} Protocol;
#endif

struct objc_protocol_list {
	struct objc_protocol_list *next;
	long count;
	Protocol *list[1];
};