fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / idlc / source / astdeclaration.cxx
blobc23894ed902a805832edf4e194f1331a26047291
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/astdeclaration.hxx>
21 #include <idlc/astscope.hxx>
22 #include <rtl/strbuf.hxx>
23 #include <osl/diagnose.h>
25 static OString sGlobal("::");
27 static OString convertName(const OString& name)
29 OStringBuffer nameBuffer(name.getLength()+1);
30 sal_Int32 nIndex = 0;
33 OString token( name.getToken( 0, ':', nIndex ) );
34 if( !token.isEmpty() )
36 nameBuffer.append('/');
37 nameBuffer.append( token );
39 } while( nIndex != -1 );
40 return nameBuffer.makeStringAndClear();
43 AstDeclaration::AstDeclaration(NodeType type, const OString& name, AstScope* pScope)
44 : m_localName(name)
45 , m_pScope(pScope)
46 , m_nodeType(type)
47 , m_bImported(false)
48 , m_bIsAdded(false)
49 , m_bInMainFile(false)
50 , m_bPredefined(false)
51 , m_lineNumber(0)
53 if ( m_pScope )
55 AstDeclaration* pDecl = scopeAsDecl(m_pScope);
56 if (pDecl)
58 m_scopedName = pDecl->getScopedName();
59 if (!m_scopedName.isEmpty())
60 m_scopedName += sGlobal;
61 m_scopedName += m_localName;
63 } else
65 m_scopedName = m_localName;
67 m_fullName = convertName(m_scopedName);
69 if ( idlc()->getFileName() == idlc()->getRealFileName() )
71 m_fileName = idlc()->getMainFileName();
72 m_bInMainFile = true;
73 } else
75 m_fileName = idlc()->getFileName();
76 m_bImported = true;
79 m_documentation = idlc()->processDocumentation();
81 m_bPublished = idlc()->isPublished();
85 AstDeclaration::~AstDeclaration()
90 void AstDeclaration::setPredefined(bool bPredefined)
92 m_bPredefined = bPredefined;
93 if ( m_bPredefined )
95 m_fileName.clear();
96 m_bInMainFile = false;
100 bool AstDeclaration::isType() const {
101 switch (m_nodeType) {
102 case NT_interface:
103 case NT_instantiated_struct:
104 case NT_enum:
105 case NT_sequence:
106 case NT_typedef:
107 case NT_predefined:
108 case NT_type_parameter:
109 return true;
111 default:
112 OSL_ASSERT(m_nodeType != NT_struct); // see AstStruct::isType
113 return false;
117 bool AstDeclaration::hasAncestor(AstDeclaration* pDecl)
119 if (this == pDecl)
120 return true;
121 if ( !m_pScope )
122 return false;
123 return scopeAsDecl(m_pScope)->hasAncestor(pDecl);
126 bool AstDeclaration::dump(RegistryKey& rKey)
128 AstScope* pScope = declAsScope(this);
129 bool bRet = true;
131 if ( pScope )
133 DeclList::const_iterator iter = pScope->getIteratorBegin();
134 DeclList::const_iterator end = pScope->getIteratorEnd();
135 AstDeclaration* pDecl = NULL;
136 while ( iter != end && bRet)
138 pDecl = *iter;
139 if ( pDecl->isInMainfile() )
141 switch ( pDecl->getNodeType() )
143 case NT_module:
144 case NT_constants:
145 case NT_interface:
146 case NT_struct:
147 case NT_exception:
148 case NT_enum:
149 case NT_typedef:
150 case NT_service:
151 case NT_singleton:
152 bRet = pDecl->dump(rKey);
153 break;
154 default:
155 break;
159 ++iter;
162 return bRet;
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */