Shiboken module#

Functions#

  • def isValid (obj)

  • def wrapInstance (address, type)

  • def getCppPointer (obj)

  • def delete (obj)

  • def isOwnedByPython (obj)

  • def wasCreatedByPython (obj)

  • def dump (obj)

  • def disassembleFrame (marker)

Detailed description#

This Python module can be used to access internal information related to our binding technology. Access to this internal information is required to e.g.: integrate PySide with Qt based programs that offer Python scripting like Maya™ or just for debug purposes.

Some function description refer to “Shiboken based objects”, wich means Python objects instances of any Python Type created using Shiboken.

To import the module:

from shiboken6 import Shiboken
Shiboken.isValid(obj)#

Given a Python object, returns True if the object methods can be called without an exception being thrown. A Python wrapper becomes invalid when the underlying C++ object is destroyed or unreachable.

Shiboken.wrapInstance(address, type)#

Creates a Python wrapper for a C++ object instantiated at a given memory address - the returned object type will be the same given by the user.

The type must be a Shiboken type, the C++ object will not be destroyed when the returned Python object reach zero references.

If the address is invalid or doesn’t point to a C++ object of given type the behavior is undefined.

Shiboken.getCppPointer(obj)#

Returns a tuple of longs that contain the memory addresses of the C++ instances wrapped by the given object.

Shiboken.delete(obj)#

Deletes the C++ object wrapped by the given Python object.

Shiboken.isOwnedByPython(obj)#

Given a Python object, returns True if Python is responsible for deleting the underlying C++ object, False otherwise.

If the object was not a Shiboken based object, a TypeError is thrown.

Shiboken.wasCreatedByPython(obj)#

Returns true if the given Python object was created by Python.

Shiboken.dump(obj)#

Returns a string with implementation-defined information about the object. This method should be used only for debug purposes by developers creating their own bindings as no guarantee is provided that the string format will be the same across different versions.

If the object is not a Shiboken based object, a message is printed.

Shiboken.disassembleFrame(label)#

Prints the current executing Python frame to stdout and flushes. The disassembly is decorated by some label. Example:

lambda: 42

is shown from inside C++ as

<label> BEGIN
  1           0 LOAD_CONST               1 (42)
              2 RETURN_VALUE
<label> END

When you want to set a breakpoint at the disassembleFrame function and you use it from C++, you use the pure function name.

When you want to use it from Python, you can insert it into your Python code and then maybe instead set a breakpoint at SbkShibokenModule_disassembleFrame which is the generated wrapper.

label is a simple string in C++. In Python, you can use any object; internally the str function is called with it.

This method should be used only for debug purposes by developers.

class Shiboken.VoidPtr(address, size=-1, writeable=0)#
Parameters:
  • address – (PyBuffer, SbkObject, int, VoidPtr)

  • size – int

  • writeable – int

Represents a chunk of memory by address and size and implements the buffer protocol. It can be constructed from a buffer, a Shiboken based object, a memory address or another VoidPtr instance.

toBytes()#
Return type:

bytes

Returns the contents as bytes.