1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "pyuno_impl.hxx" 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <rtl/strbuf.hxx> 31*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <osl/thread.h> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #define TO_ASCII(x) OUStringToOString( x , RTL_TEXTENCODING_ASCII_US).getStr() 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir using rtl::OStringBuffer; 43*cdf0e10cSrcweir using rtl::OUStringBuffer; 44*cdf0e10cSrcweir using rtl::OUStringToOString; 45*cdf0e10cSrcweir using rtl::OUString; 46*cdf0e10cSrcweir using com::sun::star::uno::Sequence; 47*cdf0e10cSrcweir using com::sun::star::uno::Reference; 48*cdf0e10cSrcweir using com::sun::star::uno::XInterface; 49*cdf0e10cSrcweir using com::sun::star::uno::Any; 50*cdf0e10cSrcweir using com::sun::star::uno::makeAny; 51*cdf0e10cSrcweir using com::sun::star::uno::UNO_QUERY; 52*cdf0e10cSrcweir using com::sun::star::uno::Type; 53*cdf0e10cSrcweir using com::sun::star::uno::TypeClass; 54*cdf0e10cSrcweir using com::sun::star::uno::RuntimeException; 55*cdf0e10cSrcweir using com::sun::star::uno::Exception; 56*cdf0e10cSrcweir using com::sun::star::uno::XComponentContext; 57*cdf0e10cSrcweir using com::sun::star::lang::XSingleServiceFactory; 58*cdf0e10cSrcweir using com::sun::star::lang::XServiceInfo; 59*cdf0e10cSrcweir using com::sun::star::lang::XTypeProvider; 60*cdf0e10cSrcweir using com::sun::star::script::XTypeConverter; 61*cdf0e10cSrcweir using com::sun::star::script::XInvocation2; 62*cdf0e10cSrcweir using com::sun::star::beans::XMaterialHolder; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir namespace pyuno 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir PyObject *PyUNO_str( PyObject * self ); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir void PyUNO_del (PyObject* self) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir PyUNO* me = reinterpret_cast< PyUNO* > (self); 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir PyThreadDetach antiguard; 74*cdf0e10cSrcweir delete me->members; 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir PyObject_Del (self); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef , sal_Int32 mode ) SAL_THROW( () ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir OSL_ASSERT( pVal ); 84*cdf0e10cSrcweir if (pTypeRef->eTypeClass == typelib_TypeClass_VOID) 85*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM("void") ); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir OUStringBuffer buf( 64 ); 88*cdf0e10cSrcweir buf.append( (sal_Unicode)'(' ); 89*cdf0e10cSrcweir buf.append( pTypeRef->pTypeName ); 90*cdf0e10cSrcweir buf.append( (sal_Unicode)')' ); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir switch (pTypeRef->eTypeClass) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 97*cdf0e10cSrcweir buf.append( reinterpret_cast< sal_IntPtr >(*(void **)pVal), 16 ); 98*cdf0e10cSrcweir if( VAL2STR_MODE_DEEP == mode ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir buf.appendAscii( "{" ); Reference< XInterface > r = *( Reference< XInterface > * ) pVal; 101*cdf0e10cSrcweir Reference< XServiceInfo > serviceInfo( r, UNO_QUERY); 102*cdf0e10cSrcweir Reference< XTypeProvider > typeProvider(r,UNO_QUERY); 103*cdf0e10cSrcweir if( serviceInfo.is() ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir buf.appendAscii("implementationName=" ); 106*cdf0e10cSrcweir buf.append(serviceInfo->getImplementationName() ); 107*cdf0e10cSrcweir buf.appendAscii(", supportedServices={" ); 108*cdf0e10cSrcweir Sequence< OUString > seq = serviceInfo->getSupportedServiceNames(); 109*cdf0e10cSrcweir for( int i = 0 ; i < seq.getLength() ; i ++ ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir buf.append( seq[i] ); 112*cdf0e10cSrcweir if( i +1 != seq.getLength() ) 113*cdf0e10cSrcweir buf.appendAscii( "," ); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir buf.appendAscii("}"); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir if( typeProvider.is() ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir buf.appendAscii(", supportedInterfaces={" ); 121*cdf0e10cSrcweir Sequence< Type > seq (typeProvider->getTypes()); 122*cdf0e10cSrcweir for( int i = 0 ; i < seq.getLength() ; i ++ ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir buf.append(seq[i].getTypeName()); 125*cdf0e10cSrcweir if( i +1 != seq.getLength() ) 126*cdf0e10cSrcweir buf.appendAscii( "," ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir buf.appendAscii("}"); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir buf.appendAscii( "}" ); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir break; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir case typelib_TypeClass_UNION: 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir // typelib_TypeDescription * pTypeDescr = 0; 138*cdf0e10cSrcweir // TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); 139*cdf0e10cSrcweir // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); 140*cdf0e10cSrcweir // buf.append( val2str( (char *)pVal + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset, 141*cdf0e10cSrcweir // union_getSetType( pVal, pTypeDescr ) ) ); 142*cdf0e10cSrcweir // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); 143*cdf0e10cSrcweir // TYPELIB_DANGER_RELEASE( pTypeDescr ); 144*cdf0e10cSrcweir break; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 147*cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); 150*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0; 151*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); 152*cdf0e10cSrcweir OSL_ASSERT( pTypeDescr ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir typelib_CompoundTypeDescription * pCompType = (typelib_CompoundTypeDescription *)pTypeDescr; 155*cdf0e10cSrcweir sal_Int32 nDescr = pCompType->nMembers; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if (pCompType->pBaseTypeDescription) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir buf.append( val2str( pVal, ((typelib_TypeDescription *)pCompType->pBaseTypeDescription)->pWeakRef,mode ) ); 160*cdf0e10cSrcweir if (nDescr) 161*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs; 165*cdf0e10cSrcweir sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets; 166*cdf0e10cSrcweir rtl_uString ** ppMemberNames = pCompType->ppMemberNames; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir buf.append( ppMemberNames[nPos] ); 171*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" = ") ); 172*cdf0e10cSrcweir typelib_TypeDescription * pMemberType = 0; 173*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] ); 174*cdf0e10cSrcweir buf.append( val2str( (char *)pVal + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) ); 175*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pMemberType ); 176*cdf0e10cSrcweir if (nPos < (nDescr -1)) 177*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); 183*cdf0e10cSrcweir break; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0; 188*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir uno_Sequence * pSequence = *(uno_Sequence **)pVal; 191*cdf0e10cSrcweir typelib_TypeDescription * pElementTypeDescr = 0; 192*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pElementTypeDescr, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir sal_Int32 nElementSize = pElementTypeDescr->nSize; 195*cdf0e10cSrcweir sal_Int32 nElements = pSequence->nElements; 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir if (nElements) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); 200*cdf0e10cSrcweir char * pElements = pSequence->elements; 201*cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir buf.append( val2str( pElements + (nElementSize * nPos), pElementTypeDescr->pWeakRef, mode ) ); 204*cdf0e10cSrcweir if (nPos < (nElements -1)) 205*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir else 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{}") ); 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pElementTypeDescr ); 214*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 215*cdf0e10cSrcweir break; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir case typelib_TypeClass_ANY: 218*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); 219*cdf0e10cSrcweir buf.append( val2str( ((uno_Any *)pVal)->pData, 220*cdf0e10cSrcweir ((uno_Any *)pVal)->pType , 221*cdf0e10cSrcweir mode) ); 222*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); 223*cdf0e10cSrcweir break; 224*cdf0e10cSrcweir case typelib_TypeClass_TYPE: 225*cdf0e10cSrcweir buf.append( (*(typelib_TypeDescriptionReference **)pVal)->pTypeName ); 226*cdf0e10cSrcweir break; 227*cdf0e10cSrcweir case typelib_TypeClass_STRING: 228*cdf0e10cSrcweir buf.append( (sal_Unicode)'\"' ); 229*cdf0e10cSrcweir buf.append( *(rtl_uString **)pVal ); 230*cdf0e10cSrcweir buf.append( (sal_Unicode)'\"' ); 231*cdf0e10cSrcweir break; 232*cdf0e10cSrcweir case typelib_TypeClass_ENUM: 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0; 235*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir sal_Int32 * pValues = ((typelib_EnumTypeDescription *)pTypeDescr)->pEnumValues; 238*cdf0e10cSrcweir sal_Int32 nPos = ((typelib_EnumTypeDescription *)pTypeDescr)->nEnumValues; 239*cdf0e10cSrcweir while (nPos--) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir if (pValues[nPos] == *(int *)pVal) 242*cdf0e10cSrcweir break; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir if (nPos >= 0) 245*cdf0e10cSrcweir buf.append( ((typelib_EnumTypeDescription *)pTypeDescr)->ppEnumNames[nPos] ); 246*cdf0e10cSrcweir else 247*cdf0e10cSrcweir buf.append( (sal_Unicode)'?' ); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 250*cdf0e10cSrcweir break; 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 253*cdf0e10cSrcweir if (*(sal_Bool *)pVal) 254*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("true") ); 255*cdf0e10cSrcweir else 256*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("false") ); 257*cdf0e10cSrcweir break; 258*cdf0e10cSrcweir case typelib_TypeClass_CHAR: 259*cdf0e10cSrcweir buf.append( (sal_Unicode)'\'' ); 260*cdf0e10cSrcweir buf.append( *(sal_Unicode *)pVal ); 261*cdf0e10cSrcweir buf.append( (sal_Unicode)'\'' ); 262*cdf0e10cSrcweir break; 263*cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 264*cdf0e10cSrcweir buf.append( *(float *)pVal ); 265*cdf0e10cSrcweir break; 266*cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 267*cdf0e10cSrcweir buf.append( *(double *)pVal ); 268*cdf0e10cSrcweir break; 269*cdf0e10cSrcweir case typelib_TypeClass_BYTE: 270*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 271*cdf0e10cSrcweir buf.append( (sal_Int32)*(sal_Int8 *)pVal, 16 ); 272*cdf0e10cSrcweir break; 273*cdf0e10cSrcweir case typelib_TypeClass_SHORT: 274*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 275*cdf0e10cSrcweir buf.append( (sal_Int32)*(sal_Int16 *)pVal, 16 ); 276*cdf0e10cSrcweir break; 277*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 278*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 279*cdf0e10cSrcweir buf.append( (sal_Int32)*(sal_uInt16 *)pVal, 16 ); 280*cdf0e10cSrcweir break; 281*cdf0e10cSrcweir case typelib_TypeClass_LONG: 282*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 283*cdf0e10cSrcweir buf.append( *(sal_Int32 *)pVal, 16 ); 284*cdf0e10cSrcweir break; 285*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 286*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 287*cdf0e10cSrcweir buf.append( (sal_Int64)*(sal_uInt32 *)pVal, 16 ); 288*cdf0e10cSrcweir break; 289*cdf0e10cSrcweir case typelib_TypeClass_HYPER: 290*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 291*cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 292*cdf0e10cSrcweir #if defined(GCC) && defined(SPARC) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir sal_Int64 aVal; 295*cdf0e10cSrcweir *(sal_Int32 *)&aVal = *(sal_Int32 *)pVal; 296*cdf0e10cSrcweir *((sal_Int32 *)&aVal +1)= *((sal_Int32 *)pVal +1); 297*cdf0e10cSrcweir buf.append( aVal, 16 ); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir #else 300*cdf0e10cSrcweir buf.append( *(sal_Int64 *)pVal, 16 ); 301*cdf0e10cSrcweir #endif 302*cdf0e10cSrcweir break; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir case typelib_TypeClass_VOID: 305*cdf0e10cSrcweir case typelib_TypeClass_ARRAY: 306*cdf0e10cSrcweir case typelib_TypeClass_UNKNOWN: 307*cdf0e10cSrcweir case typelib_TypeClass_SERVICE: 308*cdf0e10cSrcweir case typelib_TypeClass_MODULE: 309*cdf0e10cSrcweir default: 310*cdf0e10cSrcweir buf.append( (sal_Unicode)'?' ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir return buf.makeStringAndClear(); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir PyObject *PyUNO_repr( PyObject * self ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir PyUNO *me = (PyUNO * ) self; 320*cdf0e10cSrcweir PyObject * ret = 0; 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir if( me->members->wrappedObject.getValueType().getTypeClass() 323*cdf0e10cSrcweir == com::sun::star::uno::TypeClass_EXCEPTION ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir Reference< XMaterialHolder > rHolder(me->members->xInvocation,UNO_QUERY); 326*cdf0e10cSrcweir if( rHolder.is() ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir Any a = rHolder->getMaterial(); 329*cdf0e10cSrcweir Exception e; 330*cdf0e10cSrcweir a >>= e; 331*cdf0e10cSrcweir ret = ustring2PyUnicode(e.Message ).getAcquired(); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir else 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir ret = PyUNO_str( self ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir return ret; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir PyObject *PyUNO_invoke( PyObject *object, const char *name , PyObject *args ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir PyRef ret; 344*cdf0e10cSrcweir try 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir Runtime runtime; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir PyRef paras,callable; 349*cdf0e10cSrcweir if( PyObject_IsInstance( object, getPyUnoClass( runtime ).get() ) ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir PyUNO* me = (PyUNO*) object; 352*cdf0e10cSrcweir OUString attrName = OUString::createFromAscii(name); 353*cdf0e10cSrcweir if (! me->members->xInvocation->hasMethod (attrName)) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir OUStringBuffer buf; 356*cdf0e10cSrcweir buf.appendAscii( "Attribute " ); 357*cdf0e10cSrcweir buf.append( attrName ); 358*cdf0e10cSrcweir buf.appendAscii( " unknown" ); 359*cdf0e10cSrcweir throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface > () ); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir callable = PyUNO_callable_new ( 362*cdf0e10cSrcweir me->members->xInvocation, 363*cdf0e10cSrcweir attrName, 364*cdf0e10cSrcweir runtime.getImpl()->cargo->xInvocation, 365*cdf0e10cSrcweir runtime.getImpl()->cargo->xTypeConverter, 366*cdf0e10cSrcweir ACCEPT_UNO_ANY); 367*cdf0e10cSrcweir paras = args; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir else 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir // clean the tuple from uno.Any ! 372*cdf0e10cSrcweir int size = PyTuple_Size( args ); 373*cdf0e10cSrcweir { // for CC, keeping ref-count of tuple being 1 374*cdf0e10cSrcweir paras = PyRef(PyTuple_New( size ), SAL_NO_ACQUIRE); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir for( int i = 0 ; i < size ;i ++ ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir PyObject * element = PyTuple_GetItem( args , i ); 379*cdf0e10cSrcweir if( PyObject_IsInstance( element , getAnyClass( runtime ).get() ) ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir element = PyObject_GetAttrString( 382*cdf0e10cSrcweir element, const_cast< char * >("value") ); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir else 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir Py_XINCREF( element ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir PyTuple_SetItem( paras.get(), i , element ); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir callable = PyRef( PyObject_GetAttrString( object , (char*)name ), SAL_NO_ACQUIRE ); 391*cdf0e10cSrcweir if( !callable.is() ) 392*cdf0e10cSrcweir return 0; 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir ret = PyRef( PyObject_CallObject( callable.get(), paras.get() ), SAL_NO_ACQUIRE ); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir catch (::com::sun::star::lang::IllegalArgumentException &e) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) ); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir catch (::com::sun::star::script::CannotConvertException &e) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) ); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir catch (::com::sun::star::uno::RuntimeException &e) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) ); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir catch (::com::sun::star::uno::Exception &e) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir return ret.getAcquired(); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir PyObject *PyUNO_str( PyObject * self ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir PyUNO *me = ( PyUNO * ) self; 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir OStringBuffer buf; 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir if( me->members->wrappedObject.getValueType().getTypeClass() 424*cdf0e10cSrcweir == com::sun::star::uno::TypeClass_STRUCT || 425*cdf0e10cSrcweir me->members->wrappedObject.getValueType().getTypeClass() 426*cdf0e10cSrcweir == com::sun::star::uno::TypeClass_EXCEPTION) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir Reference< XMaterialHolder > rHolder(me->members->xInvocation,UNO_QUERY); 429*cdf0e10cSrcweir if( rHolder.is() ) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir PyThreadDetach antiguard; 432*cdf0e10cSrcweir Any a = rHolder->getMaterial(); 433*cdf0e10cSrcweir OUString s = val2str( (void*) a.getValue(), a.getValueType().getTypeLibType() ); 434*cdf0e10cSrcweir buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) ); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir else 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir // a common UNO object 440*cdf0e10cSrcweir PyThreadDetach antiguard; 441*cdf0e10cSrcweir buf.append( "pyuno object " ); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir OUString s = val2str( (void*)me->members->wrappedObject.getValue(), 444*cdf0e10cSrcweir me->members->wrappedObject.getValueType().getTypeLibType() ); 445*cdf0e10cSrcweir buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) ); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir return PyString_FromString( buf.getStr()); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir PyObject* PyUNO_getattr (PyObject* self, char* name) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir PyUNO* me; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir try 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir Runtime runtime; 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir me = (PyUNO*) self; 461*cdf0e10cSrcweir //Handle Python dir () stuff first... 462*cdf0e10cSrcweir if (strcmp (name, "__members__") == 0) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir PyObject* member_list; 465*cdf0e10cSrcweir Sequence<OUString> oo_member_list; 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir oo_member_list = me->members->xInvocation->getMemberNames (); 468*cdf0e10cSrcweir member_list = PyList_New (oo_member_list.getLength ()); 469*cdf0e10cSrcweir for (int i = 0; i < oo_member_list.getLength (); i++) 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir // setitem steals a reference 472*cdf0e10cSrcweir PyList_SetItem (member_list, i, ustring2PyString(oo_member_list[i]).getAcquired() ); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir return member_list; 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir if (strcmp (name, "__dict__") == 0) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir Py_INCREF (Py_None); 480*cdf0e10cSrcweir return Py_None; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir if (strcmp (name, "__methods__") == 0) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir Py_INCREF (Py_None); 485*cdf0e10cSrcweir return Py_None; 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir if (strcmp (name, "__class__") == 0) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir if( me->members->wrappedObject.getValueTypeClass() == 490*cdf0e10cSrcweir com::sun::star::uno::TypeClass_STRUCT || 491*cdf0e10cSrcweir me->members->wrappedObject.getValueTypeClass() == 492*cdf0e10cSrcweir com::sun::star::uno::TypeClass_EXCEPTION ) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir return getClass( 495*cdf0e10cSrcweir me->members->wrappedObject.getValueType().getTypeName(), runtime ).getAcquired(); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir Py_INCREF (Py_None); 498*cdf0e10cSrcweir return Py_None; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir OUString attrName( OUString::createFromAscii( name ) ); 502*cdf0e10cSrcweir //We need to find out if it's a method... 503*cdf0e10cSrcweir if (me->members->xInvocation->hasMethod (attrName)) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir //Create a callable object to invoke this... 506*cdf0e10cSrcweir PyRef ret = PyUNO_callable_new ( 507*cdf0e10cSrcweir me->members->xInvocation, 508*cdf0e10cSrcweir attrName, 509*cdf0e10cSrcweir runtime.getImpl()->cargo->xInvocation, 510*cdf0e10cSrcweir runtime.getImpl()->cargo->xTypeConverter); 511*cdf0e10cSrcweir Py_XINCREF( ret.get() ); 512*cdf0e10cSrcweir return ret.get(); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir //or a property 517*cdf0e10cSrcweir if (me->members->xInvocation->hasProperty ( attrName)) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir //Return the value of the property 520*cdf0e10cSrcweir Any anyRet; 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir PyThreadDetach antiguard; 523*cdf0e10cSrcweir anyRet = me->members->xInvocation->getValue (attrName); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir PyRef ret = runtime.any2PyObject(anyRet); 526*cdf0e10cSrcweir Py_XINCREF( ret.get() ); 527*cdf0e10cSrcweir return ret.get(); 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir //or else... 531*cdf0e10cSrcweir PyErr_SetString (PyExc_AttributeError, name); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir catch( com::sun::star::reflection::InvocationTargetException & e ) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e.TargetException) ); 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir catch( com::sun::star::beans::UnknownPropertyException & e ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e) ); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir catch( com::sun::star::lang::IllegalArgumentException &e ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e) ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir catch( com::sun::star::script::CannotConvertException &e ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e) ); 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir catch( RuntimeException &e ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e) ); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir return NULL; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir int PyUNO_setattr (PyObject* self, char* name, PyObject* value) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir PyUNO* me; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir me = (PyUNO*) self; 562*cdf0e10cSrcweir try 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir Runtime runtime; 565*cdf0e10cSrcweir Any val= runtime.pyObject2Any(value, ACCEPT_UNO_ANY); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir OUString attrName( OUString::createFromAscii( name ) ); 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir PyThreadDetach antiguard; 570*cdf0e10cSrcweir if (me->members->xInvocation->hasProperty (attrName)) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir me->members->xInvocation->setValue (attrName, val); 573*cdf0e10cSrcweir return 0; //Keep with Python's boolean system 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir catch( com::sun::star::reflection::InvocationTargetException & e ) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e.TargetException) ); 580*cdf0e10cSrcweir return 1; 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir catch( com::sun::star::beans::UnknownPropertyException & e ) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e) ); 585*cdf0e10cSrcweir return 1; 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir catch( com::sun::star::script::CannotConvertException &e ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny(e) ); 590*cdf0e10cSrcweir return 1; 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir catch( RuntimeException & e ) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny( e ) ); 595*cdf0e10cSrcweir return 1; 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir PyErr_SetString (PyExc_AttributeError, name); 598*cdf0e10cSrcweir return 1; //as above. 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir // ensure object identity and struct equality 602*cdf0e10cSrcweir static int PyUNO_cmp( PyObject *self, PyObject *that ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir if( self == that ) 605*cdf0e10cSrcweir return 0; 606*cdf0e10cSrcweir int retDefault = self > that ? 1 : -1; 607*cdf0e10cSrcweir try 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir Runtime runtime; 610*cdf0e10cSrcweir if( PyObject_IsInstance( that, getPyUnoClass( runtime ).get() ) ) 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir PyUNO *me = reinterpret_cast< PyUNO*> ( self ); 614*cdf0e10cSrcweir PyUNO *other = reinterpret_cast< PyUNO *> (that ); 615*cdf0e10cSrcweir com::sun::star::uno::TypeClass tcMe = me->members->wrappedObject.getValueTypeClass(); 616*cdf0e10cSrcweir com::sun::star::uno::TypeClass tcOther = other->members->wrappedObject.getValueTypeClass(); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir if( tcMe == tcOther ) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir if( tcMe == com::sun::star::uno::TypeClass_STRUCT || 621*cdf0e10cSrcweir tcMe == com::sun::star::uno::TypeClass_EXCEPTION ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir Reference< XMaterialHolder > xMe( me->members->xInvocation,UNO_QUERY); 624*cdf0e10cSrcweir Reference< XMaterialHolder > xOther( other->members->xInvocation,UNO_QUERY ); 625*cdf0e10cSrcweir if( xMe->getMaterial() == xOther->getMaterial() ) 626*cdf0e10cSrcweir return 0; 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir else if( tcMe == com::sun::star::uno::TypeClass_INTERFACE ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir if( me->members->wrappedObject == other->members->wrappedObject ) 631*cdf0e10cSrcweir // if( me->members->xInvocation == other->members->xInvocation ) 632*cdf0e10cSrcweir return 0; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir catch( com::sun::star::uno::RuntimeException & e) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir raisePyExceptionWithAny( makeAny( e ) ); 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir return retDefault; 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir static PyTypeObject PyUNOType = 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir PyObject_HEAD_INIT (&PyType_Type) 647*cdf0e10cSrcweir 0, 648*cdf0e10cSrcweir const_cast< char * >("pyuno"), 649*cdf0e10cSrcweir sizeof (PyUNO), 650*cdf0e10cSrcweir 0, 651*cdf0e10cSrcweir (destructor) PyUNO_del, 652*cdf0e10cSrcweir (printfunc) 0, 653*cdf0e10cSrcweir (getattrfunc) PyUNO_getattr, 654*cdf0e10cSrcweir (setattrfunc) PyUNO_setattr, 655*cdf0e10cSrcweir (cmpfunc) PyUNO_cmp, 656*cdf0e10cSrcweir (reprfunc) PyUNO_repr, 657*cdf0e10cSrcweir 0, 658*cdf0e10cSrcweir 0, 659*cdf0e10cSrcweir 0, 660*cdf0e10cSrcweir (hashfunc) 0, 661*cdf0e10cSrcweir (ternaryfunc) 0, 662*cdf0e10cSrcweir (reprfunc) PyUNO_str, 663*cdf0e10cSrcweir (getattrofunc)0, 664*cdf0e10cSrcweir (setattrofunc)0, 665*cdf0e10cSrcweir NULL, 666*cdf0e10cSrcweir 0, 667*cdf0e10cSrcweir NULL, 668*cdf0e10cSrcweir (traverseproc)0, 669*cdf0e10cSrcweir (inquiry)0, 670*cdf0e10cSrcweir (richcmpfunc)0, 671*cdf0e10cSrcweir 0, 672*cdf0e10cSrcweir (getiterfunc)0, 673*cdf0e10cSrcweir (iternextfunc)0, 674*cdf0e10cSrcweir NULL, 675*cdf0e10cSrcweir NULL, 676*cdf0e10cSrcweir NULL, 677*cdf0e10cSrcweir NULL, 678*cdf0e10cSrcweir NULL, 679*cdf0e10cSrcweir (descrgetfunc)0, 680*cdf0e10cSrcweir (descrsetfunc)0, 681*cdf0e10cSrcweir 0, 682*cdf0e10cSrcweir (initproc)0, 683*cdf0e10cSrcweir (allocfunc)0, 684*cdf0e10cSrcweir (newfunc)0, 685*cdf0e10cSrcweir (freefunc)0, 686*cdf0e10cSrcweir (inquiry)0, 687*cdf0e10cSrcweir NULL, 688*cdf0e10cSrcweir NULL, 689*cdf0e10cSrcweir NULL, 690*cdf0e10cSrcweir NULL, 691*cdf0e10cSrcweir NULL, 692*cdf0e10cSrcweir (destructor)0 693*cdf0e10cSrcweir #if PY_VERSION_HEX >= 0x02060000 694*cdf0e10cSrcweir , 0 695*cdf0e10cSrcweir #endif 696*cdf0e10cSrcweir }; 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir PyRef getPyUnoClass( const Runtime &) 699*cdf0e10cSrcweir { 700*cdf0e10cSrcweir return PyRef( reinterpret_cast< PyObject * > ( &PyUNOType ) ); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir PyObject* PyUNO_new ( 704*cdf0e10cSrcweir const Any & targetInterface, const Reference<XSingleServiceFactory> &ssf) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir Reference<XInterface> tmp_interface; 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir targetInterface >>= tmp_interface; 709*cdf0e10cSrcweir if (!tmp_interface.is ()) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir // empty reference ! 712*cdf0e10cSrcweir Py_INCREF( Py_None ); 713*cdf0e10cSrcweir return Py_None; 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir return PyUNO_new_UNCHECKED (targetInterface, ssf); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir PyObject* PyUNO_new_UNCHECKED ( 721*cdf0e10cSrcweir const Any &targetInterface, 722*cdf0e10cSrcweir const Reference<XSingleServiceFactory> &ssf ) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir PyUNO* self; 725*cdf0e10cSrcweir Sequence<Any> arguments (1); 726*cdf0e10cSrcweir Reference<XInterface> tmp_interface; 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir self = PyObject_New (PyUNO, &PyUNOType); 729*cdf0e10cSrcweir if (self == NULL) 730*cdf0e10cSrcweir return NULL; //NULL == error 731*cdf0e10cSrcweir self->members = new PyUNOInternals(); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir arguments[0] <<= targetInterface; 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir PyThreadDetach antiguard; 736*cdf0e10cSrcweir tmp_interface = ssf->createInstanceWithArguments (arguments); 737*cdf0e10cSrcweir Reference<XInvocation2> tmp_invocation (tmp_interface, UNO_QUERY); 738*cdf0e10cSrcweir self->members->xInvocation = tmp_invocation; 739*cdf0e10cSrcweir self->members->wrappedObject = targetInterface; 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir return (PyObject*) self; 742*cdf0e10cSrcweir } 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir } 745