fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / idlc / source / fehelper.cxx
blob2a5fb1d3468c5feee386235e6b38dd9ff70fee4a
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 FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
25 : m_pComplexPart(pComplPart)
26 , m_name(name)
27 , m_declType(declType)
31 FeDeclarator::~FeDeclarator()
35 bool FeDeclarator::checkType(AstDeclaration const * type)
37 OString tmp(m_name);
38 sal_Int32 count = m_name.lastIndexOf( ':' );
39 if( count != -1 )
40 tmp = m_name.copy( count+1 );
42 if (tmp == type->getLocalName())
43 return false;
44 else
45 return true;
48 AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
50 const AstType* pType;
52 if ( pDecl == 0 )
54 return NULL;
56 if ( !pDecl->isType() )
58 ErrorHandler::noTypeError(pDecl);
59 return NULL;
61 pType = static_cast<const AstType*>(pDecl);
62 if (m_declType == FD_simple || m_pComplexPart == NULL)
63 return pType;
65 return NULL; // return through this statement should not happen
68 FeInheritanceHeader::FeInheritanceHeader(
69 NodeType nodeType, OString* pName, OString* pInherits,
70 std::vector< OString > * typeParameters)
71 : m_nodeType(nodeType)
72 , m_pName(pName)
73 , m_pInherits(NULL)
75 if (typeParameters != 0) {
76 m_typeParameters = *typeParameters;
78 initializeInherits(pInherits);
81 void FeInheritanceHeader::initializeInherits(OString* pInherits)
83 if ( pInherits )
85 AstScope* pScope = idlc()->scopes()->topNonNull();
86 AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
87 if ( pDecl )
89 AstDeclaration const * resolved = resolveTypedefs(pDecl);
90 if ( resolved->getNodeType() == getNodeType()
91 && (resolved->getNodeType() != NT_interface
92 || static_cast< AstInterface const * >(
93 resolved)->isDefined()) )
95 if ( ErrorHandler::checkPublished( pDecl ) )
97 m_pInherits = pDecl;
100 else
102 ErrorHandler::inheritanceError(
103 getNodeType(), getName(), pDecl);
106 else
108 ErrorHandler::lookupError(*pInherits);
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */