Differences From Artifact [536375a07c]:
- File src/OFRunLoop.m — part of check-in [da2dd2dde5] at 2018-12-08 18:55:26 on branch trunk — OFUDPSocket: Use a delegate for async operations (user: js, size: 28607) [annotate] [blame] [check-ins using]
To Artifact [2b70c16414]:
- File
src/OFRunLoop.m
— part of check-in
[064dbe5127]
at
2018-12-11 22:57:46
on branch trunk
— Include an exception in delegate methods
Otherwise, there would be two methods for every operation: One for
success and one for failure. It also makes it easy to forget about
handling failure, so it's better to always pass an optional exception. (user: js, size: 27224) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
319 320 321 322 323 324 325 | } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, exception); else { # endif | < | | | | | | < < < < | < < < | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, exception); else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadIntoBuffer:length:exception:)]) return false; return [_delegate stream: object didReadIntoBuffer: _buffer length: length exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ | |||
379 380 381 382 383 384 385 | if (!_block(object, _buffer, _readLength, exception)) return false; _readLength = 0; return true; } else { # endif | < | | | | | | > | | | < < < < < < < < | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | if (!_block(object, _buffer, _readLength, exception)) return false; _readLength = 0; return true; } else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadIntoBuffer:length:exception:)]) return false; if (![_delegate stream: object didReadIntoBuffer: _buffer length: _readLength exception: exception]) return false; _readLength = 0; return true; # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ | |||
435 436 437 438 439 440 441 | return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, line, exception); else { # endif | < | | | | | < < < < | < < < | 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, line, exception); else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadLine:exception:)]) return false; return [_delegate stream: object didReadLine: line exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ | |||
495 496 497 498 499 500 501 | if (_length == 0) return false; _writtenLength = 0; return true; } else { # endif | < | | | | | | > | | | | < < < < < < < < | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | if (_length == 0) return false; _writtenLength = 0; return true; } else { # endif if (![_delegate respondsToSelector: @selector(stream:didWriteBuffer:length:exception:)]) return false; _length = [_delegate stream: object didWriteBuffer: &_buffer length: _length exception: exception]; if (_length == 0) return false; _writtenLength = 0; return true; # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ | |||
572 573 574 575 576 577 578 | } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, acceptedSocket, exception); else { # endif | < | | | | | < < < < | < < < | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, acceptedSocket, exception); else { # endif if (![_delegate respondsToSelector: @selector(socket:didAcceptSocket:exception:)]) return false; return [_delegate socket: object didAcceptSocket: acceptedSocket exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ | |||
623 624 625 626 627 628 629 | } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, address, exception); else { # endif | < | | | | | | | < < < < | < < < | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, address, exception); else { # endif if (![_delegate respondsToSelector: @selector( socket:didReceiveIntoBuffer:length:sender:exception:)]) return false; return [_delegate socket: object didReceiveIntoBuffer: _buffer length: length sender: address exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ | |||
676 677 678 679 680 681 682 | if (_block != NULL) { _length = _block(object, &_buffer, (exception == nil ? _length : 0), &_receiver, exception); return (_length > 0); } else { # endif | < | | | | | | | < < < < < < | | < | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | if (_block != NULL) { _length = _block(object, &_buffer, (exception == nil ? _length : 0), &_receiver, exception); return (_length > 0); } else { # endif if (![_delegate respondsToSelector: @selector(socket:didSendBuffer:length:receiver:exception:)]) return false; _length = [_delegate socket: object didSendBuffer: &_buffer length: (exception == nil ? _length : 0) receiver: &_receiver exception: exception]; return (_length > 0); # ifdef OF_HAVE_BLOCKS } # endif } # ifdef OF_HAVE_BLOCKS - (void)dealloc |
︙ | ︙ |