LCOV - code coverage report
Current view: top level - codemaker/source/cppumaker - dependencies.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 151 158 95.6 %
Date: 2014-11-03 Functions: 3 3 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 "sal/config.h"
      21             : 
      22             : #include <cassert>
      23             : #include <utility>
      24             : #include <vector>
      25             : 
      26             : #include "codemaker/global.hxx"
      27             : #include "codemaker/typemanager.hxx"
      28             : #include "codemaker/unotype.hxx"
      29             : 
      30             : #include "osl/diagnose.h"
      31             : #include "rtl/ref.hxx"
      32             : #include "rtl/string.hxx"
      33             : #include "rtl/ustring.hxx"
      34             : #include "sal/types.h"
      35             : #include "unoidl/unoidl.hxx"
      36             : 
      37             : #include "dependencies.hxx"
      38             : 
      39             : namespace codemaker { namespace cppumaker {
      40             : 
      41        8314 : Dependencies::Dependencies(
      42             :     rtl::Reference< TypeManager > const & manager, OUString const & name):
      43             :     m_manager(manager), m_voidDependency(false), m_booleanDependency(false),
      44             :     m_byteDependency(false), m_shortDependency(false),
      45             :     m_unsignedShortDependency(false), m_longDependency(false),
      46             :     m_unsignedLongDependency(false), m_hyperDependency(false),
      47             :     m_unsignedHyperDependency(false), m_floatDependency(false),
      48             :     m_doubleDependency(false), m_charDependency(false),
      49             :     m_stringDependency(false), m_typeDependency(false), m_anyDependency(false),
      50        8314 :     m_sequenceDependency(false)
      51             : {
      52             :     assert(manager.is());
      53        8314 :     rtl::Reference< unoidl::Entity > ent;
      54        8314 :     switch (m_manager->getSort(name, &ent)) {
      55             :     case UnoType::SORT_ENUM_TYPE:
      56         401 :         break;
      57             :     case UnoType::SORT_PLAIN_STRUCT_TYPE:
      58             :         {
      59             :             rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
      60         831 :                 static_cast< unoidl::PlainStructTypeEntity * >(ent.get()));
      61         831 :             if (!ent2->getDirectBase().isEmpty()) {
      62         209 :                 insert(ent2->getDirectBase());
      63             :             }
      64       11217 :             for (std::vector< unoidl::PlainStructTypeEntity::Member >::
      65         831 :                      const_iterator i(ent2->getDirectMembers().begin());
      66        7478 :                  i != ent2->getDirectMembers().end(); ++i)
      67             :             {
      68        2908 :                 insert(i->type);
      69             :             }
      70         831 :             break;
      71             :         }
      72             :     case UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
      73             :         {
      74             :             rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
      75             :                 static_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
      76          16 :                     ent.get()));
      77         138 :             for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::
      78          16 :                      Member >::const_iterator i(ent2->getMembers().begin());
      79          92 :                  i != ent2->getMembers().end(); ++i)
      80             :             {
      81          30 :                 if (!i->parameterized) {
      82          11 :                     insert(i->type);
      83             :                 }
      84             :             }
      85          16 :             break;
      86             :         }
      87             :     case UnoType::SORT_EXCEPTION_TYPE:
      88             :         {
      89             :             rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
      90         555 :                 static_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
      91         555 :             if (!ent2->getDirectBase().isEmpty()) {
      92         552 :                 insert(ent2->getDirectBase());
      93             :             }
      94        2643 :             for (std::vector< unoidl::ExceptionTypeEntity::Member >::
      95         555 :                      const_iterator i(ent2->getDirectMembers().begin());
      96        1762 :                  i != ent2->getDirectMembers().end(); ++i)
      97             :             {
      98         326 :                 insert(i->type);
      99             :             }
     100         555 :             break;
     101             :         }
     102             :     case UnoType::SORT_INTERFACE_TYPE:
     103             :         {
     104             :             rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
     105        3825 :                 static_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
     106       24414 :             for (std::vector< unoidl::AnnotatedReference >::const_iterator i(
     107        3825 :                      ent2->getDirectMandatoryBases().begin());
     108       16276 :                  i != ent2->getDirectMandatoryBases().end(); ++i)
     109             :             {
     110        4313 :                 insert(i->name, true);
     111             :             }
     112        7650 :             if (!(ent2->getDirectAttributes().empty()
     113        3825 :                   && ent2->getDirectMethods().empty()))
     114             :             {
     115        3597 :                 insert("com.sun.star.uno.RuntimeException");
     116             :             }
     117       16845 :             for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::
     118        3825 :                      const_iterator i(ent2->getDirectAttributes().begin());
     119       11230 :                  i != ent2->getDirectAttributes().end(); ++i)
     120             :             {
     121        1790 :                 insert(i->type);
     122        5886 :                 for (std::vector< OUString >::const_iterator j(
     123        1790 :                          i->getExceptions.begin());
     124        3924 :                      j != i->getExceptions.end(); ++j)
     125             :                 {
     126         172 :                     insert(*j);
     127             :                 }
     128        6087 :                 for (std::vector< OUString >::const_iterator j(
     129        1790 :                          i->setExceptions.begin());
     130        4058 :                      j != i->setExceptions.end(); ++j)
     131             :                 {
     132         239 :                     insert(*j);
     133             :                 }
     134             :             }
     135       48807 :             for (std::vector< unoidl::InterfaceTypeEntity::Method >::
     136        3825 :                      const_iterator i(ent2->getDirectMethods().begin());
     137       32538 :                  i != ent2->getDirectMethods().end(); ++i)
     138             :             {
     139       12444 :                 insert(i->returnType);
     140       76833 :                 for (std::vector<
     141             :                          unoidl::InterfaceTypeEntity::Method::Parameter >::
     142       12444 :                          const_iterator j(i->parameters.begin());
     143       51222 :                      j != i->parameters.end(); ++j)
     144             :                 {
     145       13167 :                     insert(j->type);
     146             :                 }
     147       55380 :                 for (std::vector< OUString >::const_iterator j(
     148       12444 :                          i->exceptions.begin());
     149       36920 :                      j != i->exceptions.end(); ++j)
     150             :                 {
     151        6016 :                     insert(*j);
     152             :                 }
     153             :             }
     154        3825 :             break;
     155             :         }
     156             :     case UnoType::SORT_TYPEDEF:
     157          75 :         insert(static_cast< unoidl::TypedefEntity * >(ent.get())->getType());
     158          75 :         break;
     159             :     case UnoType::SORT_CONSTANT_GROUP:
     160             :         {
     161             :             rtl::Reference< unoidl::ConstantGroupEntity > ent2(
     162        1537 :                 static_cast< unoidl::ConstantGroupEntity * >(ent.get()));
     163       50280 :             for (std::vector< unoidl::ConstantGroupEntity::Member >::
     164        1537 :                      const_iterator i(ent2->getMembers().begin());
     165       33520 :                  i != ent2->getMembers().end(); ++i)
     166             :             {
     167       15223 :                 switch (i->value.type) {
     168             :                 case unoidl::ConstantValue::TYPE_BOOLEAN:
     169           0 :                     m_booleanDependency = true;
     170           0 :                     break;
     171             :                 case unoidl::ConstantValue::TYPE_BYTE:
     172         492 :                     m_byteDependency = true;
     173         492 :                     break;
     174             :                 case unoidl::ConstantValue::TYPE_SHORT:
     175        4162 :                     m_shortDependency = true;
     176        4162 :                     break;
     177             :                 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT:
     178           2 :                     m_unsignedShortDependency = true;
     179           2 :                     break;
     180             :                 case unoidl::ConstantValue::TYPE_LONG:
     181       10463 :                     m_longDependency = true;
     182       10463 :                     break;
     183             :                 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG:
     184           2 :                     m_unsignedLongDependency = true;
     185           2 :                     break;
     186             :                 case unoidl::ConstantValue::TYPE_HYPER:
     187          60 :                     m_hyperDependency = true;
     188          60 :                     break;
     189             :                 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER:
     190           2 :                     m_unsignedHyperDependency = true;
     191           2 :                     break;
     192             :                 case unoidl::ConstantValue::TYPE_FLOAT:
     193          40 :                     m_floatDependency = true;
     194          40 :                     break;
     195             :                 case unoidl::ConstantValue::TYPE_DOUBLE:
     196           0 :                     m_doubleDependency = true;
     197           0 :                     break;
     198             :                 }
     199             :             }
     200        1537 :             break;
     201             :         }
     202             :     case UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
     203             :         {
     204             :             rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
     205             :                 static_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
     206         861 :                     ent.get()));
     207         861 :             if (!ent2->getConstructors().empty()) {
     208         823 :                 insert(ent2->getBase());
     209             :             }
     210        5331 :             for (std::vector<
     211             :                      unoidl::SingleInterfaceBasedServiceEntity::Constructor >::
     212         861 :                      const_iterator i(ent2->getConstructors().begin());
     213        3554 :                  i != ent2->getConstructors().end(); ++i)
     214             :             {
     215        4812 :                 for (std::vector<
     216             :                          unoidl::SingleInterfaceBasedServiceEntity::
     217             :                          Constructor::Parameter >::const_iterator j(
     218         916 :                              i->parameters.begin());
     219        3208 :                      j != i->parameters.end(); ++j)
     220             :                 {
     221         688 :                     insert(j->type);
     222         688 :                     if (j->rest) {
     223           2 :                         m_sequenceDependency = true;
     224             :                     }
     225             :                 }
     226        3096 :                 for (std::vector< OUString >::const_iterator j(
     227         916 :                          i->exceptions.begin());
     228        2064 :                      j != i->exceptions.end(); ++j)
     229             :                 {
     230         116 :                     insert(*j);
     231             :                 }
     232             :             }
     233         861 :             break;
     234             :         }
     235             :     case UnoType::SORT_INTERFACE_BASED_SINGLETON:
     236             :         insert(
     237         213 :             static_cast< unoidl::InterfaceBasedSingletonEntity * >(ent.get())->
     238         213 :             getBase());
     239         213 :         break;
     240             :     default:
     241             :         assert(false); // this cannot happen
     242        8314 :     }
     243        8314 : }
     244             : 
     245        8314 : Dependencies::~Dependencies() {}
     246             : 
     247       47829 : void Dependencies::insert(OUString const & name, bool base) {
     248             :     sal_Int32 k;
     249       47829 :     std::vector< OString > args;
     250       95658 :     OUString n(b2u(UnoType::decompose(u2b(name), &k, &args)));
     251       47829 :     if (k != 0) {
     252        2409 :         m_sequenceDependency = true;
     253             :     }
     254       47829 :     switch (m_manager->getSort(n)) {
     255             :     case UnoType::SORT_VOID:
     256        5097 :         m_voidDependency = true;
     257        5097 :         break;
     258             :     case UnoType::SORT_BOOLEAN:
     259        2713 :         m_booleanDependency = true;
     260        2713 :         break;
     261             :     case UnoType::SORT_BYTE:
     262         368 :         m_byteDependency = true;
     263         368 :         break;
     264             :     case UnoType::SORT_SHORT:
     265        1181 :         m_shortDependency = true;
     266        1181 :         break;
     267             :     case UnoType::SORT_UNSIGNED_SHORT:
     268          83 :         m_unsignedShortDependency = true;
     269          83 :         break;
     270             :     case UnoType::SORT_LONG:
     271        3764 :         m_longDependency = true;
     272        3764 :         break;
     273             :     case UnoType::SORT_UNSIGNED_LONG:
     274          87 :         m_unsignedLongDependency = true;
     275          87 :         break;
     276             :     case UnoType::SORT_HYPER:
     277         168 :         m_hyperDependency = true;
     278         168 :         break;
     279             :     case UnoType::SORT_UNSIGNED_HYPER:
     280          17 :         m_unsignedHyperDependency = true;
     281          17 :         break;
     282             :     case UnoType::SORT_FLOAT:
     283         112 :         m_floatDependency = true;
     284         112 :         break;
     285             :     case UnoType::SORT_DOUBLE:
     286         727 :         m_doubleDependency = true;
     287         727 :         break;
     288             :     case UnoType::SORT_CHAR:
     289          82 :         m_charDependency = true;
     290          82 :         break;
     291             :     case UnoType::SORT_STRING:
     292        5659 :         m_stringDependency = true;
     293        5659 :         break;
     294             :     case UnoType::SORT_TYPE:
     295         117 :         m_typeDependency = true;
     296         117 :         break;
     297             :     case UnoType::SORT_ANY:
     298        2055 :         m_anyDependency = true;
     299        2055 :         break;
     300             :     case UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
     301         298 :         for (std::vector< OString >::iterator i(args.begin()); i != args.end();
     302             :              ++i)
     303             :         {
     304         170 :             insert(b2u(*i), false);
     305             :         }
     306             :         // fall through
     307             :     case UnoType::SORT_SEQUENCE_TYPE:
     308             :     case UnoType::SORT_ENUM_TYPE:
     309             :     case UnoType::SORT_PLAIN_STRUCT_TYPE:
     310             :     case UnoType::SORT_EXCEPTION_TYPE:
     311             :     case UnoType::SORT_INTERFACE_TYPE:
     312             :     case UnoType::SORT_TYPEDEF:
     313             :         {
     314             :             std::pair< Map::iterator, bool > i(
     315             :                 m_map.insert(
     316       25599 :                     Map::value_type(n, base ? KIND_BASE : KIND_NO_BASE)));
     317       25599 :             if (!i.second && base) {
     318           0 :                 i.first->second = KIND_BASE;
     319             :             }
     320       25599 :             break;
     321             :         }
     322             :     default:
     323             :         throw CannotDumpException(
     324           0 :             "unexpected type \"" + name
     325           0 :             + "\" in call to codemaker::cppumaker::Dependencies::Dependencies");
     326       47829 :     }
     327       47829 : }
     328             : 
     329             : } }
     330             : 
     331             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10