LCOV - code coverage report
Current view: top level - idlc/source - astoperation.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 47 53 88.7 %
Date: 2015-06-13 12:38:46 Functions: 4 4 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             : 
      20             : #include <idlc/astoperation.hxx>
      21             : #include <idlc/asttype.hxx>
      22             : #include <idlc/astbasetype.hxx>
      23             : #include <idlc/astparameter.hxx>
      24             : #include <idlc/errorhandler.hxx>
      25             : 
      26             : #include <registry/writer.hxx>
      27             : 
      28          76 : void AstOperation::setExceptions(DeclList const * pExceptions)
      29             : {
      30          76 :     if (pExceptions != 0) {
      31           8 :         m_exceptions = *pExceptions;
      32             :     }
      33          76 : }
      34             : 
      35          49 : bool AstOperation::isVariadic() const {
      36          49 :     DeclList::const_iterator i(getIteratorEnd());
      37         196 :     return i != getIteratorBegin()
      38         196 :         && static_cast< AstParameter const * >(*(--i))->isRest();
      39             : }
      40             : 
      41          37 : bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
      42             : {
      43          37 :     sal_uInt16      nParam = getNodeCount(NT_parameter);
      44          37 :     sal_uInt16      nExcep = nExceptions();
      45          37 :     RTMethodMode    methodMode = RTMethodMode::TWOWAY;
      46             : 
      47          37 :     OUString returnTypeName;
      48          37 :     if (m_pReturnType == 0) {
      49          18 :         returnTypeName = "void";
      50             :     } else {
      51          38 :         returnTypeName = OStringToOUString(
      52          38 :             m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8);
      53             :     }
      54             :     rBlob.setMethodData(
      55          37 :         index, getDocumentation(), methodMode,
      56          37 :         OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
      57         111 :         returnTypeName, nParam, nExcep);
      58             : 
      59          37 :     if ( nParam )
      60             :     {
      61          17 :         DeclList::const_iterator iter = getIteratorBegin();
      62          17 :         DeclList::const_iterator end = getIteratorEnd();
      63             :         RTParamMode paramMode;
      64          17 :         sal_uInt16 paramIndex = 0;
      65          55 :         while ( iter != end )
      66             :         {
      67          21 :             AstDeclaration* pDecl = *iter;
      68          21 :             if ( pDecl->getNodeType() == NT_parameter )
      69             :             {
      70          21 :                 AstParameter* pParam = static_cast<AstParameter*>(pDecl);
      71          21 :                 switch (pParam->getDirection())
      72             :                 {
      73             :                     case DIR_IN :
      74          21 :                         paramMode = RT_PARAM_IN;
      75          21 :                         break;
      76             :                     case DIR_OUT :
      77           0 :                         paramMode = RT_PARAM_OUT;
      78           0 :                         break;
      79             :                     case DIR_INOUT :
      80           0 :                         paramMode = RT_PARAM_INOUT;
      81           0 :                         break;
      82             :                     default:
      83           0 :                         paramMode = RT_PARAM_INVALID;
      84           0 :                         break;
      85             :                 }
      86          21 :                 if (pParam->isRest()) {
      87             :                     paramMode = static_cast< RTParamMode >(
      88           4 :                         paramMode | RT_PARAM_REST);
      89             :                 }
      90             : 
      91             :                 rBlob.setMethodParameterData(
      92             :                     index, paramIndex++, paramMode,
      93             :                     OStringToOUString(
      94          21 :                         pDecl->getLocalName(), RTL_TEXTENCODING_UTF8),
      95             :                     OStringToOUString(
      96          21 :                         pParam->getType()->getRelativName(),
      97          42 :                         RTL_TEXTENCODING_UTF8));
      98             :             }
      99          21 :             ++iter;
     100             :         }
     101             :     }
     102             : 
     103          37 :     if ( nExcep )
     104             :     {
     105           6 :         DeclList::iterator iter = m_exceptions.begin();
     106           6 :         DeclList::iterator end = m_exceptions.end();
     107           6 :         sal_uInt16 exceptIndex = 0;
     108          18 :         while ( iter != end )
     109             :         {
     110             :             rBlob.setMethodExceptionTypeName(
     111             :                 index, exceptIndex++,
     112             :                 OStringToOUString(
     113           6 :                     (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8));
     114           6 :             ++iter;
     115             :         }
     116             :     }
     117             : 
     118          37 :     return true;
     119             : }
     120             : 
     121         369 : AstDeclaration* AstOperation::addDeclaration(AstDeclaration* pDecl)
     122             : {
     123         369 :     return AstScope::addDeclaration(pDecl);
     124             : }
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11