22#include <osl/thread.h> 
   23#include <osl/thread.hxx> 
   25#include <rtl/ustrbuf.hxx> 
   29using com::sun::star::uno::Any;
 
   30using com::sun::star::uno::RuntimeException;
 
   37#if Py_UNICODE_SIZE == 2 
   39    ret = 
PyRef( PyUnicode_FromUnicode( 
reinterpret_cast<const unsigned short *
>(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE );
 
   41    static_assert(
sizeof (wchar_t) == Py_UNICODE_SIZE, 
"bad assumption");
 
   42    ret = 
PyRef( PyUnicode_FromUnicode( 
reinterpret_cast<wchar_t const *
>(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE );
 
   46    ret = 
PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), 
nullptr) , SAL_NO_ACQUIRE );
 
   54    return PyRef( PyUnicode_FromString( o.getStr() ), SAL_NO_ACQUIRE );
 
   60    if( PyUnicode_Check( pystr ) )
 
   62#if Py_UNICODE_SIZE == 2 
   64            reinterpret_cast<sal_Unicode const *
>(PyUnicode_AS_UNICODE( pystr )) );
 
   67        char const *pUtf8(PyUnicode_AsUTF8AndSize(pystr, &
size));
 
   68        ret = OUString(pUtf8, 
size, RTL_TEXTENCODING_UTF8);
 
   73        char *
name = PyBytes_AsString(pystr); 
 
   74        ret = OUString( 
name, strlen(
name), osl_getThreadTextEncoding() );
 
   84        throw RuntimeException(
"couldn't find core function " + OUString::createFromAscii(func));
 
  105    if( !
isLog( cargo, level ) )
 
  108    static const char *strLevel[] = { 
"NONE", 
"CALL", 
"ARGS" };
 
  110    TimeValue systemTime;
 
  112    oslDateTime localDateTime;
 
  114    osl_getSystemTime( &systemTime );
 
  115    osl_getLocalTimeFromSystemTime( &systemTime, &localTime );
 
  116    osl_getDateTimeFromTimeValue( &localTime, &localDateTime );
 
  119             "%4i-%02i-%02i %02i:%02i:%02i,%03lu [%s,tid %ld]: %s\n",
 
  124             localDateTime.Minutes,
 
  125             localDateTime.Seconds,
 
  126             sal::static_int_cast< unsigned long >(
 
  127                 localDateTime.NanoSeconds/1000000),
 
  129             sal::static_int_cast< long >(
 
  130                 static_cast<sal_Int32
>(osl::Thread::getCurrentIdentifier())),
 
  136void appendPointer(OUStringBuffer & buffer, 
void * pointer) {
 
  138        sal::static_int_cast< sal_Int64 >(
 
  139            reinterpret_cast< sal_IntPtr 
>(pointer)),
 
  146                   void * ptr, std::u16string_view aFunctionName,
 
  147                   const void * data, 
const css::uno::Type & type )
 
  151        OUStringBuffer buf( 128 );
 
  152        buf.appendAscii( intro );
 
  153        appendPointer(buf, ptr);
 
  154        buf.append( OUString::Concat(
"].") + aFunctionName + 
" = " );
 
  166    std::u16string_view aFunctionName,
 
  167    const Any &returnValue,
 
  170    OUStringBuffer buf( 128 );
 
  171    buf.appendAscii( intro );
 
  172    appendPointer(buf, ptr);
 
  173    buf.append( OUString::Concat(
"].") + aFunctionName + 
"()=" );
 
  178        for( 
const auto & 
p : aParams )
 
  188              void * ptr, std::u16string_view aFunctionName,
 
  191    OUStringBuffer buf( 128 );
 
  192    buf.appendAscii( intro );
 
  193    appendPointer(buf, ptr);
 
  194    buf.append( OUString::Concat(
"].") + aFunctionName + 
"(" );
 
  197        for( 
int i = 0; 
i < aParams.getLength() ; 
i ++ )
 
Helper class for keeping references to python objects.
 
PyObject * get() const noexcept
 
The pyuno::Runtime class keeps the internal state of the python UNO bridge for the currently in use p...
 
RuntimeImpl * getImpl() const
Returns the internal handle.
 
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
 
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
 
void log(RuntimeCargo *cargo, sal_Int32 level, std::u16string_view logString)
 
bool isLog(RuntimeCargo const *cargo, sal_Int32 loglevel)
 
void logCall(RuntimeCargo *cargo, const char *intro, void *ptr, std::u16string_view aFunctionName, const css::uno::Sequence< css::uno::Any > &args)
 
PyRef ustring2PyString(std::u16string_view source)
 
OUString val2str(const void *pVal, typelib_TypeDescriptionReference *pTypeRef, sal_Int32 mode)
 
void logException(RuntimeCargo *cargo, const char *intro, void *ptr, std::u16string_view aFunctionName, const void *data, const css::uno::Type &type)
 
OUString pyString2ustring(PyObject *str)
 
PyRef getObjectFromUnoModule(const Runtime &runtime, const char *object)
 
PyRef ustring2PyUnicode(const OUString &source)
 
void logReply(RuntimeCargo *cargo, const char *intro, void *ptr, std::u16string_view aFunctionName, const css::uno::Any &returnValue, const css::uno::Sequence< css::uno::Any > &args)
 
const sal_Int32 VAL2STR_MODE_SHALLOW
 
PyRef const & getUnoModule()
 
PyObject_HEAD struct RuntimeCargo * cargo