LCOV - code coverage report
Current view: top level - idlc/source - astenum.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 50 0.0 %
Date: 2014-04-14 Functions: 0 6 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             : 
      20             : #include <idlc/astenum.hxx>
      21             : 
      22             : #include "registry/version.h"
      23             : #include "registry/writer.hxx"
      24             : 
      25             : using namespace ::rtl;
      26             : 
      27           0 : AstEnum::AstEnum(const OString& name, AstScope* pScope)
      28             :     : AstType(NT_enum, name, pScope)
      29             :     , AstScope(NT_enum)
      30           0 :     , m_enumValueCount(0)
      31             : {
      32           0 : }
      33             : 
      34           0 : AstEnum::~AstEnum()
      35             : {
      36           0 : }
      37             : 
      38           0 : AstConstant* AstEnum::checkValue(AstExpression* pExpr)
      39             : {
      40           0 :     DeclList::const_iterator iter = getIteratorBegin();
      41           0 :     DeclList::const_iterator end = getIteratorEnd();
      42           0 :     AstConstant*        pConst = NULL;
      43           0 :     AstDeclaration*     pDecl = NULL;
      44             : 
      45           0 :     while ( iter != end)
      46             :     {
      47           0 :         pDecl = *iter;
      48           0 :         pConst = (AstConstant*)pDecl;
      49             : 
      50           0 :         if (pConst->getConstValue()->compare(pExpr))
      51           0 :             return pConst;
      52             : 
      53           0 :         ++iter;
      54             :     }
      55             : 
      56           0 :     if ( pExpr->getExprValue()->u.lval > m_enumValueCount )
      57           0 :         m_enumValueCount = pExpr->getExprValue()->u.lval + 1;
      58             : 
      59           0 :     return NULL;
      60             : }
      61             : 
      62           0 : bool AstEnum::dump(RegistryKey& rKey)
      63             : {
      64           0 :     RegistryKey localKey;
      65           0 :     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 false;
      71             :     }
      72             : 
      73           0 :     OUString emptyStr;
      74           0 :     sal_uInt16 nConst = getNodeCount(NT_enum_val);
      75           0 :     if ( nConst > 0 )
      76             :     {
      77             :         typereg::Writer aBlob(
      78             :             m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0,
      79           0 :             getDocumentation(), emptyStr, RT_TYPE_ENUM, m_bPublished,
      80           0 :             OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0,
      81           0 :             nConst, 0, 0);
      82             : 
      83           0 :         DeclList::const_iterator iter = getIteratorBegin();
      84           0 :         DeclList::const_iterator end = getIteratorEnd();
      85           0 :         AstDeclaration* pDecl = NULL;
      86           0 :         sal_uInt16 index = 0;
      87           0 :         while ( iter != end )
      88             :         {
      89           0 :             pDecl = *iter;
      90           0 :             if ( pDecl->getNodeType() == NT_enum_val )
      91           0 :                 ((AstConstant*)pDecl)->dumpBlob(aBlob, index++, false);
      92             : 
      93           0 :             ++iter;
      94             :         }
      95             : 
      96             :         sal_uInt32 aBlobSize;
      97           0 :         void const * pBlob = aBlob.getBlob(&aBlobSize);
      98             : 
      99           0 :         if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY,
     100           0 :                                 (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 false;
     106           0 :         }
     107             :     }
     108             : 
     109           0 :     return true;
     110             : }
     111             : 
     112           0 : AstDeclaration* AstEnum::addDeclaration(AstDeclaration* pDecl)
     113             : {
     114           0 :     return AstScope::addDeclaration(pDecl);
     115             : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10