Files
libreoffice/idlc/source/fehelper.cxx

116 lines
3.2 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
2001-03-15 11:30:43 +00:00
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2001-03-15 11:30:43 +00:00
*
* This file incorporates work covered by the following license notice:
2001-03-15 11:30:43 +00:00
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2001-03-15 11:30:43 +00:00
#include <idlc/fehelper.hxx>
#include <idlc/errorhandler.hxx>
#include "idlc/idlc.hxx"
2001-03-15 11:30:43 +00:00
using namespace ::rtl;
FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
: m_pComplexPart(pComplPart)
, m_name(name)
, m_declType(declType)
{
}
FeDeclarator::~FeDeclarator()
{
}
bool FeDeclarator::checkType(AstDeclaration const * type)
2001-03-15 11:30:43 +00:00
{
OString tmp(m_name);
2001-05-10 12:07:49 +00:00
sal_Int32 count = m_name.lastIndexOf( ':' );
if( count != -1 )
tmp = m_name.copy( count+1 );
2001-03-15 11:30:43 +00:00
if (tmp == type->getLocalName())
return false;
2001-03-15 11:30:43 +00:00
else
return true;
2001-03-15 11:30:43 +00:00
}
AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
2001-03-15 11:30:43 +00:00
{
AstType* pType;
if ( pDecl == 0 )
{
return NULL;
}
2001-03-15 11:30:43 +00:00
if ( !pDecl->isType() )
{
idlc()->error()->noTypeError(pDecl);
return NULL;
}
pType = (AstType*)pDecl;
if (m_declType == FD_simple || m_pComplexPart == NULL)
return pType;
return NULL; // return through this statement should not happen
}
FeInheritanceHeader::FeInheritanceHeader(
NodeType nodeType, OString* pName, OString* pInherits,
std::vector< OString > * typeParameters)
2001-03-15 11:30:43 +00:00
: m_nodeType(nodeType)
, m_pName(pName)
, m_pInherits(NULL)
{
if (typeParameters != 0) {
m_typeParameters = *typeParameters;
}
2001-03-15 11:30:43 +00:00
initializeInherits(pInherits);
}
void FeInheritanceHeader::initializeInherits(OString* pInherits)
2001-03-15 11:30:43 +00:00
{
if ( pInherits )
2001-03-15 11:30:43 +00:00
{
AstScope* pScope = idlc()->scopes()->topNonNull();
AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
if ( pDecl )
2001-03-15 11:30:43 +00:00
{
AstDeclaration const * resolved = resolveTypedefs(pDecl);
if ( resolved->getNodeType() == getNodeType()
&& (resolved->getNodeType() != NT_interface
|| static_cast< AstInterface const * >(
resolved)->isDefined()) )
2001-03-15 11:30:43 +00:00
{
if ( idlc()->error()->checkPublished( pDecl ) )
{
m_pInherits = pDecl;
}
}
else
2001-03-15 11:30:43 +00:00
{
idlc()->error()->inheritanceError(
getNodeType(), getName(), pDecl);
2001-03-15 11:30:43 +00:00
}
}
else
2001-03-15 11:30:43 +00:00
{
idlc()->error()->lookupError(*pInherits);
2001-03-15 11:30:43 +00:00
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */