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/fehelper.hxx>
21 : #include <idlc/errorhandler.hxx>
22 : #include "idlc/idlc.hxx"
23 :
24 257 : FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
25 : : m_pComplexPart(pComplPart)
26 : , m_name(name)
27 257 : , m_declType(declType)
28 : {
29 257 : }
30 :
31 364 : FeDeclarator::~FeDeclarator()
32 : {
33 364 : }
34 :
35 145 : bool FeDeclarator::checkType(AstDeclaration const * type)
36 : {
37 145 : OString tmp(m_name);
38 145 : sal_Int32 count = m_name.lastIndexOf( ':' );
39 145 : if( count != -1 )
40 0 : tmp = m_name.copy( count+1 );
41 :
42 145 : if (tmp == type->getLocalName())
43 1 : return false;
44 : else
45 144 : return true;
46 : }
47 :
48 222 : AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
49 : {
50 : const AstType* pType;
51 :
52 222 : if ( pDecl == 0 )
53 : {
54 1 : return NULL;
55 : }
56 221 : if ( !pDecl->isType() )
57 : {
58 0 : ErrorHandler::noTypeError(pDecl);
59 0 : return NULL;
60 : }
61 221 : pType = static_cast<const AstType*>(pDecl);
62 221 : if (m_declType == FD_simple || m_pComplexPart == NULL)
63 221 : return pType;
64 :
65 0 : return NULL; // return through this statement should not happen
66 : }
67 :
68 410 : FeInheritanceHeader::FeInheritanceHeader(
69 : NodeType nodeType, OString* pName, OString* pInherits,
70 : std::vector< OString > * typeParameters)
71 : : m_nodeType(nodeType)
72 : , m_pName(pName)
73 410 : , m_pInherits(NULL)
74 : {
75 410 : if (typeParameters != 0) {
76 71 : m_typeParameters = *typeParameters;
77 : }
78 410 : initializeInherits(pInherits);
79 410 : }
80 :
81 410 : void FeInheritanceHeader::initializeInherits(OString* pInherits)
82 : {
83 410 : if ( pInherits )
84 : {
85 37 : AstScope* pScope = idlc()->scopes()->topNonNull();
86 37 : AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
87 37 : if ( pDecl )
88 : {
89 37 : AstDeclaration const * resolved = resolveTypedefs(pDecl);
90 74 : if ( resolved->getNodeType() == getNodeType()
91 71 : && (resolved->getNodeType() != NT_interface
92 23 : || static_cast< AstInterface const * >(
93 23 : resolved)->isDefined()) )
94 : {
95 34 : if ( ErrorHandler::checkPublished( pDecl ) )
96 : {
97 31 : m_pInherits = pDecl;
98 : }
99 : }
100 : else
101 : {
102 : ErrorHandler::inheritanceError(
103 3 : getNodeType(), getName(), pDecl);
104 : }
105 : }
106 : else
107 : {
108 0 : ErrorHandler::lookupError(*pInherits);
109 : }
110 : }
111 410 : }
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|