ObjFW  Diff

Differences From Artifact [35d1810bb5]:

To Artifact [1a169f665d]:


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
}
@end

@implementation OFRunLoop_ReadQueueItem
- (bool)handleForObject: (id)object
{
	size_t length;
	OFException *exception = nil;

	@try {
		length = [object readIntoBuffer: _buffer
					 length: _length];
	} @catch (OFException *e) {
		length = 0;
		exception = e;
	}

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, _buffer, length, exception);
	else {
# endif
		bool (*func)(id, SEL, OFStream *, void *, size_t, id,
		    OFException *) = (bool (*)(id, SEL, OFStream *, void *,
		    size_t, id, OFException *))
		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, _buffer, length,
		    _context, exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif







|




|









|
|
<







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
}
@end

@implementation OFRunLoop_ReadQueueItem
- (bool)handleForObject: (id)object
{
	size_t length;
	id exception = nil;

	@try {
		length = [object readIntoBuffer: _buffer
					 length: _length];
	} @catch (id e) {
		length = 0;
		exception = e;
	}

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, _buffer, length, exception);
	else {
# endif
		bool (*func)(id, SEL, OFStream *, void *, size_t, id, id) =
		    (bool (*)(id, SEL, OFStream *, void *, size_t, id, id))

		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, _buffer, length,
		    _context, exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif
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
193
194
195
196
197
198
199
200
# endif
@end

@implementation OFRunLoop_ExactReadQueueItem
- (bool)handleForObject: (id)object
{
	size_t length;
	OFException *exception = nil;

	@try {
		length = [object readIntoBuffer: (char *)_buffer + _readLength
					 length: _exactLength - _readLength];
	} @catch (OFException *e) {
		length = 0;
		exception = e;
	}

	_readLength += length;

	if (_readLength != _exactLength && ![object isAtEndOfStream] &&
	    exception == nil)
		return true;

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL) {
		if (!_block(object, _buffer, _readLength, exception))
			return false;

		_readLength = 0;
		return true;
	} else {
# endif
		bool (*func)(id, SEL, OFStream *, void *, size_t, id,
		    OFException *) = (bool (*)(id, SEL, OFStream *, void *,
		    size_t, id, OFException *))
		    [_target methodForSelector: _selector];

		if (!func(_target, _selector, object, _buffer, _readLength,
		    _context, exception))
			return false;

		_readLength = 0;







|




|



















|
|
<







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
193
194
195
196
197
198
# endif
@end

@implementation OFRunLoop_ExactReadQueueItem
- (bool)handleForObject: (id)object
{
	size_t length;
	id exception = nil;

	@try {
		length = [object readIntoBuffer: (char *)_buffer + _readLength
					 length: _exactLength - _readLength];
	} @catch (id e) {
		length = 0;
		exception = e;
	}

	_readLength += length;

	if (_readLength != _exactLength && ![object isAtEndOfStream] &&
	    exception == nil)
		return true;

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL) {
		if (!_block(object, _buffer, _readLength, exception))
			return false;

		_readLength = 0;
		return true;
	} else {
# endif
		bool (*func)(id, SEL, OFStream *, void *, size_t, id, id) =
		    (bool (*)(id, SEL, OFStream *, void *, size_t, id, id))

		    [_target methodForSelector: _selector];

		if (!func(_target, _selector, object, _buffer, _readLength,
		    _context, exception))
			return false;

		_readLength = 0;
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
239
240
241
242
243
244
245
246
247
# endif
@end

@implementation OFRunLoop_ReadLineQueueItem
- (bool)handleForObject: (id)object
{
	OFString *line;
	OFException *exception = nil;

	@try {
		line = [object tryReadLineWithEncoding: _encoding];
	} @catch (OFException *e) {
		line = nil;
		exception = e;
	}

	if (line == nil && ![object isAtEndOfStream] && exception == nil)
		return true;

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, line, exception);
	else {
# endif
		bool (*func)(id, SEL, OFStream *, OFString *, id,
		    OFException *) = (bool (*)(id, SEL, OFStream *, OFString *,
		    id, OFException *))[_target methodForSelector: _selector];

		return func(_target, _selector, object, line, _context,
		    exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif
}







|



|












|
|
|







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
239
240
241
242
243
244
245
# endif
@end

@implementation OFRunLoop_ReadLineQueueItem
- (bool)handleForObject: (id)object
{
	OFString *line;
	id exception = nil;

	@try {
		line = [object tryReadLineWithEncoding: _encoding];
	} @catch (id e) {
		line = nil;
		exception = e;
	}

	if (line == nil && ![object isAtEndOfStream] && exception == nil)
		return true;

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, line, exception);
	else {
# endif
		bool (*func)(id, SEL, OFStream *, OFString *, id, id) =
		    (bool (*)(id, SEL, OFStream *, OFString *, id, id))
		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, line, _context,
		    exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif
}
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# endif
@end

@implementation OFRunLoop_AcceptQueueItem
- (bool)handleForObject: (id)object
{
	OFTCPSocket *newSocket;
	OFException *exception = nil;

	@try {
		newSocket = [object accept];
	} @catch (OFException *e) {
		newSocket = nil;
		exception = e;
	}

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, newSocket, exception);
	else {
# endif
		bool (*func)(id, SEL, OFTCPSocket *, OFTCPSocket *, id,
		    OFException *) = (bool (*)(id, SEL, OFTCPSocket *,
		    OFTCPSocket *, id, OFException *))
		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, newSocket, _context,
		    exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif







|



|









|
|
<







254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276

277
278
279
280
281
282
283
# endif
@end

@implementation OFRunLoop_AcceptQueueItem
- (bool)handleForObject: (id)object
{
	OFTCPSocket *newSocket;
	id exception = nil;

	@try {
		newSocket = [object accept];
	} @catch (id e) {
		newSocket = nil;
		exception = e;
	}

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, newSocket, exception);
	else {
# endif
		bool (*func)(id, SEL, OFTCPSocket *, OFTCPSocket *, id, id) =
		    (bool (*)(id, SEL, OFTCPSocket *, OFTCPSocket *, id, id))

		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, newSocket, _context,
		    exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
@end

@implementation OFRunLoop_UDPReceiveQueueItem
- (bool)handleForObject: (id)object
{
	size_t length;
	of_udp_socket_address_t address;
	OFException *exception = nil;

	@try {
		length = [object receiveIntoBuffer: _buffer
					    length: _length
					    sender: &address];
	} @catch (OFException *e) {
		length = 0;
		exception = e;
	}

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, _buffer, length, address, exception);
	else {
# endif
		bool (*func)(id, SEL, OFUDPSocket *, void *, size_t,
		    of_udp_socket_address_t address, id, OFException *) =
		    (bool (*)(id, SEL, OFUDPSocket *, void *, size_t,
		    of_udp_socket_address_t, id, OFException *))
		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, _buffer, length,
		    address, _context, exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif







|





|










|

|







294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
@end

@implementation OFRunLoop_UDPReceiveQueueItem
- (bool)handleForObject: (id)object
{
	size_t length;
	of_udp_socket_address_t address;
	id exception = nil;

	@try {
		length = [object receiveIntoBuffer: _buffer
					    length: _length
					    sender: &address];
	} @catch (id e) {
		length = 0;
		exception = e;
	}

# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, _buffer, length, address, exception);
	else {
# endif
		bool (*func)(id, SEL, OFUDPSocket *, void *, size_t,
		    of_udp_socket_address_t address, id, id) =
		    (bool (*)(id, SEL, OFUDPSocket *, void *, size_t,
		    of_udp_socket_address_t, id, id))
		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, _buffer, length,
		    address, _context, exception);
# ifdef OF_HAVE_BLOCKS
	}
# endif