LCOV - code coverage report
Current view: top level - codemaker/source/cppumaker - dependencies.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 151 158 95.6 %
Date: 2015-06-13 12:38:46 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        8354 : 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        8354 :     m_sequenceDependency(false)
      51             : {
      52             :     assert(manager.is());
      53        8354 :     rtl::Reference< unoidl::Entity > ent;
      54        8354 :     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         557 :                 static_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
      91         557 :             if (!ent2->getDirectBase().isEmpty()) {
      92         554 :                 insert(ent2->getDirectBase());
      93             :             }
      94        2661 :             for (std::vector< unoidl::ExceptionTypeEntity::Member >::
      95         557 :                      const_iterator i(ent2->getDirectMembers().begin());
      96        1774 :                  i != ent2->getDirectMembers().end(); ++i)
      97             :             {
      98         330 :                 insert(i->type);
      99             :             }
     100         557 :             break;
     101             :         }
     102             :     case UnoType::SORT_INTERFACE_TYPE:
     103             :         {
     104             :             rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
     105        3845 :                 static_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
     106       24540 :             for (std::vector< unoidl::AnnotatedReference >::const_iterator i(
     107        3845 :                      ent2->getDirectMandatoryBases().begin());
     108       16360 :                  i != ent2->getDirectMandatoryBases().end(); ++i)
     109             :             {
     110        4335 :                 insert(i->name, true);
     111             :             }
     112        7690 :             if (!(ent2->getDirectAttributes().empty()
     113        3845 :                   && ent2->getDirectMethods().empty()))
     114             :             {
     115        3617 :                 insert("com.sun.star.uno.RuntimeException");
     116             :             }
     117       16911 :             for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::
     118        3845 :                      const_iterator i(ent2->getDirectAttributes().begin());
     119       11274 :                  i != ent2->getDirectAttributes().end(); ++i)
     120             :             {
     121        1792 :                 insert(i->type);
     122        5892 :                 for (std::vector< OUString >::const_iterator j(
     123        1792 :                          i->getExceptions.begin());
     124        3928 :                      j != i->getExceptions.end(); ++j)
     125             :                 {
     126         172 :                     insert(*j);
     127             :                 }
     128        6093 :                 for (std::vector< OUString >::const_iterator j(
     129        1792 :                          i->setExceptions.begin());
     130        4062 :                      j != i->setExceptions.end(); ++j)
     131             :                 {
     132         239 :                     insert(*j);
     133             :                 }
     134             :             }
     135       49059 :             for (std::vector< unoidl::InterfaceTypeEntity::Method >::
     136        3845 :                      const_iterator i(ent2->getDirectMethods().begin());
     137       32706 :                  i != ent2->getDirectMethods().end(); ++i)
     138             :             {
     139       12508 :                 insert(i->returnType);
     140       77115 :                 for (std::vector<
     141             :                          unoidl::InterfaceTypeEntity::Method::Parameter >::
     142       12508 :                          const_iterator j(i->parameters.begin());
     143       51410 :                      j != i->parameters.end(); ++j)
     144             :                 {
     145       13197 :                     insert(j->type);
     146             :                 }
     147       55590 :                 for (std::vector< OUString >::const_iterator j(
     148       12508 :                          i->exceptions.begin());
     149       37060 :                      j != i->exceptions.end(); ++j)
     150             :                 {
     151        6022 :                     insert(*j);
     152             :                 }
     153             :             }
     154        3845 :             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        1553 :                 static_cast< unoidl::ConstantGroupEntity * >(ent.get()));
     163       50826 :             for (std::vector< unoidl::ConstantGroupEntity::Member >::
     164        1553 :                      const_iterator i(ent2->getMembers().begin());
     165       33884 :                  i != ent2->getMembers().end(); ++i)
     166             :             {
     167       15389 :                 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       10629 :                     m_longDependency = true;
     182       10629 :                     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        1553 :             break;
     201             :         }
     202             :     case UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
     203             :         {
     204             :             rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
     205             :                 static_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
     206         863 :                     ent.get()));
     207         863 :             if (!ent2->getConstructors().empty()) {
     208         825 :                 insert(ent2->getBase());
     209             :             }
     210        5343 :             for (std::vector<
     211             :                      unoidl::SingleInterfaceBasedServiceEntity::Constructor >::
     212         863 :                      const_iterator i(ent2->getConstructors().begin());
     213        3562 :                  i != ent2->getConstructors().end(); ++i)
     214             :             {
     215        4818 :                 for (std::vector<
     216             :                          unoidl::SingleInterfaceBasedServiceEntity::
     217             :                          Constructor::Parameter >::const_iterator j(
     218         918 :                              i->parameters.begin());
     219        3212 :                      j != i->parameters.end(); ++j)
     220             :                 {
     221         688 :                     insert(j->type);
     222         688 :                     if (j->rest) {
     223           2 :                         m_sequenceDependency = true;
     224             :                     }
     225             :                 }
     226        3102 :                 for (std::vector< OUString >::const_iterator j(
     227         918 :                          i->exceptions.begin());
     228        2068 :                      j != i->exceptions.end(); ++j)
     229             :                 {
     230         116 :                     insert(*j);
     231             :                 }
     232             :             }
     233         863 :             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        8354 :     }
     243        8354 : }
     244             : 
     245        8354 : Dependencies::~Dependencies() {}
     246             : 
     247       47981 : void Dependencies::insert(OUString const & name, bool base) {
     248             :     sal_Int32 k;
     249       47981 :     std::vector< OString > args;
     250       95962 :     OUString n(b2u(UnoType::decompose(u2b(name), &k, &args)));
     251       47981 :     if (k != 0) {
     252        2411 :         m_sequenceDependency = true;
     253             :     }
     254       47981 :     switch (m_manager->getSort(n)) {
     255             :     case UnoType::SORT_VOID:
     256        5135 :         m_voidDependency = true;
     257        5135 :         break;
     258             :     case UnoType::SORT_BOOLEAN:
     259        2715 :         m_booleanDependency = true;
     260        2715 :         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        3794 :         m_longDependency = true;
     272        3794 :         break;
     273             :     case UnoType::SORT_UNSIGNED_LONG:
     274          87 :         m_unsignedLongDependency = true;
     275          87 :         break;
     276             :     case UnoType::SORT_HYPER:
     277         166 :         m_hyperDependency = true;
     278         166 :         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         731 :         m_doubleDependency = true;
     287         731 :         break;
     288             :     case UnoType::SORT_CHAR:
     289          82 :         m_charDependency = true;
     290          82 :         break;
     291             :     case UnoType::SORT_STRING:
     292        5677 :         m_stringDependency = true;
     293        5677 :         break;
     294             :     case UnoType::SORT_TYPE:
     295         117 :         m_typeDependency = true;
     296         117 :         break;
     297             :     case UnoType::SORT_ANY:
     298        2057 :         m_anyDependency = true;
     299        2057 :         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       25659 :                     Map::value_type(n, base ? KIND_BASE : KIND_NO_BASE)));
     317       25659 :             if (!i.second && base) {
     318           0 :                 i.first->second = KIND_BASE;
     319             :             }
     320       25659 :             break;
     321             :         }
     322             :     default:
     323             :         throw CannotDumpException(
     324           0 :             "unexpected type \"" + name
     325           0 :             + "\" in call to codemaker::cppumaker::Dependencies::Dependencies");
     326       47981 :     }
     327       47981 : }
     328             : 
     329             : } }
     330             : 
     331             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11