In this section we describe the API that can be used by handwritten code in specification files.
This is a C preprocessor symbol that defines the major number of the SIP API. Its value is a number. There is no direct relationship between this and the SIP version number.
This is a C preprocessor symbol that defines the minor number of the SIP API. Its value is a number. There is no direct relationship between this and the SIP version number.
This is a C preprocessor macro that will make sure the Python Global Interpreter Lock (GIL) is acquired. Python API calls must only be made when the GIL has been acquired. There must be a corresponding SIP_UNBLOCK_THREADS at the same lexical scope.
New in version 4.15.2.
This is a flag used by various array constructors that species that the array owns the memory that holds the array’s contents.
This is a flag used by various type convertors that suppresses the use of a type’s %ConvertToTypeCode.
This is a flag used by various type convertors that causes the conversion to fail if the Python object being converted is Py_None.
New in version 4.10.
This is a C preprocessor symbol that is defined automatically by the build system to specify that the generated code is being compiled with protected redefined as public. This allows handwritten code to determine if the generated helper functions for accessing protected C++ functions are available (see %MethodCode).
New in version 4.15.2.
This is a flag used by various array constructors that species that the array is read-only.
New in version 4.14.4.
This is called from the handwritten code specified with the VirtualErrorHandler in order to release the Python Global Interpreter Lock (GIL) prior to changing the execution path (e.g. by throwing a C++ exception). It should not be called under any other circumstances.
Parameters: |
|
---|
This is a C preprocessor macro that is defined as Py_ssize_t for Python v2.5 and later, and as int for earlier versions of Python. It makes it easier to write PEP 353 compliant handwritten code.
New in version 4.15.4.
This is a C preprocessor macro that is defined as %zd for Python v2.5 and later, and as %d for earlier versions of Python. It makes it easier to write PEP 353 compliant handwritten code.
This is a C preprocessor macro that will restore the Python Global Interpreter Lock (GIL) to the state it was prior to the corresponding SIP_BLOCK_THREADS.
New in version 4.11.
This is a C preprocessor symbol that is defined when PyCapsule objects are being used rather than the (now deprecated) PyCObject objects.
This is a C preprocessor symbol that defines the SIP version number represented as a 3 part hexadecimal number (e.g. v4.0.0 is represented as 0x040000).
This is a C preprocessor symbol that defines the SIP version number represented as a string. For development snapshots it will start with snapshot-.
New in version 4.10.
This is called from %MethodCode to raise a Python exception when an argument to a function, a C++ constructor or method is found to have an unexpected type. This should be used when the %MethodCode does additional type checking of the supplied arguments.
Parameters: |
|
---|---|
Returns: | the value that should be assigned to sipError. |
This raises a Python exception when the result of a Python reimplementation of a C++ method doesn’t have the expected type. It is normally called by handwritten code specified with the %VirtualCatcherCode directive.
Parameters: |
|
---|
This raises a Python exception when the length of a slice object is inappropriate for a sequence-like object. It is normally called by handwritten code specified for __setitem__() methods.
Parameters: |
|
---|
This creates a Python object based on a format string and associated values in a similar way to the Python Py_BuildValue() function.
Parameters: |
|
---|---|
Returns: | If there was an error then NULL is returned and a Python exception is raised. |
If the format string begins and ends with parentheses then a tuple of objects is created. If it contains more than one format character then parentheses must be specified.
In the following description the first letter is the format character, the entry in parentheses is the Python object type that the format character will create, and the entry in brackets are the types of the C/C++ values to be passed.
Deprecated since version 4.8: Use N instead.
Convert a new C structure or a new C++ class instance to a Python class instance object. Ownership of the structure or instance is determined by the PyObject * argument. If it is NULL and the instance has already been wrapped then the ownership is unchanged. If it is NULL or Py_None then ownership will be with Python. Otherwise ownership will be with C/C++ and the instance associated with the PyObject * argument. The Python class is influenced by any applicable %ConvertToSubClassCode code.
Deprecated since version 4.8: Use D instead.
Convert a C structure or a C++ class instance to a Python class instance object. If the structure or class instance has already been wrapped then the result is a new reference to the existing class instance object. Ownership of the structure or instance is determined by the PyObject * argument. If it is NULL and the instance has already been wrapped then the ownership is unchanged. If it is NULL and the instance is newly wrapped then ownership will be with C/C++. If it is Py_None then ownership is transferred to Python via a call to sipTransferBack(). Otherwise ownership is transferred to C/C++ and the instance associated with the PyObject * argument via a call to sipTransferTo(). The Python class is influenced by any applicable %ConvertToSubClassCode code.
Deprecated since version 4.8: Use F instead.
Convert a named C/C++ enum to an instance of the corresponding Python named enum type.
New in version 4.12.
Convert a C/C++ char to a Python integer.
New in version 4.12.
Convert a C/C++ unsigned char to a Python long.
New in version 4.14.1.
Convert a C/C++ void * to a Python named capsule object.
This calls a Python method passing a tuple of arguments based on a format string and associated values in a similar way to the Python PyObject_CallObject() function.
Parameters: |
|
---|---|
Returns: | If there was an error then NULL is returned and a Python exception is raised. |
It is normally called by handwritten code specified with the %VirtualCatcherCode directive with method being the supplied sipMethod.
This checks if a Python object can be converted to a named enum.
Parameters: |
|
---|---|
Returns: | a non-zero value if the object can be converted. |
Deprecated since version 4.8: Use sipCanConvertToType() instead.
This checks if a Python object can be converted to an instance of a C structure or C++ class.
Parameters: |
|
---|---|
Returns: | a non-zero value if the object can be converted. |
Deprecated since version 4.8: Use sipCanConvertToType() instead.
This checks if a Python object can be converted to an instance of a C structure or C++ class which has been implemented as a mapped type.
Parameters: |
|
---|---|
Returns: | a non-zero value if the object can be converted. |
This checks if a Python object can be converted to an instance of a C structure, C++ class or mapped type.
Parameters: |
|
---|---|
Returns: | a non-zero value if the object can be converted. |
Deprecated since version 4.8: Use the following instead:
PyString_FromString(obj->ob_type->tp_name)
This gets the class name of a wrapped instance as a Python string. It comes with a reference.
Parameters: |
|
---|---|
Returns: | the name of the instance’s class. |
This creates a sip.voidptr object for a memory address. The object will not be writeable and has no associated size.
Parameters: |
|
---|---|
Returns: | the sip.voidptr object. |
This creates a sip.voidptr object for a memory address. The object will not be writeable and can be used as an immutable buffer object.
Parameters: |
|
---|---|
Returns: | the sip.voidptr object. |
This converts a named C/C++ enum to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
Deprecated since version 4.8: Use sipConvertFromType() instead.
This converts a C structure or a C++ class instance to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
If the C/C++ instance has already been wrapped then the result is a new reference to the existing class instance object.
If transferObj is NULL and the instance has already been wrapped then the ownership is unchanged.
If transferObj is NULL and the instance is newly wrapped then ownership will be with C/C++.
If transferObj is Py_None then ownership is transferred to Python via a call to sipTransferBack().
Otherwise ownership is transferred to C/C++ and the instance associated with transferObj via a call to sipTransferTo().
The Python type is influenced by any applicable %ConvertToSubClassCode code.
Deprecated since version 4.8: Use sipConvertFromType() instead.
This converts a C structure or a C++ class instance wrapped as a mapped type to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
If transferObj is NULL then the ownership is unchanged.
If transferObj is Py_None then ownership is transferred to Python via a call to sipTransferBack().
Otherwise ownership is transferred to C/C++ and the instance associated with transferObj argument via a call to sipTransferTo().
Deprecated since version 4.8: Use sipConvertFromEnum() instead.
This converts a named C/C++ enum to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
Deprecated since version 4.8: Use sipConvertFromNewType() instead.
This converts a new C structure or a C++ class instance to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
If transferObj is NULL or Py_None then ownership will be with Python.
Otherwise ownership will be with C/C++ and the instance associated with transferObj.
The Python type is influenced by any applicable %ConvertToSubClassCode code.
New in version 4.15.
This converts a new C structure or a C++ class instance to an instance of a corresponding Python type (as opposed to the corresponding generated Python type). This is useful when the C/C++ library provides some sort of mechanism whereby handwritten code has some control over the exact type of structure or class being created. Typically it would be used to create an instance of the generated derived class which would then allow Python re-implementations of C++ virtual methods to function properly.
Parameters: |
|
---|---|
Returns: | the Python object. If there was an error then NULL is returned and a Python exception is raised. |
This converts a new C structure or a C++ class instance to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
If transferObj is NULL or Py_None then ownership will be with Python.
Otherwise ownership will be with C/C++ and the instance associated with transferObj.
The Python type is influenced by any applicable %ConvertToSubClassCode code.
This converts a Python sequence index (i.e. where a negative value refers to the offset from the end of the sequence) to a C/C++ array index. If the index was out of range then a negative value is returned and a Python exception raised.
Parameters: |
|
---|---|
Returns: | the unsigned array index. |
This is a thin wrapper around the Python PySlice_GetIndicesEx() function provided to make it easier to write handwritten code that is compatible with SIP v3.x and versions of Python earlier that v2.3.
This converts a C structure or a C++ class instance to an instance of the corresponding generated Python type.
Parameters: |
|
---|---|
Returns: | the Python object. |
If the C/C++ instance has already been wrapped then the result is a new reference to the existing object.
If transferObj is NULL and the instance has already been wrapped then the ownership is unchanged.
If transferObj is NULL and the instance is newly wrapped then ownership will be with C/C++.
If transferObj is Py_None then ownership is transferred to Python via a call to sipTransferBack().
Otherwise ownership is transferred to C/C++ and the instance associated with transferObj via a call to sipTransferTo().
The Python class is influenced by any applicable %ConvertToSubClassCode code.
This creates a sip.voidptr object for a memory address. The object will be writeable but has no associated size.
Parameters: |
|
---|---|
Returns: | the sip.voidptr object. |
This creates a sip.voidptr object for a memory address. The object will be writeable and can be used as a mutable buffer object.
Parameters: |
|
---|---|
Returns: | the sip.voidptr object. |
New in version 4.15.
This converts a one dimensional array of fundamental types to a sip.array object.
An array is very like a Python memoryview object. The underlying memory is not copied and may be modified in situ. Arrays support the buffer protocol and so can be passed to other modules, again without the underlying memory being copied.
sip.array objects are not supported by the sip code generator. They can only be created by handwritten code.
Parameters: |
|
---|---|
Returns: | the sip.array object. |
Deprecated since version 4.8: Use sipConvertToType() instead.
This converts a Python object to an instance of a C structure or C++ class assuming that a previous call to sipCanConvertToInstance() has been successful.
Parameters: |
|
---|---|
Returns: | the C/C++ instance. |
If transferObj is NULL then the ownership is unchanged.
If transferObj is Py_None then ownership is transferred to Python via a call to sipTransferBack().
Otherwise ownership is transferred to C/C++ and obj associated with transferObj via a call to sipTransferTo().
If state is not NULL then the location it points to is set to describe the state of the returned C/C++ instance and is the value returned by any %ConvertToTypeCode. The calling code must then release the value at some point to prevent a memory leak by calling sipReleaseInstance().
If there is an error then the location iserr points to is set to a non-zero value. If it was initially a non-zero value then the conversion isn’t attempted in the first place. (This allows several calls to be made that share the same error flag so that it only needs to be tested once rather than after each call.)
Deprecated since version 4.8: Use sipConvertToType() instead.
This converts a Python object to an instance of a C structure or C++ class that is implemented as a mapped type assuming that a previous call to sipCanConvertToMappedType() has been successful.
Parameters: |
|
---|---|
Returns: | the C/C++ instance. |
If transferObj is NULL then the ownership is unchanged.
If transferObj is Py_None then ownership is transferred to Python via a call to sipTransferBack().
Otherwise ownership is transferred to C/C++ and obj associated with transferObj via a call to sipTransferTo().
If state is not NULL then the location it points to is set to describe the state of the returned C/C++ instance and is the value returned by any %ConvertToTypeCode. The calling code must then release the value at some point to prevent a memory leak by calling sipReleaseMappedType().
If there is an error then the location iserr points to is set to a non-zero value. If it was initially a non-zero value then the conversion isn’t attempted in the first place. (This allows several calls to be made that share the same error flag so that it only needs to be tested once rather than after each call.)
This converts a Python object to an instance of a C structure, C++ class or mapped type assuming that a previous call to sipCanConvertToType() has been successful.
Parameters: |
|
---|---|
Returns: | the C/C++ instance. |
If transferObj is NULL then the ownership is unchanged. If it is Py_None then ownership is transferred to Python via a call to sipTransferBack().
Otherwise ownership is transferred to C/C++ and obj associated with transferObj via a call to sipTransferTo().
Note that obj can also be managed by the C/C++ instance itself, but this can only be achieved by using sipTransferTo().
If state is not NULL then the location it points to is set to describe the state of the returned C/C++ instance and is the value returned by any %ConvertToTypeCode. The calling code must then release the value at some point to prevent a memory leak by calling sipReleaseType().
If there is an error then the location iserr points to is set to a non-zero value. If it was initially a non-zero value then the conversion isn’t attempted in the first place. (This allows several calls to be made that share the same error flag so that it only needs to be tested once rather than after each call.)
New in version 4.15.
This converts a one dimensional array of instances of a C structure, C++ class or mapped type to a sip.array object.
An array is very like a Python memoryview object but it’s elements correspond to C structures or C++ classes. The underlying memory is not copied and may be modified in situ. Arrays support the buffer protocol and so can be passed to other modules, again without the underlying memory being copied.
sip.array objects are not supported by the sip code generator. They can only be created by handwritten code.
Parameters: |
|
---|---|
Returns: | the sip.array object. |
This converts a Python object to a memory address. PyErr_Occurred() must be used to determine if the conversion was successful.
Parameters: |
|
---|---|
Returns: | the memory address. |
New in version 4.14.7.
Instances of some classes may be automatically converted to other Python objects even though the class has been wrapped. This allows that behaviour to be suppressed so that an instances of the wrapped class is returned instead.
Parameters: |
|
---|---|
Returns: | 1 or 0 depending on whether or not auto-conversion was previously enabled for the type. This allows the previous state to be restored later on. -1 is returned, and a Python exception raised, if there was an error. |
Python does not allow extension modules to directly access symbols in another extension module. This exports a symbol, referenced by a name, that can subsequently be imported, using sipImportSymbol(), by another module.
Parameters: |
|
---|---|
Returns: | 0 if there was no error. A negative value is returned if name is already associated with a symbol or there was some other error. |
Deprecated since version 4.8: Use sipFindType() instead.
This returns a pointer to the generated type object corresponding to a C/C++ type.
Parameters: |
|
---|---|
Returns: | the generated type object. This will not change and may be saved in a static cache. NULL is returned if the C/C++ type doesn’t exist. |
Deprecated since version 4.8: Use sipFindType() instead.
This returns a pointer to an opaque structure describing a mapped type.
Parameters: |
|
---|---|
Returns: | the opaque structure. This will not change and may be saved in a static cache. NULL is returned if the C/C++ type doesn’t exist. |
Deprecated since version 4.8: Use sipFindType() instead.
This returns a pointer to the generated Python type object corresponding to a named C/C++ enum.
Parameters: |
|
---|---|
Returns: | the generated Python type object. This will not change and may be saved in a static cache. NULL is returned if the C/C++ enum doesn’t exist. |
This returns a pointer to the generated type structure corresponding to a C/C++ type.
Parameters: |
|
---|---|
Returns: | the generated type structure. This will not change and may be saved in a static cache. NULL is returned if the C/C++ type doesn’t exist. |
Deprecated since version 4.8: Use sipForceConvertToType() instead.
This converts a Python object to an instance of a C structure or C++ class by calling sipCanConvertToInstance() and, if it is successfull, calling sipConvertToInstance().
See sipConvertToInstance() for a full description of the arguments.
Deprecated since version 4.8: Use sipForceConvertToType() instead.
This converts a Python object to an instance of a C structure or C++ class which has been implemented as a mapped type by calling sipCanConvertToMappedType() and, if it is successfull, calling sipConvertToMappedType().
See sipConvertToMappedType() for a full description of the arguments.
This converts a Python object to an instance of a C structure, C++ class or mapped type by calling sipCanConvertToType() and, if it is successfull, calling sipConvertToType().
See sipConvertToType() for a full description of the arguments.
This returns an area of memory allocated by sipMalloc() to the heap.
Parameters: |
|
---|
New in version 4.12.
This returns the address of the C structure or C++ class instance wrapped by a Python object.
Parameters: |
|
---|---|
Returns: | the address of the C/C++ instance |
New in version 4.15.
This returns the address of the C++ class instance that implements the mixin of a wrapped Python object.
Parameters: |
|
---|---|
Returns: | the address of the C++ instance |
This returns a borrowed reference to the Python object for a C structure or C++ class instance.
Parameters: |
|
---|---|
Returns: | the Python object or NULL (and no exception is raised) if the C/C++ instance hasn’t been wrapped. |
The %ConvertToTypeCode directive requires that the provided code returns an int describing the state of the converted value. The state usually depends on any transfers of ownership that have been requested. This is a convenience function that returns the correct state when the converted value is a temporary.
Parameters: |
|
---|---|
Returns: | the state of the converted value. |
Deprecated since version 4.8: Use sipGetPyObject() instead.
This returns a borrowed reference to the wrapped instance object for a C structure or C++ class instance.
Parameters: |
|
---|---|
Returns: | the Python object or NULL (and no exception is raised) if the C/C++ instance hasn’t been wrapped. |
Python does not allow extension modules to directly access symbols in another extension module. This imports a symbol, referenced by a name, that has previously been exported, using sipExportSymbol(), by another module.
Parameters: |
|
---|---|
Returns: | the value of the symbol. NULL is returned if there is no such symbol. |
Deprecated since version 4.8.
This C structure is used with sipMapIntToClass() to define a mapping between integer based RTTI and generated type objects. The structure elements are as follows.
The integer RTTI.
A pointer to the corresponding generated type object.
New in version 4.9.
This checks to see if the current version number of an API falls within a given range. See Managing Incompatible APIs for more detail.
Parameters: |
|
---|---|
Returns: | a non-zero value if the API is enabled. |
This function is a thin wrapper around PyLong_AsUnsignedLong() that works around a bug in Python v2.3.x and earlier when converting integer objects.
This allocates an area of memory on the heap using the Python PyMem_Malloc() function. The memory is freed by calling sipFree().
Parameters: |
|
---|---|
Returns: | the memory address. If there was an error then NULL is returned and a Python exception raised. |
Deprecated since version 4.8.
This can be used in %ConvertToSubClassCode code as a convenient way of converting integer based RTTI to the corresponding generated type object.
Parameters: |
|
---|---|
Returns: | the corresponding type object, or NULL if type wasn’t in map. |
Deprecated since version 4.8.
This can be used in %ConvertToSubClassCode code as a convenient way of converting '\0' terminated string based RTTI to the corresponding generated type object.
Parameters: |
|
---|---|
Returns: | the corresponding type object, or NULL if type wasn’t in map. |
This converts a Python object (usually returned by a method) to C/C++ based on a format string and associated values in a similar way to the Python PyArg_ParseTuple() function.
Parameters: |
|
---|---|
Returns: | 0 if there was no error. Otherwise a negative value is returned, and an exception raised. |
This is normally called by handwritten code specified with the %VirtualCatcherCode directive with method being the supplied sipMethod and result being the value returned by sipCallMethod().
If format begins and ends with parentheses then result must be a Python tuple and the rest of format is applied to the tuple contents.
In the following description the first letter is the format character, the entry in parentheses is the Python object type that the format character will convert, and the entry in brackets are the types of the C/C++ values to be passed.
Deprecated since version 4.8: Use B instead.
Convert a Python v2 string object or a Python v3 bytes object to a C/C++ '\0' terminated string. If the Python object is Py_None then the string is NULL.
Deprecated since version 4.8: Use Hf instead.
Convert a Python object to a C structure or a C++ class instance and return its state as described in sipConvertToInstance(). f is a combination of the following flags encoded as an ASCII character by adding 0 to the combined value:
0x01 disallows the conversion of Py_None to NULL
- 0x02 implements the Factory and TransferBack
- annotations
- 0x04 suppresses the return of the state of the returned C/C++
- instance. Note that the int * used to return the state is not passed if this flag is specified.
Deprecated since version 4.10.1: Use Hf instead.
Convert a Python object to a C structure, C++ class or mapped type instance and return its state as described in sipConvertToType(). f is a combination of the following flags encoded as an ASCII character by adding 0 to the combined value:
0x01 disallows the conversion of Py_None to NULL
- 0x02 implements the Factory and TransferBack
- annotations
- 0x04 suppresses the return of the state of the returned C/C++
- instance. Note that the int * used to return the state is not passed if this flag is specified.
Deprecated since version 4.8: Use F instead.
Convert a Python named enum type to the corresponding C/C++ enum.
Convert a Python object to a C structure, C++ class or mapped type instance as described in sipConvertToType(). f is a combination of the following flags encoded as an ASCII character by adding 0 to the combined value:
0x01 disallows the conversion of Py_None to NULL
- 0x02 implements the Factory and TransferBack
- annotations
0x04 returns a copy of the C/C++ instance.
New in version 4.12.
Convert a Python integer to a C/C++ signed char.
New in version 4.12.
Convert a Python long to a C/C++ unsigned char.
New in version 4.14.1.
Convert a Python named capsule object to a C/C++ void *.
New in version 4.14.1.
A Python object is checked to see if it implements the buffer protocol and then returned without any conversions. The reference count is incremented. The Python object may not be Py_None.
New in version 4.14.1.
A Python object is checked to see if it implements the buffer protocol and then returned without any conversions. The reference count is incremented. The Python object may be Py_None.
This registers a handler that will called just before SIP needs to get an attribute from a wrapped type’s dictionary for the first time. The handler must then populate the type’s dictionary with any lazy attributes.
Parameters: |
|
---|---|
Returns: | 0 if there was no error, otherwise -1 is returned. |
If td is not NULL then the handler will only be called for types with that type or that are sub-classed from it. Otherwise the handler will be called for all types.
A handler has the following signature.
int handler(const sipTypeDef *td, PyObject *dict)
td is the generated type definition of the type whose dictionary is to be populated.
dict is the dictionary to be populated.
0 is returned if there was no error, otherwise -1 is returned.
See the section Lazy Type Attributes for more details.
New in version 4.15.
This registers a resolver that will called just before SIP wraps a C/C++ pointer in a Python object. The resolver may choose to replace the C/C++ pointer with the address of another object. Typically this is used to replace a proxy by the object that is being proxied for.
Parameters: |
|
---|---|
Returns: | 0 if there was no error, otherwise -1 is returned. |
A resolver has the following signature.
void *resolver(void *proxy)
proxy is C/C++ pointer that is being wrapped.
The C/C++ pointer that will actually be wrapped is returned.
This registers a Python type object that can be used as the meta-type or super-type of a wrapped C++ type.
Parameters: |
|
---|---|
Returns: | 0 if there was no error, otherwise -1 is returned. |
See the section Types and Meta-types for more details.
Deprecated since version 4.8: Use sipReleaseType() instead.
This destroys a wrapped C/C++ instance if it was a temporary instance. It is called after a call to either sipConvertToInstance() or sipForceConvertToInstance().
Parameters: |
|
---|
Deprecated since version 4.8: Use sipReleaseType() instead.
This destroys a wrapped C/C++ mapped type if it was a temporary instance. It is called after a call to either sipConvertToMappedType() or sipForceConvertToMappedType().
Parameters: |
|
---|
This destroys a wrapped C/C++ or mapped type instance if it was a temporary instance. It is called after a call to either sipConvertToType() or sipForceConvertToType().
Parameters: |
|
---|
This returns the value of a C/C++ typedef.
Parameters: |
|
---|---|
Returns: | the value of the typedef or NULL if there was no such typedef. |
New in version 4.14.7.
When the Python interpreter exits it garbage collects those objects that it can. This means that any corresponding C++ instances and C structures owned by Python are destroyed. Unfortunately this happens in an unpredictable order and so can cause memory faults within the wrapped library. Calling this function with a value of zero disables the automatic destruction of C++ instances and C structures.
Parameters: |
|
---|
This is a C structure that represents a Python wrapped instance whose type is sip.simplewrapper. It is an extension of the PyObject structure and so may be safely cast to it.
This is initialised to the address of the C/C++ instance. If an access function is subsequently provided then it may be used for any purpose by the access function.
This is the address of an optional access function that is called, with a pointer to this structure as its first argument. If its second argument is UnguardedPointer then it returns the address of the C/C++ instance, even if it is known that its value is no longer valid. If the second argument is GuardedPointer then it returns the address of the C++ instance or 0 if it is known to be invalid. If the second argument is ReleaseGuard then the structure is being deallocated and any dynamic resources used by the access function should be released. If there is no access function then the sipSimpleWrapper.data is used as the address of the C/C++ instance. Typically a custom meta-type is used to set an access method after the Python object has been created.
This can be used for any purpose by handwritten code and will automatically be garbage collected at the appropriate time.
This is the type of a sipSimpleWrapper structure and is the C implementation of sip.simplewrapper. It may be safely cast to sipWrapperType.
Deprecated since version 4.8.
This C structure is used with sipMapStringToClass() to define a mapping between '\0' terminated string based RTTI and Generated Type Objects. The structure elements are as follows.
The '\0' terminated string RTTI.
A pointer to the corresponding generated type object.
This transfers ownership of a Python wrapped instance to Python (see Ownership of Objects).
Parameters: |
|
---|
In addition, any association of the instance with regard to the cyclic garbage collector with another instance is removed.
Any association of a Python wrapped instance with regard to the cyclic garbage collector with another instance is removed. Ownership of the instance should be with C++.
Parameters: |
|
---|
Deprecated since version 4.14: Use the following instead:
sipTransferTo(obj, NULL);
This transfers ownership of a Python wrapped instance to C++ (see Ownership of Objects).
Parameters: |
|
---|
This returns a pointer to the Python type object that SIP creates for a generated type structure.
Parameters: |
|
---|---|
Returns: | the Python type object. If the type structure refers to a mapped type then NULL will be returned. |
If the type structure refers to a C structure or C++ class then the Python type object may be safely cast to a sipWrapperType.
This returns the generated type structure for a Python type object.
Parameters: |
|
---|---|
Returns: | the type structure or NULL if the Python type object doesn’t correspond to a type structure. |
This checks if a generated type structure refers to a C structure or C++ class.
Parameters: |
|
---|---|
Returns: | a non-zero value if the type structure refers to a structure or class. |
This checks if a generated type structure refers to a named enum.
Parameters: |
|
---|---|
Returns: | a non-zero value if the type structure refers to an enum. |
This checks if a generated type structure refers to a mapped type.
Parameters: |
|
---|---|
Returns: | a non-zero value if the type structure refers to a mapped type. |
This checks if a generated type structure refers to a C++ namespace.
Parameters: |
|
---|---|
Returns: | a non-zero value if the type structure refers to a namespace. |
This returns the C/C++ name of a wrapped type.
Parameters: |
|
---|---|
Returns: | the name of the C/C++ type. |
This returns the generated type structure of the enclosing scope of another generated type structure.
Parameters: |
|
---|---|
Returns: | the type structure of the scope or NULL if the type has no scope. |
This is the type of a PyObject structure that is used to wrap a void *.
This is a C structure that represents a Python wrapped instance whose type is sip.wrapper. It is an extension of the sipSimpleWrapper and PyObject structures and so may be safely cast to both.
Deprecated since version 4.8: Use the following instead:
PyObject_TypeCheck(obj, sipWrapper_Type)
This checks if a Python object is a wrapped instance.
Parameters: |
|
---|---|
Returns: | a non-zero value if the Python object is a wrapped instance. |
This is the type of a sipWrapper structure and is the C implementation of sip.wrapper. It may be safely cast to sipWrapperType.
This is a C structure that represents a SIP generated type object. It is an extension of the PyTypeObject structure (which is itself an extension of the PyObject structure) and so may be safely cast to PyTypeObject (and PyObject).
This is the type of a sipWrapperType structure and is the C implementation of sip.wrappertype.
SIP generates an opaque type structure for each C structure, C++ class, C++ namespace, named enum or mapped type being wrapped. These are sipTypeDef structures and are used extensively by the SIP API.
The names of these structure are prefixed by sipType_.
For those structures that correspond to C structures, C++ classes, C++ namespaces or named enums the remaining part of the name is the fully qualified name of the structure, class, namespace or enum name. Any :: scope separators are replaced by an underscore. For example, the type object for class Klass is sipType_Klass.
For those structure that correspond to mapped types the remaining part of the name is generated by SIP. The only way for handwritten code to obtain a pointer to a structure for a mapped type is to use sipFindType().
The type structures of all imported types are available to handwritten code.
Deprecated since version 4.8: Use the corresponding generated type structure (see Generated Type Structures) and sipTypeAsPyTypeObject() instead.
SIP generates a sipWrapperType type object for each C structure or C++ class being wrapped.
These objects are named with the structure or class name prefixed by sipClass_. For example, the type object for class Klass is sipClass_Klass.
Deprecated since version 4.8: Use the corresponding generated type structure (see Generated Type Structures) and sipTypeAsPyTypeObject() instead.
SIP generates a type object for each named enum being wrapped. These are PyTypeObject structures. (Anonymous enums are wrapped as Python integers.)
These objects are named with the fully qualified enum name (i.e. including any enclosing scope) prefixed by sipEnum_. For example, the type object for enum Enum defined in class Klass is sipEnum_Klass_Enum.
For most C++ classes being wrapped SIP generates a derived class with the same name prefixed by sip. For example, the derived class for class Klass is sipKlass.
If a C++ class doesn’t have any virtual or protected methods in it or any of it’s super-class hierarchy, or does not emit any Qt signals, then a derived class is not generated.
Most of the time handwritten code should ignore the derived classes. The only exception is that handwritten constructor code specified using the %MethodCode directive should call the derived class’s constructor (which has the same C++ signature) rather then the wrapped class’s constructor.
SIP generates a Python object for each exception defined with the %Exception directive.
These objects are named with the fully qualified exception name (i.e. including any enclosing scope) prefixed by sipException_. For example, the type object for enum Except defined in class Klass is sipException_Klass_Except.
The objects of all imported exceptions are available to handwritten code.