LCOV - code coverage report
Current view: top level - cppu/source/uno - constr.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 51 52 98.1 %
Date: 2015-06-13 12:38:46 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    12337951 : inline void _defaultConstructStruct(
      38             :     void * pMem,
      39             :     typelib_CompoundTypeDescription * pTypeDescr )
      40             : {
      41    12337951 :     if (pTypeDescr->pBaseTypeDescription)
      42             :     {
      43      462763 :         defaultConstructStruct( pMem, pTypeDescr->pBaseTypeDescription );
      44             :     }
      45             : 
      46    12337951 :     typelib_TypeDescriptionReference ** ppTypeRefs = (pTypeDescr)->ppTypeRefs;
      47    12337951 :     sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
      48    12337951 :     sal_Int32 nDescr = pTypeDescr->nMembers;
      49             : 
      50    78735041 :     while (nDescr--)
      51             :     {
      52    54059138 :         ::uno_type_constructData( static_cast<char *>(pMem) + pMemberOffsets[nDescr], ppTypeRefs[nDescr] );
      53             :     }
      54    12337952 : }
      55             : 
      56             : 
      57    54059662 : inline void _defaultConstructData(
      58             :     void * pMem,
      59             :     typelib_TypeDescriptionReference * pType,
      60             :     typelib_TypeDescription * pTypeDescr )
      61             : {
      62    54059662 :     switch (pType->eTypeClass)
      63             :     {
      64             :     case typelib_TypeClass_CHAR:
      65        5822 :         *static_cast<sal_Unicode *>(pMem) = '\0';
      66        5822 :         break;
      67             :     case typelib_TypeClass_BOOLEAN:
      68     2763133 :         *static_cast<sal_Bool *>(pMem) = sal_False;
      69     2763133 :         break;
      70             :     case typelib_TypeClass_BYTE:
      71           8 :         *static_cast<sal_Int8 *>(pMem) = 0;
      72           8 :         break;
      73             :     case typelib_TypeClass_SHORT:
      74             :     case typelib_TypeClass_UNSIGNED_SHORT:
      75     4935548 :         *static_cast<sal_Int16 *>(pMem) = 0;
      76     4935548 :         break;
      77             :     case typelib_TypeClass_LONG:
      78             :     case typelib_TypeClass_UNSIGNED_LONG:
      79     8800755 :         *static_cast<sal_Int32 *>(pMem) = 0;
      80     8800755 :         break;
      81             :     case typelib_TypeClass_HYPER:
      82             :     case typelib_TypeClass_UNSIGNED_HYPER:
      83          16 :         *static_cast<sal_Int64 *>(pMem) = 0;
      84          16 :         break;
      85             :     case typelib_TypeClass_FLOAT:
      86           8 :         *static_cast<float *>(pMem) = 0.0;
      87           8 :         break;
      88             :     case typelib_TypeClass_DOUBLE:
      89       26534 :         *static_cast<double *>(pMem) = 0.0;
      90       26534 :         break;
      91             :     case typelib_TypeClass_STRING:
      92    20966286 :         *static_cast<rtl_uString **>(pMem) = 0;
      93    20966286 :         ::rtl_uString_new( static_cast<rtl_uString **>(pMem) );
      94    20966286 :         break;
      95             :     case typelib_TypeClass_TYPE:
      96      824342 :         *static_cast<typelib_TypeDescriptionReference **>(pMem) = _getVoidType();
      97      824342 :         break;
      98             :     case typelib_TypeClass_ANY:
      99     7913332 :         CONSTRUCT_EMPTY_ANY( static_cast<uno_Any *>(pMem) );
     100     7913332 :         break;
     101             :     case typelib_TypeClass_ENUM:
     102     7525075 :         if (pTypeDescr)
     103             :         {
     104           2 :             *static_cast<sal_Int32 *>(pMem) = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nDefaultEnumValue;
     105             :         }
     106             :         else
     107             :         {
     108     7525073 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     109     7525073 :             *static_cast<sal_Int32 *>(pMem) = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nDefaultEnumValue;
     110     7525073 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     111             :         }
     112     7525075 :         break;
     113             :     case typelib_TypeClass_STRUCT:
     114             :     case typelib_TypeClass_EXCEPTION:
     115       42317 :         if (pTypeDescr)
     116             :         {
     117           3 :             _defaultConstructStruct( pMem, reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr) );
     118             :         }
     119             :         else
     120             :         {
     121       42314 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     122       42314 :             _defaultConstructStruct( pMem, reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr) );
     123       42314 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     124             :         }
     125       42317 :         break;
     126             :     case typelib_TypeClass_SEQUENCE:
     127      115647 :         *static_cast<uno_Sequence **>(pMem) = createEmptySequence();
     128      115647 :         break;
     129             :     case typelib_TypeClass_INTERFACE:
     130      140839 :         *static_cast<void **>(pMem) = 0; // either cpp or c-uno interface
     131      140839 :         break;
     132             :     default:
     133             :         OSL_ASSERT(false);
     134           0 :         break;
     135             :     }
     136    54059662 : }
     137             : 
     138             : }
     139             : 
     140             : #endif
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11