1#ifndef PyObjC_SUPER_CALL_H
2#define PyObjC_SUPER_CALL_H
3/*!
4 * @header super-call.h
5 * @abstract Finding the right functions to call Objective-C methods
6 * @discussion
7 *     This module deals with finding the correct function to call a method,
8 *     both from Python to Objective-C and from Objective-C to python.
9 *
10 *     The default Python to Objective-C calls for 'normal' calls is good enough
11 *     for most methods, but for some methods we need specialized functions.
12 */
13
14/*!
15 * @constant PyObjC_MappingCount
16 * @abstract The number of registered special mappings
17 * @discussion
18 *     This is NOT a constant, but there seems to be no way to mark up
19 *     variables.
20 *
21 *     This value is used by the objc-class module to detect if the methods in
22 *     a class should be regenerated.
23 */
24extern Py_ssize_t PyObjC_MappingCount;
25
26extern BOOL PyObjC_UpdatingMetaData;
27
28
29/*!
30 * @function PyObjC_RegisterMethodMapping
31 * @abstract Register a mapping for a specific method
32 * @param aClass         Class for which this mapping is valid (+subclasses)
33 * @param sel            The selector with a custom mapping
34 * @param call_to_objc   Function for calling into Objective-C (from Python),
35 * 	                 the default is 'PyObjCFFI_Caller'.
36 * @param call_to_python Function for calling into Python (from Objective-C)
37 * @result Returns 0 on success, -1 on error.
38 */
39extern int PyObjC_RegisterMethodMapping(
40	Class aClass,
41	SEL sel,
42	PyObjC_CallFunc call_to_objc,
43	PyObjCFFI_ClosureFunc call_to_python
44	);
45
46/*!
47 * @function PyObjC_RegisterSignatureMapping
48 * @abstract Register a mapping for methods with a specific signature
49 * @param signature      An Objective-C method signature string
50 * @param call_to_objc   Function for calling into Objective-C (from Python)
51 * @param call_to_python Function for calling into Python (from Objective-C)
52 * @result Returns 0 on success, -1 on failure
53 */
54extern int PyObjC_RegisterSignatureMapping(
55	char* signature,
56	PyObjC_CallFunc call_to_super,
57	PyObjCFFI_ClosureFunc call_to_python);
58
59/*!
60 * @function PyObjC_FindCallFunc
61 * @abstract Find the function to call into Objective-C
62 * @param aClass     An Objective-C class
63 * @param sel        A selector
64 * @result Returns a function or NULL
65 * @discussion
66 * 	This finds the function that can be used to call the Objective-C
67 * 	implementation of the specified method.
68 */
69extern PyObjC_CallFunc PyObjC_FindCallFunc(Class aClass, SEL sel);
70
71/*!
72 * @function PyObjC_MakeIMP
73 * @abstract Create an IMP for calling the specified method from Objective-C
74 * @param aClass  An Objective-C class
75 * @param aSuperClass  An Objective-C super class
76 * @param sel     A selector object
77 * @param imp     The Python implementation for sel
78 * @result  A method stub or NULL
79 * @discussion
80 *      Objective-C classes have method dispatch tables. This function creates
81 *      and returns functions that can be used in these tables. The returned
82 *      function will convert it's arguments to Python objects and call 'imp'.
83 *      The result of 'imp' will be converted back to Objective-C.
84 */
85extern IMP PyObjC_MakeIMP(Class aClass, Class aSuperClass, PyObject* sel, PyObject* imp);
86
87/*!
88 * @constant PyObjCUnsupportedMethod_IMP
89 * @discussion
90 * 	Use this as the 'call_to_python' argument to
91 * 	PyObjC_RegisterMethodMapping and PyObjC_RegisterSignatureMapping if
92 * 	the method cannot be implemented in Python.
93 */
94extern void PyObjCUnsupportedMethod_IMP(ffi_cif*, void*, void**, void*);
95
96/*!
97 * @constant PyOBjCUnsupportedMethod_Caller
98 * @discussion
99 * 	Use this as the 'call_to_objc' argument to
100 * 	PyObjC_RegisterMethodMapping and PyObjC_RegisterSignatureMapping if
101 * 	the method cannot be called from Python.
102 */
103extern PyObject* PyObjCUnsupportedMethod_Caller(PyObject*, PyObject*, PyObject*);
104
105#endif /* PyObjC_SUPER_CALL_H */
106