LCOV - code coverage report
Current view: top level - idlc/source - aststruct.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 75 0.0 %
Date: 2014-04-14 Functions: 0 7 0.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/aststruct.hxx>
      21             : #include <idlc/astmember.hxx>
      22             : 
      23             : #include "registry/version.h"
      24             : #include "registry/writer.hxx"
      25             : 
      26             : using namespace ::rtl;
      27             : 
      28           0 : AstStruct::AstStruct(
      29             :     const OString& name, std::vector< OString > const & typeParameters,
      30             :     AstStruct const* pBaseType, AstScope* pScope)
      31             :     : AstType(NT_struct, name, pScope)
      32             :     , AstScope(NT_struct)
      33           0 :     , m_pBaseType(pBaseType)
      34             : {
      35           0 :     for (std::vector< OString >::const_iterator i(typeParameters.begin());
      36           0 :          i != typeParameters.end(); ++i)
      37             :     {
      38             :         m_typeParameters.push_back(
      39           0 :             new AstType(NT_type_parameter, *i, 0));
      40             :     }
      41           0 : }
      42             : 
      43           0 : AstStruct::AstStruct(const NodeType type,
      44             :                         const OString& name,
      45             :                        AstStruct const* pBaseType,
      46             :                      AstScope* pScope)
      47             :     : AstType(type, name, pScope)
      48             :     , AstScope(type)
      49           0 :     , m_pBaseType(pBaseType)
      50             : {
      51           0 : }
      52             : 
      53           0 : AstStruct::~AstStruct()
      54             : {
      55           0 :     for (DeclList::iterator i(m_typeParameters.begin());
      56           0 :          i != m_typeParameters.end(); ++i)
      57             :     {
      58           0 :         delete *i;
      59             :     }
      60           0 : }
      61             : 
      62           0 : AstDeclaration const * AstStruct::findTypeParameter(OString const & name)
      63             :     const
      64             : {
      65           0 :     for (DeclList::const_iterator i(m_typeParameters.begin());
      66           0 :          i != m_typeParameters.end(); ++i)
      67             :     {
      68           0 :         if ((*i)->getLocalName() == name) {
      69           0 :             return *i;
      70             :         }
      71             :     }
      72           0 :     return 0;
      73             : }
      74             : 
      75           0 : bool AstStruct::isType() const {
      76           0 :     return getNodeType() == NT_struct
      77           0 :         ? getTypeParameterCount() == 0 : AstDeclaration::isType();
      78             : }
      79             : 
      80           0 : bool AstStruct::dump(RegistryKey& rKey)
      81             : {
      82           0 :     RegistryKey localKey;
      83           0 :     if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey))
      84             :     {
      85             :         fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n",
      86           0 :                 idlc()->getOptions()->getProgramName().getStr(),
      87           0 :                 getFullName().getStr(), OUStringToOString(rKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
      88           0 :         return false;
      89             :     }
      90             : 
      91           0 :     if (m_typeParameters.size() > SAL_MAX_UINT16) {
      92             :         fprintf(
      93             :             stderr,
      94             :             ("%s: polymorphic struct type template %s has too many type"
      95             :              " parameters\n"),
      96           0 :             idlc()->getOptions()->getProgramName().getStr(),
      97           0 :             getScopedName().getStr());
      98           0 :         return false;
      99             :     }
     100             : 
     101           0 :     sal_uInt16 nMember = getNodeCount(NT_member);
     102             : 
     103           0 :     RTTypeClass typeClass = RT_TYPE_STRUCT;
     104           0 :     if ( getNodeType() == NT_exception )
     105           0 :         typeClass = RT_TYPE_EXCEPTION;
     106             : 
     107           0 :     OUString emptyStr;
     108             :     typereg::Writer aBlob(
     109           0 :         (m_typeParameters.empty() && !m_bPublished
     110             :          ? TYPEREG_VERSION_0 : TYPEREG_VERSION_1),
     111           0 :         getDocumentation(), emptyStr, typeClass, m_bPublished,
     112           0 :         OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8),
     113             :         m_pBaseType == 0 ? 0 : 1, nMember, 0,
     114           0 :         static_cast< sal_uInt16 >(m_typeParameters.size()));
     115           0 :     if (m_pBaseType != 0) {
     116             :         aBlob.setSuperTypeName(
     117             :             0,
     118             :             OStringToOUString(
     119           0 :                 m_pBaseType->getRelativName(), RTL_TEXTENCODING_UTF8));
     120             :     }
     121             : 
     122           0 :     if ( nMember > 0 )
     123             :     {
     124           0 :         DeclList::const_iterator iter = getIteratorBegin();
     125           0 :         DeclList::const_iterator end = getIteratorEnd();
     126           0 :         AstDeclaration* pDecl = NULL;
     127           0 :         AstMember*  pMember = NULL;
     128           0 :         sal_uInt16  index = 0;
     129           0 :         while ( iter != end )
     130             :         {
     131           0 :             pDecl = *iter;
     132           0 :             if ( pDecl->getNodeType() == NT_member )
     133             :             {
     134           0 :                 pMember = (AstMember*)pDecl;
     135           0 :                 RTFieldAccess flags = RT_ACCESS_READWRITE;
     136           0 :                 OString typeName;
     137           0 :                 if (pMember->getType()->getNodeType() == NT_type_parameter) {
     138           0 :                     flags |= RT_ACCESS_PARAMETERIZED_TYPE;
     139           0 :                     typeName = pMember->getType()->getLocalName();
     140             :                 } else {
     141           0 :                     typeName = pMember->getType()->getRelativName();
     142             :                 }
     143             :                 aBlob.setFieldData(
     144           0 :                     index++, pMember->getDocumentation(), emptyStr, flags,
     145             :                     OStringToOUString(
     146           0 :                         pMember->getLocalName(), RTL_TEXTENCODING_UTF8),
     147             :                     OStringToOUString(typeName, RTL_TEXTENCODING_UTF8),
     148           0 :                     RTConstValue());
     149             :             }
     150           0 :             ++iter;
     151             :         }
     152             :     }
     153             : 
     154           0 :     sal_uInt16 index = 0;
     155           0 :     for (DeclList::iterator i(m_typeParameters.begin());
     156           0 :          i != m_typeParameters.end(); ++i)
     157             :     {
     158             :         aBlob.setReferenceData(
     159             :             index++, emptyStr, RT_REF_TYPE_PARAMETER, RT_ACCESS_INVALID,
     160             :             OStringToOUString(
     161           0 :                 (*i)->getLocalName(), RTL_TEXTENCODING_UTF8));
     162             :     }
     163             : 
     164             :     sal_uInt32 aBlobSize;
     165           0 :     void const * pBlob = aBlob.getBlob(&aBlobSize);
     166             : 
     167           0 :     if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY,
     168           0 :                             (RegValue)pBlob, aBlobSize))
     169             :     {
     170             :         fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n",
     171           0 :                 idlc()->getOptions()->getProgramName().getStr(),
     172           0 :                 getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
     173           0 :         return false;
     174             :     }
     175             : 
     176           0 :     return true;
     177             : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10