22#include <com/sun/star/beans/UnknownPropertyException.hpp>
23#include <com/sun/star/beans/XMaterialHolder.hpp>
24#include <com/sun/star/script/CannotConvertException.hpp>
25#include <com/sun/star/script/XInvocation2.hpp>
26#include <com/sun/star/lang/XSingleServiceFactory.hpp>
32using com::sun::star::uno::Any;
33using com::sun::star::uno::UNO_QUERY;
34using com::sun::star::uno::TypeClass;
35using com::sun::star::uno::RuntimeException;
36using com::sun::star::uno::Exception;
37using com::sun::star::lang::XSingleServiceFactory;
38using com::sun::star::script::XInvocation2;
39using com::sun::star::beans::XMaterialHolder;
63 Any a = rHolder->getMaterial();
64 OUString s =
val2str(
a.getValue(),
a.getValueType().getTypeLibType() );
68 return PyUnicode_FromString( buf.getStr());
74 PyObject *ret =
nullptr;
77 == css::uno::TypeClass_EXCEPTION )
82 Any a = rHolder->getMaterial();
100 PyObject* member_list =
nullptr;
104 member_list = PyList_New( 0 );
105 const css::uno::Sequence<OUString> aMemberNames = me->
members->
xInvocation->getMemberNames();
106 for(
const auto& aMember : aMemberNames )
128 me =
reinterpret_cast<PyUNO*
>(self);
129 if (strcmp (
name,
"__dict__") == 0)
131 Py_INCREF (Py_TYPE(me)->tp_dict);
132 return Py_TYPE(me)->tp_dict;
134 if( strcmp(
name,
"__class__" ) == 0 )
140 PyObject *pRet = PyObject_GenericGetAttr( self, PyUnicode_FromString(
name ) );
155 Py_XINCREF( ret.
get() );
160 PyErr_SetString (PyExc_AttributeError,
name);
162 catch(
const css::reflection::InvocationTargetException & e )
166 catch(
const css::beans::UnknownPropertyException & e )
170 catch(
const css::lang::IllegalArgumentException &e )
174 catch(
const css::script::CannotConvertException &e )
190 me =
reinterpret_cast<PyUNO*
>(self);
206 catch(
const css::reflection::InvocationTargetException & e )
211 catch(
const css::beans::UnknownPropertyException & e )
216 catch(
const css::script::CannotConvertException &e )
226 PyErr_SetString (PyExc_AttributeError,
name);
235 if(op != Py_EQ && op != Py_NE)
237 PyErr_SetString( PyExc_TypeError,
"only '==' and '!=' comparisons are defined" );
242 result = (op == Py_EQ ? Py_True : Py_False);
252 PyUNO *me =
reinterpret_cast< PyUNO *
> ( self );
253 PyUNO *other =
reinterpret_cast< PyUNO *
> ( that );
257 if( tcMe == tcOther )
259 if( tcMe == css::uno::TypeClass_STRUCT ||
260 tcMe == css::uno::TypeClass_EXCEPTION )
264 if( xMe->getMaterial() == xOther->getMaterial() )
266 result = (op == Py_EQ ? Py_True : Py_False);
274 catch(
const css::uno::RuntimeException & e)
279 result = (op == Py_EQ ? Py_False : Py_True);
286 {
"__dir__",
reinterpret_cast<PyCFunction
>(
PyUNOStruct_dir), METH_NOARGS,
nullptr},
287 {
nullptr,
nullptr, 0,
nullptr}
292 PyVarObject_HEAD_INIT( &PyType_Type, 0 )
297#
if PY_VERSION_HEX >= 0x03080000
343#
if PY_VERSION_HEX >= 0x03040000
345#
if PY_VERSION_HEX >= 0x03080000
347#
if PY_VERSION_HEX < 0x03090000
349#pragma clang diagnostic push
350#pragma clang diagnostic ignored
"-Wdeprecated-declarations"
354#pragma clang diagnostic pop
372 const Any &targetInterface,
380 ssf->createInstanceWithArguments(
Sequence<Any>( &targetInterface, 1 ) ), css::uno::UNO_QUERY_THROW );
382 if( !Py_IsInitialized() )
391 return PyRef(
reinterpret_cast<PyObject*
>(self), SAL_NO_ACQUIRE );
Helper class for keeping references to python objects.
PyObject * get() const noexcept
PyObject * getAcquired() const
helper class for detaching the current thread from the python runtime to do some blocking,...
The pyuno::Runtime class keeps the internal state of the python UNO bridge for the currently in use p...
css::uno::Any pyObject2Any(const PyRef &source, enum ConversionMode mode=REJECT_UNO_ANY) const
converts a Python object to a UNO any
PyRef any2PyObject(const css::uno::Any &source) const
converts something contained in a UNO Any to a Python object
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
static PyTypeObject PyUNOStructType
static PyObject * PyUNOStruct_getattr(PyObject *self, char *name)
static void PyUNOStruct_del(PyObject *self)
static int PyUNOStruct_setattr(PyObject *self, char *name, PyObject *value)
static PyObject * PyUNOStruct_cmp(PyObject *self, PyObject *that, int op)
PyRef getPyUnoStructClass()
static PyObject * PyUNOStruct_dir(PyObject *self)
int PyUNOStruct_initType()
PyRef ustring2PyString(std::u16string_view source)
static PyMethodDef PyUNOStructMethods[]
void raisePyExceptionWithAny(const css::uno::Any &anyExc)
static PyObject * PyUNOStruct_str(PyObject *self)
OUString val2str(const void *pVal, typelib_TypeDescriptionReference *pTypeRef, sal_Int32 mode)
PyRef ustring2PyUnicode(const OUString &source)
PyRef getClass(const OUString &name, const Runtime &runtime)
static PyObject * PyUNOStruct_repr(PyObject *self)
PyRef PyUNOStruct_new(const css::uno::Any &targetInterface, const css::uno::Reference< css::lang::XSingleServiceFactory > &ssf)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XInvocation2 > xInvocation
#define Py_TPFLAGS_HAVE_RICHCOMPARE
css::uno::Any wrappedObject
css::uno::Reference< css::script::XInvocation2 > xInvocation
PyObject_HEAD PyUNOInternals * members