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
|
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
|
-
+
+
-
+
|
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#import <ObjFW/ObjFW.h>
#import <ObjFW/OFDataArray.h>
#import <ObjFW/OFData.h>
#import "XMPPMulticastDelegate.h"
@implementation XMPPMulticastDelegate
- init
{
self = [super init];
@try {
_delegates = [[OFMutableData alloc]
_delegates = [[OFDataArray alloc] initWithItemSize: sizeof(id)];
initWithItemSize: sizeof(id)];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
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
|
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
125
126
|
+
-
+
+
+
+
-
+
+
+
|
return;
}
}
- (bool)broadcastSelector: (SEL)selector
withObject: (id)object
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDataArray *currentDelegates = [_delegates copy];
OFMutableData *currentDelegates = [[_delegates copy] autorelease];
id *items = [currentDelegates items];
size_t i, count = [currentDelegates count];
bool handled = false;
for (i = 0; i < count; i++) {
id responder = items[i];
if (![responder respondsToSelector: selector])
continue;
bool (*imp)(id, SEL, id) = (bool(*)(id, SEL, id))
[responder methodForSelector: selector];
handled |= imp(responder, selector, object);
}
[pool release];
return handled;
}
- (bool)broadcastSelector: (SEL)selector
withObject: (id)object1
withObject: (id)object2
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDataArray *currentDelegates = [_delegates copy];
OFMutableData *currentDelegates = [[_delegates copy] autorelease];
id *items = [currentDelegates items];
size_t i, count = [currentDelegates count];
bool handled = false;
for (i = 0; i < count; i++) {
id responder = items[i];
if (![responder respondsToSelector: selector])
continue;
bool (*imp)(id, SEL, id, id) = (bool(*)(id, SEL, id, id))
[responder methodForSelector: selector];
handled |= imp(responder, selector, object1, object2);
}
[pool release];
return handled;
}
@end
|