ObjXMPP  Diff

Differences From Artifact [0321dd1eed]:

To Artifact [8c2482d4cf]:


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
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
112

113
114

115
116
117
118
119
120
121
122
123
124







-
-
-
+
+
+
+
+
+
+
-






+

-


-
-
+
+
+



-
+

-
+
+
+
+
+









+

-


-
-
+
+
+



-
+

-
+
+
+
+
+






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

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

		[_delegates removeItemAtIndex: i];
		if (i <= handlerIndex)
			handlerIndex--;
		return;
		}
	}
}

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

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

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

		handled |= imp(items[i], selector, object);
		handled |= imp(responder, selector, object);
		// Update count and items, since the handler might have
		// changed them.
		count = [_delegates count];
		items = [_delegates items];
	}

	return handled;
}

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

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

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

		handled |= imp(items[i], selector, object1, object2);
		handled |= imp(responder, selector, object1, object2);
		// Update count and items, since the handler might have
		// changed them.
		count = [_delegates count];
		items = [_delegates items];
	}

	return handled;
}
@end