2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-03-15 11:30:43 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:26:30 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
2008-04-11 09:26:30 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
2008-04-11 09:26:30 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
2008-04-11 09:26:30 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
2008-04-11 09:26:30 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
2008-04-11 09:26:30 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-03-15 11:30:43 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 07:10:58 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_idlc.hxx"
|
2001-03-15 11:30:43 +00:00
|
|
|
#include <idlc/astconstant.hxx>
|
|
|
|
#include <idlc/astscope.hxx>
|
|
|
|
|
2004-03-30 15:44:23 +00:00
|
|
|
#include "registry/writer.hxx"
|
|
|
|
|
2001-03-15 11:30:43 +00:00
|
|
|
using namespace ::rtl;
|
|
|
|
|
|
|
|
AstConstant::AstConstant(const ExprType type,
|
|
|
|
const NodeType nodeType,
|
|
|
|
AstExpression* pExpr,
|
|
|
|
const ::rtl::OString& name,
|
|
|
|
AstScope* pScope)
|
|
|
|
: AstDeclaration(nodeType, name, pScope)
|
|
|
|
, m_pConstValue(pExpr)
|
|
|
|
, m_constValueType(type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AstConstant::AstConstant(const ExprType type,
|
|
|
|
AstExpression* pExpr,
|
|
|
|
const ::rtl::OString& name,
|
|
|
|
AstScope* pScope)
|
|
|
|
: AstDeclaration(NT_const, name, pScope)
|
|
|
|
, m_pConstValue(pExpr)
|
|
|
|
, m_constValueType(type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AstConstant::~AstConstant()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-06-03 14:06:56 +00:00
|
|
|
sal_Bool AstConstant::dumpBlob(
|
|
|
|
typereg::Writer & rBlob, sal_uInt16 index, bool published)
|
2001-03-15 11:30:43 +00:00
|
|
|
{
|
|
|
|
RTConstValue aConst;
|
|
|
|
sal_Unicode* str = NULL;
|
|
|
|
|
|
|
|
AstExprValue *exprVal = getConstValue()->getExprValue();
|
|
|
|
switch (getConstValueType())
|
|
|
|
{
|
|
|
|
case ET_short:
|
|
|
|
aConst.m_type = RT_TYPE_INT16;
|
|
|
|
aConst.m_value.aShort = exprVal->u.sval;
|
|
|
|
break;
|
|
|
|
case ET_ushort:
|
|
|
|
aConst.m_type = RT_TYPE_UINT16;
|
|
|
|
aConst.m_value.aUShort = exprVal->u.usval;
|
|
|
|
break;
|
|
|
|
case ET_long:
|
|
|
|
aConst.m_type = RT_TYPE_INT32;
|
|
|
|
aConst.m_value.aLong = exprVal->u.lval;
|
|
|
|
break;
|
|
|
|
case ET_ulong:
|
|
|
|
aConst.m_type = RT_TYPE_UINT32;
|
|
|
|
aConst.m_value.aULong = exprVal->u.ulval;
|
|
|
|
break;
|
|
|
|
case ET_hyper:
|
|
|
|
aConst.m_type = RT_TYPE_INT64;
|
|
|
|
aConst.m_value.aHyper = exprVal->u.hval;
|
|
|
|
break;
|
|
|
|
case ET_uhyper:
|
|
|
|
aConst.m_type = RT_TYPE_UINT64;
|
|
|
|
aConst.m_value.aUHyper = exprVal->u.uhval;
|
|
|
|
break;
|
|
|
|
case ET_float:
|
|
|
|
aConst.m_type = RT_TYPE_FLOAT;
|
|
|
|
aConst.m_value.aFloat = exprVal->u.fval;
|
|
|
|
break;
|
|
|
|
case ET_double:
|
|
|
|
aConst.m_type = RT_TYPE_DOUBLE;
|
|
|
|
aConst.m_value.aDouble = exprVal->u.dval;
|
|
|
|
break;
|
|
|
|
case ET_byte:
|
|
|
|
aConst.m_type = RT_TYPE_BYTE;
|
|
|
|
aConst.m_value.aByte = exprVal->u.byval;
|
|
|
|
break;
|
|
|
|
case ET_boolean:
|
|
|
|
aConst.m_type = RT_TYPE_BOOL;
|
|
|
|
aConst.m_value.aBool = exprVal->u.bval;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: exprtype to const type: cannot convert ExprType\n",
|
|
|
|
idlc()->getOptions()->getProgramName().getStr());
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-27 09:53:19 +00:00
|
|
|
OString name = getLocalName();
|
2001-03-15 11:30:43 +00:00
|
|
|
|
|
|
|
OUString type;
|
|
|
|
if ( getNodeType() != NT_enum_val )
|
|
|
|
{
|
|
|
|
type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8);
|
|
|
|
}
|
|
|
|
|
2004-03-30 15:44:23 +00:00
|
|
|
rBlob.setFieldData(
|
2005-01-31 14:44:35 +00:00
|
|
|
index, getDocumentation(), OUString(),
|
2004-06-03 14:06:56 +00:00
|
|
|
RT_ACCESS_CONST | (published ? RT_ACCESS_PUBLISHED : 0),
|
2004-03-30 15:44:23 +00:00
|
|
|
OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst);
|
2001-03-15 11:30:43 +00:00
|
|
|
if (str)
|
|
|
|
delete[] str;
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
2010-10-14 08:30:07 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|