Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
PythonBindings Namespace Reference

Classes

class  Director
 
struct  PyHolder
 
class  PyObjectDecrementor
 
struct  PythonCompare
 
class  PythonToCppException
 
struct  TypeInfo
 

Functions

PyObjectPyInit_Module_xbmcdrm (void)
 
PyObjectPyInit_Module_xbmcgui (void)
 
PyObjectPyInit_Module_xbmc (void)
 
PyObjectPyInit_Module_xbmcplugin (void)
 
PyObjectPyInit_Module_xbmcaddon (void)
 
PyObjectPyInit_Module_xbmcvfs (void)
 
void PyXBMCGetUnicodeString (std::string &buf, PyObject *pObject, bool coerceToString, const char *argumentName, const char *methodname)
 
bool isParameterRightType (const char *passedType, const char *expectedType, const char *methodNamespacePrefix, bool tryReverse)
 
XBMCAddon::AddonClassdoretrieveApiInstance (const PyHolder *pythonObj, const TypeInfo *typeInfo, const char *expectedType, const char *methodNamespacePrefix, const char *methodNameForErrorString)
 
void prepareForReturn (XBMCAddon::AddonClass *c)
 
void cleanForDealloc (XBMCAddon::AddonClass *c)
 
void cleanForDealloc (XBMCAddon::xbmcgui::Window *c)
 
PyObjectmakePythonInstance (XBMCAddon::AddonClass *api, PyTypeObject *pytype, bool incrementRefCount)
 
void registerAddonClassTypeInformation (const TypeInfo *classInfo)
 
const TypeInfogetTypeInfoForInstance (XBMCAddon::AddonClass *obj)
 
int dummy_tp_init (PyObject *self, PyObject *args, PyObject *kwds)
 
XBMCAddon::AddonClassretrieveApiInstance (PyObject *pythonObj, const TypeInfo *typeToCheck, const char *methodNameForErrorString, const char *typenameForErrorString)
 
XBMCAddon::AddonClassretrieveApiInstance (const PyObject *pythonObj, const char *expectedType, const char *methodNamespacePrefix, const char *methodNameForErrorString)
 
PyObjectmakePythonInstance (XBMCAddon::AddonClass *api, bool incrementRefCount)
 
PyObjectPyInit_Module_xbmcwsgi (void)
 

Variables

std::map< std::type_index, const TypeInfo * > typeInfoLookup
 

Function Documentation

◆ cleanForDealloc() [1/2]

void PythonBindings::cleanForDealloc ( XBMCAddon::AddonClass * c)

This method is a helper for the generated API. It's called prior to any API class destructor being dealloc-ed from the generated code from Python

◆ cleanForDealloc() [2/2]

void PythonBindings::cleanForDealloc ( XBMCAddon::xbmcgui::Window * c)

This method is a helper for the generated API. It's called prior to any API class destructor being dealloc-ed from the generated code from Python

There is a Catch-22 in the destruction of a Window. 'dispose' needs to be called on destruction but cannot be called from the destructor. This overrides the default cleanForDealloc to resolve that.

◆ doretrieveApiInstance()

XBMCAddon::AddonClass * PythonBindings::doretrieveApiInstance ( const PyHolder * pythonObj,
const TypeInfo * typeInfo,
const char * expectedType,
const char * methodNamespacePrefix,
const char * methodNameForErrorString )

◆ dummy_tp_init()

int PythonBindings::dummy_tp_init ( PyObject * self,
PyObject * args,
PyObject * kwds )

◆ getTypeInfoForInstance()

const TypeInfo * PythonBindings::getTypeInfoForInstance ( XBMCAddon::AddonClass * obj)

◆ isParameterRightType()

bool PythonBindings::isParameterRightType ( const char * passedType,
const char * expectedType,
const char * methodNamespacePrefix,
bool tryReverse )

◆ makePythonInstance() [1/2]

PyObject * PythonBindings::makePythonInstance ( XBMCAddon::AddonClass * api,
bool incrementRefCount )
inline

This method allows for conversion of the native api Type to the Python type.

When this form of the call is used then the python type constructed will be the type given by the class metadata in the AddonClass instance 'api'.

This is just a helper inline to call the other makePythonInstance with NULL as the pythonType.

◆ makePythonInstance() [2/2]

PyObject * PythonBindings::makePythonInstance ( XBMCAddon::AddonClass * api,
PyTypeObject * pytype,
bool incrementRefCount )

This method allows for conversion of the native api Type to the Python type.

When this form of the call is used (and pytype isn't NULL) then the passed type is used in the instance. This is for classes that extend API classes in python. The type passed may not be the same type that's stored in the class metadata of the AddonClass of which 'api' is an instance, it can be a subclass in python.

if pytype is NULL then the type is inferred using the class metadata stored in the AddonClass instance 'api'.

This method allows for conversion of the native api Type to the Python type.

When this form of the call is used (and pythonType isn't NULL) then the passed type is used in the instance. This is for classes that extend API classes in python. The type passed may not be the same type that's stored in the class metadata of the AddonClass of which 'api' is an instance, it can be a subclass in python.

if pythonType is NULL then the type is inferred using the class metadata stored in the AddonClass instance 'api'.

◆ prepareForReturn()

void PythonBindings::prepareForReturn ( XBMCAddon::AddonClass * c)

This method is a helper for the generated API. It's called prior to any API class constructor being returned from the generated code to Python

◆ PyInit_Module_xbmc()

PyObject * PythonBindings::PyInit_Module_xbmc ( void )

◆ PyInit_Module_xbmcaddon()

PyObject * PythonBindings::PyInit_Module_xbmcaddon ( void )

◆ PyInit_Module_xbmcdrm()

PyObject * PythonBindings::PyInit_Module_xbmcdrm ( void )

◆ PyInit_Module_xbmcgui()

PyObject * PythonBindings::PyInit_Module_xbmcgui ( void )

◆ PyInit_Module_xbmcplugin()

PyObject * PythonBindings::PyInit_Module_xbmcplugin ( void )

◆ PyInit_Module_xbmcvfs()

PyObject * PythonBindings::PyInit_Module_xbmcvfs ( void )

◆ PyInit_Module_xbmcwsgi()

PyObject * PythonBindings::PyInit_Module_xbmcwsgi ( void )

◆ PyXBMCGetUnicodeString()

void PythonBindings::PyXBMCGetUnicodeString ( std::string & buf,
PyObject * pObject,
bool coerceToString = false,
const char * pos = "unknown",
const char * methodname = "unknown" )

This call will convert the python object passed to a string. The object passed must be a python str or unicode object unless coerceToString is true. If coerceToString is true then the type must be castable to a string using the python call str(pObject).

This method will handle a 'None' that's passed in. If 'None' is passed then the resulting buf will contain the value of XBMCAddon::emptyString (which is simply a std::string instantiated with the default constructor.

Todo
UTF-8: Does python use UTF-16? Do we need to convert from the string charset to UTF-8 for non-unicode data?

◆ registerAddonClassTypeInformation()

void PythonBindings::registerAddonClassTypeInformation ( const TypeInfo * classInfo)

◆ retrieveApiInstance() [1/2]

XBMCAddon::AddonClass * PythonBindings::retrieveApiInstance ( const PyObject * pythonObj,
const char * expectedType,
const char * methodNamespacePrefix,
const char * methodNameForErrorString )
inline

This method retrieves the pointer from the PyHolder. The return value should be cast to the appropriate type.

Since the calls to this are generated there's no NULL pointer checks

This method will return NULL if either the pythonObj is NULL or the pythonObj is Py_None.

◆ retrieveApiInstance() [2/2]

XBMCAddon::AddonClass * PythonBindings::retrieveApiInstance ( PyObject * pythonObj,
const TypeInfo * typeToCheck,
const char * methodNameForErrorString,
const char * typenameForErrorString )
inline

This method retrieves the pointer from the PyHolder. The return value should be cast to the appropriate type.

Since the calls to this are generated there's no NULL pointer checks

Variable Documentation

◆ typeInfoLookup

std::map<std::type_index, const TypeInfo*> PythonBindings::typeInfoLookup