LCOV - code coverage report
Current view: top level - cppu/source/uno - prim.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 38 39 97.4 %
Date: 2015-06-13 12:38:46 Functions: 7 7 100.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             : #ifndef INCLUDED_CPPU_SOURCE_UNO_PRIM_HXX
      20             : #define INCLUDED_CPPU_SOURCE_UNO_PRIM_HXX
      21             : 
      22             : #include "typelib/typedescription.h"
      23             : #include "typelib/typeclass.h"
      24             : #include "uno/sequence2.h"
      25             : #include "uno/any2.h"
      26             : #include "uno/data.h"
      27             : #include "uno/mapping.h"
      28             : #include "uno/dispatcher.h"
      29             : 
      30             : #include "osl/interlck.h"
      31             : #include "osl/diagnose.h"
      32             : #include "rtl/ustring.hxx"
      33             : #include "rtl/alloc.h"
      34             : 
      35             : #if OSL_DEBUG_LEVEL > 1
      36             : #include "rtl/ustrbuf.hxx"
      37             : #include "rtl/string.hxx"
      38             : #endif
      39             : 
      40             : 
      41             : namespace cppu
      42             : {
      43             : 
      44             : extern uno_Sequence g_emptySeq;
      45             : extern typelib_TypeDescriptionReference * g_pVoidType;
      46             : 
      47             : 
      48      461043 : inline void * _map(
      49             :     void * p,
      50             :     typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
      51             :     uno_Mapping * mapping )
      52             : 
      53             : {
      54      461043 :     void * pRet = 0;
      55      461043 :     if (p)
      56             :     {
      57      457518 :         if (pTypeDescr)
      58             :         {
      59             :             (*mapping->mapInterface)(
      60       92387 :                 mapping, &pRet, p, reinterpret_cast<typelib_InterfaceTypeDescription *>(pTypeDescr) );
      61             :         }
      62             :         else
      63             :         {
      64      365131 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
      65             :             (*mapping->mapInterface)(
      66      365131 :                 mapping, &pRet, p, reinterpret_cast<typelib_InterfaceTypeDescription *>(pTypeDescr) );
      67      365131 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
      68             :         }
      69             :     }
      70      461043 :     return pRet;
      71             : }
      72             : 
      73  2636620528 : inline void _acquire( void * p, uno_AcquireFunc acquire )
      74             : {
      75  2636620528 :     if (p)
      76             :     {
      77  2635731608 :         if (acquire)
      78             :         {
      79  2635271575 :             (*acquire)( p );
      80             :         }
      81             :         else
      82             :         {
      83      460033 :             (*static_cast<uno_Interface *>(p)->acquire)( static_cast<uno_Interface *>(p) );
      84             :         }
      85             :     }
      86  2636620484 : }
      87             : 
      88  2665166721 : inline void _release( void * p, uno_ReleaseFunc release )
      89             : {
      90  2665166721 :     if (p)
      91             :     {
      92   680484120 :         if (release)
      93             :         {
      94   679747270 :             (*release)( p );
      95             :         }
      96             :         else
      97             :         {
      98      736850 :             (*static_cast<uno_Interface *>(p)->release)( static_cast<uno_Interface *>(p) );
      99             :         }
     100             :     }
     101  2665166715 : }
     102             : 
     103             : 
     104   248174037 : inline sal_uInt32 calcSeqMemSize(
     105             :     sal_Int32 nElementSize, sal_Int32 nElements )
     106             : {
     107             :     sal_uInt64 nSize =
     108             :         (sal_uInt64) SAL_SEQUENCE_HEADER_SIZE +
     109   248174037 :         ((sal_uInt64) nElementSize * (sal_uInt64) nElements);
     110   248174037 :     if (nSize > 0xffffffffU)
     111           0 :         return 0;
     112             :     else
     113   248174037 :         return (sal_uInt32) nSize;
     114             : }
     115             : 
     116             : 
     117   143558722 : inline uno_Sequence * createEmptySequence()
     118             : {
     119   143558722 :     osl_atomic_increment( &g_emptySeq.nRefCount );
     120   143558722 :     return &g_emptySeq;
     121             : }
     122             : 
     123   863429316 : inline typelib_TypeDescriptionReference * _getVoidType()
     124             : {
     125   863429316 :     if (! g_pVoidType)
     126             :     {
     127         508 :         g_pVoidType = * ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID );
     128             :     }
     129   863429316 :     ::typelib_typedescriptionreference_acquire( g_pVoidType );
     130   863429413 :     return g_pVoidType;
     131             : }
     132             : 
     133             : 
     134             : #if OSL_DEBUG_LEVEL > 0
     135             : #define CONSTRUCT_EMPTY_ANY( pAny ) \
     136             : (pAny)->pType = _getVoidType(); \
     137             : (pAny)->pData = reinterpret_cast<void *>(0xdeadbeef);
     138             : #else
     139             : #define CONSTRUCT_EMPTY_ANY( pAny ) \
     140             : (pAny)->pType = _getVoidType(); \
     141             : (pAny)->pData = (pAny);
     142             : #endif
     143             : 
     144             : 
     145             : #define TYPE_ACQUIRE( pType ) \
     146             :     osl_atomic_increment( &(pType)->nRefCount );
     147             : 
     148             : 
     149             : extern "C" void * binuno_queryInterface(
     150             :     void * pUnoI, typelib_TypeDescriptionReference * pDestType );
     151             : 
     152             : 
     153   116049651 : inline bool _type_equals(
     154             :     typelib_TypeDescriptionReference * pType1, typelib_TypeDescriptionReference * pType2 )
     155             : 
     156             : {
     157   232099302 :     return (pType1 == pType2 ||
     158   110539826 :             (pType1->eTypeClass == pType2->eTypeClass &&
     159    55264891 :              pType1->pTypeName->length == pType2->pTypeName->length &&
     160   116050488 :              ::rtl_ustr_compare( pType1->pTypeName->buffer, pType2->pTypeName->buffer ) == 0));
     161             : }
     162             : 
     163             : }
     164             : 
     165             : #endif
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11