1#ifndef PyObjC_FFI_SUPPORT_H 2#define PyObjC_FFI_SUPPORT_H 3 4#include "ffi.h" 5 6#ifndef FFI_CLOSURES 7# error "Need FFI_CLOSURES!" 8#endif 9 10struct byref_attr { 11 int token; 12 PyObject* buffer; 13}; 14 15typedef void (*PyObjCFFI_ClosureFunc)(ffi_cif*, void*, void**, void*); 16 17void PyObjCFFI_FreeCIF(ffi_cif* cif); 18ffi_cif* PyObjCFFI_CIFForSignature(PyObjCMethodSignature* signature); 19IMP PyObjCFFI_MakeClosure(PyObjCMethodSignature* signature, 20 PyObjCFFI_ClosureFunc func, void* userdata); 21void* PyObjCFFI_FreeClosure(IMP closure); 22 23IMP PyObjCFFI_MakeIMPForSignature(PyObjCMethodSignature* methinfo, SEL sel, PyObject* callable); 24IMP PyObjCFFI_MakeIMPForPyObjCSelector(PyObjCSelector *aSelector); 25PyObject *PyObjCFFI_Caller(PyObject *aMeth, PyObject* self, PyObject *args); 26void PyObjCFFI_FreeIMP(IMP imp); 27 28typedef void (*PyObjCBlockFunction)(void*, ...); 29PyObjCBlockFunction PyObjCFFI_MakeBlockFunction(PyObjCMethodSignature* sig, PyObject* callable); 30void PyObjCFFI_FreeBlockFunction(PyObjCBlockFunction value); 31 32 33int PyObjCFFI_CountArguments( 34 PyObjCMethodSignature* methinfo, Py_ssize_t argOffset, 35 Py_ssize_t* byref_in_count, 36 Py_ssize_t* byref_out_count, 37 Py_ssize_t* plain_count, 38 Py_ssize_t* argbuf_len, 39 BOOL* havePrintf); 40 41int PyObjCFFI_ParseArguments( 42 PyObjCMethodSignature* methinfo, Py_ssize_t argOffset, 43 PyObject* args, Py_ssize_t argbuf_cur, unsigned char* argbuf, Py_ssize_t argbuf_len, 44 void** byref, struct byref_attr* byref_attr, 45 ffi_type** arglist, void** values); 46 47PyObject* PyObjCFFI_BuildResult( 48 PyObjCMethodSignature* methinfo, Py_ssize_t argOffset, 49 void* pRetval, void** byref, struct byref_attr* byref_attr, 50 Py_ssize_t byref_out_count, 51 PyObject* self, int flags, void** argvalues); 52 53int PyObjCFFI_AllocByRef(int argcount, void*** byref, struct byref_attr** byref_attr); 54int PyObjCFFI_FreeByRef(int argcount, void** byref, struct byref_attr* byref_attr); 55 56/* XXX: rename me */ 57ffi_type* signature_to_ffi_return_type(const char* argtype); 58 59 60typedef void (*PyObjC_callback_function)(void); 61PyObjC_callback_function PyObjCFFI_MakeFunctionClosure(PyObjCMethodSignature* methinfo, PyObject* callable); 62 63 64#endif /* PyObjC_FFI_SUPPORT_H */ 65