ObjXMPP  Diff

Differences From Artifact [0af7f26680]:

To Artifact [0321dd1eed]:


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
69
70
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
104

105
106

107
108
109
110
111
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
69
70
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

104
105

106
107
108
109
110
111







-
+










-
+






-
+




-
-
+
+


-
-
+
+








-
-
+
+



-
+



-
+

-
+









-
-
+
+



-
+



-
+

-
+






@implementation XMPPMulticastDelegate
- init
{
	self = [super init];

	@try {
		delegates = [[OFDataArray alloc] initWithItemSize: sizeof(id)];
		_delegates = [[OFDataArray alloc] initWithItemSize: sizeof(id)];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[delegates release];
	[_delegates release];

	[super dealloc];
}

- (void)addDelegate: (id)delegate
{
	[delegates addItem: &delegate];
	[_delegates addItem: &delegate];
}

- (void)removeDelegate: (id)delegate
{
	id *cArray = [delegates items];
	size_t i, count = [delegates count];
	id *items = [_delegates items];
	size_t i, count = [_delegates count];

	for (i = 0; i < count; i++) {
		if (cArray[i] == delegate) {
			[delegates removeItemAtIndex: i];
		if (items[i] == delegate) {
			[_delegates removeItemAtIndex: i];
			return;
		}
	}
}

- (BOOL)broadcastSelector: (SEL)selector
	       withObject: (id)object
{
	id *cArray = [delegates items];
	size_t i, count = [delegates count];
	id *items = [_delegates items];
	size_t i, count = [_delegates count];
	BOOL handled = NO;

	for (i = 0; i < count; i++) {
		if (![cArray[i] respondsToSelector: selector])
		if (![items[i] respondsToSelector: selector])
			continue;

		BOOL (*imp)(id, SEL, id) = (BOOL(*)(id, SEL, id))
		    [cArray[i] methodForSelector: selector];
		    [items[i] methodForSelector: selector];

		handled |= imp(cArray[i], selector, object);
		handled |= imp(items[i], selector, object);
	}

	return handled;
}

- (BOOL)broadcastSelector: (SEL)selector
	       withObject: (id)object1
	       withObject: (id)object2
{
	id *cArray = [delegates items];
	size_t i, count = [delegates count];
	id *items = [_delegates items];
	size_t i, count = [_delegates count];
	BOOL handled = NO;

	for (i = 0; i < count; i++) {
		if (![cArray[i] respondsToSelector: selector])
		if (![items[i] respondsToSelector: selector])
			continue;

		BOOL (*imp)(id, SEL, id, id) = (BOOL(*)(id, SEL, id, id))
		    [cArray[i] methodForSelector: selector];
		    [items[i] methodForSelector: selector];

		handled |= imp(cArray[i], selector, object1, object2);
		handled |= imp(items[i], selector, object1, object2);
	}

	return handled;
}
@end