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

Generated by: LCOV version 1.11