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

Generated by: LCOV version 1.10