| File: | stoc/source/corereflection/criface.cxx |
| Location: | line 840, column 43 |
| Description: | Access to field 'pMemberName' results in a dereference of a null pointer (loaded from variable 'pTD') |
| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
| 2 | /* | |||
| 3 | * This file is part of the LibreOffice project. | |||
| 4 | * | |||
| 5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||
| 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
| 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
| 8 | * | |||
| 9 | * This file incorporates work covered by the following license notice: | |||
| 10 | * | |||
| 11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||
| 12 | * contributor license agreements. See the NOTICE file distributed | |||
| 13 | * with this work for additional information regarding copyright | |||
| 14 | * ownership. The ASF licenses this file to you under the Apache | |||
| 15 | * License, Version 2.0 (the "License"); you may not use this file | |||
| 16 | * except in compliance with the License. You may obtain a copy of | |||
| 17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||
| 18 | */ | |||
| 19 | ||||
| 20 | ||||
| 21 | #include <sal/config.h> | |||
| 22 | #ifdef SAL_UNX | |||
| 23 | #include <sal/alloca.h> | |||
| 24 | #endif | |||
| 25 | #if !(defined(MACOSX) || defined(IOS) || defined(FREEBSD)) | |||
| 26 | #include <malloc.h> | |||
| 27 | #endif | |||
| 28 | #include <rtl/alloc.h> | |||
| 29 | #include <typelib/typedescription.hxx> | |||
| 30 | #include <uno/data.h> | |||
| 31 | ||||
| 32 | #include "base.hxx" | |||
| 33 | ||||
| 34 | #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" | |||
| 35 | #include "com/sun/star/uno/RuntimeException.hpp" | |||
| 36 | #include "cppuhelper/exc_hlp.hxx" | |||
| 37 | ||||
| 38 | namespace stoc_corefl | |||
| 39 | { | |||
| 40 | ||||
| 41 | //================================================================================================== | |||
| 42 | class IdlAttributeFieldImpl | |||
| 43 | : public IdlMemberImpl | |||
| 44 | , public XIdlField | |||
| 45 | , public XIdlField2 | |||
| 46 | { | |||
| 47 | public: | |||
| 48 | typelib_InterfaceAttributeTypeDescription * getAttributeTypeDescr() | |||
| 49 | { return (typelib_InterfaceAttributeTypeDescription *)getTypeDescr(); } | |||
| 50 | ||||
| 51 | IdlAttributeFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName, | |||
| 52 | typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr ) | |||
| 53 | : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr ) | |||
| 54 | {} | |||
| 55 | ||||
| 56 | // XInterface | |||
| 57 | virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException); | |||
| 58 | virtual void SAL_CALL acquire() throw(); | |||
| 59 | virtual void SAL_CALL release() throw(); | |||
| 60 | ||||
| 61 | // XTypeProvider | |||
| 62 | virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); | |||
| 63 | virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); | |||
| 64 | ||||
| 65 | // XIdlMember | |||
| 66 | virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException); | |||
| 67 | virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); | |||
| 68 | // XIdlField | |||
| 69 | virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException); | |||
| 70 | virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException); | |||
| 71 | virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); | |||
| 72 | virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); | |||
| 73 | // XIdlField2: getType, getAccessMode and get are equal to XIdlField | |||
| 74 | virtual void SAL_CALL set( Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); | |||
| 75 | ||||
| 76 | private: | |||
| 77 | void checkException( | |||
| 78 | uno_Any * exception, Reference< XInterface > const & context); | |||
| 79 | }; | |||
| 80 | ||||
| 81 | // XInterface | |||
| 82 | //__________________________________________________________________________________________________ | |||
| 83 | Any IdlAttributeFieldImpl::queryInterface( const Type & rType ) | |||
| 84 | throw(::com::sun::star::uno::RuntimeException) | |||
| 85 | { | |||
| 86 | Any aRet( ::cppu::queryInterface( rType, | |||
| 87 | static_cast< XIdlField * >( this ), | |||
| 88 | static_cast< XIdlField2 * >( this ) ) ); | |||
| 89 | return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType )); | |||
| 90 | } | |||
| 91 | //__________________________________________________________________________________________________ | |||
| 92 | void IdlAttributeFieldImpl::acquire() throw() | |||
| 93 | { | |||
| 94 | IdlMemberImpl::acquire(); | |||
| 95 | } | |||
| 96 | //__________________________________________________________________________________________________ | |||
| 97 | void IdlAttributeFieldImpl::release() throw() | |||
| 98 | { | |||
| 99 | IdlMemberImpl::release(); | |||
| 100 | } | |||
| 101 | ||||
| 102 | // XTypeProvider | |||
| 103 | //__________________________________________________________________________________________________ | |||
| 104 | Sequence< Type > IdlAttributeFieldImpl::getTypes() | |||
| 105 | throw (::com::sun::star::uno::RuntimeException) | |||
| 106 | { | |||
| 107 | static OTypeCollection * s_pTypes = 0; | |||
| 108 | if (! s_pTypes) | |||
| 109 | { | |||
| 110 | MutexGuard aGuard( getMutexAccess() ); | |||
| 111 | if (! s_pTypes) | |||
| 112 | { | |||
| 113 | static OTypeCollection s_aTypes( | |||
| 114 | ::getCppuType( (const Reference< XIdlField2 > *)0 ), | |||
| 115 | ::getCppuType( (const Reference< XIdlField > *)0 ), | |||
| 116 | IdlMemberImpl::getTypes() ); | |||
| 117 | s_pTypes = &s_aTypes; | |||
| 118 | } | |||
| 119 | } | |||
| 120 | return s_pTypes->getTypes(); | |||
| 121 | } | |||
| 122 | //__________________________________________________________________________________________________ | |||
| 123 | Sequence< sal_Int8 > IdlAttributeFieldImpl::getImplementationId() | |||
| 124 | throw (::com::sun::star::uno::RuntimeException) | |||
| 125 | { | |||
| 126 | static OImplementationId * s_pId = 0; | |||
| 127 | if (! s_pId) | |||
| 128 | { | |||
| 129 | MutexGuard aGuard( getMutexAccess() ); | |||
| 130 | if (! s_pId) | |||
| 131 | { | |||
| 132 | static OImplementationId s_aId; | |||
| 133 | s_pId = &s_aId; | |||
| 134 | } | |||
| 135 | } | |||
| 136 | return s_pId->getImplementationId(); | |||
| 137 | } | |||
| 138 | ||||
| 139 | // XIdlMember | |||
| 140 | //__________________________________________________________________________________________________ | |||
| 141 | Reference< XIdlClass > IdlAttributeFieldImpl::getDeclaringClass() | |||
| 142 | throw(::com::sun::star::uno::RuntimeException) | |||
| 143 | { | |||
| 144 | if (! _xDeclClass.is()) | |||
| 145 | { | |||
| 146 | MutexGuard aGuard( getMutexAccess() ); | |||
| 147 | if (! _xDeclClass.is()) | |||
| 148 | { | |||
| 149 | rtl::OUString aName(getAttributeTypeDescr()->aBase.aBase.pTypeName); | |||
| 150 | sal_Int32 i = aName.indexOf(':'); | |||
| 151 | OSL_ASSERT(i >= 0)do { if (true && (!(i >= 0))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "151" ": "), "OSL_ASSERT: %s", "i >= 0"); } } while ( false); | |||
| 152 | _xDeclClass = getReflection()->forName(aName.copy(0, i)); | |||
| 153 | } | |||
| 154 | } | |||
| 155 | return _xDeclClass; | |||
| 156 | } | |||
| 157 | //__________________________________________________________________________________________________ | |||
| 158 | OUString IdlAttributeFieldImpl::getName() | |||
| 159 | throw(::com::sun::star::uno::RuntimeException) | |||
| 160 | { | |||
| 161 | return IdlMemberImpl::getName(); | |||
| 162 | } | |||
| 163 | ||||
| 164 | // XIdlField | |||
| 165 | //__________________________________________________________________________________________________ | |||
| 166 | Reference< XIdlClass > IdlAttributeFieldImpl::getType() | |||
| 167 | throw(::com::sun::star::uno::RuntimeException) | |||
| 168 | { | |||
| 169 | return getReflection()->forType( | |||
| 170 | getAttributeTypeDescr()->pAttributeTypeRef ); | |||
| 171 | } | |||
| 172 | //__________________________________________________________________________________________________ | |||
| 173 | FieldAccessMode IdlAttributeFieldImpl::getAccessMode() | |||
| 174 | throw(::com::sun::star::uno::RuntimeException) | |||
| 175 | { | |||
| 176 | return (((typelib_InterfaceAttributeTypeDescription *)getAttributeTypeDescr())->bReadOnly | |||
| 177 | ? FieldAccessMode_READONLY : FieldAccessMode_READWRITE); | |||
| 178 | } | |||
| 179 | //__________________________________________________________________________________________________ | |||
| 180 | Any IdlAttributeFieldImpl::get( const Any & rObj ) | |||
| 181 | throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) | |||
| 182 | { | |||
| 183 | uno_Interface * pUnoI = getReflection()->mapToUno( | |||
| 184 | rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() ); | |||
| 185 | OSL_ENSURE( pUnoI, "### illegal destination object given!" )do { if (true && (!(pUnoI))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "185" ": "), "%s", "### illegal destination object given!" ); } } while (false); | |||
| 186 | if (pUnoI) | |||
| 187 | { | |||
| 188 | TypeDescription aTD( getAttributeTypeDescr()->pAttributeTypeRef ); | |||
| 189 | typelib_TypeDescription * pTD = aTD.get(); | |||
| 190 | ||||
| 191 | uno_Any aExc; | |||
| 192 | uno_Any * pExc = &aExc; | |||
| 193 | void * pReturn = alloca( pTD->nSize )__builtin_alloca (pTD->nSize); | |||
| 194 | ||||
| 195 | (*pUnoI->pDispatcher)( pUnoI, getTypeDescr(), pReturn, 0, &pExc ); | |||
| 196 | (*pUnoI->release)( pUnoI ); | |||
| 197 | ||||
| 198 | checkException( | |||
| 199 | pExc, | |||
| 200 | *static_cast< Reference< XInterface > const * >(rObj.getValue())); | |||
| 201 | Any aRet; | |||
| 202 | uno_any_destruct( | |||
| 203 | &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); | |||
| 204 | uno_any_constructAndConvert( &aRet, pReturn, pTD, getReflection()->getUno2Cpp().get() ); | |||
| 205 | uno_destructData( pReturn, pTD, 0 ); | |||
| 206 | return aRet; | |||
| 207 | } | |||
| 208 | throw IllegalArgumentException( | |||
| 209 | OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!")(&("illegal object given!")[0]), ((sal_Int32)((sizeof ("illegal object given!" ) / sizeof (("illegal object given!")[0]))-1)), (((rtl_TextEncoding ) 11)) ), | |||
| 210 | (XWeak *)(OWeakObject *)this, 0 ); | |||
| 211 | } | |||
| 212 | //__________________________________________________________________________________________________ | |||
| 213 | void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue ) | |||
| 214 | throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException) | |||
| 215 | { | |||
| 216 | if (getAttributeTypeDescr()->bReadOnly) | |||
| 217 | { | |||
| 218 | throw IllegalAccessException( | |||
| 219 | OUString( RTL_CONSTASCII_USTRINGPARAM("cannot set readonly attribute!")(&("cannot set readonly attribute!")[0]), ((sal_Int32)((sizeof ("cannot set readonly attribute!") / sizeof (("cannot set readonly attribute!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
| 220 | (XWeak *)(OWeakObject *)this ); | |||
| 221 | } | |||
| 222 | ||||
| 223 | uno_Interface * pUnoI = getReflection()->mapToUno( | |||
| 224 | rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() ); | |||
| 225 | OSL_ENSURE( pUnoI, "### illegal destination object given!" )do { if (true && (!(pUnoI))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "225" ": "), "%s", "### illegal destination object given!" ); } } while (false); | |||
| 226 | if (pUnoI) | |||
| 227 | { | |||
| 228 | TypeDescription aTD( getAttributeTypeDescr()->pAttributeTypeRef ); | |||
| 229 | typelib_TypeDescription * pTD = aTD.get(); | |||
| 230 | ||||
| 231 | // construct uno value to be set | |||
| 232 | void * pArgs[1]; | |||
| 233 | void * pArg = pArgs[0] = alloca( pTD->nSize )__builtin_alloca (pTD->nSize); | |||
| 234 | ||||
| 235 | sal_Bool bAssign; | |||
| 236 | if (pTD->eTypeClass == typelib_TypeClass_ANY) | |||
| 237 | { | |||
| 238 | uno_copyAndConvertData( pArg, (const_cast< Any * >(&rValue)), | |||
| 239 | pTD, getReflection()->getCpp2Uno().get() ); | |||
| 240 | bAssign = sal_True((sal_Bool)1); | |||
| 241 | } | |||
| 242 | else if (typelib_typedescriptionreference_equals( rValue.getValueTypeRef(), pTD->pWeakRef )) | |||
| 243 | { | |||
| 244 | uno_copyAndConvertData( pArg, (const_cast< void * >(rValue.getValue()) ), | |||
| 245 | pTD, getReflection()->getCpp2Uno().get() ); | |||
| 246 | bAssign = sal_True((sal_Bool)1); | |||
| 247 | } | |||
| 248 | else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE) | |||
| 249 | { | |||
| 250 | Reference< XInterface > xObj; | |||
| 251 | bAssign = extract( | |||
| 252 | rValue, (typelib_InterfaceTypeDescription *)pTD, xObj, | |||
| 253 | getReflection() ); | |||
| 254 | if (bAssign) | |||
| 255 | { | |||
| 256 | *(void **)pArg = getReflection()->getCpp2Uno().mapInterface( | |||
| 257 | xObj.get(), (typelib_InterfaceTypeDescription *)pTD ); | |||
| 258 | } | |||
| 259 | } | |||
| 260 | else | |||
| 261 | { | |||
| 262 | typelib_TypeDescription * pValueTD = 0; | |||
| 263 | TYPELIB_DANGER_GET( &pValueTD, rValue.getValueTypeRef() ){ typelib_TypeDescriptionReference * pMacroTypeRef = (rValue. getValueTypeRef()); typelib_TypeDescription ** ppMacroTypeDescr = (&pValueTD); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||
| 264 | // construct temp uno val to do proper assignment: todo opt | |||
| 265 | void * pTemp = alloca( pValueTD->nSize )__builtin_alloca (pValueTD->nSize); | |||
| 266 | uno_copyAndConvertData( | |||
| 267 | pTemp, (void *)rValue.getValue(), pValueTD, getReflection()->getCpp2Uno().get() ); | |||
| 268 | uno_constructData( | |||
| 269 | pArg, pTD ); | |||
| 270 | // assignment does simple conversion | |||
| 271 | bAssign = uno_assignData( | |||
| 272 | pArg, pTD, pTemp, pValueTD, 0, 0, 0 ); | |||
| 273 | uno_destructData( | |||
| 274 | pTemp, pValueTD, 0 ); | |||
| 275 | TYPELIB_DANGER_RELEASE( pValueTD ){ if ((((pValueTD)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((pValueTD)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( pValueTD ); }; | |||
| 276 | } | |||
| 277 | ||||
| 278 | if (bAssign) | |||
| 279 | { | |||
| 280 | uno_Any aExc; | |||
| 281 | uno_Any * pExc = &aExc; | |||
| 282 | (*pUnoI->pDispatcher)( pUnoI, getTypeDescr(), 0, pArgs, &pExc ); | |||
| 283 | (*pUnoI->release)( pUnoI ); | |||
| 284 | ||||
| 285 | uno_destructData( pArg, pTD, 0 ); | |||
| 286 | checkException( | |||
| 287 | pExc, | |||
| 288 | *static_cast< Reference< XInterface > const * >( | |||
| 289 | rObj.getValue())); | |||
| 290 | return; | |||
| 291 | } | |||
| 292 | (*pUnoI->release)( pUnoI ); | |||
| 293 | ||||
| 294 | throw IllegalArgumentException( | |||
| 295 | OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!")(&("illegal value given!")[0]), ((sal_Int32)((sizeof ("illegal value given!" ) / sizeof (("illegal value given!")[0]))-1)), (((rtl_TextEncoding ) 11)) ), | |||
| 296 | *(const Reference< XInterface > *)rObj.getValue(), 1 ); | |||
| 297 | } | |||
| 298 | throw IllegalArgumentException( | |||
| 299 | OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!")(&("illegal destination object given!")[0]), ((sal_Int32) ((sizeof ("illegal destination object given!") / sizeof (("illegal destination object given!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
| 300 | (XWeak *)(OWeakObject *)this, 0 ); | |||
| 301 | } | |||
| 302 | //__________________________________________________________________________________________________ | |||
| 303 | void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue ) | |||
| 304 | throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException) | |||
| 305 | { | |||
| 306 | IdlAttributeFieldImpl::set( const_cast< Any & >( rObj ), rValue ); | |||
| 307 | } | |||
| 308 | ||||
| 309 | void IdlAttributeFieldImpl::checkException( | |||
| 310 | uno_Any * exception, Reference< XInterface > const & context) | |||
| 311 | { | |||
| 312 | if (exception != 0) { | |||
| 313 | Any e; | |||
| 314 | uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release)); | |||
| 315 | uno_type_any_constructAndConvert( | |||
| 316 | &e, exception->pData, exception->pType, | |||
| 317 | getReflection()->getUno2Cpp().get()); | |||
| 318 | uno_any_destruct(exception, 0); | |||
| 319 | if (e.isExtractableTo( | |||
| 320 | getCppuType(static_cast< RuntimeException const * >(0)))) | |||
| 321 | { | |||
| 322 | cppu::throwException(e); | |||
| 323 | } else { | |||
| 324 | throw WrappedTargetRuntimeException( | |||
| 325 | OUString( | |||
| 326 | RTL_CONSTASCII_USTRINGPARAM((&("non-RuntimeException occurred when accessing an" " interface type attribute" )[0]), ((sal_Int32)((sizeof ("non-RuntimeException occurred when accessing an" " interface type attribute") / sizeof (("non-RuntimeException occurred when accessing an" " interface type attribute")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
| 327 | "non-RuntimeException occurred when accessing an"(&("non-RuntimeException occurred when accessing an" " interface type attribute" )[0]), ((sal_Int32)((sizeof ("non-RuntimeException occurred when accessing an" " interface type attribute") / sizeof (("non-RuntimeException occurred when accessing an" " interface type attribute")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
| 328 | " interface type attribute")(&("non-RuntimeException occurred when accessing an" " interface type attribute" )[0]), ((sal_Int32)((sizeof ("non-RuntimeException occurred when accessing an" " interface type attribute") / sizeof (("non-RuntimeException occurred when accessing an" " interface type attribute")[0]))-1)), (((rtl_TextEncoding) 11 ))), | |||
| 329 | context, e); | |||
| 330 | } | |||
| 331 | } | |||
| 332 | } | |||
| 333 | ||||
| 334 | //################################################################################################## | |||
| 335 | //################################################################################################## | |||
| 336 | //################################################################################################## | |||
| 337 | ||||
| 338 | ||||
| 339 | //================================================================================================== | |||
| 340 | class IdlInterfaceMethodImpl | |||
| 341 | : public IdlMemberImpl | |||
| 342 | , public XIdlMethod | |||
| 343 | { | |||
| 344 | Sequence< Reference< XIdlClass > > * _pExceptionTypes; | |||
| 345 | Sequence< Reference< XIdlClass > > * _pParamTypes; | |||
| 346 | Sequence< ParamInfo > * _pParamInfos; | |||
| 347 | ||||
| 348 | public: | |||
| 349 | typelib_InterfaceMethodTypeDescription * getMethodTypeDescr() | |||
| 350 | { return (typelib_InterfaceMethodTypeDescription *)getTypeDescr(); } | |||
| 351 | ||||
| 352 | IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName, | |||
| 353 | typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr ) | |||
| 354 | : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr ) | |||
| 355 | , _pExceptionTypes( 0 ) | |||
| 356 | , _pParamTypes( 0 ) | |||
| 357 | , _pParamInfos( 0 ) | |||
| 358 | {} | |||
| 359 | virtual ~IdlInterfaceMethodImpl(); | |||
| 360 | ||||
| 361 | // XInterface | |||
| 362 | virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException); | |||
| 363 | virtual void SAL_CALL acquire() throw(); | |||
| 364 | virtual void SAL_CALL release() throw(); | |||
| 365 | ||||
| 366 | // XTypeProvider | |||
| 367 | virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); | |||
| 368 | virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); | |||
| 369 | ||||
| 370 | // XIdlMember | |||
| 371 | virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException); | |||
| 372 | virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); | |||
| 373 | // XIdlMethod | |||
| 374 | virtual Reference< XIdlClass > SAL_CALL getReturnType() throw(::com::sun::star::uno::RuntimeException); | |||
| 375 | virtual Sequence< Reference< XIdlClass > > SAL_CALL getParameterTypes() throw(::com::sun::star::uno::RuntimeException); | |||
| 376 | virtual Sequence< ParamInfo > SAL_CALL getParameterInfos() throw(::com::sun::star::uno::RuntimeException); | |||
| 377 | virtual Sequence< Reference< XIdlClass > > SAL_CALL getExceptionTypes() throw(::com::sun::star::uno::RuntimeException); | |||
| 378 | virtual MethodMode SAL_CALL getMode() throw(::com::sun::star::uno::RuntimeException); | |||
| 379 | virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); | |||
| 380 | }; | |||
| 381 | //__________________________________________________________________________________________________ | |||
| 382 | IdlInterfaceMethodImpl::~IdlInterfaceMethodImpl() | |||
| 383 | { | |||
| 384 | delete _pParamInfos; | |||
| 385 | delete _pParamTypes; | |||
| 386 | delete _pExceptionTypes; | |||
| 387 | } | |||
| 388 | ||||
| 389 | // XInterface | |||
| 390 | //__________________________________________________________________________________________________ | |||
| 391 | Any IdlInterfaceMethodImpl::queryInterface( const Type & rType ) | |||
| 392 | throw(::com::sun::star::uno::RuntimeException) | |||
| 393 | { | |||
| 394 | Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlMethod * >( this ) ) ); | |||
| 395 | return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType )); | |||
| 396 | } | |||
| 397 | //__________________________________________________________________________________________________ | |||
| 398 | void IdlInterfaceMethodImpl::acquire() throw() | |||
| 399 | { | |||
| 400 | IdlMemberImpl::acquire(); | |||
| 401 | } | |||
| 402 | //__________________________________________________________________________________________________ | |||
| 403 | void IdlInterfaceMethodImpl::release() throw() | |||
| 404 | { | |||
| 405 | IdlMemberImpl::release(); | |||
| 406 | } | |||
| 407 | ||||
| 408 | // XTypeProvider | |||
| 409 | //__________________________________________________________________________________________________ | |||
| 410 | Sequence< Type > IdlInterfaceMethodImpl::getTypes() | |||
| 411 | throw (::com::sun::star::uno::RuntimeException) | |||
| 412 | { | |||
| 413 | static OTypeCollection * s_pTypes = 0; | |||
| 414 | if (! s_pTypes) | |||
| 415 | { | |||
| 416 | MutexGuard aGuard( getMutexAccess() ); | |||
| 417 | if (! s_pTypes) | |||
| 418 | { | |||
| 419 | static OTypeCollection s_aTypes( | |||
| 420 | ::getCppuType( (const Reference< XIdlMethod > *)0 ), | |||
| 421 | IdlMemberImpl::getTypes() ); | |||
| 422 | s_pTypes = &s_aTypes; | |||
| 423 | } | |||
| 424 | } | |||
| 425 | return s_pTypes->getTypes(); | |||
| 426 | } | |||
| 427 | //__________________________________________________________________________________________________ | |||
| 428 | Sequence< sal_Int8 > IdlInterfaceMethodImpl::getImplementationId() | |||
| 429 | throw (::com::sun::star::uno::RuntimeException) | |||
| 430 | { | |||
| 431 | static OImplementationId * s_pId = 0; | |||
| 432 | if (! s_pId) | |||
| 433 | { | |||
| 434 | MutexGuard aGuard( getMutexAccess() ); | |||
| 435 | if (! s_pId) | |||
| 436 | { | |||
| 437 | static OImplementationId s_aId; | |||
| 438 | s_pId = &s_aId; | |||
| 439 | } | |||
| 440 | } | |||
| 441 | return s_pId->getImplementationId(); | |||
| 442 | } | |||
| 443 | ||||
| 444 | // XIdlMember | |||
| 445 | //__________________________________________________________________________________________________ | |||
| 446 | Reference< XIdlClass > IdlInterfaceMethodImpl::getDeclaringClass() | |||
| 447 | throw(::com::sun::star::uno::RuntimeException) | |||
| 448 | { | |||
| 449 | if (! _xDeclClass.is()) | |||
| 450 | { | |||
| 451 | MutexGuard aGuard( getMutexAccess() ); | |||
| 452 | if (! _xDeclClass.is()) | |||
| 453 | { | |||
| 454 | rtl::OUString aName(getMethodTypeDescr()->aBase.aBase.pTypeName); | |||
| 455 | sal_Int32 i = aName.indexOf(':'); | |||
| 456 | OSL_ASSERT(i >= 0)do { if (true && (!(i >= 0))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "456" ": "), "OSL_ASSERT: %s", "i >= 0"); } } while ( false); | |||
| 457 | _xDeclClass = getReflection()->forName(aName.copy(0, i)); | |||
| 458 | } | |||
| 459 | } | |||
| 460 | return _xDeclClass; | |||
| 461 | } | |||
| 462 | //__________________________________________________________________________________________________ | |||
| 463 | OUString IdlInterfaceMethodImpl::getName() | |||
| 464 | throw(::com::sun::star::uno::RuntimeException) | |||
| 465 | { | |||
| 466 | return IdlMemberImpl::getName(); | |||
| 467 | } | |||
| 468 | ||||
| 469 | // XIdlMethod | |||
| 470 | //__________________________________________________________________________________________________ | |||
| 471 | Reference< XIdlClass > SAL_CALL IdlInterfaceMethodImpl::getReturnType() | |||
| 472 | throw(::com::sun::star::uno::RuntimeException) | |||
| 473 | { | |||
| 474 | return getReflection()->forType( getMethodTypeDescr()->pReturnTypeRef ); | |||
| 475 | } | |||
| 476 | //__________________________________________________________________________________________________ | |||
| 477 | Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes() | |||
| 478 | throw(::com::sun::star::uno::RuntimeException) | |||
| 479 | { | |||
| 480 | if (! _pExceptionTypes) | |||
| 481 | { | |||
| 482 | MutexGuard aGuard( getMutexAccess() ); | |||
| 483 | if (! _pExceptionTypes) | |||
| 484 | { | |||
| 485 | sal_Int32 nExc = getMethodTypeDescr()->nExceptions; | |||
| 486 | Sequence< Reference< XIdlClass > > * pTempExceptionTypes = | |||
| 487 | new Sequence< Reference< XIdlClass > >( nExc ); | |||
| 488 | Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray(); | |||
| 489 | ||||
| 490 | typelib_TypeDescriptionReference ** ppExc = | |||
| 491 | getMethodTypeDescr()->ppExceptions; | |||
| 492 | IdlReflectionServiceImpl * pRefl = getReflection(); | |||
| 493 | ||||
| 494 | while (nExc--) | |||
| 495 | pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] ); | |||
| 496 | ||||
| 497 | _pExceptionTypes = pTempExceptionTypes; | |||
| 498 | } | |||
| 499 | } | |||
| 500 | return *_pExceptionTypes; | |||
| 501 | } | |||
| 502 | //__________________________________________________________________________________________________ | |||
| 503 | Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes() | |||
| 504 | throw(::com::sun::star::uno::RuntimeException) | |||
| 505 | { | |||
| 506 | if (! _pParamTypes) | |||
| 507 | { | |||
| 508 | MutexGuard aGuard( getMutexAccess() ); | |||
| 509 | if (! _pParamTypes) | |||
| 510 | { | |||
| 511 | sal_Int32 nParams = getMethodTypeDescr()->nParams; | |||
| 512 | Sequence< Reference< XIdlClass > > * pTempParamTypes = | |||
| 513 | new Sequence< Reference< XIdlClass > >( nParams ); | |||
| 514 | Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray(); | |||
| 515 | ||||
| 516 | typelib_MethodParameter * pTypelibParams = | |||
| 517 | getMethodTypeDescr()->pParams; | |||
| 518 | IdlReflectionServiceImpl * pRefl = getReflection(); | |||
| 519 | ||||
| 520 | while (nParams--) | |||
| 521 | pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef ); | |||
| 522 | ||||
| 523 | _pParamTypes = pTempParamTypes; | |||
| 524 | } | |||
| 525 | } | |||
| 526 | return *_pParamTypes; | |||
| 527 | } | |||
| 528 | //__________________________________________________________________________________________________ | |||
| 529 | Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos() | |||
| 530 | throw(::com::sun::star::uno::RuntimeException) | |||
| 531 | { | |||
| 532 | if (! _pParamInfos) | |||
| 533 | { | |||
| 534 | MutexGuard aGuard( getMutexAccess() ); | |||
| 535 | if (! _pParamInfos) | |||
| 536 | { | |||
| 537 | sal_Int32 nParams = getMethodTypeDescr()->nParams; | |||
| 538 | Sequence< ParamInfo > * pTempParamInfos = new Sequence< ParamInfo >( nParams ); | |||
| 539 | ParamInfo * pParamInfos = pTempParamInfos->getArray(); | |||
| 540 | ||||
| 541 | typelib_MethodParameter * pTypelibParams = | |||
| 542 | getMethodTypeDescr()->pParams; | |||
| 543 | ||||
| 544 | if (_pParamTypes) // use param types | |||
| 545 | { | |||
| 546 | const Reference< XIdlClass > * pParamTypes = _pParamTypes->getConstArray(); | |||
| 547 | ||||
| 548 | while (nParams--) | |||
| 549 | { | |||
| 550 | const typelib_MethodParameter & rParam = pTypelibParams[nParams]; | |||
| 551 | ParamInfo & rInfo = pParamInfos[nParams]; | |||
| 552 | rInfo.aName = rParam.pName; | |||
| 553 | if (rParam.bIn) | |||
| 554 | rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN); | |||
| 555 | else | |||
| 556 | rInfo.aMode = ParamMode_OUT; | |||
| 557 | rInfo.aType = pParamTypes[nParams]; | |||
| 558 | } | |||
| 559 | } | |||
| 560 | else // make also param types sequence if not already initialized | |||
| 561 | { | |||
| 562 | Sequence< Reference< XIdlClass > > * pTempParamTypes = | |||
| 563 | new Sequence< Reference< XIdlClass > >( nParams ); | |||
| 564 | Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray(); | |||
| 565 | ||||
| 566 | IdlReflectionServiceImpl * pRefl = getReflection(); | |||
| 567 | ||||
| 568 | while (nParams--) | |||
| 569 | { | |||
| 570 | const typelib_MethodParameter & rParam = pTypelibParams[nParams]; | |||
| 571 | ParamInfo & rInfo = pParamInfos[nParams]; | |||
| 572 | rInfo.aName = rParam.pName; | |||
| 573 | if (rParam.bIn) | |||
| 574 | rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN); | |||
| 575 | else | |||
| 576 | rInfo.aMode = ParamMode_OUT; | |||
| 577 | rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef ); | |||
| 578 | } | |||
| 579 | ||||
| 580 | _pParamTypes = pTempParamTypes; | |||
| 581 | } | |||
| 582 | ||||
| 583 | _pParamInfos = pTempParamInfos; | |||
| 584 | } | |||
| 585 | } | |||
| 586 | return *_pParamInfos; | |||
| 587 | } | |||
| 588 | //__________________________________________________________________________________________________ | |||
| 589 | MethodMode SAL_CALL IdlInterfaceMethodImpl::getMode() | |||
| 590 | throw(::com::sun::star::uno::RuntimeException) | |||
| 591 | { | |||
| 592 | return | |||
| 593 | getMethodTypeDescr()->bOneWay ? MethodMode_ONEWAY : MethodMode_TWOWAY; | |||
| 594 | } | |||
| 595 | //__________________________________________________________________________________________________ | |||
| 596 | Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & rArgs ) | |||
| 597 | throw(::com::sun::star::lang::IllegalArgumentException, | |||
| 598 | ::com::sun::star::reflection::InvocationTargetException, | |||
| 599 | ::com::sun::star::uno::RuntimeException) | |||
| 600 | { | |||
| 601 | if (rObj.getValueTypeClass() == TypeClass_INTERFACE) | |||
| 602 | { | |||
| 603 | // acquire()/ release() | |||
| 604 | if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer, | |||
| 605 | "com.sun.star.uno.XInterface::acquire" ) == 0) | |||
| 606 | { | |||
| 607 | (*(const Reference< XInterface > *)rObj.getValue())->acquire(); | |||
| 608 | return Any(); | |||
| 609 | } | |||
| 610 | else if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer, | |||
| 611 | "com.sun.star.uno.XInterface::release" ) == 0) | |||
| 612 | { | |||
| 613 | (*(const Reference< XInterface > *)rObj.getValue())->release(); | |||
| 614 | return Any(); | |||
| 615 | } | |||
| 616 | } | |||
| 617 | ||||
| 618 | uno_Interface * pUnoI = getReflection()->mapToUno( | |||
| 619 | rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() ); | |||
| 620 | OSL_ENSURE( pUnoI, "### illegal destination object given!" )do { if (true && (!(pUnoI))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "620" ": "), "%s", "### illegal destination object given!" ); } } while (false); | |||
| 621 | if (pUnoI) | |||
| 622 | { | |||
| 623 | sal_Int32 nParams = getMethodTypeDescr()->nParams; | |||
| 624 | if (rArgs.getLength() != nParams) | |||
| 625 | { | |||
| 626 | (*pUnoI->release)( pUnoI ); | |||
| 627 | throw IllegalArgumentException( | |||
| 628 | OUString( RTL_CONSTASCII_USTRINGPARAM("arguments len differ!")(&("arguments len differ!")[0]), ((sal_Int32)((sizeof ("arguments len differ!" ) / sizeof (("arguments len differ!")[0]))-1)), (((rtl_TextEncoding ) 11)) ), | |||
| 629 | *(const Reference< XInterface > *)rObj.getValue(), 1 ); | |||
| 630 | } | |||
| 631 | ||||
| 632 | Any * pCppArgs = rArgs.getArray(); | |||
| 633 | typelib_MethodParameter * pParams = getMethodTypeDescr()->pParams; | |||
| 634 | typelib_TypeDescription * pReturnType = 0; | |||
| 635 | TYPELIB_DANGER_GET({ typelib_TypeDescriptionReference * pMacroTypeRef = (getMethodTypeDescr ()->pReturnTypeRef); typelib_TypeDescription ** ppMacroTypeDescr = (&pReturnType); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass ) == typelib_TypeClass_INTERFACE_ATTRIBUTE)) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); } else if (!pMacroTypeRef ->pType || !pMacroTypeRef->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } } | |||
| 636 | &pReturnType, getMethodTypeDescr()->pReturnTypeRef ){ typelib_TypeDescriptionReference * pMacroTypeRef = (getMethodTypeDescr ()->pReturnTypeRef); typelib_TypeDescription ** ppMacroTypeDescr = (&pReturnType); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass ) == typelib_TypeClass_INTERFACE_ATTRIBUTE)) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); } else if (!pMacroTypeRef ->pType || !pMacroTypeRef->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||
| 637 | ||||
| 638 | void * pUnoReturn = alloca( pReturnType->nSize )__builtin_alloca (pReturnType->nSize); | |||
| 639 | void ** ppUnoArgs = (void **)alloca( sizeof(void *) * nParams *2 )__builtin_alloca (sizeof(void *) * nParams *2); | |||
| 640 | typelib_TypeDescription ** ppParamTypes = (typelib_TypeDescription **)(ppUnoArgs + nParams); | |||
| 641 | ||||
| 642 | // convert arguments | |||
| 643 | for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) | |||
| 644 | { | |||
| 645 | ppParamTypes[nPos] = 0; | |||
| 646 | TYPELIB_DANGER_GET( ppParamTypes + nPos, pParams[nPos].pTypeRef ){ typelib_TypeDescriptionReference * pMacroTypeRef = (pParams [nPos].pTypeRef); typelib_TypeDescription ** ppMacroTypeDescr = (ppParamTypes + nPos); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef-> eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE)) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); } else if (!pMacroTypeRef ->pType || !pMacroTypeRef->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||
| 647 | typelib_TypeDescription * pTD = ppParamTypes[nPos]; | |||
| 648 | ||||
| 649 | ppUnoArgs[nPos] = alloca( pTD->nSize )__builtin_alloca (pTD->nSize); | |||
| 650 | if (pParams[nPos].bIn) | |||
| 651 | { | |||
| 652 | sal_Bool bAssign; | |||
| 653 | if (typelib_typedescriptionreference_equals( | |||
| 654 | pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef )) | |||
| 655 | { | |||
| 656 | uno_type_copyAndConvertData( | |||
| 657 | ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(), | |||
| 658 | pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() ); | |||
| 659 | bAssign = sal_True((sal_Bool)1); | |||
| 660 | } | |||
| 661 | else if (pTD->eTypeClass == typelib_TypeClass_ANY) | |||
| 662 | { | |||
| 663 | uno_type_any_constructAndConvert( | |||
| 664 | (uno_Any *)ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(), | |||
| 665 | pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() ); | |||
| 666 | bAssign = sal_True((sal_Bool)1); | |||
| 667 | } | |||
| 668 | else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE) | |||
| 669 | { | |||
| 670 | Reference< XInterface > xDest; | |||
| 671 | bAssign = extract( | |||
| 672 | pCppArgs[nPos], (typelib_InterfaceTypeDescription *)pTD, | |||
| 673 | xDest, getReflection() ); | |||
| 674 | if (bAssign) | |||
| 675 | { | |||
| 676 | *(void **)ppUnoArgs[nPos] = getReflection()->getCpp2Uno().mapInterface( | |||
| 677 | xDest.get(), (typelib_InterfaceTypeDescription *)pTD ); | |||
| 678 | } | |||
| 679 | } | |||
| 680 | else | |||
| 681 | { | |||
| 682 | typelib_TypeDescription * pValueTD = 0; | |||
| 683 | TYPELIB_DANGER_GET( &pValueTD, pCppArgs[nPos].getValueTypeRef() ){ typelib_TypeDescriptionReference * pMacroTypeRef = (pCppArgs [nPos].getValueTypeRef()); typelib_TypeDescription ** ppMacroTypeDescr = (&pValueTD); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||
| 684 | // construct temp uno val to do proper assignment: todo opt | |||
| 685 | void * pTemp = alloca( pValueTD->nSize )__builtin_alloca (pValueTD->nSize); | |||
| 686 | uno_copyAndConvertData( | |||
| 687 | pTemp, (void *)pCppArgs[nPos].getValue(), pValueTD, | |||
| 688 | getReflection()->getCpp2Uno().get() ); | |||
| 689 | uno_constructData( | |||
| 690 | ppUnoArgs[nPos], pTD ); | |||
| 691 | // assignment does simple conversion | |||
| 692 | bAssign = uno_assignData( | |||
| 693 | ppUnoArgs[nPos], pTD, pTemp, pValueTD, 0, 0, 0 ); | |||
| 694 | uno_destructData( | |||
| 695 | pTemp, pValueTD, 0 ); | |||
| 696 | TYPELIB_DANGER_RELEASE( pValueTD ){ if ((((pValueTD)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((pValueTD)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( pValueTD ); }; | |||
| 697 | } | |||
| 698 | ||||
| 699 | if (! bAssign) | |||
| 700 | { | |||
| 701 | IllegalArgumentException aExc( | |||
| 702 | OUString( RTL_CONSTASCII_USTRINGPARAM("cannot coerce argument type during corereflection call!")(&("cannot coerce argument type during corereflection call!" )[0]), ((sal_Int32)((sizeof ("cannot coerce argument type during corereflection call!" ) / sizeof (("cannot coerce argument type during corereflection call!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
| 703 | *(const Reference< XInterface > *)rObj.getValue(), (sal_Int16)nPos ); | |||
| 704 | ||||
| 705 | // cleanup | |||
| 706 | while (nPos--) | |||
| 707 | { | |||
| 708 | if (pParams[nPos].bIn) | |||
| 709 | uno_destructData( ppUnoArgs[nPos], ppParamTypes[nPos], 0 ); | |||
| 710 | TYPELIB_DANGER_RELEASE( ppParamTypes[nPos] ){ if ((((ppParamTypes[nPos])->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((ppParamTypes[nPos])->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( ppParamTypes[nPos] ); }; | |||
| 711 | } | |||
| 712 | TYPELIB_DANGER_RELEASE( pReturnType ){ if ((((pReturnType)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((pReturnType)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( pReturnType ); }; | |||
| 713 | (*pUnoI->release)( pUnoI ); | |||
| 714 | ||||
| 715 | throw aExc; | |||
| 716 | } | |||
| 717 | } | |||
| 718 | } | |||
| 719 | ||||
| 720 | uno_Any aUnoExc; | |||
| 721 | uno_Any * pUnoExc = &aUnoExc; | |||
| 722 | ||||
| 723 | (*pUnoI->pDispatcher)( | |||
| 724 | pUnoI, getTypeDescr(), pUnoReturn, ppUnoArgs, &pUnoExc ); | |||
| 725 | (*pUnoI->release)( pUnoI ); | |||
| 726 | ||||
| 727 | Any aRet; | |||
| 728 | if (pUnoExc) | |||
| 729 | { | |||
| 730 | // cleanup | |||
| 731 | while (nParams--) | |||
| 732 | { | |||
| 733 | if (pParams[nParams].bIn) | |||
| 734 | uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], 0 ); | |||
| 735 | TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] ){ if ((((ppParamTypes[nParams])->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((ppParamTypes[nParams])->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( ppParamTypes[nParams] ); }; | |||
| 736 | } | |||
| 737 | TYPELIB_DANGER_RELEASE( pReturnType ){ if ((((pReturnType)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((pReturnType)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( pReturnType ); }; | |||
| 738 | ||||
| 739 | InvocationTargetException aExc; | |||
| 740 | aExc.Context = *(const Reference< XInterface > *)rObj.getValue(); | |||
| 741 | aExc.Message = OUString( RTL_CONSTASCII_USTRINGPARAM("exception occurred during invocation!")(&("exception occurred during invocation!")[0]), ((sal_Int32 )((sizeof ("exception occurred during invocation!") / sizeof ( ("exception occurred during invocation!")[0]))-1)), (((rtl_TextEncoding ) 11)) ); | |||
| 742 | uno_any_destruct( | |||
| 743 | &aExc.TargetException, | |||
| 744 | reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); | |||
| 745 | uno_type_copyAndConvertData( | |||
| 746 | &aExc.TargetException, pUnoExc, ::getCppuType( (const Any *)0 ).getTypeLibType(), | |||
| 747 | getReflection()->getUno2Cpp().get() ); | |||
| 748 | uno_any_destruct( pUnoExc, 0 ); | |||
| 749 | throw aExc; | |||
| 750 | } | |||
| 751 | else | |||
| 752 | { | |||
| 753 | // reconvert arguments and cleanup | |||
| 754 | while (nParams--) | |||
| 755 | { | |||
| 756 | if (pParams[nParams].bOut) // write back | |||
| 757 | { | |||
| 758 | uno_any_destruct( | |||
| 759 | &pCppArgs[nParams], | |||
| 760 | reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); | |||
| 761 | uno_any_constructAndConvert( | |||
| 762 | &pCppArgs[nParams], ppUnoArgs[nParams], ppParamTypes[nParams], | |||
| 763 | getReflection()->getUno2Cpp().get() ); | |||
| 764 | } | |||
| 765 | uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], 0 ); | |||
| 766 | TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] ){ if ((((ppParamTypes[nParams])->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((ppParamTypes[nParams])->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( ppParamTypes[nParams] ); }; | |||
| 767 | } | |||
| 768 | uno_any_destruct( | |||
| 769 | &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); | |||
| 770 | uno_any_constructAndConvert( | |||
| 771 | &aRet, pUnoReturn, pReturnType, | |||
| 772 | getReflection()->getUno2Cpp().get() ); | |||
| 773 | uno_destructData( pUnoReturn, pReturnType, 0 ); | |||
| 774 | TYPELIB_DANGER_RELEASE( pReturnType ){ if ((((pReturnType)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((pReturnType)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( pReturnType ); }; | |||
| 775 | } | |||
| 776 | return aRet; | |||
| 777 | } | |||
| 778 | throw IllegalArgumentException( | |||
| 779 | OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!")(&("illegal destination object given!")[0]), ((sal_Int32) ((sizeof ("illegal destination object given!") / sizeof (("illegal destination object given!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
| 780 | (XWeak *)(OWeakObject *)this, 0 ); | |||
| 781 | } | |||
| 782 | ||||
| 783 | ||||
| 784 | //################################################################################################## | |||
| 785 | //################################################################################################## | |||
| 786 | //################################################################################################## | |||
| 787 | ||||
| 788 | ||||
| 789 | //__________________________________________________________________________________________________ | |||
| 790 | InterfaceIdlClassImpl::~InterfaceIdlClassImpl() | |||
| 791 | { | |||
| 792 | for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; ) | |||
| 793 | typelib_typedescription_release( _pSortedMemberInit[nPos].second ); | |||
| 794 | ||||
| 795 | delete [] _pSortedMemberInit; | |||
| 796 | } | |||
| 797 | ||||
| 798 | //__________________________________________________________________________________________________ | |||
| 799 | Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses() | |||
| 800 | throw(::com::sun::star::uno::RuntimeException) | |||
| 801 | { | |||
| 802 | MutexGuard aGuard(getMutexAccess()); | |||
| 803 | if (_xSuperClasses.getLength() == 0) { | |||
| 804 | typelib_InterfaceTypeDescription * pType = getTypeDescr(); | |||
| 805 | _xSuperClasses.realloc(pType->nBaseTypes); | |||
| 806 | for (sal_Int32 i = 0; i < pType->nBaseTypes; ++i) { | |||
| 807 | _xSuperClasses[i] = getReflection()->forType( | |||
| 808 | &pType->ppBaseTypes[i]->aBase); | |||
| 809 | OSL_ASSERT(_xSuperClasses[i].is())do { if (true && (!(_xSuperClasses[i].is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "809" ": "), "OSL_ASSERT: %s", "_xSuperClasses[i].is()") ; } } while (false); | |||
| 810 | } | |||
| 811 | } | |||
| 812 | return Sequence< Reference< XIdlClass > >(_xSuperClasses); | |||
| 813 | } | |||
| 814 | //__________________________________________________________________________________________________ | |||
| 815 | void InterfaceIdlClassImpl::initMembers() | |||
| 816 | { | |||
| 817 | sal_Int32 nAll = getTypeDescr()->nAllMembers; | |||
| 818 | MemberInit * pSortedMemberInit = new MemberInit[nAll]; | |||
| 819 | typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers; | |||
| 820 | ||||
| 821 | for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos ) | |||
| 822 | { | |||
| 823 | sal_Int32 nIndex; | |||
| 824 | if (ppAllMembers[nPos]->eTypeClass == typelib_TypeClass_INTERFACE_METHOD) | |||
| 825 | { | |||
| 826 | // methods to front | |||
| 827 | nIndex = _nMethods; | |||
| 828 | ++_nMethods; | |||
| 829 | } | |||
| 830 | else | |||
| 831 | { | |||
| 832 | ++_nAttributes; | |||
| 833 | nIndex = (nAll - _nAttributes); | |||
| 834 | // attributes at the back | |||
| 835 | } | |||
| 836 | ||||
| 837 | typelib_TypeDescription * pTD = 0; | |||
| 838 | typelib_typedescriptionreference_getDescription( &pTD, ppAllMembers[nPos] ); | |||
| 839 | OSL_ENSURE( pTD, "### cannot get type description!" )do { if (true && (!(pTD))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/corereflection/criface.cxx" ":" "839" ": "), "%s", "### cannot get type description!"); } } while (false); | |||
| 840 | pSortedMemberInit[nIndex].first = ((typelib_InterfaceMemberTypeDescription *)pTD)->pMemberName; | |||
| ||||
| 841 | pSortedMemberInit[nIndex].second = pTD; | |||
| 842 | } | |||
| 843 | ||||
| 844 | _pSortedMemberInit = pSortedMemberInit; | |||
| 845 | } | |||
| 846 | //__________________________________________________________________________________________________ | |||
| 847 | sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType ) | |||
| 848 | throw(::com::sun::star::uno::RuntimeException) | |||
| 849 | { | |||
| 850 | if (xType.is() && xType->getTypeClass() == TypeClass_INTERFACE) | |||
| 851 | { | |||
| 852 | if (equals( xType )) | |||
| 853 | return sal_True((sal_Bool)1); | |||
| 854 | else | |||
| 855 | { | |||
| 856 | const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses(); | |||
| 857 | for (sal_Int32 i = 0; i < rSeq.getLength(); ++i) { | |||
| 858 | if (isAssignableFrom(rSeq[i])) { | |||
| 859 | return true; | |||
| 860 | } | |||
| 861 | } | |||
| 862 | } | |||
| 863 | } | |||
| 864 | return sal_False((sal_Bool)0); | |||
| 865 | } | |||
| 866 | //__________________________________________________________________________________________________ | |||
| 867 | Uik InterfaceIdlClassImpl::getUik() | |||
| 868 | throw(::com::sun::star::uno::RuntimeException) | |||
| 869 | { | |||
| 870 | return Uik(0, 0, 0, 0, 0); | |||
| 871 | // Uiks are deprecated and this function must not be called | |||
| 872 | } | |||
| 873 | //__________________________________________________________________________________________________ | |||
| 874 | Sequence< Reference< XIdlMethod > > InterfaceIdlClassImpl::getMethods() | |||
| 875 | throw(::com::sun::star::uno::RuntimeException) | |||
| 876 | { | |||
| 877 | MutexGuard aGuard( getMutexAccess() ); | |||
| 878 | if (! _pSortedMemberInit) | |||
| 879 | initMembers(); | |||
| 880 | ||||
| 881 | // create methods sequence | |||
| 882 | Sequence< Reference< XIdlMethod > > aRet( _nMethods ); | |||
| 883 | Reference< XIdlMethod > * pRet = aRet.getArray(); | |||
| 884 | for ( sal_Int32 nPos = _nMethods; nPos--; ) | |||
| 885 | { | |||
| 886 | ||||
| 887 | /*_aName2Method[_pSortedMemberInit[nPos].first] = */pRet[nPos] = new IdlInterfaceMethodImpl( | |||
| 888 | getReflection(), _pSortedMemberInit[nPos].first, | |||
| 889 | _pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() ); | |||
| 890 | } | |||
| 891 | return aRet; | |||
| 892 | } | |||
| 893 | //__________________________________________________________________________________________________ | |||
| 894 | Sequence< Reference< XIdlField > > InterfaceIdlClassImpl::getFields() | |||
| 895 | throw(::com::sun::star::uno::RuntimeException) | |||
| 896 | { | |||
| 897 | MutexGuard aGuard( getMutexAccess() ); | |||
| 898 | if (! _pSortedMemberInit) | |||
| ||||
| 899 | initMembers(); | |||
| 900 | ||||
| 901 | // create fields sequence | |||
| 902 | Sequence< Reference< XIdlField > > aRet( _nAttributes ); | |||
| 903 | Reference< XIdlField > * pRet = aRet.getArray(); | |||
| 904 | for ( sal_Int32 nPos = _nAttributes; nPos--; ) | |||
| 905 | { | |||
| 906 | /*_aName2Field[_pSortedMemberInit[_nMethods+nPos].first] = */pRet[_nAttributes-nPos-1] = | |||
| 907 | new IdlAttributeFieldImpl( | |||
| 908 | getReflection(), _pSortedMemberInit[_nMethods+nPos].first, | |||
| 909 | _pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() ); | |||
| 910 | } | |||
| 911 | return aRet; | |||
| 912 | } | |||
| 913 | //__________________________________________________________________________________________________ | |||
| 914 | Reference< XIdlMethod > InterfaceIdlClassImpl::getMethod( const OUString & rName ) | |||
| 915 | throw(::com::sun::star::uno::RuntimeException) | |||
| 916 | { | |||
| 917 | MutexGuard aGuard( getMutexAccess() ); | |||
| 918 | if (! _pSortedMemberInit) | |||
| 919 | initMembers(); | |||
| 920 | ||||
| 921 | Reference< XIdlMethod > xRet; | |||
| 922 | ||||
| 923 | // try weak map | |||
| 924 | const OUString2Method::const_iterator iFind( _aName2Method.find( rName ) ); | |||
| 925 | if (iFind != _aName2Method.end()) | |||
| 926 | xRet = (*iFind).second; // harden ref | |||
| 927 | ||||
| 928 | if (! xRet.is()) | |||
| 929 | { | |||
| 930 | for ( sal_Int32 nPos = _nMethods; nPos--; ) | |||
| 931 | { | |||
| 932 | if (_pSortedMemberInit[nPos].first == rName) | |||
| 933 | { | |||
| 934 | _aName2Method[rName] = xRet = new IdlInterfaceMethodImpl( | |||
| 935 | getReflection(), rName, | |||
| 936 | _pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() ); | |||
| 937 | break; | |||
| 938 | } | |||
| 939 | } | |||
| 940 | } | |||
| 941 | return xRet; | |||
| 942 | } | |||
| 943 | //__________________________________________________________________________________________________ | |||
| 944 | Reference< XIdlField > InterfaceIdlClassImpl::getField( const OUString & rName ) | |||
| 945 | throw(::com::sun::star::uno::RuntimeException) | |||
| 946 | { | |||
| 947 | MutexGuard aGuard( getMutexAccess() ); | |||
| 948 | if (! _pSortedMemberInit) | |||
| 949 | initMembers(); | |||
| 950 | ||||
| 951 | Reference< XIdlField > xRet; | |||
| 952 | ||||
| 953 | // try weak map | |||
| 954 | const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) ); | |||
| 955 | if (iFind != _aName2Field.end()) | |||
| 956 | xRet = (*iFind).second; // harden ref | |||
| 957 | ||||
| 958 | if (! xRet.is()) | |||
| 959 | { | |||
| 960 | for ( sal_Int32 nPos = _nAttributes; nPos--; ) | |||
| 961 | { | |||
| 962 | if (_pSortedMemberInit[_nMethods+nPos].first == rName) | |||
| 963 | { | |||
| 964 | _aName2Field[rName] = xRet = new IdlAttributeFieldImpl( | |||
| 965 | getReflection(), rName, | |||
| 966 | _pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() ); | |||
| 967 | break; | |||
| 968 | } | |||
| 969 | } | |||
| 970 | } | |||
| 971 | return xRet; | |||
| 972 | } | |||
| 973 | //__________________________________________________________________________________________________ | |||
| 974 | void InterfaceIdlClassImpl::createObject( Any & rObj ) | |||
| 975 | throw(::com::sun::star::uno::RuntimeException) | |||
| 976 | { | |||
| 977 | // interfaces cannot be constructed | |||
| 978 | rObj.clear(); | |||
| 979 | } | |||
| 980 | ||||
| 981 | } | |||
| 982 | ||||
| 983 | ||||
| 984 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |