LibreOffice Module pyuno (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
pyuno::Runtime Class Reference

The pyuno::Runtime class keeps the internal state of the python UNO bridge for the currently in use python interpreter. More...

#include <pyuno.hxx>

Collaboration diagram for pyuno::Runtime:
[legend]

Public Member Functions

 ~Runtime ()
 
 Runtime ()
 preconditions: python has been initialized before, the global interpreter lock is held and pyuno has been initialized for the currently used interpreter. More...
 
 Runtime (const Runtime &)
 
Runtimeoperator= (const Runtime &)
 
PyRef any2PyObject (const css::uno::Any &source) const
 converts something contained in a UNO Any to a Python object More...
 
css::uno::Any pyObject2Any (const PyRef &source, enum ConversionMode mode=REJECT_UNO_ANY) const
 converts a Python object to a UNO any More...
 
css::uno::Any extractUnoException (const PyRef &excType, const PyRef &excValue, const PyRef &excTraceback) const
 extracts a proper uno exception from a given python exception More...
 
RuntimeImplgetImpl () const
 Returns the internal handle. More...
 

Static Public Member Functions

static void initialize (const css::uno::Reference< css::uno::XComponentContext > &ctx)
 Initializes the python-UNO bridge. More...
 
static bool isInitialized ()
 Checks, whether the uno runtime is already initialized in the current python interpreter. More...
 

Private Member Functions

bool pyIterUnpack (PyObject *const, css::uno::Any &) const
 Safely unpacks a Python iterator into a sequence, then stores it in an Any. More...
 

Private Attributes

RuntimeImplimpl
 

Detailed Description

The pyuno::Runtime class keeps the internal state of the python UNO bridge for the currently in use python interpreter.

You may keep a Runtime instance, use it from a different thread, etc. But you must make sure to fulfill all preconditions mentioned for the specific methods.

Definition at line 163 of file pyuno.hxx.

Constructor & Destructor Documentation

◆ ~Runtime()

pyuno::Runtime::~Runtime ( )

Definition at line 363 of file pyuno_runtime.cxx.

◆ Runtime() [1/2]

pyuno::Runtime::Runtime ( )

preconditions: python has been initialized before, the global interpreter lock is held and pyuno has been initialized for the currently used interpreter.

Note: This method exists for efficiency reasons to save lookup costs for any2PyObject and pyObject2Any

Exceptions
RuntimeExceptionin case the runtime has not been initialized before

Definition at line 342 of file pyuno_runtime.cxx.

References pyuno::PyRef::get(), pyuno::getRuntimeImpl(), and pyuno::PyRef::is().

◆ Runtime() [2/2]

pyuno::Runtime::Runtime ( const Runtime r)

Definition at line 357 of file pyuno_runtime.cxx.

References impl.

Member Function Documentation

◆ any2PyObject()

PyRef pyuno::Runtime::any2PyObject ( const css::uno::Any &  source) const

◆ extractUnoException()

Any pyuno::Runtime::extractUnoException ( const PyRef excType,
const PyRef excValue,
const PyRef excTraceback 
) const

◆ getImpl()

RuntimeImpl * pyuno::Runtime::getImpl ( ) const
inline

◆ initialize()

void pyuno::Runtime::initialize ( const css::uno::Reference< css::uno::XComponentContext > &  ctx)
static

Initializes the python-UNO bridge.

May be called only once per python interpreter.

Parameters
ctxthe component context is used to instantiate bridge services needed for bridging such as invocation, typeconverter, invocationadapterfactory, etc.

preconditions: python has been initialized before and the global interpreter lock is held and pyuno is not initialized (see isInitialized() ).

Exceptions
RuntimeExceptionin case the thread is not attached or the runtime has not been initialized.

Definition at line 318 of file pyuno_runtime.cxx.

References pyuno::stRuntimeImpl::create(), ctx, pyuno::PyRef::get(), pyuno::getRuntimeImpl(), and pyuno::PyRef::is().

◆ isInitialized()

bool pyuno::Runtime::isInitialized ( )
static

Checks, whether the uno runtime is already initialized in the current python interpreter.

Exceptions
css::uno::RuntimeException

Definition at line 334 of file pyuno_runtime.cxx.

References pyuno::PyRef::get(), pyuno::getRuntimeImpl(), and pyuno::PyRef::is().

◆ operator=()

Runtime & pyuno::Runtime::operator= ( const Runtime r)

Definition at line 368 of file pyuno_runtime.cxx.

References pyuno::PyRef::get(), and impl.

◆ pyIterUnpack()

bool pyuno::Runtime::pyIterUnpack ( PyObject * const  ,
css::uno::Any &   
) const
private

Safely unpacks a Python iterator into a sequence, then stores it in an Any.

Used internally by pyObject2Any

Definition at line 614 of file pyuno_runtime.cxx.

References a, comphelper::containerToSequence(), pyuno::PyRef::get(), and pyObject2Any().

Referenced by pyObject2Any().

◆ pyObject2Any()

Any pyuno::Runtime::pyObject2Any ( const PyRef source,
enum ConversionMode  mode = REJECT_UNO_ANY 
) const

Member Data Documentation

◆ impl

RuntimeImpl* pyuno::Runtime::impl
private

Definition at line 165 of file pyuno.hxx.

Referenced by operator=(), and Runtime().


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