LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/idlc/source - astoperation.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 52 54 96.3 %
Date: 2013-07-09 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             : using namespace ::rtl;
      29             : 
      30      108351 : void AstOperation::setExceptions(DeclList const * pExceptions)
      31             : {
      32      108351 :     if (pExceptions != 0) {
      33       23160 :         m_exceptions = *pExceptions;
      34             :     }
      35      108351 : }
      36             : 
      37       86107 : bool AstOperation::isVariadic() const {
      38       86107 :     DeclList::const_iterator i(getIteratorEnd());
      39      344428 :     return i != getIteratorBegin()
      40      344428 :         && static_cast< AstParameter const * >(*(--i))->isRest();
      41             : }
      42             : 
      43        6628 : sal_Bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
      44             : {
      45        6628 :     sal_uInt16      nParam = getNodeCount(NT_parameter);
      46        6628 :     sal_uInt16      nExcep = nExceptions();
      47        6628 :     RTMethodMode    methodMode = RT_MODE_TWOWAY;
      48             : 
      49        6628 :     OUString returnTypeName;
      50        6628 :     if (m_pReturnType == 0) {
      51         306 :         returnTypeName = OUString("void");
      52             :     } else {
      53       12644 :         returnTypeName = OStringToOUString(
      54       12644 :             m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8);
      55             :     }
      56             :     rBlob.setMethodData(
      57        6628 :         index, getDocumentation(), methodMode,
      58        6628 :         OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
      59       19884 :         returnTypeName, nParam, nExcep);
      60             : 
      61        6628 :     if ( nParam )
      62             :     {
      63        4297 :         DeclList::const_iterator iter = getIteratorBegin();
      64        4297 :         DeclList::const_iterator end = getIteratorEnd();
      65        4297 :         AstDeclaration* pDecl = NULL;
      66             :         RTParamMode paramMode;
      67        4297 :         sal_uInt16 paramIndex = 0;
      68       16149 :         while ( iter != end )
      69             :         {
      70        7555 :             pDecl = *iter;
      71        7555 :             if ( pDecl->getNodeType() == NT_parameter )
      72             :             {
      73        7555 :                 AstParameter* pParam = (AstParameter*)pDecl;
      74        7555 :                 switch (pParam->getDirection())
      75             :                 {
      76             :                     case DIR_IN :
      77        7398 :                         paramMode = RT_PARAM_IN;
      78        7398 :                         break;
      79             :                     case DIR_OUT :
      80         100 :                         paramMode = RT_PARAM_OUT;
      81         100 :                         break;
      82             :                     case DIR_INOUT :
      83          57 :                         paramMode = RT_PARAM_INOUT;
      84          57 :                         break;
      85             :                     default:
      86           0 :                         paramMode = RT_PARAM_INVALID;
      87           0 :                         break;
      88             :                 }
      89        7555 :                 if (pParam->isRest()) {
      90             :                     paramMode = static_cast< RTParamMode >(
      91           6 :                         paramMode | RT_PARAM_REST);
      92             :                 }
      93             : 
      94             :                 rBlob.setMethodParameterData(
      95             :                     index, paramIndex++, paramMode,
      96             :                     OStringToOUString(
      97        7555 :                         pDecl->getLocalName(), RTL_TEXTENCODING_UTF8),
      98             :                     OStringToOUString(
      99        7555 :                         pParam->getType()->getRelativName(),
     100       15110 :                         RTL_TEXTENCODING_UTF8));
     101             :             }
     102        7555 :             ++iter;
     103             :         }
     104             :     }
     105             : 
     106        6628 :     if ( nExcep )
     107             :     {
     108        2167 :         DeclList::iterator iter = m_exceptions.begin();
     109        2167 :         DeclList::iterator end = m_exceptions.end();
     110        2167 :         sal_uInt16 exceptIndex = 0;
     111        7340 :         while ( iter != end )
     112             :         {
     113             :             rBlob.setMethodExceptionTypeName(
     114             :                 index, exceptIndex++,
     115             :                 OStringToOUString(
     116        3006 :                     (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8));
     117        3006 :             ++iter;
     118             :         }
     119             :     }
     120             : 
     121        6628 :     return sal_True;
     122             : }
     123             : 
     124       86470 : AstDeclaration* AstOperation::addDeclaration(AstDeclaration* pDecl)
     125             : {
     126       86470 :     return AstScope::addDeclaration(pDecl);
     127             : }
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10