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

pyuno::Runtime::~Runtime ( )

Definition at line 362 of file pyuno_runtime.cxx.

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 341 of file pyuno_runtime.cxx.

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

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

Definition at line 356 of file pyuno_runtime.cxx.

References impl.

Member Function Documentation

PyRef pyuno::Runtime::any2PyObject ( const css::uno::Any &  source) const
Any pyuno::Runtime::extractUnoException ( const PyRef excType,
const PyRef excValue,
const PyRef excTraceback 
) const
RuntimeImpl* pyuno::Runtime::getImpl ( ) const
inline
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 317 of file pyuno_runtime.cxx.

References pyuno::stRuntimeImpl::cargo, pyuno::stRuntimeImpl::create(), pyuno::PyRef::get(), pyuno::getRuntimeImpl(), pyuno::PyRef::is(), runtime, and pyuno::RuntimeCargo::valid.

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 333 of file pyuno_runtime.cxx.

References pyuno::stRuntimeImpl::cargo, pyuno::PyRef::get(), pyuno::getRuntimeImpl(), pyuno::PyRef::is(), runtime, and pyuno::RuntimeCargo::valid.

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

Definition at line 367 of file pyuno_runtime.cxx.

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

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 612 of file pyuno_runtime.cxx.

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

Referenced by pyObject2Any().

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

Member Data Documentation

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: