LibreOffice Module pyuno (master) 1
|
The pyuno::Runtime class keeps the internal state of the python UNO bridge for the currently in use python interpreter. More...
#include <pyuno.hxx>
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 &) | |
Runtime & | operator= (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... | |
RuntimeImpl * | getImpl () 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 | |
RuntimeImpl * | impl |
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.
pyuno::Runtime::~Runtime | ( | ) |
Definition at line 363 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
RuntimeException | in 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().
pyuno::Runtime::Runtime | ( | const Runtime & | r | ) |
Definition at line 357 of file pyuno_runtime.cxx.
References impl.
PyRef pyuno::Runtime::any2PyObject | ( | const css::uno::Any & | source | ) | const |
converts something contained in a UNO Any to a Python object
preconditions: python has been initialized before, the global interpreter lock is held and pyuno::Runtime has been initialized.
css::script::CannotConvertException | |
css::lang::IllegalArgumentException | |
css::uno::RuntimeException |
Definition at line 377 of file pyuno_runtime.cxx.
References a, any2PyObject(), args, pyuno::stRuntimeImpl::cargo, d, pyuno::PyRef::get(), pyuno::PyRef::getAcquired(), pyuno::getClass(), getImpl(), i, pyuno::PyRef::is(), pyuno::NOT_NULL, OUStringToOString(), pyuno::PyUNO_ByteSequence_new(), pyuno::PyUNO_char_new(), pyuno::PyUNO_Enum_new(), pyuno::PyUNO_new(), pyuno::PyUNO_Type_new(), pyuno::PyUNOStruct_new(), t, pyuno::ustring2PyString(), pyuno::ustring2PyUnicode(), v, value, and pyuno::RuntimeCargo::xTypeConverter.
Referenced by any2PyObject(), pyuno::Adapter::invoke(), pyuno::lcl_getitem_index(), pyuno::lcl_getitem_slice(), pyuno::lcl_getitem_string(), pyuno::lcl_getitem_XCellRange(), pyuno::PyUNO_callable_call(), pyuno::PyUNO_getattr(), pyuno::PyUNO_iter(), pyuno::PyUNO_iterator_next(), pyuno::PyUNO_list_iterator_next(), pyuno_loader::pyuno_Loader_get_implementation(), pyuno::PyUNOStruct_getattr(), pyuno::raisePyExceptionWithAny(), and pyuno::Adapter::setValue().
Any pyuno::Runtime::extractUnoException | ( | const PyRef & | excType, |
const PyRef & | excValue, | ||
const PyRef & | excTraceback | ||
) | const |
extracts a proper uno exception from a given python exception
Definition at line 855 of file pyuno_runtime.cxx.
References Any, args, Exception, pyuno::PyRef::get(), pyuno::PyRef::getAcquired(), pyuno::PyRef::is(), pyuno::isInstanceOfStructOrException(), pyuno::NOT_NULL, OUStringToOString(), pyObject2Any(), and typeName.
Referenced by pyuno::raiseInvocationTargetExceptionWhenNeeded(), and pyuno_loader::raiseRuntimeExceptionWhenNeeded().
|
inline |
Returns the internal handle.
Should only be used by the module implementation
Definition at line 242 of file pyuno.hxx.
Referenced by any2PyObject(), pyuno::callCtor(), pyuno::getClass(), pyuno::getObjectFromUnoModule(), pyuno::Adapter::getOutIndexes(), pyuno::Adapter::invoke(), pyuno::isInterfaceClass(), pyuno::lcl_setitem_index(), pyuno::lcl_setitem_slice(), pyuno::lcl_setitem_string(), pyObject2Any(), and pyuno::PyUNO_callable_call().
|
static |
Initializes the python-UNO bridge.
May be called only once per python interpreter.
ctx | the 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() ).
RuntimeException | in 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().
|
static |
Checks, whether the uno runtime is already initialized in the current python interpreter.
css::uno::RuntimeException |
Definition at line 334 of file pyuno_runtime.cxx.
References pyuno::PyRef::get(), pyuno::getRuntimeImpl(), and pyuno::PyRef::is().
Definition at line 368 of file pyuno_runtime.cxx.
References pyuno::PyRef::get(), and impl.
|
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().
Any pyuno::Runtime::pyObject2Any | ( | const PyRef & | source, |
enum ConversionMode | mode = REJECT_UNO_ANY |
||
) | const |
converts a Python object to a UNO any
preconditions: python has been initialized before, the global interpreter lock is held and pyuno has been initialized
css::uno::RuntimeException |
Definition at line 642 of file pyuno_runtime.cxx.
References a, pyuno::ACCEPT_UNO_ANY, Any, pyuno::stRuntimeImpl::cargo, d, pyuno::PyRef::get(), get(), pyuno::getAnyClass(), pyuno::getByteSequenceClass(), cppu::getCaughtException(), pyuno::getCharClass(), pyuno::getEnumClass(), getImpl(), pyuno::getPyUnoClass(), pyuno::getPyUnoStructClass(), pyuno::getTypeClass(), i, pyuno::invokeGetTypes(), pyuno::isInstanceOfStructOrException(), pyuno::lcl_ExceptionMessage(), pyuno::PyUNO::members, mode, pyuno::PyChar2Unicode(), pyuno::PyEnum2Enum(), pyIterUnpack(), pyObject2Any(), pyuno::pyString2ustring(), pyuno::PyType2Type(), t, pyuno::PyUNOInternals::wrappedObject, pyuno::RuntimeCargo::xAdapterFactory, pyuno::PyUNOInternals::xInvocation, and pyuno::RuntimeCargo::xTypeConverter.
Referenced by extractUnoException(), pyuno::Adapter::getValue(), pyuno::Adapter::invoke(), pyuno::invokeGetTypes(), pyuno::lcl_setitem_index(), pyuno::lcl_setitem_slice(), pyuno::lcl_setitem_string(), pyIterUnpack(), pyObject2Any(), pyuno::PyUNO_callable_call(), pyuno::PyUNO_contains(), pyuno_loader::pyuno_Loader_get_implementation(), pyuno::PyUNO_setattr(), and pyuno::PyUNOStruct_setattr().
|
private |
Definition at line 165 of file pyuno.hxx.
Referenced by operator=(), and Runtime().