LCOV - code coverage report
Current view: top level - libreoffice/idlc/source - astenum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 50 82.0 %
Date: 2012-12-27 Functions: 4 6 66.7 %
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             : 
      20             : #include <idlc/astenum.hxx>
      21             : 
      22             : #include "registry/version.h"
      23             : #include "registry/writer.hxx"
      24             : 
      25             : using namespace ::rtl;
      26             : 
      27        4597 : AstEnum::AstEnum(const ::rtl::OString& name, AstScope* pScope)
      28             :     : AstType(NT_enum, name, pScope)
      29             :     , AstScope(NT_enum)
      30        4597 :     , m_enumValueCount(0)
      31             : {
      32        4597 : }
      33             : 
      34           0 : AstEnum::~AstEnum()
      35             : {
      36           0 : }
      37             : 
      38       64074 : AstConstant* AstEnum::checkValue(AstExpression* pExpr)
      39             : {
      40       64074 :     DeclList::const_iterator iter = getIteratorBegin();
      41       64074 :     DeclList::const_iterator end = getIteratorEnd();
      42       64074 :     AstConstant*        pConst = NULL;
      43       64074 :     AstDeclaration*     pDecl = NULL;
      44             : 
      45     1006707 :     while ( iter != end)
      46             :     {
      47      878559 :         pDecl = *iter;
      48      878559 :         pConst = (AstConstant*)pDecl;
      49             : 
      50      878559 :         if (pConst->getConstValue()->compare(pExpr))
      51           0 :             return pConst;
      52             : 
      53      878559 :         ++iter;
      54             :     }
      55             : 
      56       64074 :     if ( pExpr->getExprValue()->u.lval > m_enumValueCount )
      57         274 :         m_enumValueCount = pExpr->getExprValue()->u.lval + 1;
      58             : 
      59       64074 :     return NULL;
      60             : }
      61             : 
      62         195 : sal_Bool AstEnum::dump(RegistryKey& rKey)
      63             : {
      64         195 :     RegistryKey localKey;
      65         195 :     if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey))
      66             :     {
      67             :         fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n",
      68           0 :                 idlc()->getOptions()->getProgramName().getStr(),
      69           0 :                 getFullName().getStr(), OUStringToOString(rKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
      70           0 :         return sal_False;
      71             :     }
      72             : 
      73         195 :     OUString emptyStr;
      74         195 :     sal_uInt16 nConst = getNodeCount(NT_enum_val);
      75         195 :     if ( nConst > 0 )
      76             :     {
      77             :         typereg::Writer aBlob(
      78             :             m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0,
      79         195 :             getDocumentation(), emptyStr, RT_TYPE_ENUM, m_bPublished,
      80         195 :             OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0,
      81         585 :             nConst, 0, 0);
      82             : 
      83         195 :         DeclList::const_iterator iter = getIteratorBegin();
      84         195 :         DeclList::const_iterator end = getIteratorEnd();
      85         195 :         AstDeclaration* pDecl = NULL;
      86         195 :         sal_uInt16 index = 0;
      87        1703 :         while ( iter != end )
      88             :         {
      89        1313 :             pDecl = *iter;
      90        1313 :             if ( pDecl->getNodeType() == NT_enum_val )
      91        1313 :                 ((AstConstant*)pDecl)->dumpBlob(aBlob, index++, false);
      92             : 
      93        1313 :             ++iter;
      94             :         }
      95             : 
      96             :         sal_uInt32 aBlobSize;
      97         195 :         void const * pBlob = aBlob.getBlob(&aBlobSize);
      98             : 
      99         195 :         if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY,
     100         195 :                                 (RegValue)pBlob, aBlobSize))
     101             :         {
     102             :             fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n",
     103           0 :                     idlc()->getOptions()->getProgramName().getStr(),
     104           0 :                     getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
     105           0 :             return sal_False;
     106         195 :         }
     107             :     }
     108             : 
     109         195 :     return sal_True;
     110             : }
     111             : 
     112       64074 : AstDeclaration* AstEnum::addDeclaration(AstDeclaration* pDecl)
     113             : {
     114       64074 :     return AstScope::addDeclaration(pDecl);
     115             : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10