LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/parser_i/idl - pe_type2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 104 116 89.7 %
Date: 2012-12-27 Functions: 16 19 84.2 %
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 <precomp.h>
      21             : #include <s2_luidl/pe_type2.hxx>
      22             : 
      23             : 
      24             : // NOT FULLY DEFINED SERVICES
      25             : #include <ary/idl/i_gate.hxx>
      26             : #include <ary/idl/i_type.hxx>
      27             : #include <ary/idl/ip_type.hxx>
      28             : #include <ary/doc/d_oldidldocu.hxx>
      29             : #include <s2_luidl/uidl_tok.hxx>
      30             : #include <s2_luidl/tk_ident.hxx>
      31             : #include <s2_luidl/tk_keyw.hxx>
      32             : #include <s2_luidl/tk_punct.hxx>
      33             : 
      34             : 
      35             : 
      36             : /** Implementation Concept for Parsing a Type
      37             : 
      38             : Example Type:
      39             :     sequence < ::abc::TName< TplType > >  AnyName;
      40             : 
      41             : Status Changes:
      42             : 
      43             : expect_type:
      44             :     sequence        -> expect_type
      45             :     <               -> expect_type
      46             :     ::              -> expect_quname_part
      47             :     abc             -> expect_quname_separator
      48             :     ::              -> expect_quname_part
      49             :     TName           -> expect_quname_separator
      50             :     <               -> in_template_type (process in nested PE_Type instance)
      51             : 
      52             :         expect_type:
      53             :             TplType         ->expect_quname_separator
      54             :             >               -> e_none (finish, '>' not handled)
      55             : 
      56             :     >               -> expect_quname_separator
      57             :     >               -> expect_quname_separator (not finish, because sequencecounter > 0)
      58             :     AnyName         -> e_none  (finish)
      59             : */
      60             : 
      61             : 
      62             : namespace csi
      63             : {
      64             : namespace uidl
      65             : {
      66             : 
      67             : 
      68          57 : PE_Type::PE_Type( ary::idl::Type_id & o_rResult )
      69             :     :   pResult(&o_rResult),
      70             :         nIsSequenceCounter(0),
      71             :         nSequenceDownCounter(0),
      72             :         bIsUnsigned(false),
      73             :         sFullType(),
      74             :         eState(e_none),
      75             :         sLastPart(),
      76             :         pPE_TemplateType(0), // @attention Recursion, only initiate, if needed!
      77             :         nTemplateType(0),
      78          57 :         aTemplateParameters()
      79             : {
      80          57 : }
      81             : 
      82         114 : PE_Type::~PE_Type()
      83             : {
      84         114 : }
      85             : 
      86             : void
      87      141758 : PE_Type::ProcessToken( const Token & i_rToken )
      88             : {
      89      141758 :     i_rToken.Trigger(*this);
      90      141758 : }
      91             : 
      92             : void
      93       72072 : PE_Type::Process_Identifier( const TokIdentifier & i_rToken )
      94             : {
      95       72072 :     if (eState == expect_type)
      96             :     {
      97       10840 :         sLastPart = i_rToken.Text();
      98       10840 :         eState = expect_quname_separator;
      99       10840 :         SetResult(done, stay);
     100             :     }
     101       61232 :     else if (eState == expect_quname_part)
     102             :     {
     103       41675 :         sLastPart = i_rToken.Text();
     104       41675 :         eState = expect_quname_separator;
     105       41675 :         SetResult(done, stay);
     106             :     }
     107       19557 :     else if (eState == expect_quname_separator)
     108             :     {
     109       19557 :         Finish();
     110             :     }
     111       72072 : }
     112             : 
     113             : void
     114       41675 : PE_Type::Process_NameSeparator()
     115             : {
     116       41675 :     if (eState == expect_type)
     117             :     {
     118        1993 :         sFullType.Init(true);
     119        1993 :         eState = expect_quname_part;
     120        1993 :         SetResult(done, stay);
     121             :     }
     122       39682 :     else if (eState == expect_quname_separator)
     123             :     {
     124       39682 :         sFullType += sLastPart;
     125       39682 :         eState = expect_quname_part;
     126       39682 :         SetResult(done, stay);
     127             :     }
     128       41675 : }
     129             : 
     130             : void
     131       10222 : PE_Type::Process_Punctuation( const TokPunctuation & i_rToken )
     132             : {
     133       10222 :     if (eState == expect_type)
     134             :     {
     135             :         csv_assert(i_rToken.Id() == TokPunctuation::Lesser);
     136        1125 :            SetResult(done, stay);
     137             :     }
     138        9097 :     else if (eState == expect_quname_separator)
     139             :     {
     140        9072 :         switch (i_rToken.Id())
     141             :         {
     142             :             case TokPunctuation::Lesser:
     143          18 :                 eState = in_template_type;
     144          18 :                 SetResult( done, push_sure, &MyTemplateType() );
     145          18 :                 break;
     146             : 
     147             :             case TokPunctuation::Greater:
     148        1143 :                 if (nSequenceDownCounter > 0)
     149             :                 {
     150        1125 :                     nSequenceDownCounter--;
     151        1125 :                     SetResult(done, stay);
     152             :                 }
     153             :                 else
     154             :                 {
     155          18 :                     Finish();
     156             :                 }
     157        1143 :                 break;
     158             : 
     159             :             default:
     160        7911 :                 Finish();
     161             :         }   // end switch
     162             :     }
     163          25 :     else if (eState == in_template_type)
     164             :     {
     165          25 :         aTemplateParameters.push_back(nTemplateType);
     166          25 :         nTemplateType = 0;
     167             : 
     168          25 :         if (i_rToken.Id() == TokPunctuation::Greater)
     169             :         {
     170          18 :         eState = expect_quname_separator;
     171          18 :         SetResult(done, stay);
     172             :     }
     173           7 :         else if (i_rToken.Id() == TokPunctuation::Comma)
     174             :         {
     175           7 :               SetResult(done, push_sure, &MyTemplateType());
     176             :         }
     177             :         else
     178             :         {
     179             :             csv_assert(false);
     180           0 :             Finish();
     181             :         }
     182             :     }
     183       10222 : }
     184             : 
     185             : void
     186       14653 : PE_Type::Process_BuiltInType( const TokBuiltInType & i_rToken )
     187             : {
     188       14653 :     if (eState == expect_type)
     189             :     {
     190       14653 :         sLastPart = i_rToken.Text();
     191       14653 :         eState = expect_quname_separator;
     192       14653 :         SetResult(done, stay);
     193             :     }
     194           0 :     else if (eState == expect_quname_part)
     195             :     {
     196             :         // Can this happen?
     197             : 
     198           0 :         sLastPart = i_rToken.Text();
     199           0 :         eState = expect_quname_separator;
     200           0 :         SetResult(done, stay);
     201             :     }
     202           0 :     else if (eState == expect_quname_separator)
     203             :     {
     204             :         // Can this happen?
     205             : 
     206           0 :         Finish();
     207             :     }
     208       14653 : }
     209             : 
     210             : void
     211        1181 : PE_Type::Process_TypeModifier( const TokTypeModifier & i_rToken )
     212             : {
     213        1181 :     if (eState == expect_type)
     214             :     {
     215        1181 :         switch ( i_rToken.Id() )
     216             :         {
     217             :             case TokTypeModifier::tmod_unsigned:
     218          56 :                     bIsUnsigned = true;
     219          56 :                     break;
     220             :             case TokTypeModifier::tmod_sequence:
     221        1125 :                     nIsSequenceCounter++;
     222        1125 :                     nSequenceDownCounter++;
     223        1125 :                     break;
     224             :             default:
     225             :                 csv_assert(false);
     226             :         }
     227        1181 :         SetResult(done, stay);
     228             :     }
     229           0 :     else if (eState == expect_quname_separator)
     230             :     {
     231             :         // Can this happen?
     232             : 
     233           0 :         Finish();
     234             :     }
     235        1181 : }
     236             : 
     237             : void
     238           0 : PE_Type::Process_Default()
     239             : {
     240           0 :     Finish();
     241           0 : }
     242             : 
     243             : void
     244       27486 : PE_Type::Finish()
     245             : {
     246             :     csv_assert(nSequenceDownCounter == 0);
     247             : 
     248       27486 :     sFullType.SetLocalName(sLastPart);
     249       27486 :     SetResult(not_done, pop_success);
     250       27486 : }
     251             : 
     252             : PE_Type &
     253          25 : PE_Type::MyTemplateType()
     254             : {
     255          25 :     if (NOT pPE_TemplateType)
     256             :     {
     257           9 :         pPE_TemplateType = new PE_Type(nTemplateType);
     258           9 :         pPE_TemplateType->EstablishContacts( this,
     259           9 :                                              MyRepository(),
     260          18 :                                              TokenResult() );
     261             :     }
     262          25 :     return *pPE_TemplateType;
     263             : }
     264             : 
     265             : void
     266       27486 : PE_Type::InitData()
     267             : {
     268       27486 :     eState = expect_type;
     269             : 
     270       27486 :     nIsSequenceCounter = 0;
     271       27486 :     nSequenceDownCounter = 0;
     272       27486 :     bIsUnsigned = false;
     273       27486 :     sFullType.Empty();
     274       27486 :     sLastPart.clear();
     275       27486 :     nTemplateType = 0;
     276       27486 :     csv::erase_container(aTemplateParameters);
     277       27486 : }
     278             : 
     279             : void
     280       27486 : PE_Type::TransferData()
     281             : {
     282       27486 :     if (bIsUnsigned)
     283             :     {
     284          56 :         StreamLock sl(40);
     285          56 :         String sName( sl() << "unsigned " << sFullType.LocalName() << c_str );
     286          56 :         sFullType.SetLocalName(sName);
     287             :     }
     288             : 
     289             :     const ary::idl::Type &
     290       27486 :         result = Gate().Types().CheckIn_Type( sFullType,
     291             :                                               nIsSequenceCounter,
     292       27486 :                                               CurNamespace().CeId(),
     293       54972 :                                               &aTemplateParameters );
     294       27486 :     *pResult = result.TypeId();
     295       27486 :     eState = e_none;
     296       27486 : }
     297             : 
     298             : UnoIDL_PE &
     299        1955 : PE_Type::MyPE()
     300             : {
     301        1955 :      return *this;
     302             : }
     303             : 
     304             : 
     305             : }   // namespace uidl
     306           3 : }   // namespace csi
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10