ObjFW  Diff

Differences From Artifact [23039ce7da]:

To Artifact [1c8a9015a1]:


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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

			if (object == nil || count_ == nil)
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			count = (size_t)[[count_ stringValue] decimalValue];

			[mapTable setValue: (void*)(uintptr_t)count
				    forKey: [object objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
		}

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (size_t)countForObject: (id)object
{
	return (size_t)(uintptr_t)[mapTable valueForKey: object];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock:
    (of_counted_set_enumeration_block_t)block
{
	@try {
		[mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, BOOL *stop) {
			block(key, (size_t)(uintptr_t)value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}
#endif

- (void)addObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[mapTable valueForKey: object];

	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[mapTable setValue: (void*)(uintptr_t)(count + 1)
		    forKey: object];
}

- (void)removeObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[mapTable valueForKey: object];

	if (count == 0)
		return;

	count--;

	if (count > 0)
		[mapTable setValue: (void*)(uintptr_t)count
			    forKey: object];
	else
		[mapTable removeValueForKey: object];
}

- (void)makeImmutable
{
}
@end







|
|















|







|













|




|
|




|







|
|

|






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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

			if (object == nil || count_ == nil)
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			count = (size_t)[[count_ stringValue] decimalValue];

			[_mapTable setValue: (void*)(uintptr_t)count
				     forKey: [object objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
		}

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (size_t)countForObject: (id)object
{
	return (size_t)(uintptr_t)[_mapTable valueForKey: object];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock:
    (of_counted_set_enumeration_block_t)block
{
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, BOOL *stop) {
			block(key, (size_t)(uintptr_t)value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}
#endif

- (void)addObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object];

	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[_mapTable setValue: (void*)(uintptr_t)(count + 1)
		     forKey: object];
}

- (void)removeObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object];

	if (count == 0)
		return;

	count--;

	if (count > 0)
		[_mapTable setValue: (void*)(uintptr_t)count
			     forKey: object];
	else
		[_mapTable removeValueForKey: object];
}

- (void)makeImmutable
{
}
@end