LCOV - code coverage report
Current view: top level - cppu/source/uno - constr.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 51 52 98.1 %
Date: 2014-11-03 Functions: 2 2 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_CONSTR_HXX
      20             : #define INCLUDED_CPPU_SOURCE_UNO_CONSTR_HXX
      21             : 
      22             : #include <string.h>
      23             : #include "prim.hxx"
      24             : 
      25             : namespace cppu
      26             : {
      27             : 
      28             : 
      29             : //#### construction ################################################################################
      30             : 
      31             : 
      32             : 
      33             : void defaultConstructStruct(
      34             :     void * pMem,
      35             :     typelib_CompoundTypeDescription * pCompType );
      36             : 
      37    23259575 : inline void _defaultConstructStruct(
      38             :     void * pMem,
      39             :     typelib_CompoundTypeDescription * pTypeDescr )
      40             : {
      41    23259575 :     if (pTypeDescr->pBaseTypeDescription)
      42             :     {
      43      630207 :         defaultConstructStruct( pMem, pTypeDescr->pBaseTypeDescription );
      44             :     }
      45             : 
      46    23259575 :     typelib_TypeDescriptionReference ** ppTypeRefs = (pTypeDescr)->ppTypeRefs;
      47    23259575 :     sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
      48    23259575 :     sal_Int32 nDescr = pTypeDescr->nMembers;
      49             : 
      50   147474226 :     while (nDescr--)
      51             :     {
      52   100955076 :         ::uno_type_constructData( (char *)pMem + pMemberOffsets[nDescr], ppTypeRefs[nDescr] );
      53             :     }
      54    23259575 : }
      55             : 
      56             : 
      57   100955746 : inline void _defaultConstructData(
      58             :     void * pMem,
      59             :     typelib_TypeDescriptionReference * pType,
      60             :     typelib_TypeDescription * pTypeDescr )
      61             : {
      62   100955746 :     switch (pType->eTypeClass)
      63             :     {
      64             :     case typelib_TypeClass_CHAR:
      65       37360 :         *(sal_Unicode *)pMem = '\0';
      66       37360 :         break;
      67             :     case typelib_TypeClass_BOOLEAN:
      68     4602230 :         *(sal_Bool *)pMem = sal_False;
      69     4602230 :         break;
      70             :     case typelib_TypeClass_BYTE:
      71          16 :         *(sal_Int8 *)pMem = 0;
      72          16 :         break;
      73             :     case typelib_TypeClass_SHORT:
      74             :     case typelib_TypeClass_UNSIGNED_SHORT:
      75     8168490 :         *(sal_Int16 *)pMem = 0;
      76     8168490 :         break;
      77             :     case typelib_TypeClass_LONG:
      78             :     case typelib_TypeClass_UNSIGNED_LONG:
      79    17020586 :         *(sal_Int32 *)pMem = 0;
      80    17020586 :         break;
      81             :     case typelib_TypeClass_HYPER:
      82             :     case typelib_TypeClass_UNSIGNED_HYPER:
      83          32 :         *(sal_Int64 *)pMem = 0;
      84          32 :         break;
      85             :     case typelib_TypeClass_FLOAT:
      86          16 :         *(float *)pMem = 0.0;
      87          16 :         break;
      88             :     case typelib_TypeClass_DOUBLE:
      89       51246 :         *(double *)pMem = 0.0;
      90       51246 :         break;
      91             :     case typelib_TypeClass_STRING:
      92    37840159 :         *(rtl_uString **)pMem = 0;
      93    37840159 :         ::rtl_uString_new( (rtl_uString **)pMem );
      94    37840159 :         break;
      95             :     case typelib_TypeClass_TYPE:
      96     1298193 :         *(typelib_TypeDescriptionReference **)pMem = _getVoidType();
      97     1298193 :         break;
      98             :     case typelib_TypeClass_ANY:
      99    16123001 :         CONSTRUCT_EMPTY_ANY( (uno_Any *)pMem );
     100    16123002 :         break;
     101             :     case typelib_TypeClass_ENUM:
     102    15148132 :         if (pTypeDescr)
     103             :         {
     104           4 :             *(sal_Int32 *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
     105             :         }
     106             :         else
     107             :         {
     108    15148128 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     109    15148128 :             *(sal_Int32 *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
     110    15148128 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     111             :         }
     112    15148132 :         break;
     113             :     case typelib_TypeClass_STRUCT:
     114             :     case typelib_TypeClass_EXCEPTION:
     115      254870 :         if (pTypeDescr)
     116             :         {
     117           6 :             _defaultConstructStruct( pMem, (typelib_CompoundTypeDescription *)pTypeDescr );
     118             :         }
     119             :         else
     120             :         {
     121      254864 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     122      254864 :             _defaultConstructStruct( pMem, (typelib_CompoundTypeDescription *)pTypeDescr );
     123      254864 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     124             :         }
     125      254870 :         break;
     126             :     case typelib_TypeClass_SEQUENCE:
     127      177092 :         *(uno_Sequence **)pMem = createEmptySequence();
     128      177092 :         break;
     129             :     case typelib_TypeClass_INTERFACE:
     130      234323 :         *(void **)pMem = 0; // either cpp or c-uno interface
     131      234323 :         break;
     132             :     default:
     133             :         OSL_ASSERT(false);
     134           0 :         break;
     135             :     }
     136   100955747 : }
     137             : 
     138             : }
     139             : 
     140             : #endif
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10