fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / codemaker / source / cppumaker / dependencies.cxx
blobb56bacfd4b1fe820cf47cec4dde7a49c46ea6715
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 "sal/config.h"
22 #include <cassert>
23 #include <utility>
24 #include <vector>
26 #include "codemaker/global.hxx"
27 #include "codemaker/typemanager.hxx"
28 #include "codemaker/unotype.hxx"
30 #include "osl/diagnose.h"
31 #include "rtl/ref.hxx"
32 #include "rtl/string.hxx"
33 #include "rtl/ustring.hxx"
34 #include "sal/types.h"
35 #include "unoidl/unoidl.hxx"
37 #include "dependencies.hxx"
39 namespace codemaker { namespace cppumaker {
41 Dependencies::Dependencies(
42 rtl::Reference< TypeManager > const & manager, OUString const & name):
43 m_manager(manager), m_voidDependency(false), m_booleanDependency(false),
44 m_byteDependency(false), m_shortDependency(false),
45 m_unsignedShortDependency(false), m_longDependency(false),
46 m_unsignedLongDependency(false), m_hyperDependency(false),
47 m_unsignedHyperDependency(false), m_floatDependency(false),
48 m_doubleDependency(false), m_charDependency(false),
49 m_stringDependency(false), m_typeDependency(false), m_anyDependency(false),
50 m_sequenceDependency(false)
52 assert(manager.is());
53 rtl::Reference< unoidl::Entity > ent;
54 switch (m_manager->getSort(name, &ent)) {
55 case UnoType::SORT_ENUM_TYPE:
56 break;
57 case UnoType::SORT_PLAIN_STRUCT_TYPE:
59 rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
60 static_cast< unoidl::PlainStructTypeEntity * >(ent.get()));
61 if (!ent2->getDirectBase().isEmpty()) {
62 insert(ent2->getDirectBase());
64 for (std::vector< unoidl::PlainStructTypeEntity::Member >::
65 const_iterator i(ent2->getDirectMembers().begin());
66 i != ent2->getDirectMembers().end(); ++i)
68 insert(i->type);
70 break;
72 case UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
74 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
75 static_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
76 ent.get()));
77 for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::
78 Member >::const_iterator i(ent2->getMembers().begin());
79 i != ent2->getMembers().end(); ++i)
81 if (!i->parameterized) {
82 insert(i->type);
85 break;
87 case UnoType::SORT_EXCEPTION_TYPE:
89 rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
90 static_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
91 if (!ent2->getDirectBase().isEmpty()) {
92 insert(ent2->getDirectBase());
94 for (std::vector< unoidl::ExceptionTypeEntity::Member >::
95 const_iterator i(ent2->getDirectMembers().begin());
96 i != ent2->getDirectMembers().end(); ++i)
98 insert(i->type);
100 break;
102 case UnoType::SORT_INTERFACE_TYPE:
104 rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
105 static_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
106 for (std::vector< unoidl::AnnotatedReference >::const_iterator i(
107 ent2->getDirectMandatoryBases().begin());
108 i != ent2->getDirectMandatoryBases().end(); ++i)
110 insert(i->name, true);
112 if (!(ent2->getDirectAttributes().empty()
113 && ent2->getDirectMethods().empty()))
115 insert("com.sun.star.uno.RuntimeException");
117 for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::
118 const_iterator i(ent2->getDirectAttributes().begin());
119 i != ent2->getDirectAttributes().end(); ++i)
121 insert(i->type);
122 for (std::vector< OUString >::const_iterator j(
123 i->getExceptions.begin());
124 j != i->getExceptions.end(); ++j)
126 insert(*j);
128 for (std::vector< OUString >::const_iterator j(
129 i->setExceptions.begin());
130 j != i->setExceptions.end(); ++j)
132 insert(*j);
135 for (std::vector< unoidl::InterfaceTypeEntity::Method >::
136 const_iterator i(ent2->getDirectMethods().begin());
137 i != ent2->getDirectMethods().end(); ++i)
139 insert(i->returnType);
140 for (std::vector<
141 unoidl::InterfaceTypeEntity::Method::Parameter >::
142 const_iterator j(i->parameters.begin());
143 j != i->parameters.end(); ++j)
145 insert(j->type);
147 for (std::vector< OUString >::const_iterator j(
148 i->exceptions.begin());
149 j != i->exceptions.end(); ++j)
151 insert(*j);
154 break;
156 case UnoType::SORT_TYPEDEF:
157 insert(static_cast< unoidl::TypedefEntity * >(ent.get())->getType());
158 break;
159 case UnoType::SORT_CONSTANT_GROUP:
161 rtl::Reference< unoidl::ConstantGroupEntity > ent2(
162 static_cast< unoidl::ConstantGroupEntity * >(ent.get()));
163 for (std::vector< unoidl::ConstantGroupEntity::Member >::
164 const_iterator i(ent2->getMembers().begin());
165 i != ent2->getMembers().end(); ++i)
167 switch (i->value.type) {
168 case unoidl::ConstantValue::TYPE_BOOLEAN:
169 m_booleanDependency = true;
170 break;
171 case unoidl::ConstantValue::TYPE_BYTE:
172 m_byteDependency = true;
173 break;
174 case unoidl::ConstantValue::TYPE_SHORT:
175 m_shortDependency = true;
176 break;
177 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT:
178 m_unsignedShortDependency = true;
179 break;
180 case unoidl::ConstantValue::TYPE_LONG:
181 m_longDependency = true;
182 break;
183 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG:
184 m_unsignedLongDependency = true;
185 break;
186 case unoidl::ConstantValue::TYPE_HYPER:
187 m_hyperDependency = true;
188 break;
189 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER:
190 m_unsignedHyperDependency = true;
191 break;
192 case unoidl::ConstantValue::TYPE_FLOAT:
193 m_floatDependency = true;
194 break;
195 case unoidl::ConstantValue::TYPE_DOUBLE:
196 m_doubleDependency = true;
197 break;
200 break;
202 case UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
204 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
205 static_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
206 ent.get()));
207 if (!ent2->getConstructors().empty()) {
208 insert(ent2->getBase());
210 for (std::vector<
211 unoidl::SingleInterfaceBasedServiceEntity::Constructor >::
212 const_iterator i(ent2->getConstructors().begin());
213 i != ent2->getConstructors().end(); ++i)
215 for (std::vector<
216 unoidl::SingleInterfaceBasedServiceEntity::
217 Constructor::Parameter >::const_iterator j(
218 i->parameters.begin());
219 j != i->parameters.end(); ++j)
221 insert(j->type);
222 if (j->rest) {
223 m_sequenceDependency = true;
226 for (std::vector< OUString >::const_iterator j(
227 i->exceptions.begin());
228 j != i->exceptions.end(); ++j)
230 insert(*j);
233 break;
235 case UnoType::SORT_INTERFACE_BASED_SINGLETON:
236 insert(
237 static_cast< unoidl::InterfaceBasedSingletonEntity * >(ent.get())->
238 getBase());
239 break;
240 default:
241 assert(false); // this cannot happen
245 Dependencies::~Dependencies() {}
247 void Dependencies::insert(OUString const & name, bool base) {
248 sal_Int32 k;
249 std::vector< OString > args;
250 OUString n(b2u(UnoType::decompose(u2b(name), &k, &args)));
251 if (k != 0) {
252 m_sequenceDependency = true;
254 switch (m_manager->getSort(n)) {
255 case UnoType::SORT_VOID:
256 m_voidDependency = true;
257 break;
258 case UnoType::SORT_BOOLEAN:
259 m_booleanDependency = true;
260 break;
261 case UnoType::SORT_BYTE:
262 m_byteDependency = true;
263 break;
264 case UnoType::SORT_SHORT:
265 m_shortDependency = true;
266 break;
267 case UnoType::SORT_UNSIGNED_SHORT:
268 m_unsignedShortDependency = true;
269 break;
270 case UnoType::SORT_LONG:
271 m_longDependency = true;
272 break;
273 case UnoType::SORT_UNSIGNED_LONG:
274 m_unsignedLongDependency = true;
275 break;
276 case UnoType::SORT_HYPER:
277 m_hyperDependency = true;
278 break;
279 case UnoType::SORT_UNSIGNED_HYPER:
280 m_unsignedHyperDependency = true;
281 break;
282 case UnoType::SORT_FLOAT:
283 m_floatDependency = true;
284 break;
285 case UnoType::SORT_DOUBLE:
286 m_doubleDependency = true;
287 break;
288 case UnoType::SORT_CHAR:
289 m_charDependency = true;
290 break;
291 case UnoType::SORT_STRING:
292 m_stringDependency = true;
293 break;
294 case UnoType::SORT_TYPE:
295 m_typeDependency = true;
296 break;
297 case UnoType::SORT_ANY:
298 m_anyDependency = true;
299 break;
300 case UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
301 for (std::vector< OString >::iterator i(args.begin()); i != args.end();
302 ++i)
304 insert(b2u(*i), false);
306 // fall through
307 case UnoType::SORT_SEQUENCE_TYPE:
308 case UnoType::SORT_ENUM_TYPE:
309 case UnoType::SORT_PLAIN_STRUCT_TYPE:
310 case UnoType::SORT_EXCEPTION_TYPE:
311 case UnoType::SORT_INTERFACE_TYPE:
312 case UnoType::SORT_TYPEDEF:
314 std::pair< Map::iterator, bool > i(
315 m_map.insert(
316 Map::value_type(n, base ? KIND_BASE : KIND_NO_BASE)));
317 if (!i.second && base) {
318 i.first->second = KIND_BASE;
320 break;
322 default:
323 throw CannotDumpException(
324 "unexpected type \"" + name
325 + "\" in call to codemaker::cppumaker::Dependencies::Dependencies");
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */