OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
23 */ | |
24 | |
25 #ifndef WTF_ObjcRuntimeExtras_h | |
26 #define WTF_ObjcRuntimeExtras_h | |
27 | |
28 #include <objc/message.h> | |
29 | |
30 template<typename RetType> | |
31 RetType wtfObjcMsgSend(id target, SEL selector) | |
32 { | |
33 return reinterpret_cast<RetType (*)(id, SEL)>(objc_msgSend)(target, selector
); | |
34 } | |
35 | |
36 template<typename RetType, typename Arg1Type> | |
37 RetType wtfObjcMsgSend(id target, SEL selector, Arg1Type arg1) | |
38 { | |
39 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type)>(objc_msgSend)(target
, selector, arg1); | |
40 } | |
41 | |
42 template<typename RetType, typename Arg1Type, typename Arg2Type> | |
43 RetType wtfObjcMsgSend(id target, SEL selector, Arg1Type arg1, Arg2Type arg2) | |
44 { | |
45 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type)>(objc_msgSe
nd)(target, selector, arg1, arg2); | |
46 } | |
47 | |
48 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe> | |
49 RetType wtfObjcMsgSend(id target, SEL selector, Arg1Type arg1, Arg2Type arg2, Ar
g3Type arg3) | |
50 { | |
51 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type)>(
objc_msgSend)(target, selector, arg1, arg2, arg3); | |
52 } | |
53 | |
54 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe, typename Arg4Type> | |
55 RetType wtfObjcMsgSend(id target, SEL selector, Arg1Type arg1, Arg2Type arg2, Ar
g3Type arg3, Arg4Type arg4) | |
56 { | |
57 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type, A
rg4Type)>(objc_msgSend)(target, selector, arg1, arg2, arg3, arg4); | |
58 } | |
59 | |
60 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe, typename Arg4Type, typename Arg5Type> | |
61 RetType wtfObjcMsgSend(id target, SEL selector, Arg1Type arg1, Arg2Type arg2, Ar
g3Type arg3, Arg4Type arg4, Arg5Type arg5) | |
62 { | |
63 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type, A
rg4Type, Arg5Type)>(objc_msgSend)(target, selector, arg1, arg2, arg3, arg4, arg5
); | |
64 } | |
65 | |
66 template<typename RetType> | |
67 RetType wtfCallIMP(IMP implementation, id target, SEL selector) | |
68 { | |
69 return reinterpret_cast<RetType (*)(id, SEL)>(implementation)(target, select
or); | |
70 } | |
71 | |
72 template<typename RetType, typename Arg1Type> | |
73 RetType wtfCallIMP(IMP implementation, id target, SEL selector, Arg1Type arg1) | |
74 { | |
75 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type)>(implementation)(targ
et, selector, arg1); | |
76 } | |
77 | |
78 template<typename RetType, typename Arg1Type, typename Arg2Type> | |
79 RetType wtfCallIMP(IMP implementation, id target, SEL selector, Arg1Type arg1, A
rg2Type arg2) | |
80 { | |
81 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type)>(implementa
tion)(target, selector, arg1, arg2); | |
82 } | |
83 | |
84 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe> | |
85 RetType wtfCallIMP(IMP implementation, id target, SEL selector, Arg1Type arg1, A
rg2Type arg2, Arg3Type arg3) | |
86 { | |
87 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type)>(
implementation)(target, selector, arg1, arg2, arg3); | |
88 } | |
89 | |
90 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe, typename Arg4Type> | |
91 RetType wtfCallIMP(IMP implementation, id target, SEL selector, Arg1Type arg1, A
rg2Type arg2, Arg3Type arg3, Arg4Type arg4) | |
92 { | |
93 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type, A
rg4Type)>(implementation)(target, selector, arg1, arg2, arg3, arg4); | |
94 } | |
95 | |
96 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe, typename Arg4Type, typename Arg5Type> | |
97 RetType wtfCallIMP(IMP implementation, id target, SEL selector, Arg1Type arg1, A
rg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5) | |
98 { | |
99 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type, A
rg4Type, Arg5Type)>(implementation)(target, selector, arg1, arg2, arg3, arg4, ar
g5); | |
100 } | |
101 | |
102 template<typename RetType, typename Arg1Type, typename Arg2Type, typename Arg3Ty
pe, typename Arg4Type, typename Arg5Type, typename Arg6Type> | |
103 RetType wtfCallIMP(IMP implementation, id target, SEL selector, Arg1Type arg1, A
rg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5, Arg6Type arg6) | |
104 { | |
105 return reinterpret_cast<RetType (*)(id, SEL, Arg1Type, Arg2Type, Arg3Type, A
rg4Type, Arg5Type, Arg6Type)>(implementation)(target, selector, arg1, arg2, arg3
, arg4, arg5, arg6); | |
106 } | |
107 | |
108 #endif | |
OLD | NEW |