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