LCOV - code coverage report
Current view: top level - stoc/source/corereflection - base.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 0.0 %
Date: 2014-04-14 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : //  #define TEST_LIST_CLASSES
      20             : 
      21             : #include <osl/diagnose.h>
      22             : #include <osl/mutex.hxx>
      23             : #include <uno/mapping.hxx>
      24             : #include <uno/dispatcher.h>
      25             : #include <cppuhelper/weak.hxx>
      26             : #include <cppuhelper/factory.hxx>
      27             : #include <cppuhelper/component.hxx>
      28             : #include <cppuhelper/typeprovider.hxx>
      29             : #include <rtl/ustring.hxx>
      30             : 
      31             : #include "lrucache.hxx"
      32             : 
      33             : #ifdef TEST_LIST_CLASSES
      34             : #include <list>
      35             : #include <algorithm>
      36             : #endif
      37             : #include <boost/unordered_map.hpp>
      38             : 
      39             : #include <com/sun/star/uno/XComponentContext.hpp>
      40             : #include <com/sun/star/lang/XServiceInfo.hpp>
      41             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      42             : 
      43             : #include <com/sun/star/reflection/XIdlClass.hpp>
      44             : #include <com/sun/star/reflection/XIdlReflection.hpp>
      45             : #include <com/sun/star/reflection/XIdlField.hpp>
      46             : #include <com/sun/star/reflection/XIdlField2.hpp>
      47             : #include <com/sun/star/reflection/XIdlMethod.hpp>
      48             : 
      49             : using namespace std;
      50             : using namespace osl;
      51             : using namespace cppu;
      52             : using namespace com::sun::star::uno;
      53             : using namespace com::sun::star::lang;
      54             : using namespace com::sun::star::reflection;
      55             : using namespace com::sun::star::container;
      56             : 
      57             : namespace stoc_corefl
      58             : {
      59             : 
      60             : #ifdef TEST_LIST_CLASSES
      61             : typedef list< OUString > ClassNameList;
      62             : extern ClassNameList g_aClassNames;
      63             : #endif
      64             : 
      65             : 
      66             : Mutex & getMutexAccess();
      67             : 
      68             : 
      69           0 : inline bool td_equals( typelib_TypeDescription * pTD, typelib_TypeDescriptionReference * pType )
      70             : {
      71           0 :     return (pTD->pWeakRef == pType ||
      72           0 :             (pTD->pTypeName->length == pType->pTypeName->length &&
      73           0 :              rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0));
      74             : }
      75             : 
      76             : inline typelib_TypeDescription * getTypeByName( const OUString & rName )
      77             : {
      78             :     typelib_TypeDescription * pTypeDescr = 0;
      79             :     typelib_typedescription_getByName( &pTypeDescr, rName.pData );
      80             :     if (! pTypeDescr->bComplete)
      81             :         typelib_typedescription_complete( &pTypeDescr );
      82             :     return pTypeDescr;
      83             : }
      84             : 
      85             : typedef boost::unordered_map< OUString, WeakReference< XIdlField >,
      86             :     FctHashOUString, equal_to< OUString > > OUString2Field;
      87             : typedef boost::unordered_map< OUString, WeakReference< XIdlMethod >,
      88             :     FctHashOUString, equal_to< OUString > > OUString2Method;
      89             : 
      90             : 
      91             : class IdlReflectionServiceImpl
      92             :     : public OComponentHelper
      93             :     , public XIdlReflection
      94             :     , public XHierarchicalNameAccess
      95             :     , public XServiceInfo
      96             : {
      97             :     Mutex                                   _aComponentMutex;
      98             :     Reference< XMultiServiceFactory >       _xMgr;
      99             :     Reference< XHierarchicalNameAccess >    _xTDMgr;
     100             : 
     101             :     // caching
     102             :     LRU_CacheAnyByOUString                  _aElements;
     103             : 
     104             :     Mapping                     _aCpp2Uno;
     105             :     Mapping                     _aUno2Cpp;
     106             : 
     107             :     inline Reference< XIdlClass > constructClass( typelib_TypeDescription * pTypeDescr );
     108             : public:
     109             :     Reference< XHierarchicalNameAccess > getTDMgr() const
     110             :         { return _xTDMgr; }
     111             :     Reference< XMultiServiceFactory > getSMgr() const
     112             :         { return _xMgr; }
     113             : 
     114             :     const Mapping & getCpp2Uno() throw(::com::sun::star::uno::RuntimeException);
     115             :     const Mapping & getUno2Cpp() throw(::com::sun::star::uno::RuntimeException);
     116             :     uno_Interface * mapToUno( const Any & rObj, typelib_InterfaceTypeDescription * pTo ) throw(::com::sun::star::uno::RuntimeException);
     117             : 
     118             :     // ctor/ dtor
     119             :     IdlReflectionServiceImpl( const Reference< XComponentContext > & xContext );
     120             :     virtual ~IdlReflectionServiceImpl();
     121             : 
     122             :     // XInterface
     123             :     virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     124             :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
     125             :     virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     126             : 
     127             :     // some XComponent part from OComponentHelper
     128             :     virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             : 
     130             :     // XServiceInfo
     131             :     virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     132             :     virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     134             : 
     135             :     // XTypeProvider
     136             :     virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : 
     139             :     // XIdlReflection
     140             :     virtual Reference< XIdlClass > SAL_CALL forName( const OUString & rTypeName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     virtual Reference< XIdlClass > SAL_CALL getType( const Any & rObj ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             : 
     143             :     // XHierarchicalNameAccess
     144             :     virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             :     virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     146             : 
     147             :     Reference< XIdlClass > forType( typelib_TypeDescription * pTypeDescr ) throw(::com::sun::star::uno::RuntimeException);
     148             :     Reference< XIdlClass > forType( typelib_TypeDescriptionReference * pRef ) throw(::com::sun::star::uno::RuntimeException);
     149             : };
     150             : 
     151             : 
     152             : class IdlClassImpl
     153             :     : public WeakImplHelper1< XIdlClass >
     154             : {
     155             :     IdlReflectionServiceImpl *  _pReflection;
     156             : 
     157             :     OUString                    _aName;
     158             :     TypeClass                   _eTypeClass;
     159             : 
     160             :     typelib_TypeDescription *   _pTypeDescr;
     161             : 
     162             : public:
     163           0 :     typelib_TypeDescription *   getTypeDescr() const
     164           0 :         { return _pTypeDescr; }
     165           0 :     IdlReflectionServiceImpl *  getReflection() const
     166           0 :         { return _pReflection; }
     167             :     Reference< XMultiServiceFactory > getSMgr() const
     168             :         { return _pReflection->getSMgr(); }
     169             :     Reference< XHierarchicalNameAccess > getTDMgr() const
     170             :         { return getReflection()->getTDMgr(); }
     171             : 
     172             :     // Ctor
     173             :     IdlClassImpl( IdlReflectionServiceImpl * pReflection,
     174             :                   const OUString & rName, typelib_TypeClass eTypeClass,
     175             :                   typelib_TypeDescription * pTypeDescr );
     176             :     virtual ~IdlClassImpl();
     177             : 
     178             :     // XIdlClassImpl default implementation
     179             :     virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     180             :     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             :     virtual sal_Bool SAL_CALL equals( const Reference< XIdlClass >& xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     182             : 
     183             :     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     184             :     virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     185             : 
     186             :     // def impl ????
     187             :     virtual Sequence< Reference< XIdlClass > > SAL_CALL getClasses() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     188             :     virtual Reference< XIdlClass > SAL_CALL getClass( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     189             :     virtual Sequence< Reference< XIdlClass > > SAL_CALL getInterfaces() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     190             : 
     191             :     // structs, interfaces
     192             :     virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     193             :     // structs
     194             :     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             :     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     196             :     // interfaces
     197             :     virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     198             :     virtual Reference< XIdlMethod > SAL_CALL getMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     199             :     virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             :     // array
     201             :     virtual Reference< XIdlClass > SAL_CALL getComponentType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     202             :     virtual Reference< XIdlArray > SAL_CALL getArray() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : };
     204             : 
     205             : 
     206             : class InterfaceIdlClassImpl
     207             :     : public IdlClassImpl
     208             : {
     209             :     typedef pair< OUString, typelib_TypeDescription * > MemberInit;
     210             : 
     211             :     Sequence< Reference< XIdlClass > >      _xSuperClasses;
     212             : 
     213             :     MemberInit *                            _pSortedMemberInit; // first methods, then attributes
     214             :     OUString2Field                          _aName2Field;
     215             :     OUString2Method                         _aName2Method;
     216             :     sal_Int32                               _nMethods;
     217             :     sal_Int32                               _nAttributes;
     218             : 
     219             :     void initMembers();
     220             : 
     221             : public:
     222           0 :     typelib_InterfaceTypeDescription * getTypeDescr() const
     223           0 :         { return (typelib_InterfaceTypeDescription *)IdlClassImpl::getTypeDescr(); }
     224             : 
     225             :     // ctor/ dtor
     226           0 :     InterfaceIdlClassImpl( IdlReflectionServiceImpl * pReflection,
     227             :                            const OUString & rName, typelib_TypeClass eTypeClass,
     228             :                            typelib_TypeDescription * pTypeDescr )
     229             :         : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
     230             :         , _pSortedMemberInit( 0 )
     231             :         , _nMethods( 0 )
     232           0 :         , _nAttributes( 0 )
     233           0 :         {}
     234             :     virtual ~InterfaceIdlClassImpl();
     235             : 
     236             :     // IdlClassImpl modifications
     237             :     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     238             :     virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             :     virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     240             :     virtual Reference< XIdlMethod > SAL_CALL getMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     241             :     virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     242             :     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     243             :     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     244             :     virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     245             : };
     246             : 
     247             : 
     248             : class CompoundIdlClassImpl
     249             :     : public IdlClassImpl
     250             : {
     251             :     Reference< XIdlClass >                  _xSuperClass;
     252             : 
     253             :     Sequence< Reference< XIdlField > > *    _pFields;
     254             :     OUString2Field                          _aName2Field;
     255             : 
     256             : public:
     257           0 :     typelib_CompoundTypeDescription * getTypeDescr() const
     258           0 :         { return (typelib_CompoundTypeDescription *)IdlClassImpl::getTypeDescr(); }
     259             : 
     260             :     // ctor/ dtor
     261           0 :     CompoundIdlClassImpl( IdlReflectionServiceImpl * pReflection,
     262             :                           const OUString & rName, typelib_TypeClass eTypeClass,
     263             :                           typelib_TypeDescription * pTypeDescr )
     264             :         : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
     265           0 :         , _pFields( 0 )
     266           0 :         {}
     267             :     virtual ~CompoundIdlClassImpl();
     268             : 
     269             :     // IdlClassImpl modifications
     270             :     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     271             :     virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     272             :     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     273             :     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     274             : };
     275             : 
     276             : 
     277           0 : class ArrayIdlClassImpl
     278             :     : public IdlClassImpl
     279             :     , public XIdlArray
     280             : {
     281             : public:
     282           0 :     typelib_IndirectTypeDescription * getTypeDescr() const
     283           0 :         { return (typelib_IndirectTypeDescription *)IdlClassImpl::getTypeDescr(); }
     284             : 
     285             :     // ctor
     286           0 :     ArrayIdlClassImpl( IdlReflectionServiceImpl * pReflection,
     287             :                        const OUString & rName, typelib_TypeClass eTypeClass,
     288             :                        typelib_TypeDescription * pTypeDescr )
     289           0 :         : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
     290           0 :         {}
     291             : 
     292             :     virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     293             :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
     294             :     virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     295             : 
     296             :     // XTypeProvider
     297             :     virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     298             :     virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     299             : 
     300             :     // IdlClassImpl modifications
     301             :     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     302             :     virtual Reference< XIdlClass > SAL_CALL getComponentType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     303             :     virtual Reference< XIdlArray > SAL_CALL getArray() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     304             : 
     305             :     // XIdlArray
     306             :     virtual void SAL_CALL realloc( Any & rArray, sal_Int32 nLen ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     307             :     virtual sal_Int32 SAL_CALL getLen( const Any & rArray ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     308             :     virtual Any SAL_CALL get( const Any & rArray, sal_Int32 nIndex ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     309             :     virtual void SAL_CALL set( Any & rArray, sal_Int32 nIndex, const Any & rNewValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     310             : };
     311             : 
     312             : 
     313             : class EnumIdlClassImpl
     314             :     : public IdlClassImpl
     315             : {
     316             :     Sequence< Reference< XIdlField > > * _pFields;
     317             :     OUString2Field                       _aName2Field;
     318             : 
     319             : public:
     320           0 :     typelib_EnumTypeDescription * getTypeDescr() const
     321           0 :         { return (typelib_EnumTypeDescription *)IdlClassImpl::getTypeDescr(); }
     322             : 
     323             :     // ctor/ dtor
     324           0 :     EnumIdlClassImpl( IdlReflectionServiceImpl * pReflection,
     325             :                       const OUString & rName, typelib_TypeClass eTypeClass,
     326             :                       typelib_TypeDescription * pTypeDescr )
     327             :         : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
     328           0 :         , _pFields( 0 )
     329           0 :         {}
     330             :     virtual ~EnumIdlClassImpl();
     331             : 
     332             :     // IdlClassImpl modifications
     333             :     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     334             :     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     335             :     virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     336             : };
     337             : 
     338             : 
     339             : class IdlMemberImpl
     340             :     : public WeakImplHelper1< XIdlMember >
     341             : {
     342             :     IdlReflectionServiceImpl *  _pReflection;
     343             :     OUString                    _aName;
     344             : 
     345             :     typelib_TypeDescription *   _pTypeDescr;
     346             :     typelib_TypeDescription *   _pDeclTypeDescr;
     347             : 
     348             : protected:
     349             :     Reference< XIdlClass >      _xDeclClass;
     350             : 
     351             : public:
     352           0 :     IdlReflectionServiceImpl *  getReflection() const
     353           0 :         { return _pReflection; }
     354             :     Reference< XMultiServiceFactory > getSMgr() const
     355             :         { return _pReflection->getSMgr(); }
     356           0 :     typelib_TypeDescription *   getTypeDescr() const
     357           0 :         { return _pTypeDescr; }
     358           0 :     typelib_TypeDescription *   getDeclTypeDescr() const
     359           0 :         { return _pDeclTypeDescr; }
     360             : 
     361             :     // ctor/ dtor
     362             :     IdlMemberImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
     363             :                    typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr );
     364             :     virtual ~IdlMemberImpl();
     365             : 
     366             :     // XIdlMember
     367             :     virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     368             :     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     369             : };
     370             : 
     371             : 
     372             : // coerces to type descr pTo else queries for it: the interface pointer is returned via rDest
     373             : // ## type to XidlClass coercion possible
     374           0 : inline sal_Bool extract(
     375             :     const Any & rObj, typelib_InterfaceTypeDescription * pTo,
     376             :     Reference< XInterface > & rDest,
     377             :     IdlReflectionServiceImpl * pRefl )
     378             : {
     379           0 :     rDest.clear();
     380           0 :     if (0 != pTo)
     381             :     {
     382           0 :         if (! rObj.hasValue())
     383           0 :             return sal_True;
     384           0 :         if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
     385             :         {
     386             :             return ::uno_type_assignData(
     387             :                 &rDest, ((typelib_TypeDescription *)pTo)->pWeakRef,
     388           0 :                 const_cast< void * >( rObj.getValue() ), rObj.getValueTypeRef(),
     389             :                 reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
     390             :                 reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
     391           0 :                 reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
     392             :         }
     393           0 :         else if (rObj.getValueTypeClass() == TypeClass_TYPE)
     394             :         {
     395           0 :             rDest = pRefl->forType( reinterpret_cast< const Type * >( rObj.getValue() )->getTypeLibType() );
     396           0 :             return rDest.is();
     397             :         }
     398             :     }
     399           0 :     return sal_False;
     400             : }
     401             : 
     402           0 : inline sal_Bool coerce_assign(
     403             :     void * pDest, typelib_TypeDescription * pTD, const Any & rSource,
     404             :     IdlReflectionServiceImpl * pRefl )
     405             : {
     406           0 :     if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
     407             :     {
     408           0 :         Reference< XInterface > xVal;
     409           0 :         if (extract( rSource, (typelib_InterfaceTypeDescription *)pTD, xVal, pRefl ))
     410             :         {
     411           0 :             if (*(XInterface **)pDest)
     412           0 :                 (*(XInterface **)pDest)->release();
     413           0 :             *(XInterface **)pDest = xVal.get();
     414           0 :             if (*(XInterface **)pDest)
     415           0 :                 (*(XInterface **)pDest)->acquire();
     416           0 :             return sal_True;
     417             :         }
     418           0 :         return sal_False;
     419             :     }
     420           0 :     else if (pTD->eTypeClass == typelib_TypeClass_ANY)
     421             :     {
     422             :         return uno_assignData(
     423             :             pDest, pTD,
     424             :             (void *)&rSource, pTD,
     425             :             reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
     426             :             reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
     427           0 :             reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
     428             :     }
     429             :     else
     430             :     {
     431             :         return uno_type_assignData(
     432             :             pDest, pTD->pWeakRef,
     433           0 :             (void *)rSource.getValue(), rSource.getValueTypeRef(),
     434             :             reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
     435             :             reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
     436           0 :             reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
     437             :     }
     438             : }
     439             : 
     440             : }
     441             : 
     442             : 
     443             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10