22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
+
|
#import "OFMutableSet_hashtable.h"
#import "OFCountedSet_hashtable.h"
#import "OFMutableDictionary_hashtable.h"
#import "OFArray.h"
#import "OFString.h"
#import "OFNumber.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFInvalidArgumentException.h"
#import "autorelease.h"
@implementation OFSet_hashtable
- init
{
self = [super init];
@try {
|
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
+
-
-
+
-
+
|
}
- initWithSet: (OFSet*)set
{
self = [self init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
void *pool = objc_autoreleasePoolPush();
OFNumber *one = [OFNumber numberWithSize: 1];
OFEnumerator *enumerator = [set objectEnumerator];
id object;
/*
* We can't just copy the dictionary as the specified set might
* be a counted set, but we're just a normal set.
*/
while ((object = [enumerator nextObject]) != nil)
[dictionary _setObject: one
forKey: object
copyKey: NO];
[pool release];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithArray: (OFArray*)array
{
self = [self init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
void *pool = objc_autoreleasePoolPush();
OFNumber *one = [OFNumber numberWithSize: 1];
id *objects = [array objects];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[dictionary _setObject: one
forKey: objects[i]
copyKey: NO];
[pool release];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithObjects: (id const*)objects
count: (size_t)count
{
self = [self init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
void *pool = objc_autoreleasePoolPush();
OFNumber *one = [OFNumber numberWithSize: 1];
size_t i;
for (i = 0; i < count; i++)
[dictionary _setObject: one
forKey: objects[i]
copyKey: NO];
[pool release];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithObject: (id)firstObject
arguments: (va_list)arguments
{
self = [self init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
void *pool = objc_autoreleasePoolPush();
OFNumber *one = [OFNumber numberWithSize: 1];
id object;
[dictionary _setObject: one
forKey: firstObject
copyKey: NO];
while ((object = va_arg(arguments, id)) != nil)
[dictionary _setObject: one
forKey: object
copyKey: NO];
[pool release];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithSerialization: (OFXMLElement*)element
{
self = [self init];
@try {
OFAutoreleasePool *pool, *pool2;
void *pool = objc_autoreleasePoolPush();
OFNumber *one;
OFEnumerator *enumerator;
OFXMLElement *child;
pool = [[OFAutoreleasePool alloc] init];
if ((![[element name] isEqual: @"OFSet"] &&
![[element name] isEqual: @"OFMutableSet"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
one = [OFNumber numberWithSize: 1];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
while ((child = [enumerator nextObject]) != nil) {
pool2 = [[OFAutoreleasePool alloc] init];
void *pool2 = objc_autoreleasePoolPush();
while ((child = [enumerator nextObject]) != nil) {
[dictionary _setObject: one
forKey: [child objectByDeserializing]
copyKey: NO];
[pool2 releaseObjects];
objc_autoreleasePoolPop(pool2);
}
[pool release];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|