commit | author | age
|
df1e8e
|
1 |
/* |
L |
2 |
* Copyright 2018 Google LLC |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
|
|
17 |
/** |
|
18 |
* GULOriginalIMPConvenienceMacros.h |
|
19 |
* |
|
20 |
* This header contains convenience macros for invoking the original IMP of a swizzled method. |
|
21 |
*/ |
|
22 |
|
|
23 |
/** |
|
24 |
* Invokes original IMP when the original selector takes no arguments. |
|
25 |
* |
|
26 |
* @param __receivingObject The object on which the IMP is invoked. |
|
27 |
* @param __swizzledSEL The selector used for swizzling. |
|
28 |
* @param __returnType The return type of the original implementation. |
|
29 |
* @param __originalIMP The original IMP. |
|
30 |
*/ |
|
31 |
#define GUL_INVOKE_ORIGINAL_IMP0(__receivingObject, __swizzledSEL, __returnType, __originalIMP) \ |
|
32 |
((__returnType(*)(id, SEL))__originalIMP)(__receivingObject, __swizzledSEL) |
|
33 |
|
|
34 |
/** |
|
35 |
* Invokes original IMP when the original selector takes 1 argument. |
|
36 |
* |
|
37 |
* @param __receivingObject The object on which the IMP is invoked. |
|
38 |
* @param __swizzledSEL The selector used for swizzling. |
|
39 |
* @param __returnType The return type of the original implementation. |
|
40 |
* @param __originalIMP The original IMP. |
|
41 |
* @param __arg1 The first argument. |
|
42 |
*/ |
|
43 |
#define GUL_INVOKE_ORIGINAL_IMP1(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
44 |
__arg1) \ |
|
45 |
((__returnType(*)(id, SEL, __typeof__(__arg1)))__originalIMP)(__receivingObject, __swizzledSEL, \ |
|
46 |
__arg1) |
|
47 |
|
|
48 |
/** |
|
49 |
* Invokes original IMP when the original selector takes 2 arguments. |
|
50 |
* |
|
51 |
* @param __receivingObject The object on which the IMP is invoked. |
|
52 |
* @param __swizzledSEL The selector used for swizzling. |
|
53 |
* @param __returnType The return type of the original implementation. |
|
54 |
* @param __originalIMP The original IMP. |
|
55 |
* @param __arg1 The first argument. |
|
56 |
* @param __arg2 The second argument. |
|
57 |
*/ |
|
58 |
#define GUL_INVOKE_ORIGINAL_IMP2(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
59 |
__arg1, __arg2) \ |
|
60 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2)))__originalIMP)( \ |
|
61 |
__receivingObject, __swizzledSEL, __arg1, __arg2) |
|
62 |
|
|
63 |
/** |
|
64 |
* Invokes original IMP when the original selector takes 3 arguments. |
|
65 |
* |
|
66 |
* @param __receivingObject The object on which the IMP is invoked. |
|
67 |
* @param __swizzledSEL The selector used for swizzling. |
|
68 |
* @param __returnType The return type of the original implementation. |
|
69 |
* @param __originalIMP The original IMP. |
|
70 |
* @param __arg1 The first argument. |
|
71 |
* @param __arg2 The second argument. |
|
72 |
* @param __arg3 The third argument. |
|
73 |
*/ |
|
74 |
#define GUL_INVOKE_ORIGINAL_IMP3(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
75 |
__arg1, __arg2, __arg3) \ |
|
76 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), \ |
|
77 |
__typeof__(__arg3)))__originalIMP)(__receivingObject, __swizzledSEL, __arg1, \ |
|
78 |
__arg2, __arg3) |
|
79 |
|
|
80 |
/** |
|
81 |
* Invokes original IMP when the original selector takes 4 arguments. |
|
82 |
* |
|
83 |
* @param __receivingObject The object on which the IMP is invoked. |
|
84 |
* @param __swizzledSEL The selector used for swizzling. |
|
85 |
* @param __returnType The return type of the original implementation. |
|
86 |
* @param __originalIMP The original IMP. |
|
87 |
* @param __arg1 The first argument. |
|
88 |
* @param __arg2 The second argument. |
|
89 |
* @param __arg3 The third argument. |
|
90 |
* @param __arg4 The fourth argument. |
|
91 |
*/ |
|
92 |
#define GUL_INVOKE_ORIGINAL_IMP4(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
93 |
__arg1, __arg2, __arg3, __arg4) \ |
|
94 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \ |
|
95 |
__typeof__(__arg4)))__originalIMP)(__receivingObject, __swizzledSEL, __arg1, \ |
|
96 |
__arg2, __arg3, __arg4) |
|
97 |
|
|
98 |
/** |
|
99 |
* Invokes original IMP when the original selector takes 5 arguments. |
|
100 |
* |
|
101 |
* @param __receivingObject The object on which the IMP is invoked. |
|
102 |
* @param __swizzledSEL The selector used for swizzling. |
|
103 |
* @param __returnType The return type of the original implementation. |
|
104 |
* @param __originalIMP The original IMP. |
|
105 |
* @param __arg1 The first argument. |
|
106 |
* @param __arg2 The second argument. |
|
107 |
* @param __arg3 The third argument. |
|
108 |
* @param __arg4 The fourth argument. |
|
109 |
* @param __arg5 The fifth argument. |
|
110 |
*/ |
|
111 |
#define GUL_INVOKE_ORIGINAL_IMP5(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
112 |
__arg1, __arg2, __arg3, __arg4, __arg5) \ |
|
113 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \ |
|
114 |
__typeof__(__arg4), __typeof__(__arg5)))__originalIMP)( \ |
|
115 |
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5) |
|
116 |
|
|
117 |
/** |
|
118 |
* Invokes original IMP when the original selector takes 6 arguments. |
|
119 |
* |
|
120 |
* @param __receivingObject The object on which the IMP is invoked. |
|
121 |
* @param __swizzledSEL The selector used for swizzling. |
|
122 |
* @param __returnType The return type of the original implementation. |
|
123 |
* @param __originalIMP The original IMP. |
|
124 |
* @param __arg1 The first argument. |
|
125 |
* @param __arg2 The second argument. |
|
126 |
* @param __arg3 The third argument. |
|
127 |
* @param __arg4 The fourth argument. |
|
128 |
* @param __arg5 The fifth argument. |
|
129 |
* @param __arg6 The sixth argument. |
|
130 |
*/ |
|
131 |
#define GUL_INVOKE_ORIGINAL_IMP6(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
132 |
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \ |
|
133 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \ |
|
134 |
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6)))__originalIMP)( \ |
|
135 |
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) |
|
136 |
|
|
137 |
/** |
|
138 |
* Invokes original IMP when the original selector takes 7 arguments. |
|
139 |
* |
|
140 |
* @param __receivingObject The object on which the IMP is invoked. |
|
141 |
* @param __swizzledSEL The selector used for swizzling. |
|
142 |
* @param __returnType The return type of the original implementation. |
|
143 |
* @param __originalIMP The original IMP. |
|
144 |
* @param __arg1 The first argument. |
|
145 |
* @param __arg2 The second argument. |
|
146 |
* @param __arg3 The third argument. |
|
147 |
* @param __arg4 The fourth argument. |
|
148 |
* @param __arg5 The fifth argument. |
|
149 |
* @param __arg6 The sixth argument. |
|
150 |
* @param __arg7 The seventh argument. |
|
151 |
*/ |
|
152 |
#define GUL_INVOKE_ORIGINAL_IMP7(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
153 |
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7) \ |
|
154 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \ |
|
155 |
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6), \ |
|
156 |
__typeof__(__arg7)))__originalIMP)( \ |
|
157 |
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7) |
|
158 |
|
|
159 |
/** |
|
160 |
* Invokes original IMP when the original selector takes 8 arguments. |
|
161 |
* |
|
162 |
* @param __receivingObject The object on which the IMP is invoked. |
|
163 |
* @param __swizzledSEL The selector used for swizzling. |
|
164 |
* @param __returnType The return type of the original implementation. |
|
165 |
* @param __originalIMP The original IMP. |
|
166 |
* @param __arg1 The first argument. |
|
167 |
* @param __arg2 The second argument. |
|
168 |
* @param __arg3 The third argument. |
|
169 |
* @param __arg4 The fourth argument. |
|
170 |
* @param __arg5 The fifth argument. |
|
171 |
* @param __arg6 The sixth argument. |
|
172 |
* @param __arg7 The seventh argument. |
|
173 |
* @param __arg8 The eighth argument. |
|
174 |
*/ |
|
175 |
#define GUL_INVOKE_ORIGINAL_IMP8(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
176 |
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, __arg8) \ |
|
177 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \ |
|
178 |
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6), \ |
|
179 |
__typeof__(__arg7), __typeof__(__arg8)))__originalIMP)( \ |
|
180 |
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, \ |
|
181 |
__arg8) |
|
182 |
|
|
183 |
/** |
|
184 |
* Invokes original IMP when the original selector takes 9 arguments. |
|
185 |
* |
|
186 |
* @param __receivingObject The object on which the IMP is invoked. |
|
187 |
* @param __swizzledSEL The selector used for swizzling. |
|
188 |
* @param __returnType The return type of the original implementation. |
|
189 |
* @param __originalIMP The original IMP. |
|
190 |
* @param __arg1 The first argument. |
|
191 |
* @param __arg2 The second argument. |
|
192 |
* @param __arg3 The third argument. |
|
193 |
* @param __arg4 The fourth argument. |
|
194 |
* @param __arg5 The fifth argument. |
|
195 |
* @param __arg6 The sixth argument. |
|
196 |
* @param __arg7 The seventh argument. |
|
197 |
* @param __arg8 The eighth argument. |
|
198 |
* @param __arg9 The ninth argument. |
|
199 |
*/ |
|
200 |
#define GUL_INVOKE_ORIGINAL_IMP9(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \ |
|
201 |
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, __arg8, \ |
|
202 |
__arg9) \ |
|
203 |
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \ |
|
204 |
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6), \ |
|
205 |
__typeof__(__arg7), __typeof__(__arg8), __typeof__(__arg9)))__originalIMP)( \ |
|
206 |
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, \ |
|
207 |
__arg8, __arg9) |