📄 sip.h
字号:
/* * The SIP module interface. * * Copyright (c) 2006 * Riverbank Computing Limited <info@riverbankcomputing.co.uk> * * This file is part of SIP. * * This copy of SIP is licensed for use under the terms of the SIP License * Agreement. See the file LICENSE for more details. * * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */#ifndef _SIP_H#define _SIP_H#include <Python.h>/* * There is a mis-feature somewhere with the Borland compiler. This works * around it. */#if defined(__BORLANDC__)#include <rpc.h>#endif#ifdef __cplusplusextern "C" {#endif/* Sanity check on the Python version. */#if PY_VERSION_HEX < 0x02030000#error "This version of SIP requires Python v2.3 or later"#endif/* * Define the SIP version number. */#define SIP_VERSION 0x040403#define SIP_VERSION_STR "4.4.3"/* * Define the current API version number. SIP must handle modules with the * same major number and with the same or earlier minor number. Whenever data * structure elements are added they must be appended and the minor number * incremented. Whenever data structure elements are removed or the order * changed then the major number must be incremented and the minor number set * to 0. * * History: * * 3.1 Added sip_api_add_mapped_type_instance(). * * 3.0 Moved the Qt support out of the sip module and into PyQt. This is * such a dramatic change that there is no point in attempting to maintain * backwards compatibility. * * 2.0 Added the td_flags field to the sipTypeDef structure. * Added the first_child, sibling_next, sibling_prev and parent fields to * the sipWrapper structure. * Added the td_traverse and td_clear fields to the sipTypeDef structure. * Added the em_api_minor field to the sipExportedModuleDef structure. * Added sip_api_bad_operator_arg(). * Added sip_api_wrapper_check(). * * 1.1 Added support for __pos__ and __abs__. * * 1.0 Removed all deprecated parts of the API. * Removed the td_proxy field from the sipTypeDef structure. * Removed the create proxy function from the 'q' and 'y' format * characters to sip_api_parse_args(). * Removed sip_api_emit_to_slot(). * Reworked the enum related structures. * * 0.2 Added the 'H' format character to sip_api_parse_args(). * * 0.1 Added sip_api_add_class_instance(). * Added the 't' format character to sip_api_parse_args(). * Deprecated the 'J' and 'K' format characters to sip_api_parse_result(). * * 0.0 Original version. */#define SIP_API_MAJOR_NR 3#define SIP_API_MINOR_NR 1/* Some compatibility stuff to help with handwritten code for SIP v3. */#if !defined(ANY)#define ANY void#endif/* * The mask that can be passed to sipTrace(). */#define SIP_TRACE_CATCHERS 0x0001#define SIP_TRACE_CTORS 0x0002#define SIP_TRACE_DTORS 0x0004#define SIP_TRACE_INITS 0x0008#define SIP_TRACE_DEALLOCS 0x0010#define SIP_TRACE_METHODS 0x0020/* * Hide some thread dependent stuff. */#ifdef WITH_THREADtypedef PyGILState_STATE sip_gilstate_t;#define SIP_RELEASE_GIL(gs) PyGILState_Release(gs);#define SIP_BLOCK_THREADS {PyGILState_STATE sipGIL = PyGILState_Ensure();#define SIP_UNBLOCK_THREADS PyGILState_Release(sipGIL);}#elsetypedef int sip_gilstate_t;#define SIP_RELEASE_GIL(gs)#define SIP_BLOCK_THREADS#define SIP_UNBLOCK_THREADS#endif/* * The metatype for a wrapper type. */typedef struct _sipWrapperType { PyHeapTypeObject super; /* The super-metatype. */ struct _sipTypeDef *type; /* The additional type information. */ struct _sipInitExtenderDef *iextend; /* The list of init extenders. */} sipWrapperType;/* * A C/C++ object wrapped as a Python object. */typedef struct _sipWrapper { PyObject_HEAD PyObject *user; /* For the user to use. */ union { void *cppPtr; /* C/C++ object pointer. */ void *(*afPtr)(); /* Access function. */ } u; int flags; /* Object flags. */ PyObject *dict; /* The instance dictionary. */ struct _sipPySig *pySigList; /* Python signal list (complex). */ struct _sipWrapper *next; /* Next object at this address. */ struct _sipWrapper *first_child; /* First child object. */ struct _sipWrapper *sibling_next; /* Next sibling. */ struct _sipWrapper *sibling_prev; /* Previous sibling. */ struct _sipWrapper *parent; /* Owning object. */} sipWrapper;/* * Some convenient function pointers. */typedef void *(*sipInitFunc)(sipWrapper *,PyObject *,sipWrapper **,int *);typedef int (*sipTraverseFunc)(void *, visitproc, void *);typedef int (*sipClearFunc)(void *);typedef int (*sipBufferFunc)(PyObject *,void *,int,void **);typedef int (*sipSegCountFunc)(PyObject *,void *,int *);typedef void (*sipDeallocFunc)(sipWrapper *);typedef void *(*sipCastFunc)(void *,sipWrapperType *);typedef sipWrapperType *(*sipSubClassConvertFunc)(void **);typedef void *(*sipForceConvertToFunc)(PyObject *,int *);typedef int (*sipConvertToFunc)(PyObject *,void **,int *,PyObject *);typedef PyObject *(*sipConvertFromFunc)(void *,PyObject *);typedef int (*sipVirtHandlerFunc)(void *,PyObject *,...);typedef int (*sipEmitFunc)(sipWrapper *,PyObject *);typedef void (*sipReleaseFunc)(void *, int);/* * The information describing an encoded class ID. */typedef struct _sipEncodedClassDef { unsigned sc_class:16; /* The class number. */ unsigned sc_module:8; /* The module number (255 for this one). */ unsigned sc_flag:1; /* A context specific flag. */} sipEncodedClassDef;/* * The information describing an enum member. */typedef struct _sipEnumMemberDef { const char *em_name; /* The member name. */ int em_val; /* The member value. */ int em_enum; /* The member enum, -ve if anonymous. */} sipEnumMemberDef;/* * The information describing a named enum. */typedef struct _sipEnumDef { const char *e_name; /* The Python name of the enum. */ const char *e_cname; /* The C/C++ name of the enum, NULL if the same as the Python name. */ int e_scope; /* The scoping type. */ struct _sipPySlotDef *e_pyslots; /* The Python slots. */} sipEnumDef;/* * The information describing static instances. */typedef struct _sipInstancesDef { struct _sipClassInstanceDef *id_class; /* The classes. */ struct _sipVoidPtrInstanceDef *id_voidp; /* The void *. */ struct _sipCharInstanceDef *id_char; /* The chars. */ struct _sipStringInstanceDef *id_string; /* The strings. */ struct _sipIntInstanceDef *id_int; /* The ints. */ struct _sipLongInstanceDef *id_long; /* The longs. */ struct _sipUnsignedLongInstanceDef *id_ulong; /* The unsigned longs. */ struct _sipLongLongInstanceDef *id_llong; /* The long longs. */ struct _sipUnsignedLongLongInstanceDef *id_ullong; /* The unsigned long longs. */ struct _sipDoubleInstanceDef *id_double; /* The doubles. */ struct _sipEnumInstanceDef *id_enum; /* The enums. */} sipInstancesDef;/* * The information describing a type initialiser extender. */typedef struct _sipInitExtenderDef { sipInitFunc ie_extender; /* The extender function. */ sipEncodedClassDef ie_class; /* The class being extended. */ struct _sipInitExtenderDef *ie_next; /* The next extender for this class. */} sipInitExtenderDef;/* * The information describing a sub-class convertor. */typedef struct _sipSubClassConvertorDef { sipSubClassConvertFunc scc_convertor; /* The convertor. */ sipEncodedClassDef scc_base; /* The encoded base type. */ sipWrapperType *scc_basetype; /* The base type. */} sipSubClassConvertorDef;/* * The different Python slot types. */typedef enum { str_slot, /* __str__ */ int_slot, /* __int__ */ long_slot, /* __long__ */ float_slot, /* __float__ */ len_slot, /* __len__ */ contains_slot, /* __contains__ */ add_slot, /* __add__ for number */ concat_slot, /* __add__ for sequence types */ sub_slot, /* __sub__ */ mul_slot, /* __mul__ for number types */ repeat_slot, /* __mul__ for sequence types */ div_slot, /* __div__ */ mod_slot, /* __mod__ */ and_slot, /* __and__ */ or_slot, /* __or__ */ xor_slot, /* __xor__ */ lshift_slot, /* __lshift__ */ rshift_slot, /* __rshift__ */ iadd_slot, /* __iadd__ for number types */ iconcat_slot, /* __iadd__ for sequence types */ isub_slot, /* __isub__ */ imul_slot, /* __imul__ for number types */ irepeat_slot, /* __imul__ for sequence types */ idiv_slot, /* __idiv__ */ imod_slot, /* __imod__ */ iand_slot, /* __iand__ */ ior_slot, /* __ior__ */ ixor_slot, /* __ixor__ */ ilshift_slot, /* __ilshift__ */ irshift_slot, /* __irshift__ */ invert_slot, /* __invert__ */ call_slot, /* __call__ */ getitem_slot, /* __getitem__ */ setitem_slot, /* __setitem__ */ delitem_slot, /* __delitem__ */ lt_slot, /* __lt__ */ le_slot, /* __le__ */ eq_slot, /* __eq__ */ ne_slot, /* __ne__ */ gt_slot, /* __gt__ */ ge_slot, /* __ge__ */ cmp_slot, /* __cmp__ */ nonzero_slot, /* __nonzero__ */ neg_slot, /* __neg__ */ repr_slot, /* __repr__ */ hash_slot, /* __hash__ */ pos_slot, /* __pos__ */ abs_slot /* __abs__ */} sipPySlotType;/* * The information describing a Python slot function. */typedef struct _sipPySlotDef { void *psd_func; /* The function. */ sipPySlotType psd_type; /* The type. */} sipPySlotDef;/* * The information describing a Python slot extender. */typedef struct _sipPySlotExtenderDef { void *pse_func; /* The function. */ sipPySlotType pse_type; /* The type. */ sipEncodedClassDef pse_class; /* The encoded class. */} sipPySlotExtenderDef;/* * This enumerates the different dynamic signal argument types. */typedef enum { unknown_sat, char_sat, uchar_sat, string_sat, ustring_sat, short_sat, ushort_sat, int_sat, uint_sat, long_sat, ulong_sat, longlong_sat, ulonglong_sat, float_sat, double_sat, enum_sat, bool_sat, void_sat, class_sat, classp_sat, mtype_sat, mtypep_sat, qvariant_sat, qvariantp_sat, pyobject_sat, schar_sat, sstring_sat} sipSigArgType;/* * The information describing a typedef. */typedef struct _sipTypedefDef { const char *tdd_name; /* The typedef name. */ sipSigArgType tdd_type; /* The typedef type. */ const char *tdd_type_name; /* The type name for enum_sat, class_sat and mtype_sat. */ const char *tdd_mod_name; /* The defining module, NULL if the current one. */} sipTypedefDef;/* * The information describing a type. */typedef struct _sipTypeDef { struct _sipExportedModuleDef *td_module; /* The module. */ int td_flags; /* Type flags, see the sipType*() macros. */ const char *td_name; /* The Python name of the type. */ const char *td_cname; /* The C/C++ name of the type, NULL if the same as the Python name. */ sipEncodedClassDef td_scope; /* The scoping type. */ sipEncodedClassDef *td_supers; /* The super-types. */ sipPySlotDef *td_pyslots; /* The table of Python slots. */ int td_nrmethods; /* The number of lazy methods. */ PyMethodDef *td_methods; /* The table of lazy methods. */ int td_nrenummembers; /* The number of lazy enum members. */ sipEnumMemberDef *td_enummembers; /* The table of lazy enum members. */ PyMethodDef *td_variables; /* The variable table. */ sipInitFunc td_init; /* The initialisation function. */ sipTraverseFunc td_traverse; /* The traverse function. */ sipClearFunc td_clear; /* The clear function. */ sipBufferFunc td_readbuffer; /* The read buffer function. */ sipBufferFunc td_writebuffer; /* The write buffer function. */ sipSegCountFunc td_segcount; /* The segment count function. */ sipBufferFunc td_charbuffer; /* The char buffer function. */ sipDeallocFunc td_dealloc; /* The deallocation function. */ sipCastFunc td_cast; /* The cast function, 0 if a C struct. */ sipReleaseFunc td_release; /* The release function. */ sipForceConvertToFunc td_fcto; /* The force convert to function, 0 if a C++ namespace. */ sipConvertToFunc td_cto; /* The convert to function. */ struct _sipQtSignal *td_emit; /* Emit table for Qt signals. */ sipInstancesDef td_instances; /* The static instances. */ struct _sipTypeDef *td_nsextender; /* The next namespace extender. */} sipTypeDef;/* * The information describing an external type. */typedef struct _sipExternalTypeDef { int et_nr; /* The index into the type table. */ const char *et_name; /* The name of the type. */} sipExternalTypeDef;/* * The information describing a mapped class. */typedef struct _sipMappedType { const char *mt_name; /* The corresponding C++ definition. */ sipReleaseFunc mt_release; /* The release function. */ sipForceConvertToFunc mt_fcto; /* The force convert to function. */ sipConvertToFunc mt_cto; /* The convert to function. */ sipConvertFromFunc mt_cfrom; /* The convert from function. */} sipMappedType;/* * Defines an entry in the module specific list of delayed dtor calls. */typedef struct _sipDelayedDtor { void *dd_ptr; /* The C/C++ instance. */ const char *dd_name; /* The class name. */ int dd_isderived; /* Non-zero if dd_ptr is a derived class instance. */ struct _sipDelayedDtor *dd_next; /* Next in the list. */} sipDelayedDtor;/* * The information describing an imported module. */typedef struct _sipImportedModuleDef { char *im_name; /* The module name. */ int im_version; /* The required version. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -