Differences From Artifact [aac405c1ea]:
- File
src/XMPPCallback.m
— part of check-in
[cd21ff1157]
at
2018-11-05 22:30:18
on branch trunk
— Kill #ifdef HAVE_CONFIG_H
There no longer is an Xcode project for which it is needed. (user: js, size: 2275) [annotate] [blame] [check-ins using]
To Artifact [1ccfe848fa]:
- File src/XMPPCallback.m — part of check-in [9919057cb8] at 2021-04-29 00:06:23 on branch trunk — Adjust to ObjFW style (user: js, size: 2301) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de> * * https://heap.zone/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * | > | 1 2 3 4 5 6 7 8 9 10 | /* * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2021, Jonathan Schleifer <js@nil.im> * * https://heap.zone/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * |
︙ | ︙ | |||
22 23 24 25 26 27 28 | #include "config.h" #import "XMPPCallback.h" @implementation XMPPCallback #ifdef OF_HAVE_BLOCKS | | | | < | < | < | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 | #include "config.h" #import "XMPPCallback.h" @implementation XMPPCallback #ifdef OF_HAVE_BLOCKS + (instancetype)callbackWithBlock: (XMPPCallbackBlock)block { return [[(XMPPCallback *)[self alloc] initWithBlock: block] autorelease]; } - (instancetype)initWithBlock: (XMPPCallbackBlock)block { self = [super init]; @try { _block = [block copy]; } @catch (id e) { [self release]; @throw e; } return self; } #endif + (instancetype)callbackWithTarget: (id)target selector: (SEL)selector { return [[[self alloc] initWithTarget: target selector: selector] autorelease]; } - (instancetype)initWithTarget: (id)target selector: (SEL)selector { self = [super init]; _target = [target retain]; _selector = selector; return self; } - (void)dealloc { [_target release]; #ifdef OF_HAVE_BLOCKS [_block release]; #endif [super dealloc]; } - (void)runWithIQ: (XMPPIQ *)IQ connection: (XMPPConnection *)connection { #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(connection, IQ); else #endif [_target performSelector: _selector withObject: connection withObject: IQ]; } @end |