LCOV - code coverage report
Current view: top level - idlc/source - astconstant.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 51 0.0 %
Date: 2014-04-14 Functions: 0 5 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/astconstant.hxx>
      21             : #include <idlc/astscope.hxx>
      22             : 
      23             : #include "registry/writer.hxx"
      24             : 
      25             : using namespace ::rtl;
      26             : 
      27           0 : AstConstant::AstConstant(const ExprType type,
      28             :                          const NodeType nodeType,
      29             :                          AstExpression* pExpr,
      30             :                          const OString& name,
      31             :                          AstScope* pScope)
      32             :     : AstDeclaration(nodeType, name, pScope)
      33             :     , m_pConstValue(pExpr)
      34           0 :     , m_constValueType(type)
      35             : {
      36           0 : }
      37             : 
      38           0 : AstConstant::AstConstant(const ExprType type,
      39             :                          AstExpression* pExpr,
      40             :                          const OString& name,
      41             :                          AstScope* pScope)
      42             :     : AstDeclaration(NT_const, name, pScope)
      43             :     , m_pConstValue(pExpr)
      44           0 :     , m_constValueType(type)
      45             : {
      46           0 : }
      47             : 
      48           0 : AstConstant::~AstConstant()
      49             : {
      50             : 
      51           0 : }
      52             : 
      53           0 : bool AstConstant::dumpBlob(
      54             :     typereg::Writer & rBlob, sal_uInt16 index, bool published)
      55             : {
      56           0 :     RTConstValue    aConst;
      57             : 
      58           0 :     AstExprValue *exprVal = getConstValue()->getExprValue();
      59           0 :     switch (getConstValueType())
      60             :     {
      61             :         case ET_short:
      62           0 :             aConst.m_type = RT_TYPE_INT16;
      63           0 :             aConst.m_value.aShort = exprVal->u.sval;
      64           0 :             break;
      65             :         case ET_ushort:
      66           0 :             aConst.m_type = RT_TYPE_UINT16;
      67           0 :             aConst.m_value.aUShort = exprVal->u.usval;
      68           0 :             break;
      69             :         case ET_long:
      70           0 :             aConst.m_type = RT_TYPE_INT32;
      71           0 :             aConst.m_value.aLong = exprVal->u.lval;
      72           0 :             break;
      73             :         case ET_ulong:
      74           0 :             aConst.m_type = RT_TYPE_UINT32;
      75           0 :             aConst.m_value.aULong = exprVal->u.ulval;
      76           0 :             break;
      77             :         case ET_hyper:
      78           0 :             aConst.m_type = RT_TYPE_INT64;
      79           0 :             aConst.m_value.aHyper = exprVal->u.hval;
      80           0 :             break;
      81             :         case ET_uhyper:
      82           0 :             aConst.m_type = RT_TYPE_UINT64;
      83           0 :             aConst.m_value.aUHyper = exprVal->u.uhval;
      84           0 :             break;
      85             :         case ET_float:
      86           0 :             aConst.m_type = RT_TYPE_FLOAT;
      87           0 :             aConst.m_value.aFloat = exprVal->u.fval;
      88           0 :             break;
      89             :         case ET_double:
      90           0 :             aConst.m_type = RT_TYPE_DOUBLE;
      91           0 :             aConst.m_value.aDouble = exprVal->u.dval;
      92           0 :             break;
      93             :         case ET_byte:
      94           0 :             aConst.m_type = RT_TYPE_BYTE;
      95           0 :             aConst.m_value.aByte = exprVal->u.byval;
      96           0 :             break;
      97             :         case ET_boolean:
      98           0 :             aConst.m_type = RT_TYPE_BOOL;
      99           0 :             aConst.m_value.aBool = exprVal->u.bval;
     100           0 :             break;
     101             :         default:
     102             :             {
     103             :                 fprintf(stderr, "%s: exprtype to const type: cannot convert ExprType\n",
     104           0 :                         idlc()->getOptions()->getProgramName().getStr());
     105           0 :                 return false;
     106             :             }
     107             :     }
     108             : 
     109           0 :     OString name = getLocalName();
     110             : 
     111           0 :     OUString type;
     112           0 :     if ( getNodeType() != NT_enum_val )
     113             :     {
     114           0 :         type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8);
     115             :     }
     116             : 
     117             :     rBlob.setFieldData(
     118           0 :         index, getDocumentation(), OUString(),
     119             :         RT_ACCESS_CONST | (published ? RT_ACCESS_PUBLISHED : 0),
     120           0 :         OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst);
     121             : 
     122           0 :     return true;
     123             : }
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10