The main purpose of the sip module is to provide functionality common to all SIP generated bindings. It is loaded automatically and most of the time you will completely ignore it. However, it does expose some functionality that can be used by applications.
This does the Python equivalent of casting a C++ instance to one of its sub or super-class types.
Parameters: |
|
---|---|
Returns: | a new Python object is that wraps the same C++ instance as obj, but has the type type. |
For C++ instances this calls the C++ destructor. For C structures it returns the structure’s memory to the heap.
Parameter: | obj – the Python object. |
---|
This displays various bits of useful information about the internal state of the Python object that wraps a C++ instance or C structure.
Parameter: | obj – the Python object. |
---|
This checks if the C++ instance or C structure has been deleted and returned to the heap.
Parameter: | obj – the Python object. |
---|---|
Returns: | True if the C/C++ instance has been deleted. |
This marks the C++ instance or C structure as having been deleted and returned to the heap so that future references to it raise an exception rather than cause a program crash. Normally SIP handles such things automatically, but there may be circumstances where this isn’t possible.
Parameter: | obj – the Python object. |
---|
If the bindings have been created with SIP’s -r command line option then the generated code will include debugging statements that trace the execution of the code. (It is particularly useful when trying to understand the operation of a C++ library’s virtual function calls.)
Parameter: | mask – the mask that determines which debugging statements are enabled. |
---|
Debugging statements are generated at the following points:
By default the trace mask is zero and all debugging statements are disabled.
This returns the address, as an integer, of a wrapped C/C++ structure or class instance.
Parameter: | obj – the Python object. |
---|---|
Returns: | an integer that is the address of the C/C++ instance. |
This is the type object for the type SIP uses to represent a C/C++ void *. It may have a size associated with the address in which case the Python buffer protocol is supported. This means that the memory can be treated as a mutable array of bytes when wrapped with the buffer() builtin. The type has the following methods.
Parameters: |
|
---|
This returns the address as an integer.
Returns: | the integer address. |
---|
This returns the address as a hexadecimal string.
Returns: | the hexadecimal string address. |
---|
This returns the address as a Python CObject.
Returns: | the CObject address. |
---|
This returns a copy of the block of memory as a Python v2 string object or a Python v3 bytes object.
Parameter: | size – the number of bytes to copy. If it is negative then the size associated with the address is used. If there is no associated size then an exception is raised. |
---|---|
Returns: | the string or bytes object. |
This returns the size associated with the address.
Returns: | the associated size which will be negative if there is none. |
---|
This sets the size associated with the address.
Parameter: | size – the size to associate. If it is negative then no size is associated. |
---|
This returns the writeable state of the memory.
Returns: | True if the memory is writeable. |
---|
This sets the writeable state of the memory.
Parameter: | writeable – the writeable state to set. |
---|
This wraps a C structure or C++ class instance in a Python object. If the instance has already been wrapped then a new reference to the existing object is returned.
Parameters: |
|
---|---|
Returns: | the Python object that wraps the instance. |