LCOV - code coverage report
Current view: top level - idlc/source - astdeclaration.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 63 66 95.5 %
Date: 2014-11-03 Functions: 9 10 90.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/astdeclaration.hxx>
      21             : #include <idlc/astscope.hxx>
      22             : #include <rtl/strbuf.hxx>
      23             : 
      24         658 : static OString sGlobal("::");
      25             : 
      26       29540 : static OString convertName(const OString& name)
      27             : {
      28       29540 :     OStringBuffer nameBuffer(name.getLength()+1);
      29       29540 :     sal_Int32 nIndex = 0;
      30       73928 :     do
      31             :     {
      32       73928 :         OString token( name.getToken( 0, ':', nIndex ) );
      33       73928 :         if( !token.isEmpty() )
      34             :         {
      35       50418 :             nameBuffer.append('/');
      36       50418 :             nameBuffer.append( token );
      37       73928 :         }
      38       73928 :     } while( nIndex != -1 );
      39       29540 :     return nameBuffer.makeStringAndClear();
      40             : }
      41             : 
      42       29540 : AstDeclaration::AstDeclaration(NodeType type, const OString& name, AstScope* pScope)
      43             :     : m_localName(name)
      44             :     , m_pScope(pScope)
      45             :     , m_nodeType(type)
      46             :     , m_bImported(false)
      47             :     , m_bIsAdded(false)
      48             :     , m_bInMainFile(false)
      49             :     , m_bPredefined(false)
      50       29540 :     , m_lineNumber(0)
      51             : {
      52       29540 :     if ( m_pScope )
      53             :     {
      54       28074 :         AstDeclaration* pDecl = scopeAsDecl(m_pScope);
      55       28074 :         if (pDecl)
      56             :         {
      57       28074 :             m_scopedName = pDecl->getScopedName();
      58       28074 :             if (!m_scopedName.isEmpty())
      59        6318 :                 m_scopedName += sGlobal;
      60       28074 :             m_scopedName += m_localName;
      61             :         }
      62             :     } else
      63             :     {
      64        1466 :         m_scopedName = m_localName;
      65             :     }
      66       29540 :     m_fullName = convertName(m_scopedName);
      67             : 
      68       29540 :     if ( idlc()->getFileName() == idlc()->getRealFileName() )
      69             :     {
      70       29540 :         m_fileName = idlc()->getMainFileName();
      71       29540 :         m_bInMainFile = true;
      72             :     } else
      73             :     {
      74           0 :         m_fileName = idlc()->getFileName();
      75           0 :         m_bImported = true;
      76             :     }
      77             : 
      78       29540 :     m_documentation = idlc()->processDocumentation();
      79             : 
      80       29540 :     m_bPublished = idlc()->isPublished();
      81       29540 : }
      82             : 
      83             : 
      84         884 : AstDeclaration::~AstDeclaration()
      85             : {
      86             : 
      87         884 : }
      88             : 
      89        3504 : void AstDeclaration::setPredefined(bool bPredefined)
      90             : {
      91        3504 :     m_bPredefined = bPredefined;
      92        3504 :     if ( m_bPredefined )
      93             :     {
      94        3290 :         m_fileName = OString();
      95        3290 :         m_bInMainFile = false;
      96             :     }
      97        3504 : }
      98             : 
      99         552 : bool AstDeclaration::isType() const {
     100         552 :     switch (m_nodeType) {
     101             :     case NT_interface:
     102             :     case NT_instantiated_struct:
     103             :     case NT_enum:
     104             :     case NT_sequence:
     105             :     case NT_typedef:
     106             :     case NT_predefined:
     107             :     case NT_type_parameter:
     108         542 :         return true;
     109             : 
     110             :     default:
     111             :         OSL_ASSERT(m_nodeType != NT_struct); // see AstStruct::isType
     112          10 :         return false;
     113             :     }
     114             : }
     115             : 
     116          24 : bool AstDeclaration::hasAncestor(AstDeclaration* pDecl)
     117             : {
     118          24 :     if (this == pDecl)
     119           0 :         return true;
     120          24 :     if ( !m_pScope )
     121           8 :         return false;
     122          16 :     return scopeAsDecl(m_pScope)->hasAncestor(pDecl);
     123             : }
     124             : 
     125         480 : bool AstDeclaration::dump(RegistryKey& rKey)
     126             : {
     127         480 :     AstScope* pScope = declAsScope(this);
     128         480 :     bool bRet = true;
     129             : 
     130         480 :     if ( pScope )
     131             :     {
     132         480 :         DeclList::const_iterator iter = pScope->getIteratorBegin();
     133         480 :         DeclList::const_iterator end = pScope->getIteratorEnd();
     134         480 :         AstDeclaration* pDecl = NULL;
     135        6540 :         while ( iter != end && bRet)
     136             :         {
     137        5580 :             pDecl = *iter;
     138        5580 :             if ( pDecl->isInMainfile() )
     139             :             {
     140        5298 :                 switch ( pDecl->getNodeType() )
     141             :                 {
     142             :                     case NT_module:
     143             :                     case NT_constants:
     144             :                     case NT_interface:
     145             :                     case NT_struct:
     146             :                     case NT_exception:
     147             :                     case NT_enum:
     148             :                     case NT_typedef:
     149             :                     case NT_service:
     150             :                     case NT_singleton:
     151         786 :                         bRet = pDecl->dump(rKey);
     152         786 :                         break;
     153             :                     default:
     154        4512 :                         break;
     155             :                 }
     156             :             }
     157             : 
     158        5580 :             ++iter;
     159             :         }
     160             :     }
     161         480 :     return bRet;
     162        1974 : }
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10