xbmc
Public Member Functions | Static Public Member Functions | List of all members
XBMCAddon::Python::PythonLanguageHook Class Reference

This class supplies the python specific functionality for plugging into the API. More...

#include <LanguageHook.h>

Inheritance diagram for XBMCAddon::Python::PythonLanguageHook:
Inheritance graph
[legend]
Collaboration diagram for XBMCAddon::Python::PythonLanguageHook:
Collaboration graph
[legend]

Public Member Functions

 PythonLanguageHook (PyInterpreterState *interp)
 
void DelayedCallOpen () override
 If the scripting language needs special handling for calls that block or are delayed in any other means, this should be overloaded. More...
 
void DelayedCallClose () override
 If the scripting language needs special handling for calls that block or are delayed in any other means, this should be overloaded. More...
 
void MakePendingCalls () override
 
XBMCAddon::CallbackHandlerGetCallbackHandler () override
 PythonCallbackHandler expects to be instantiated PER AddonClass instance that is to be used as a callback. More...
 
String GetAddonId () override
 This method should be done a different way but since the only other way I can think to do it requires an InheritableThreadLocal C++ equivalent, I'm going to defer to this technique for now. More...
 
String GetAddonVersion () override
 
long GetInvokerId () override
 
void RegisterPlayerCallback (IPlayerCallback *player) override
 
void UnregisterPlayerCallback (IPlayerCallback *player) override
 
void RegisterMonitorCallback (XBMCAddon::xbmc::Monitor *monitor) override
 
void UnregisterMonitorCallback (XBMCAddon::xbmc::Monitor *monitor) override
 
bool WaitForEvent (CEvent &hEvent, unsigned int milliseconds) override
 
void RegisterAddonClassInstance (AddonClass *obj)
 
void UnregisterAddonClassInstance (AddonClass *obj)
 
bool HasRegisteredAddonClassInstance (AddonClass *obj)
 
bool HasRegisteredAddonClasses ()
 
std::set< AddonClass * > & GetRegisteredAddonClasses ()
 
void UnregisterMe ()
 
void RegisterMe ()
 
- Public Member Functions inherited from XBMCAddon::LanguageHook
virtual void Constructing (AddonClass *beingConstructed)
 This is a callback method that can be overridden to receive a callback when an AddonClass that has this language hook is on is being constructed. More...
 
virtual void Destructing (AddonClass *beingDestructed)
 This is a callback method that can be overridden to receive a callback when an AddonClass that has this language hook is on is being destructed. More...
 
- Public Member Functions inherited from XBMCAddon::AddonClass
const char * GetClassname () const
 
LanguageHookGetLanguageHook ()
 
bool isDeallocating ()
 This method should be called while holding a Synchronize on the object. More...
 
void Release () const
 
void Acquire () const
 

Static Public Member Functions

static AddonClass::Ref< PythonLanguageHookGetIfExists (PyInterpreterState *interp)
 
static bool IsAddonClassInstanceRegistered (AddonClass *obj)
 
- Static Public Member Functions inherited from XBMCAddon::LanguageHook
static void SetLanguageHook (LanguageHook *languageHook)
 
static LanguageHookGetLanguageHook ()
 
static void ClearLanguageHook ()
 
- Static Public Member Functions inherited from XBMCAddon::AddonClass
static short getNumAddonClasses ()
 

Additional Inherited Members

- Protected Member Functions inherited from XBMCAddon::AddonClass
virtual void deallocating ()
 This method is meant to be called from the destructor of the lowest level class. More...
 
- Static Protected Member Functions inherited from XBMCAddon::AddonClass
static short getNextClassIndex ()
 This is meant to be called during static initialization and so isn't synchronized.
 
- Protected Attributes inherited from XBMCAddon::AddonClass
LanguageHooklanguageHook
 

Detailed Description

This class supplies the python specific functionality for plugging into the API.

It's got a static only implementation and uses the singleton pattern for access.

Member Function Documentation

◆ DelayedCallClose()

void XBMCAddon::Python::PythonLanguageHook::DelayedCallClose ( )
overridevirtual

If the scripting language needs special handling for calls that block or are delayed in any other means, this should be overloaded.

In Python when control is passed to a native method that blocks, you need to allow other threads in Python to run by using Py_BEGIN_ALLOW_THREADS. When that delayed method ends you need to restore the Python thread state using Py_END_ALLOW_THREADS. This is the place to put that functionality

Reimplemented from XBMCAddon::LanguageHook.

◆ DelayedCallOpen()

void XBMCAddon::Python::PythonLanguageHook::DelayedCallOpen ( )
overridevirtual

If the scripting language needs special handling for calls that block or are delayed in any other means, this should be overloaded.

In Python when control is passed to a native method that blocks, you need to allow other threads in Python to run by using Py_BEGIN_ALLOW_THREADS. This is the place to put that functionality

Reimplemented from XBMCAddon::LanguageHook.

◆ GetAddonId()

String XBMCAddon::Python::PythonLanguageHook::GetAddonId ( )
overridevirtual

This method should be done a different way but since the only other way I can think to do it requires an InheritableThreadLocal C++ equivalent, I'm going to defer to this technique for now.

Currently (for python) the scripting language has the Addon id injected into it as a global variable. Therefore the only way to retrieve it is to use scripting language specific calls. So until I figure out a better way to do this, this is how I need to retrieve it.

Reimplemented from XBMCAddon::LanguageHook.

◆ GetCallbackHandler()

XBMCAddon::CallbackHandler * XBMCAddon::Python::PythonLanguageHook::GetCallbackHandler ( )
overridevirtual

PythonCallbackHandler expects to be instantiated PER AddonClass instance that is to be used as a callback.

This is why this cannot be instantiated once.

There is an expectation that this method is called from the Python thread that instantiated an AddonClass that has the potential for a callback.

See RetardedAsyncCallbackHandler for more details. See PythonCallbackHandler for more details See PythonCallbackHandler::PythonCallbackHandler for more details

Reimplemented from XBMCAddon::LanguageHook.


The documentation for this class was generated from the following files: