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

Generated by: LCOV version 1.10