Bump version to 4.3-4
[LibreOffice.git] / idlc / source / fehelper.cxx
blob12636e1ef6a6b9ebc7a07bf0d98d320d989392ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <idlc/fehelper.hxx>
21 #include <idlc/errorhandler.hxx>
22 #include "idlc/idlc.hxx"
24 using namespace ::rtl;
26 FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
27 : m_pComplexPart(pComplPart)
28 , m_name(name)
29 , m_declType(declType)
33 FeDeclarator::~FeDeclarator()
37 bool FeDeclarator::checkType(AstDeclaration const * type)
39 OString tmp(m_name);
40 sal_Int32 count = m_name.lastIndexOf( ':' );
41 if( count != -1 )
42 tmp = m_name.copy( count+1 );
44 if (tmp == type->getLocalName())
45 return false;
46 else
47 return true;
50 AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
52 AstType* pType;
54 if ( pDecl == 0 )
56 return NULL;
58 if ( !pDecl->isType() )
60 idlc()->error()->noTypeError(pDecl);
61 return NULL;
63 pType = (AstType*)pDecl;
64 if (m_declType == FD_simple || m_pComplexPart == NULL)
65 return pType;
67 return NULL; // return through this statement should not happen
70 FeInheritanceHeader::FeInheritanceHeader(
71 NodeType nodeType, OString* pName, OString* pInherits,
72 std::vector< OString > * typeParameters)
73 : m_nodeType(nodeType)
74 , m_pName(pName)
75 , m_pInherits(NULL)
77 if (typeParameters != 0) {
78 m_typeParameters = *typeParameters;
80 initializeInherits(pInherits);
83 void FeInheritanceHeader::initializeInherits(OString* pInherits)
85 if ( pInherits )
87 AstScope* pScope = idlc()->scopes()->topNonNull();
88 AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
89 if ( pDecl )
91 AstDeclaration const * resolved = resolveTypedefs(pDecl);
92 if ( resolved->getNodeType() == getNodeType()
93 && (resolved->getNodeType() != NT_interface
94 || static_cast< AstInterface const * >(
95 resolved)->isDefined()) )
97 if ( idlc()->error()->checkPublished( pDecl ) )
99 m_pInherits = pDecl;
102 else
104 idlc()->error()->inheritanceError(
105 getNodeType(), getName(), pDecl);
108 else
110 idlc()->error()->lookupError(*pInherits);
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */