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 :
10 : #include "sal/config.h"
11 :
12 : #include <cassert>
13 : #include <cstddef>
14 : #include <cstdlib>
15 : #include <cstring>
16 : #include <set>
17 : #include <stack>
18 : #include <vector>
19 :
20 : #include "boost/noncopyable.hpp"
21 : #include "com/sun/star/container/ElementExistException.hpp"
22 : #include "com/sun/star/container/NoSuchElementException.hpp"
23 : #include "com/sun/star/lang/IllegalArgumentException.hpp"
24 : #include "com/sun/star/reflection/InvalidTypeNameException.hpp"
25 : #include "com/sun/star/reflection/NoSuchTypeNameException.hpp"
26 : #include "com/sun/star/reflection/TypeDescriptionSearchDepth.hpp"
27 : #include "com/sun/star/reflection/XConstantTypeDescription.hpp"
28 : #include "com/sun/star/reflection/XConstantsTypeDescription.hpp"
29 : #include "com/sun/star/reflection/XEnumTypeDescription.hpp"
30 : #include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
31 : #include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
32 : #include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
33 : #include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
34 : #include "com/sun/star/reflection/XModuleTypeDescription.hpp"
35 : #include "com/sun/star/reflection/XPublished.hpp"
36 : #include "com/sun/star/reflection/XServiceTypeDescription2.hpp"
37 : #include "com/sun/star/reflection/XSingletonTypeDescription2.hpp"
38 : #include "com/sun/star/reflection/XStructTypeDescription.hpp"
39 : #include "com/sun/star/reflection/XTypeDescription.hpp"
40 : #include "com/sun/star/uno/Any.hxx"
41 : #include "com/sun/star/uno/DeploymentException.hpp"
42 : #include "com/sun/star/uno/Reference.hxx"
43 : #include "com/sun/star/uno/RuntimeException.hpp"
44 : #include "com/sun/star/uno/Sequence.hxx"
45 : #include "com/sun/star/uno/Type.hxx"
46 : #include "com/sun/star/uno/TypeClass.hpp"
47 : #include "cppu/unotype.hxx"
48 : #include "cppuhelper/implbase1.hxx"
49 : #include "cppuhelper/supportsservice.hxx"
50 : #include "osl/file.hxx"
51 : #include "osl/mutex.hxx"
52 : #include "rtl/ref.hxx"
53 : #include "rtl/string.h"
54 : #include "rtl/ustring.hxx"
55 : #include "sal/macros.h"
56 : #include "sal/types.h"
57 :
58 : using rtl::OUString;
59 :
60 : #include "unoidl/unoidl.hxx"
61 :
62 : #include "paths.hxx"
63 : #include "typemanager.hxx"
64 :
65 : namespace {
66 :
67 0 : rtl::OUString makePrefix(rtl::OUString const & name) {
68 0 : return name.isEmpty() ? name : name + ".";
69 : }
70 :
71 3 : css::uno::Any resolveTypedefs(css::uno::Any const & type) {
72 3 : for (css::uno::Any t(type);;) {
73 : css::uno::Reference< css::reflection::XIndirectTypeDescription > ind(
74 3 : type, css::uno::UNO_QUERY);
75 3 : if (!ind.is() || ind->getTypeClass() != css::uno::TypeClass_TYPEDEF) {
76 6 : return t;
77 : }
78 0 : t = css::uno::makeAny(ind->getReferencedType());
79 0 : }
80 : }
81 :
82 : class SimpleTypeDescription:
83 : public cppu::WeakImplHelper1< css::reflection::XTypeDescription >
84 : {
85 : public:
86 3 : SimpleTypeDescription(
87 : css::uno::TypeClass typeClass, rtl::OUString const & name):
88 3 : typeClass_(typeClass), name_(name)
89 3 : {}
90 :
91 : private:
92 6 : virtual ~SimpleTypeDescription() {}
93 :
94 3 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
95 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
96 3 : { return typeClass_; }
97 :
98 2 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
99 2 : { return name_; }
100 :
101 : css::uno::TypeClass typeClass_;
102 : rtl::OUString name_;
103 : };
104 :
105 : class SequenceTypeDescription:
106 : public cppu::WeakImplHelper1< css::reflection::XIndirectTypeDescription >
107 : {
108 : public:
109 0 : SequenceTypeDescription(
110 : rtl::Reference< cppuhelper::TypeManager > const & manager,
111 : rtl::OUString const & name, rtl::OUString const & componentType):
112 0 : manager_(manager), name_(name), componentType_(componentType)
113 0 : { assert(manager.is()); }
114 :
115 : private:
116 0 : virtual ~SequenceTypeDescription() {}
117 :
118 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
119 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
120 0 : { return css::uno::TypeClass_SEQUENCE; }
121 :
122 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
123 0 : { return name_; }
124 :
125 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
126 0 : getReferencedType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
127 0 : { return manager_->resolve(componentType_); }
128 :
129 : rtl::Reference< cppuhelper::TypeManager > manager_;
130 : rtl::OUString name_;
131 : rtl::OUString componentType_;
132 : };
133 :
134 : class PublishableDescription:
135 : public cppu::WeakImplHelper1< css::reflection::XPublished >
136 : {
137 : protected:
138 10 : PublishableDescription(bool published): published_(published) {}
139 :
140 10 : virtual ~PublishableDescription() {}
141 :
142 : private:
143 0 : virtual sal_Bool SAL_CALL isPublished() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
144 0 : { return published_; }
145 :
146 : bool published_;
147 : };
148 :
149 : class ModuleDescription:
150 : public cppu::WeakImplHelper1< css::reflection::XModuleTypeDescription >
151 : {
152 : public:
153 0 : ModuleDescription(
154 : rtl::Reference< cppuhelper::TypeManager > const & manager,
155 : rtl::OUString const & name,
156 : rtl::Reference< unoidl::ModuleEntity > const & entity):
157 0 : manager_(manager), name_(name), entity_(entity)
158 0 : { assert(manager.is()); assert(entity.is()); }
159 :
160 : private:
161 0 : virtual ~ModuleDescription() {}
162 :
163 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
164 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
165 0 : { return css::uno::TypeClass_MODULE; }
166 :
167 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
168 0 : { return name_; }
169 :
170 : virtual
171 : css::uno::Sequence<
172 : css::uno::Reference< css::reflection::XTypeDescription > >
173 : SAL_CALL getMembers() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 :
175 : rtl::Reference< cppuhelper::TypeManager > manager_;
176 : rtl::OUString name_;
177 : rtl::Reference< unoidl::ModuleEntity > entity_;
178 : };
179 :
180 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
181 0 : ModuleDescription::getMembers() throw (css::uno::RuntimeException, std::exception) {
182 : try {
183 0 : std::vector< rtl::OUString > names(entity_->getMemberNames());
184 : assert(names.size() <= SAL_MAX_INT32);
185 0 : sal_Int32 n = static_cast< sal_Int32 >(names.size());
186 : css::uno::Sequence<
187 0 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
188 0 : for (sal_Int32 i = 0; i != n; ++i) {
189 0 : s[i] = manager_->resolve(makePrefix(name_) + names[i]);
190 : }
191 0 : return s;
192 0 : } catch (unoidl::FileFormatException & e) {
193 : throw css::uno::DeploymentException(
194 0 : e.getUri() + ": " + e.getDetail(),
195 0 : static_cast< cppu::OWeakObject * >(this));
196 : }
197 : }
198 :
199 : typedef cppu::ImplInheritanceHelper1<
200 : PublishableDescription, css::reflection::XEnumTypeDescription >
201 : EnumTypeDescription_Base;
202 :
203 : class EnumTypeDescription: public EnumTypeDescription_Base {
204 : public:
205 0 : EnumTypeDescription(
206 : rtl::OUString const & name,
207 : rtl::Reference< unoidl::EnumTypeEntity > const & entity):
208 0 : EnumTypeDescription_Base(entity->isPublished()), name_(name),
209 0 : entity_(entity)
210 0 : { assert(entity.is()); }
211 :
212 : private:
213 0 : virtual ~EnumTypeDescription() {}
214 :
215 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
216 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
217 0 : { return css::uno::TypeClass_ENUM; }
218 :
219 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
220 0 : { return name_; }
221 :
222 0 : virtual sal_Int32 SAL_CALL getDefaultEnumValue()
223 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
224 0 : { return entity_->getMembers()[0].value; }
225 :
226 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getEnumNames()
227 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
228 :
229 : virtual css::uno::Sequence< sal_Int32 > SAL_CALL getEnumValues()
230 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
231 :
232 : rtl::OUString name_;
233 : rtl::Reference< unoidl::EnumTypeEntity > entity_;
234 : };
235 :
236 0 : css::uno::Sequence< rtl::OUString > EnumTypeDescription::getEnumNames()
237 : throw (css::uno::RuntimeException, std::exception)
238 : {
239 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
240 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
241 0 : css::uno::Sequence< rtl::OUString > s(n);
242 0 : for (sal_Int32 i = 0; i != n; ++i) {
243 0 : s[i] = entity_->getMembers()[i].name;
244 : }
245 0 : return s;
246 : }
247 :
248 0 : css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
249 : throw (css::uno::RuntimeException, std::exception)
250 : {
251 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
252 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
253 0 : css::uno::Sequence< sal_Int32 > s(n);
254 0 : for (sal_Int32 i = 0; i != n; ++i) {
255 0 : s[i] = entity_->getMembers()[i].value;
256 : }
257 0 : return s;
258 : }
259 :
260 : typedef cppu::ImplInheritanceHelper1<
261 : PublishableDescription, css::reflection::XStructTypeDescription >
262 : PlainStructTypeDescription_Base;
263 :
264 : class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
265 : public:
266 0 : PlainStructTypeDescription(
267 : rtl::Reference< cppuhelper::TypeManager > const & manager,
268 : rtl::OUString const & name,
269 : rtl::Reference< unoidl::PlainStructTypeEntity > const & entity):
270 0 : PlainStructTypeDescription_Base(entity->isPublished()),
271 0 : manager_(manager), name_(name), entity_(entity)
272 0 : { assert(manager.is()); assert(entity.is()); }
273 :
274 : private:
275 0 : virtual ~PlainStructTypeDescription() {}
276 :
277 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
278 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
279 0 : { return css::uno::TypeClass_STRUCT; }
280 :
281 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
282 0 : { return name_; }
283 :
284 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
285 0 : getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
286 0 : return entity_->getDirectBase().isEmpty()
287 : ? css::uno::Reference< css::reflection::XTypeDescription >()
288 0 : : manager_->resolve(entity_->getDirectBase());
289 : }
290 :
291 : virtual
292 : css::uno::Sequence<
293 : css::uno::Reference< css::reflection::XTypeDescription > >
294 : SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
295 :
296 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
297 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
298 :
299 0 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
300 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
301 0 : { return css::uno::Sequence< rtl::OUString >(); }
302 :
303 : virtual
304 : css::uno::Sequence<
305 : css::uno::Reference< css::reflection::XTypeDescription > >
306 0 : SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
307 : return css::uno::Sequence<
308 0 : css::uno::Reference< css::reflection::XTypeDescription > >();
309 : }
310 :
311 : rtl::Reference< cppuhelper::TypeManager > manager_;
312 : rtl::OUString name_;
313 : rtl::Reference< unoidl::PlainStructTypeEntity > entity_;
314 : };
315 :
316 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
317 0 : PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException, std::exception)
318 : {
319 : assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
320 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
321 : css::uno::Sequence<
322 0 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
323 0 : for (sal_Int32 i = 0; i != n; ++i) {
324 0 : s[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
325 : }
326 0 : return s;
327 : }
328 :
329 0 : css::uno::Sequence< rtl::OUString > PlainStructTypeDescription::getMemberNames()
330 : throw (css::uno::RuntimeException, std::exception)
331 : {
332 : assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
333 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
334 0 : css::uno::Sequence< rtl::OUString > s(n);
335 0 : for (sal_Int32 i = 0; i != n; ++i) {
336 0 : s[i] = entity_->getDirectMembers()[i].name;
337 : }
338 0 : return s;
339 : }
340 :
341 : class ParameterizedMemberTypeDescription:
342 : public cppu::WeakImplHelper1< css::reflection::XTypeDescription >
343 : {
344 : public:
345 1 : explicit ParameterizedMemberTypeDescription(
346 : rtl::OUString const & typeParameterName):
347 1 : typeParameterName_(typeParameterName)
348 1 : {}
349 :
350 : private:
351 2 : virtual ~ParameterizedMemberTypeDescription() {}
352 :
353 1 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
354 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
355 1 : { return css::uno::TypeClass_UNKNOWN; }
356 :
357 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
358 0 : { return typeParameterName_; }
359 :
360 : rtl::OUString typeParameterName_;
361 : };
362 :
363 : typedef cppu::ImplInheritanceHelper1<
364 : PublishableDescription, css::reflection::XStructTypeDescription >
365 : PolymorphicStructTypeTemplateDescription_Base;
366 :
367 : class PolymorphicStructTypeTemplateDescription:
368 : public PolymorphicStructTypeTemplateDescription_Base
369 : {
370 : public:
371 1 : PolymorphicStructTypeTemplateDescription(
372 : rtl::Reference< cppuhelper::TypeManager > const & manager,
373 : rtl::OUString const & name,
374 : rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > const &
375 : entity):
376 1 : PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
377 1 : manager_(manager), name_(name), entity_(entity)
378 1 : { assert(manager.is()); assert(entity.is()); }
379 :
380 : private:
381 2 : virtual ~PolymorphicStructTypeTemplateDescription() {}
382 :
383 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
384 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
385 0 : { return css::uno::TypeClass_STRUCT; }
386 :
387 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
388 0 : { return name_; }
389 :
390 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
391 0 : getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
392 0 : { return css::uno::Reference< css::reflection::XTypeDescription >(); }
393 :
394 : virtual
395 : css::uno::Sequence<
396 : css::uno::Reference< css::reflection::XTypeDescription > >
397 : SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
398 :
399 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
400 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
401 :
402 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
403 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
404 :
405 : virtual
406 : css::uno::Sequence<
407 : css::uno::Reference< css::reflection::XTypeDescription > >
408 0 : SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
409 : return css::uno::Sequence<
410 0 : css::uno::Reference< css::reflection::XTypeDescription > >();
411 : }
412 :
413 : rtl::Reference< cppuhelper::TypeManager > manager_;
414 : rtl::OUString name_;
415 : rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_;
416 : };
417 :
418 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
419 1 : PolymorphicStructTypeTemplateDescription::getMemberTypes()
420 : throw (css::uno::RuntimeException, std::exception)
421 : {
422 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
423 1 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
424 : css::uno::Sequence<
425 1 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
426 3 : for (sal_Int32 i = 0; i != n; ++i) {
427 6 : s[i] = entity_->getMembers()[i].parameterized
428 : ? new ParameterizedMemberTypeDescription(
429 2 : entity_->getMembers()[i].type)
430 5 : : manager_->resolve(entity_->getMembers()[i].type);
431 : }
432 1 : return s;
433 : }
434 :
435 : css::uno::Sequence< rtl::OUString >
436 0 : PolymorphicStructTypeTemplateDescription::getMemberNames()
437 : throw (css::uno::RuntimeException, std::exception)
438 : {
439 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
440 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
441 0 : css::uno::Sequence< rtl::OUString > s(n);
442 0 : for (sal_Int32 i = 0; i != n; ++i) {
443 0 : s[i] = entity_->getMembers()[i].name;
444 : }
445 0 : return s;
446 : }
447 :
448 : css::uno::Sequence< rtl::OUString >
449 0 : PolymorphicStructTypeTemplateDescription::getTypeParameters()
450 : throw (css::uno::RuntimeException, std::exception)
451 : {
452 : assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32);
453 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size());
454 0 : css::uno::Sequence< rtl::OUString > s(n);
455 0 : for (sal_Int32 i = 0; i != n; ++i) {
456 0 : s[i] = entity_->getTypeParameters()[i];
457 : }
458 0 : return s;
459 : }
460 :
461 : class InstantiatedPolymorphicStructTypeDescription:
462 : public cppu::WeakImplHelper1< css::reflection::XStructTypeDescription >
463 : {
464 : public:
465 1 : InstantiatedPolymorphicStructTypeDescription(
466 : rtl::Reference< cppuhelper::TypeManager > const & manager,
467 : rtl::OUString const & name,
468 : rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > const &
469 : entity,
470 : std::vector< rtl::OUString > const & arguments):
471 1 : manager_(manager), name_(name), entity_(entity), arguments_(arguments)
472 : {
473 : assert(manager.is());
474 : assert(entity.is());
475 : assert(arguments.size() == entity->getTypeParameters().size());
476 1 : }
477 :
478 : private:
479 2 : virtual ~InstantiatedPolymorphicStructTypeDescription() {}
480 :
481 1 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
482 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
483 1 : { return css::uno::TypeClass_STRUCT; }
484 :
485 1 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
486 1 : { return name_; }
487 :
488 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
489 1 : getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
490 1 : { return css::uno::Reference< css::reflection::XTypeDescription >(); }
491 :
492 : virtual
493 : css::uno::Sequence<
494 : css::uno::Reference< css::reflection::XTypeDescription > >
495 : SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
496 :
497 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
498 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
499 :
500 1 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
501 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
502 1 : { return css::uno::Sequence< rtl::OUString >(); }
503 :
504 : virtual
505 : css::uno::Sequence<
506 : css::uno::Reference< css::reflection::XTypeDescription > >
507 : SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
508 :
509 : rtl::Reference< cppuhelper::TypeManager > manager_;
510 : rtl::OUString name_;
511 : rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_;
512 : std::vector< rtl::OUString > arguments_;
513 : };
514 :
515 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
516 1 : InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
517 : throw (css::uno::RuntimeException, std::exception)
518 : {
519 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
520 1 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
521 : css::uno::Sequence<
522 1 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
523 3 : for (sal_Int32 i = 0; i != n; ++i) {
524 2 : rtl::OUString type(entity_->getMembers()[i].type);
525 2 : if (entity_->getMembers()[i].parameterized) {
526 3 : for (std::vector< rtl::OUString >::const_iterator j(
527 1 : entity_->getTypeParameters().begin());
528 2 : j != entity_->getTypeParameters().end(); ++j)
529 : {
530 1 : if (*j == type) {
531 1 : type = arguments_[j - entity_->getTypeParameters().begin()];
532 1 : goto found;
533 : }
534 : }
535 : assert(false); // this cannot happen //TODO!
536 : found:;
537 : }
538 2 : s[i] = manager_->resolve(type);
539 2 : }
540 1 : return s;
541 : }
542 :
543 : css::uno::Sequence< rtl::OUString >
544 1 : InstantiatedPolymorphicStructTypeDescription::getMemberNames()
545 : throw (css::uno::RuntimeException, std::exception)
546 : {
547 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
548 1 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
549 1 : css::uno::Sequence< rtl::OUString > s(n);
550 3 : for (sal_Int32 i = 0; i != n; ++i) {
551 2 : s[i] = entity_->getMembers()[i].name;
552 : }
553 1 : return s;
554 : }
555 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
556 0 : InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
557 : throw (css::uno::RuntimeException, std::exception)
558 : {
559 : assert(arguments_.size() <= SAL_MAX_INT32);
560 0 : sal_Int32 n = static_cast< sal_Int32 >(arguments_.size());
561 : css::uno::Sequence<
562 0 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
563 0 : for (sal_Int32 i = 0; i != n; ++i) {
564 0 : s[i] = manager_->resolve(arguments_[i]);
565 : }
566 0 : return s;
567 : }
568 :
569 : typedef cppu::ImplInheritanceHelper1<
570 : PublishableDescription, css::reflection::XCompoundTypeDescription >
571 : ExceptionTypeDescription_Base;
572 :
573 : class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
574 : public:
575 0 : ExceptionTypeDescription(
576 : rtl::Reference< cppuhelper::TypeManager > const & manager,
577 : rtl::OUString const & name,
578 : rtl::Reference< unoidl::ExceptionTypeEntity > const & entity):
579 0 : ExceptionTypeDescription_Base(entity->isPublished()), manager_(manager),
580 0 : name_(name), entity_(entity)
581 0 : { assert(manager.is()); assert(entity.is()); }
582 :
583 : private:
584 0 : virtual ~ExceptionTypeDescription() {}
585 :
586 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
587 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
588 0 : { return css::uno::TypeClass_EXCEPTION; }
589 :
590 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
591 0 : { return name_; }
592 :
593 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
594 0 : getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
595 0 : return entity_->getDirectBase().isEmpty()
596 : ? css::uno::Reference< css::reflection::XTypeDescription >()
597 0 : : manager_->resolve(entity_->getDirectBase());
598 : }
599 :
600 : virtual
601 : css::uno::Sequence<
602 : css::uno::Reference< css::reflection::XTypeDescription > >
603 : SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
604 :
605 : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
606 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
607 :
608 : rtl::Reference< cppuhelper::TypeManager > manager_;
609 : rtl::OUString name_;
610 : rtl::Reference< unoidl::ExceptionTypeEntity > entity_;
611 : };
612 :
613 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
614 0 : ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException, std::exception) {
615 : assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
616 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
617 : css::uno::Sequence<
618 0 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
619 0 : for (sal_Int32 i = 0; i != n; ++i) {
620 0 : s[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
621 : }
622 0 : return s;
623 : }
624 :
625 0 : css::uno::Sequence< rtl::OUString > ExceptionTypeDescription::getMemberNames()
626 : throw (css::uno::RuntimeException, std::exception)
627 : {
628 : assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
629 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
630 0 : css::uno::Sequence< rtl::OUString > s(n);
631 0 : for (sal_Int32 i = 0; i != n; ++i) {
632 0 : s[i] = entity_->getDirectMembers()[i].name;
633 : }
634 0 : return s;
635 : }
636 :
637 : class AttributeDescription:
638 : public cppu::WeakImplHelper1<
639 : css::reflection::XInterfaceAttributeTypeDescription2 >
640 : {
641 : public:
642 0 : AttributeDescription(
643 : rtl::Reference< cppuhelper::TypeManager > const & manager,
644 : rtl::OUString const & name,
645 : unoidl::InterfaceTypeEntity::Attribute const & attribute,
646 : sal_Int32 position):
647 : manager_(manager), name_(name), attribute_(attribute),
648 0 : position_(position)
649 0 : { assert(manager.is()); }
650 :
651 : private:
652 0 : virtual ~AttributeDescription() {}
653 :
654 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
655 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
656 0 : { return css::uno::TypeClass_INTERFACE_ATTRIBUTE; }
657 :
658 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
659 0 : { return name_; }
660 :
661 0 : virtual rtl::OUString SAL_CALL getMemberName()
662 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
663 0 : { return attribute_.name; }
664 :
665 0 : virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
666 0 : { return position_; }
667 :
668 0 : virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
669 0 : { return attribute_.readOnly; }
670 :
671 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
672 0 : getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
673 0 : { return manager_->resolve(attribute_.type); }
674 :
675 0 : virtual sal_Bool SAL_CALL isBound() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
676 0 : { return attribute_.bound; }
677 :
678 : virtual
679 : css::uno::Sequence<
680 : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
681 : SAL_CALL getGetExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
682 :
683 : virtual
684 : css::uno::Sequence<
685 : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
686 : SAL_CALL getSetExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
687 :
688 : rtl::Reference< cppuhelper::TypeManager > manager_;
689 : rtl::OUString name_;
690 : unoidl::InterfaceTypeEntity::Attribute attribute_;
691 : sal_Int32 position_;
692 : };
693 :
694 : css::uno::Sequence<
695 : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
696 0 : AttributeDescription::getGetExceptions() throw (css::uno::RuntimeException, std::exception) {
697 : assert(attribute_.getExceptions.size() <= SAL_MAX_INT32);
698 0 : sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size());
699 : css::uno::Sequence<
700 0 : css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
701 0 : for (sal_Int32 i = 0; i != n; ++i) {
702 0 : s[i].set(
703 0 : manager_->resolve(attribute_.getExceptions[i]),
704 0 : css::uno::UNO_QUERY_THROW);
705 : }
706 0 : return s;
707 : }
708 :
709 : css::uno::Sequence<
710 : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
711 0 : AttributeDescription::getSetExceptions() throw (css::uno::RuntimeException, std::exception) {
712 : assert(attribute_.setExceptions.size() <= SAL_MAX_INT32);
713 0 : sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size());
714 : css::uno::Sequence<
715 0 : css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
716 0 : for (sal_Int32 i = 0; i != n; ++i) {
717 0 : s[i].set(
718 0 : manager_->resolve(attribute_.setExceptions[i]),
719 0 : css::uno::UNO_QUERY_THROW);
720 : }
721 0 : return s;
722 : }
723 :
724 : class MethodParameter:
725 : public cppu::WeakImplHelper1< css::reflection::XMethodParameter >
726 : {
727 : public:
728 0 : MethodParameter(
729 : rtl::Reference< cppuhelper::TypeManager > const & manager,
730 : unoidl::InterfaceTypeEntity::Method::Parameter const & parameter,
731 : sal_Int32 position):
732 0 : manager_(manager), parameter_(parameter), position_(position)
733 0 : { assert(manager.is()); }
734 :
735 : private:
736 0 : virtual ~MethodParameter() {}
737 :
738 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
739 0 : { return parameter_.name; }
740 :
741 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
742 0 : getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
743 0 : { return manager_->resolve(parameter_.type); }
744 :
745 0 : virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
746 : return
747 : (parameter_.direction
748 0 : == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
749 0 : || (parameter_.direction
750 0 : == unoidl::InterfaceTypeEntity::Method::Parameter::
751 0 : DIRECTION_IN_OUT);
752 : }
753 :
754 0 : virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
755 : return
756 : (parameter_.direction
757 0 : == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT)
758 0 : || (parameter_.direction
759 0 : == unoidl::InterfaceTypeEntity::Method::Parameter::
760 0 : DIRECTION_IN_OUT);
761 : }
762 :
763 0 : virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
764 0 : { return position_; }
765 :
766 : rtl::Reference< cppuhelper::TypeManager > manager_;
767 : unoidl::InterfaceTypeEntity::Method::Parameter parameter_;
768 : sal_Int32 position_;
769 : };
770 :
771 : class MethodDescription:
772 : public cppu::WeakImplHelper1<
773 : css::reflection::XInterfaceMethodTypeDescription >
774 : {
775 : public:
776 26 : MethodDescription(
777 : rtl::Reference< cppuhelper::TypeManager > const & manager,
778 : rtl::OUString const & name,
779 : unoidl::InterfaceTypeEntity::Method const & method, sal_Int32 position):
780 26 : manager_(manager), name_(name), method_(method), position_(position)
781 26 : { assert(manager.is()); }
782 :
783 : private:
784 52 : virtual ~MethodDescription() {}
785 :
786 17 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
787 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
788 17 : { return css::uno::TypeClass_INTERFACE_METHOD; }
789 :
790 17 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
791 17 : { return name_; }
792 :
793 0 : virtual rtl::OUString SAL_CALL getMemberName()
794 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
795 0 : { return method_.name; }
796 :
797 0 : virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
798 0 : { return position_; }
799 :
800 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
801 0 : getReturnType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
802 0 : { return manager_->resolve(method_.returnType); }
803 :
804 0 : virtual sal_Bool SAL_CALL isOneway() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
805 0 : { return false; }
806 :
807 : virtual
808 : css::uno::Sequence<
809 : css::uno::Reference< css::reflection::XMethodParameter > >
810 : SAL_CALL getParameters() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
811 :
812 : virtual
813 : css::uno::Sequence<
814 : css::uno::Reference< css::reflection::XTypeDescription > >
815 : SAL_CALL getExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
816 :
817 : rtl::Reference< cppuhelper::TypeManager > manager_;
818 : rtl::OUString name_;
819 : unoidl::InterfaceTypeEntity::Method method_;
820 : sal_Int32 position_;
821 : };
822 :
823 : css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > >
824 0 : MethodDescription::getParameters() throw (css::uno::RuntimeException, std::exception) {
825 : assert(method_.parameters.size() <= SAL_MAX_INT32);
826 0 : sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size());
827 : css::uno::Sequence<
828 0 : css::uno::Reference< css::reflection::XMethodParameter > > s(n);
829 0 : for (sal_Int32 i = 0; i != n; ++i) {
830 0 : s[i] = new MethodParameter(manager_, method_.parameters[i], i);
831 : }
832 0 : return s;
833 : }
834 :
835 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
836 0 : MethodDescription::getExceptions() throw (css::uno::RuntimeException, std::exception) {
837 : assert(method_.exceptions.size() <= SAL_MAX_INT32);
838 0 : sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size());
839 : css::uno::Sequence<
840 0 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
841 0 : for (sal_Int32 i = 0; i != n; ++i) {
842 0 : s[i] = manager_->resolve(method_.exceptions[i]);
843 : }
844 0 : return s;
845 : }
846 :
847 9 : class BaseOffset: private boost::noncopyable {
848 : public:
849 : BaseOffset(
850 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
851 : const & description);
852 :
853 9 : sal_Int32 get() const { return offset_; }
854 :
855 : private:
856 : void calculateBases(
857 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
858 : const & description);
859 :
860 : void calculate(
861 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
862 : const & description);
863 :
864 : std::set< rtl::OUString > set_;
865 : sal_Int32 offset_;
866 : };
867 :
868 9 : BaseOffset::BaseOffset(
869 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
870 : description):
871 9 : offset_(0)
872 : {
873 9 : calculateBases(description);
874 9 : }
875 :
876 12 : void BaseOffset::calculateBases(
877 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
878 : description)
879 : {
880 : css::uno::Sequence<
881 : css::uno::Reference < css::reflection::XTypeDescription > > bases(
882 12 : description->getBaseTypes());
883 15 : for (sal_Int32 i = 0; i != bases.getLength(); ++i) {
884 : calculate(
885 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
886 3 : resolveTypedefs(css::uno::makeAny(bases[i])),
887 3 : css::uno::UNO_QUERY_THROW));
888 12 : }
889 12 : }
890 :
891 3 : void BaseOffset::calculate(
892 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
893 : description)
894 : {
895 3 : if (set_.insert(description->getName()).second) {
896 3 : calculateBases(description);
897 3 : offset_ += description->getMembers().getLength();
898 : }
899 3 : }
900 :
901 : typedef cppu::ImplInheritanceHelper1<
902 : PublishableDescription, css::reflection::XInterfaceTypeDescription2 >
903 : InterfaceTypeDescription_Base;
904 :
905 : class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
906 : public:
907 9 : InterfaceTypeDescription(
908 : rtl::Reference< cppuhelper::TypeManager > const & manager,
909 : rtl::OUString const & name,
910 : rtl::Reference< unoidl::InterfaceTypeEntity > const & entity):
911 9 : InterfaceTypeDescription_Base(entity->isPublished()), manager_(manager),
912 9 : name_(name), entity_(entity)
913 9 : { assert(manager.is()); assert(entity.is()); }
914 :
915 : private:
916 18 : virtual ~InterfaceTypeDescription() {}
917 :
918 6 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
919 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
920 6 : { return css::uno::TypeClass_INTERFACE; }
921 :
922 9 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
923 9 : { return name_; }
924 :
925 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
926 0 : getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
927 0 : return entity_->getDirectMandatoryBases().empty()
928 : ? css::uno::Reference< css::reflection::XTypeDescription >()
929 0 : : manager_->resolve(entity_->getDirectMandatoryBases()[0].name);
930 : }
931 :
932 0 : virtual css::uno::Uik SAL_CALL getUik() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
933 0 : { return css::uno::Uik(); }
934 :
935 : virtual
936 : css::uno::Sequence<
937 : css::uno::Reference<
938 : css::reflection::XInterfaceMemberTypeDescription > >
939 : SAL_CALL getMembers() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
940 :
941 : virtual
942 : css::uno::Sequence<
943 : css::uno::Reference< css::reflection::XTypeDescription > >
944 : SAL_CALL getBaseTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
945 :
946 : virtual
947 : css::uno::Sequence<
948 : css::uno::Reference< css::reflection::XTypeDescription > >
949 : SAL_CALL getOptionalBaseTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
950 :
951 : rtl::Reference< cppuhelper::TypeManager > manager_;
952 : rtl::OUString name_;
953 : rtl::Reference< unoidl::InterfaceTypeEntity > entity_;
954 : };
955 :
956 : css::uno::Sequence<
957 : css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
958 9 : InterfaceTypeDescription::getMembers() throw (css::uno::RuntimeException, std::exception) {
959 : assert(
960 : entity_->getDirectAttributes().size() <= SAL_MAX_INT32
961 : && (entity_->getDirectMethods().size()
962 : <= SAL_MAX_INT32 - entity_->getDirectAttributes().size()));
963 : sal_Int32 n1 = static_cast< sal_Int32 >(
964 9 : entity_->getDirectAttributes().size());
965 9 : sal_Int32 n2 = static_cast< sal_Int32 >(entity_->getDirectMethods().size());
966 : css::uno::Sequence<
967 : css::uno::Reference<
968 9 : css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2);
969 9 : sal_Int32 off = BaseOffset(this).get();
970 9 : for (sal_Int32 i = 0; i != n1; ++i) {
971 0 : s[i] = new AttributeDescription(
972 0 : manager_, name_ + "::" + entity_->getDirectAttributes()[i].name,
973 0 : entity_->getDirectAttributes()[i], off + i);
974 : }
975 35 : for (sal_Int32 i = 0; i != n2; ++i) {
976 104 : s[n1 + i] = new MethodDescription(
977 52 : manager_, name_ + "::" + entity_->getDirectMethods()[i].name,
978 78 : entity_->getDirectMethods()[i], off + n1 + i);
979 : }
980 9 : return s;
981 : }
982 :
983 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
984 18 : InterfaceTypeDescription::getBaseTypes() throw (css::uno::RuntimeException, std::exception) {
985 : assert(entity_->getDirectMandatoryBases().size() <= SAL_MAX_INT32);
986 : sal_Int32 n = static_cast< sal_Int32 >(
987 18 : entity_->getDirectMandatoryBases().size());
988 : css::uno::Sequence<
989 18 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
990 24 : for (sal_Int32 i = 0; i != n; ++i) {
991 6 : s[i] = manager_->resolve(entity_->getDirectMandatoryBases()[i].name);
992 : }
993 18 : return s;
994 : }
995 :
996 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
997 0 : InterfaceTypeDescription::getOptionalBaseTypes()
998 : throw (css::uno::RuntimeException, std::exception)
999 : {
1000 : assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
1001 : sal_Int32 n = static_cast< sal_Int32 >(
1002 0 : entity_->getDirectOptionalBases().size());
1003 : css::uno::Sequence<
1004 0 : css::uno::Reference< css::reflection::XTypeDescription > > s(n);
1005 0 : for (sal_Int32 i = 0; i != n; ++i) {
1006 0 : s[i] = manager_->resolve(entity_->getDirectOptionalBases()[i].name);
1007 : }
1008 0 : return s;
1009 : }
1010 :
1011 : class ConstantDescription:
1012 : public cppu::WeakImplHelper1< css::reflection::XConstantTypeDescription >
1013 : {
1014 : public:
1015 : ConstantDescription(
1016 : rtl::OUString const & constantGroupName,
1017 : unoidl::ConstantGroupEntity::Member const & member);
1018 :
1019 : private:
1020 0 : virtual ~ConstantDescription() {}
1021 :
1022 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1023 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1024 0 : { return css::uno::TypeClass_CONSTANT; }
1025 :
1026 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1027 0 : { return name_; }
1028 :
1029 0 : virtual css::uno::Any SAL_CALL getConstantValue()
1030 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1031 0 : { return value_; }
1032 :
1033 : rtl::OUString name_;
1034 : css::uno::Any value_;
1035 : };
1036 :
1037 0 : ConstantDescription::ConstantDescription(
1038 : rtl::OUString const & constantGroupName,
1039 : unoidl::ConstantGroupEntity::Member const & member):
1040 0 : name_(makePrefix(constantGroupName) + member.name)
1041 : {
1042 0 : switch (member.value.type) {
1043 : case unoidl::ConstantValue::TYPE_BOOLEAN:
1044 0 : value_ <<= member.value.booleanValue;
1045 0 : break;
1046 : case unoidl::ConstantValue::TYPE_BYTE:
1047 0 : value_ <<= member.value.byteValue;
1048 0 : break;
1049 : case unoidl::ConstantValue::TYPE_SHORT:
1050 0 : value_ <<= member.value.shortValue;
1051 0 : break;
1052 : case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT:
1053 0 : value_ <<= member.value.unsignedShortValue;
1054 0 : break;
1055 : case unoidl::ConstantValue::TYPE_LONG:
1056 0 : value_ <<= member.value.longValue;
1057 0 : break;
1058 : case unoidl::ConstantValue::TYPE_UNSIGNED_LONG:
1059 0 : value_ <<= member.value.unsignedLongValue;
1060 0 : break;
1061 : case unoidl::ConstantValue::TYPE_HYPER:
1062 0 : value_ <<= member.value.hyperValue;
1063 0 : break;
1064 : case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER:
1065 0 : value_ <<= member.value.unsignedHyperValue;
1066 0 : break;
1067 : case unoidl::ConstantValue::TYPE_FLOAT:
1068 0 : value_ <<= member.value.floatValue;
1069 0 : break;
1070 : case unoidl::ConstantValue::TYPE_DOUBLE:
1071 0 : value_ <<= member.value.doubleValue;
1072 0 : break;
1073 : default:
1074 0 : for (;;) { std::abort(); } // this cannot happen
1075 : }
1076 0 : }
1077 :
1078 : typedef cppu::ImplInheritanceHelper1<
1079 : PublishableDescription, css::reflection::XConstantsTypeDescription >
1080 : ConstantGroupDescription_Base;
1081 :
1082 : class ConstantGroupDescription: public ConstantGroupDescription_Base {
1083 : public:
1084 0 : ConstantGroupDescription(
1085 : rtl::OUString const & name,
1086 : rtl::Reference< unoidl::ConstantGroupEntity > const & entity):
1087 0 : ConstantGroupDescription_Base(entity->isPublished()), name_(name),
1088 0 : entity_(entity)
1089 0 : { assert(entity.is()); }
1090 :
1091 : private:
1092 0 : virtual ~ConstantGroupDescription() {}
1093 :
1094 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1095 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1096 0 : { return css::uno::TypeClass_CONSTANTS; }
1097 :
1098 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1099 0 : { return name_; }
1100 :
1101 : virtual
1102 : css::uno::Sequence<
1103 : css::uno::Reference< css::reflection::XConstantTypeDescription > >
1104 : SAL_CALL getConstants() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1105 :
1106 : rtl::OUString name_;
1107 : rtl::Reference< unoidl::ConstantGroupEntity > entity_;
1108 : };
1109 :
1110 : css::uno::Sequence<
1111 : css::uno::Reference< css::reflection::XConstantTypeDescription > >
1112 0 : ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException, std::exception) {
1113 : assert(entity_->getMembers().size() <= SAL_MAX_INT32);
1114 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
1115 : css::uno::Sequence<
1116 0 : css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n);
1117 0 : for (sal_Int32 i = 0; i != n; ++i) {
1118 0 : s[i] = new ConstantDescription(name_, entity_->getMembers()[i]);
1119 : }
1120 0 : return s;
1121 : }
1122 :
1123 : typedef cppu::ImplInheritanceHelper1<
1124 : PublishableDescription, css::reflection::XIndirectTypeDescription >
1125 : TypedefDescription_Base;
1126 :
1127 : class TypedefDescription: public TypedefDescription_Base {
1128 : public:
1129 0 : TypedefDescription(
1130 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1131 : rtl::OUString const & name,
1132 : rtl::Reference< unoidl::TypedefEntity > const & entity):
1133 0 : TypedefDescription_Base(entity->isPublished()), manager_(manager),
1134 0 : name_(name), entity_(entity)
1135 0 : { assert(manager.is()); assert(entity.is()); }
1136 :
1137 : private:
1138 0 : virtual ~TypedefDescription() {}
1139 :
1140 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1141 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1142 0 : { return css::uno::TypeClass_TYPEDEF; }
1143 :
1144 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1145 0 : { return name_; }
1146 :
1147 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1148 0 : getReferencedType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1149 0 : { return manager_->resolve(entity_->getType()); }
1150 :
1151 : rtl::Reference< cppuhelper::TypeManager > manager_;
1152 : rtl::OUString name_;
1153 : rtl::Reference< unoidl::TypedefEntity > entity_;
1154 : };
1155 :
1156 : class ConstructorParameter:
1157 : public cppu::WeakImplHelper1< css::reflection::XParameter >
1158 : {
1159 : public:
1160 0 : ConstructorParameter(
1161 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1162 : unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1163 : const & parameter,
1164 : sal_Int32 position):
1165 0 : manager_(manager), parameter_(parameter), position_(position)
1166 0 : { assert(manager.is()); }
1167 :
1168 : private:
1169 0 : virtual ~ConstructorParameter() {}
1170 :
1171 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1172 0 : { return parameter_.name; }
1173 :
1174 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1175 0 : getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1176 0 : { return manager_->resolve(parameter_.type); }
1177 :
1178 0 : virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1179 0 : { return true; }
1180 :
1181 0 : virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1182 0 : { return false; }
1183 :
1184 0 : virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1185 0 : { return position_; }
1186 :
1187 0 : virtual sal_Bool SAL_CALL isRestParameter()
1188 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1189 0 : { return parameter_.rest; }
1190 :
1191 : rtl::Reference< cppuhelper::TypeManager > manager_;
1192 : unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1193 : parameter_;
1194 : sal_Int32 position_;
1195 : };
1196 :
1197 : class ConstructorDescription:
1198 : public cppu::WeakImplHelper1<
1199 : css::reflection::XServiceConstructorDescription >
1200 : {
1201 : public:
1202 0 : ConstructorDescription(
1203 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1204 : unoidl::SingleInterfaceBasedServiceEntity::Constructor const &
1205 : constructor):
1206 0 : manager_(manager), constructor_(constructor)
1207 0 : { assert(manager.is()); }
1208 :
1209 : private:
1210 0 : virtual ~ConstructorDescription() {}
1211 :
1212 0 : virtual sal_Bool SAL_CALL isDefaultConstructor()
1213 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1214 0 : { return constructor_.defaultConstructor; }
1215 :
1216 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1217 0 : { return constructor_.name; }
1218 :
1219 : virtual
1220 : css::uno::Sequence<
1221 : css::uno::Reference< css::reflection::XParameter > >
1222 : SAL_CALL getParameters() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1223 :
1224 : virtual
1225 : css::uno::Sequence<
1226 : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1227 : SAL_CALL getExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1228 :
1229 : rtl::Reference< cppuhelper::TypeManager > manager_;
1230 : unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_;
1231 : };
1232 :
1233 : css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
1234 0 : ConstructorDescription::getParameters() throw (css::uno::RuntimeException, std::exception) {
1235 : assert(constructor_.parameters.size() <= SAL_MAX_INT32);
1236 0 : sal_Int32 n = static_cast< sal_Int32 >(constructor_.parameters.size());
1237 : css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > > s(
1238 0 : n);
1239 0 : for (sal_Int32 i = 0; i != n; ++i) {
1240 0 : s[i] = new ConstructorParameter(
1241 0 : manager_, constructor_.parameters[i], i);
1242 : }
1243 0 : return s;
1244 : }
1245 :
1246 : css::uno::Sequence<
1247 : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1248 0 : ConstructorDescription::getExceptions() throw (css::uno::RuntimeException, std::exception) {
1249 : assert(constructor_.exceptions.size() <= SAL_MAX_INT32);
1250 0 : sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size());
1251 : css::uno::Sequence<
1252 0 : css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
1253 0 : for (sal_Int32 i = 0; i != n; ++i) {
1254 0 : s[i].set(
1255 0 : manager_->resolve(constructor_.exceptions[i]),
1256 0 : css::uno::UNO_QUERY_THROW);
1257 : }
1258 0 : return s;
1259 : }
1260 :
1261 : typedef cppu::ImplInheritanceHelper1<
1262 : PublishableDescription, css::reflection::XServiceTypeDescription2 >
1263 : SingleInterfaceBasedServiceDescription_Base;
1264 :
1265 : class SingleInterfaceBasedServiceDescription:
1266 : public SingleInterfaceBasedServiceDescription_Base
1267 : {
1268 : public:
1269 0 : SingleInterfaceBasedServiceDescription(
1270 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1271 : rtl::OUString const & name,
1272 : rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > const &
1273 : entity):
1274 0 : SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
1275 0 : manager_(manager), name_(name), entity_(entity)
1276 0 : { assert(manager.is()); assert(entity.is()); }
1277 :
1278 : private:
1279 0 : virtual ~SingleInterfaceBasedServiceDescription() {}
1280 :
1281 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1282 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1283 0 : { return css::uno::TypeClass_SERVICE; }
1284 :
1285 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1286 0 : { return name_; }
1287 :
1288 : virtual
1289 : css::uno::Sequence<
1290 : css::uno::Reference< css::reflection::XServiceTypeDescription > >
1291 0 : SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1292 : {
1293 : return css::uno::Sequence<
1294 0 : css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1295 : }
1296 :
1297 : virtual
1298 : css::uno::Sequence<
1299 : css::uno::Reference< css::reflection::XServiceTypeDescription > >
1300 0 : SAL_CALL getOptionalServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1301 : {
1302 : return css::uno::Sequence<
1303 0 : css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1304 : }
1305 :
1306 : virtual
1307 : css::uno::Sequence<
1308 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1309 0 : SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1310 : {
1311 : return css::uno::Sequence<
1312 : css::uno::Reference<
1313 0 : css::reflection::XInterfaceTypeDescription > >();
1314 : }
1315 :
1316 : virtual
1317 : css::uno::Sequence<
1318 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1319 0 : SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1320 : {
1321 : return css::uno::Sequence<
1322 : css::uno::Reference<
1323 0 : css::reflection::XInterfaceTypeDescription > >();
1324 : }
1325 :
1326 : virtual
1327 : css::uno::Sequence<
1328 : css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1329 0 : SAL_CALL getProperties() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1330 : {
1331 : return css::uno::Sequence<
1332 : css::uno::Reference<
1333 0 : css::reflection::XPropertyTypeDescription > >();
1334 : }
1335 :
1336 0 : virtual sal_Bool SAL_CALL isSingleInterfaceBased()
1337 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1338 0 : { return true; }
1339 :
1340 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1341 0 : getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1342 0 : { return manager_->resolve(entity_->getBase()); }
1343 :
1344 : virtual
1345 : css::uno::Sequence<
1346 : css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1347 : SAL_CALL getConstructors() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1348 :
1349 : rtl::Reference< cppuhelper::TypeManager > manager_;
1350 : rtl::OUString name_;
1351 : rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > entity_;
1352 : };
1353 :
1354 : css::uno::Sequence<
1355 : css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1356 0 : SingleInterfaceBasedServiceDescription::getConstructors()
1357 : throw (css::uno::RuntimeException, std::exception)
1358 : {
1359 : assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
1360 0 : sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
1361 : css::uno::Sequence<
1362 : css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1363 0 : s(n);
1364 0 : for (sal_Int32 i = 0; i != n; ++i) {
1365 0 : s[i] = new ConstructorDescription(
1366 0 : manager_, entity_->getConstructors()[i]);
1367 : }
1368 0 : return s;
1369 : }
1370 :
1371 : class PropertyDescription:
1372 : public cppu::WeakImplHelper1< css::reflection::XPropertyTypeDescription >
1373 : {
1374 : public:
1375 0 : PropertyDescription(
1376 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1377 : unoidl::AccumulationBasedServiceEntity::Property const & property):
1378 0 : manager_(manager), property_(property)
1379 0 : { assert(manager.is()); }
1380 :
1381 : private:
1382 0 : virtual ~PropertyDescription() {}
1383 :
1384 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1385 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1386 0 : { return css::uno::TypeClass_PROPERTY; }
1387 :
1388 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1389 0 : { return property_.name; }
1390 :
1391 0 : virtual sal_Int16 SAL_CALL getPropertyFlags()
1392 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1393 0 : { return property_.attributes; }
1394 :
1395 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1396 0 : getPropertyTypeDescription() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1397 0 : { return manager_->resolve(property_.type); }
1398 :
1399 : rtl::Reference< cppuhelper::TypeManager > manager_;
1400 : unoidl::AccumulationBasedServiceEntity::Property property_;
1401 : };
1402 :
1403 : typedef cppu::ImplInheritanceHelper1<
1404 : PublishableDescription, css::reflection::XServiceTypeDescription2 >
1405 : AccumulationBasedServiceDescription_Base;
1406 :
1407 : class AccumulationBasedServiceDescription:
1408 : public AccumulationBasedServiceDescription_Base
1409 : {
1410 : public:
1411 0 : AccumulationBasedServiceDescription(
1412 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1413 : rtl::OUString const & name,
1414 : rtl::Reference< unoidl::AccumulationBasedServiceEntity > const &
1415 : entity):
1416 0 : AccumulationBasedServiceDescription_Base(entity->isPublished()),
1417 0 : manager_(manager), name_(name), entity_(entity)
1418 0 : { assert(manager.is()); assert(entity.is()); }
1419 :
1420 : private:
1421 0 : virtual ~AccumulationBasedServiceDescription() {}
1422 :
1423 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1424 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1425 0 : { return css::uno::TypeClass_SERVICE; }
1426 :
1427 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1428 0 : { return name_; }
1429 :
1430 : virtual
1431 : css::uno::Sequence<
1432 : css::uno::Reference< css::reflection::XServiceTypeDescription > >
1433 : SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1434 :
1435 : virtual
1436 : css::uno::Sequence<
1437 : css::uno::Reference< css::reflection::XServiceTypeDescription > >
1438 : SAL_CALL getOptionalServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1439 :
1440 : virtual
1441 : css::uno::Sequence<
1442 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1443 : SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1444 :
1445 : virtual
1446 : css::uno::Sequence<
1447 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1448 : SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1449 :
1450 : virtual
1451 : css::uno::Sequence<
1452 : css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1453 : SAL_CALL getProperties() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1454 :
1455 0 : virtual sal_Bool SAL_CALL isSingleInterfaceBased()
1456 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1457 0 : { return false; }
1458 :
1459 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1460 0 : getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1461 0 : { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1462 :
1463 : virtual
1464 : css::uno::Sequence<
1465 : css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1466 0 : SAL_CALL getConstructors() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1467 : {
1468 : return css::uno::Sequence<
1469 : css::uno::Reference<
1470 0 : css::reflection::XServiceConstructorDescription > >();
1471 : }
1472 :
1473 : rtl::Reference< cppuhelper::TypeManager > manager_;
1474 : rtl::OUString name_;
1475 : rtl::Reference< unoidl::AccumulationBasedServiceEntity > entity_;
1476 : };
1477 :
1478 : css::uno::Sequence<
1479 : css::uno::Reference< css::reflection::XServiceTypeDescription > >
1480 0 : AccumulationBasedServiceDescription::getMandatoryServices()
1481 : throw (css::uno::RuntimeException, std::exception)
1482 : {
1483 : assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
1484 : sal_Int32 n = static_cast< sal_Int32 >(
1485 0 : entity_->getDirectMandatoryBaseServices().size());
1486 : css::uno::Sequence<
1487 0 : css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1488 0 : for (sal_Int32 i = 0; i != n; ++i) {
1489 0 : s[i].set(
1490 : manager_->resolve(
1491 0 : entity_->getDirectMandatoryBaseServices()[i].name),
1492 0 : css::uno::UNO_QUERY_THROW);
1493 : }
1494 0 : return s;
1495 : }
1496 :
1497 : css::uno::Sequence<
1498 : css::uno::Reference< css::reflection::XServiceTypeDescription > >
1499 0 : AccumulationBasedServiceDescription::getOptionalServices()
1500 : throw (css::uno::RuntimeException, std::exception)
1501 : {
1502 : assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
1503 : sal_Int32 n = static_cast< sal_Int32 >(
1504 0 : entity_->getDirectOptionalBaseServices().size());
1505 : css::uno::Sequence<
1506 0 : css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1507 0 : for (sal_Int32 i = 0; i != n; ++i) {
1508 0 : s[i].set(
1509 0 : manager_->resolve(entity_->getDirectOptionalBaseServices()[i].name),
1510 0 : css::uno::UNO_QUERY_THROW);
1511 : }
1512 0 : return s;
1513 : }
1514 :
1515 : css::uno::Sequence<
1516 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1517 0 : AccumulationBasedServiceDescription::getMandatoryInterfaces()
1518 : throw (css::uno::RuntimeException, std::exception)
1519 : {
1520 : assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
1521 : sal_Int32 n = static_cast< sal_Int32 >(
1522 0 : entity_->getDirectMandatoryBaseInterfaces().size());
1523 : css::uno::Sequence<
1524 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1525 0 : n);
1526 0 : for (sal_Int32 i = 0; i != n; ++i) {
1527 0 : s[i].set(
1528 : resolveTypedefs(
1529 : manager_->find(
1530 0 : entity_->getDirectMandatoryBaseInterfaces()[i].name)),
1531 0 : css::uno::UNO_QUERY_THROW);
1532 : }
1533 0 : return s;
1534 : }
1535 :
1536 : css::uno::Sequence<
1537 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1538 0 : AccumulationBasedServiceDescription::getOptionalInterfaces()
1539 : throw (css::uno::RuntimeException, std::exception)
1540 : {
1541 : assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
1542 : sal_Int32 n = static_cast< sal_Int32 >(
1543 0 : entity_->getDirectOptionalBaseInterfaces().size());
1544 : css::uno::Sequence<
1545 : css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1546 0 : n);
1547 0 : for (sal_Int32 i = 0; i != n; ++i) {
1548 0 : s[i].set(
1549 : resolveTypedefs(
1550 : manager_->find(
1551 0 : entity_->getDirectOptionalBaseInterfaces()[i].name)),
1552 0 : css::uno::UNO_QUERY_THROW);
1553 : }
1554 0 : return s;
1555 : }
1556 :
1557 : css::uno::Sequence<
1558 : css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1559 0 : AccumulationBasedServiceDescription::getProperties()
1560 : throw (css::uno::RuntimeException, std::exception)
1561 : {
1562 : assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
1563 : sal_Int32 n = static_cast< sal_Int32 >(
1564 0 : entity_->getDirectProperties().size());
1565 : css::uno::Sequence<
1566 0 : css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n);
1567 0 : for (sal_Int32 i = 0; i != n; ++i) {
1568 0 : s[i] = new PropertyDescription(
1569 0 : manager_, entity_->getDirectProperties()[i]);
1570 : }
1571 0 : return s;
1572 : }
1573 :
1574 : typedef cppu::ImplInheritanceHelper1<
1575 : PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1576 : InterfaceBasedSingletonDescription_Base;
1577 :
1578 : class InterfaceBasedSingletonDescription:
1579 : public InterfaceBasedSingletonDescription_Base
1580 : {
1581 : public:
1582 0 : InterfaceBasedSingletonDescription(
1583 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1584 : rtl::OUString const & name,
1585 : rtl::Reference< unoidl::InterfaceBasedSingletonEntity > const & entity):
1586 0 : InterfaceBasedSingletonDescription_Base(entity->isPublished()),
1587 0 : manager_(manager), name_(name), entity_(entity)
1588 0 : { assert(manager.is()); assert(entity.is()); }
1589 :
1590 : private:
1591 0 : virtual ~InterfaceBasedSingletonDescription() {}
1592 :
1593 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1594 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1595 0 : { return css::uno::TypeClass_SINGLETON; }
1596 :
1597 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1598 0 : { return name_; }
1599 :
1600 : virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1601 0 : SAL_CALL getService() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1602 : {
1603 : return
1604 0 : css::uno::Reference< css::reflection::XServiceTypeDescription >();
1605 : }
1606 :
1607 0 : virtual sal_Bool SAL_CALL isInterfaceBased()
1608 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1609 0 : { return true; }
1610 :
1611 : virtual css::uno::Reference< css::reflection::XTypeDescription >
1612 0 : SAL_CALL getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1613 0 : { return manager_->resolve(entity_->getBase()); }
1614 :
1615 : rtl::Reference< cppuhelper::TypeManager > manager_;
1616 : rtl::OUString name_;
1617 : rtl::Reference< unoidl::InterfaceBasedSingletonEntity > entity_;
1618 : };
1619 :
1620 : typedef cppu::ImplInheritanceHelper1<
1621 : PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1622 : ServiceBasedSingletonDescription_Base;
1623 :
1624 : class ServiceBasedSingletonDescription:
1625 : public ServiceBasedSingletonDescription_Base
1626 : {
1627 : public:
1628 0 : ServiceBasedSingletonDescription(
1629 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1630 : rtl::OUString const & name,
1631 : rtl::Reference< unoidl::ServiceBasedSingletonEntity > const & entity):
1632 0 : ServiceBasedSingletonDescription_Base(entity_->isPublished()),
1633 0 : manager_(manager), name_(name), entity_(entity)
1634 0 : { assert(manager.is()); assert(entity.is()); }
1635 :
1636 : private:
1637 0 : virtual ~ServiceBasedSingletonDescription() {}
1638 :
1639 0 : virtual css::uno::TypeClass SAL_CALL getTypeClass()
1640 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1641 0 : { return css::uno::TypeClass_SINGLETON; }
1642 :
1643 0 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1644 0 : { return name_; }
1645 :
1646 : virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1647 0 : SAL_CALL getService() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1648 : {
1649 : return css::uno::Reference< css::reflection::XServiceTypeDescription >(
1650 0 : manager_->resolve(entity_->getBase()), css::uno::UNO_QUERY_THROW);
1651 : }
1652 :
1653 0 : virtual sal_Bool SAL_CALL isInterfaceBased()
1654 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1655 0 : { return false; }
1656 :
1657 : virtual css::uno::Reference< css::reflection::XTypeDescription >
1658 0 : SAL_CALL getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1659 0 : { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1660 :
1661 : rtl::Reference< cppuhelper::TypeManager > manager_;
1662 : rtl::OUString name_;
1663 : rtl::Reference< unoidl::ServiceBasedSingletonEntity > entity_;
1664 : };
1665 :
1666 : class Enumeration:
1667 : public cppu::WeakImplHelper1< css::reflection::XTypeDescriptionEnumeration >
1668 : {
1669 : public:
1670 0 : Enumeration(
1671 : rtl::Reference< cppuhelper::TypeManager > const & manager,
1672 : rtl::OUString const & prefix,
1673 : rtl::Reference< unoidl::MapCursor > const & cursor,
1674 : css::uno::Sequence< css::uno::TypeClass > const & types, bool deep):
1675 0 : manager_(manager), types_(types), deep_(deep)
1676 : {
1677 : assert(manager.is());
1678 0 : positions_.push(Position(prefix, cursor));
1679 0 : findNextMatch();
1680 0 : }
1681 :
1682 : private:
1683 0 : virtual ~Enumeration() {}
1684 :
1685 0 : virtual sal_Bool SAL_CALL hasMoreElements()
1686 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1687 0 : { return !positions_.empty(); }
1688 :
1689 0 : virtual css::uno::Any SAL_CALL nextElement()
1690 : throw (
1691 : css::container::NoSuchElementException,
1692 : css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1693 0 : { return css::uno::makeAny(nextTypeDescription()); }
1694 :
1695 : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1696 : nextTypeDescription()
1697 : throw (
1698 : css::container::NoSuchElementException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1699 :
1700 : bool matches(css::uno::TypeClass tc) const;
1701 :
1702 : void findNextMatch();
1703 :
1704 0 : struct Position {
1705 0 : Position(
1706 : rtl::OUString const & thePrefix,
1707 : rtl::Reference< unoidl::MapCursor > const & theCursor):
1708 0 : prefix(thePrefix), cursor(theCursor)
1709 0 : { assert(theCursor.is()); }
1710 :
1711 0 : Position(
1712 : rtl::OUString const & thePrefix,
1713 : rtl::Reference< unoidl::ConstantGroupEntity > const &
1714 : theConstantGroup):
1715 : prefix(thePrefix), constantGroup(theConstantGroup),
1716 0 : constantGroupIndex(constantGroup->getMembers().begin())
1717 0 : { assert(theConstantGroup.is()); }
1718 :
1719 0 : Position(Position const & other):
1720 : prefix(other.prefix), cursor(other.cursor),
1721 0 : constantGroup(other.constantGroup)
1722 : {
1723 0 : if (constantGroup.is()) {
1724 0 : constantGroupIndex = other.constantGroupIndex;
1725 : }
1726 0 : }
1727 :
1728 : rtl::OUString prefix;
1729 : rtl::Reference< unoidl::MapCursor > cursor;
1730 : rtl::Reference< unoidl::ConstantGroupEntity > constantGroup;
1731 : std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator
1732 : constantGroupIndex;
1733 : };
1734 :
1735 : rtl::Reference< cppuhelper::TypeManager > manager_;
1736 : css::uno::Sequence< css::uno::TypeClass > types_;
1737 : bool deep_;
1738 :
1739 : osl::Mutex mutex_;
1740 : std::stack< Position > positions_;
1741 : rtl::OUString current_;
1742 : };
1743 :
1744 : css::uno::Reference< css::reflection::XTypeDescription >
1745 0 : Enumeration::nextTypeDescription()
1746 : throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
1747 : {
1748 0 : rtl::OUString name;
1749 : {
1750 0 : osl::MutexGuard g(mutex_);
1751 0 : if (positions_.empty()) {
1752 : throw css::container::NoSuchElementException(
1753 : "exhausted XTypeDescriptionEnumeration",
1754 0 : static_cast< cppu::OWeakObject * >(this));
1755 : }
1756 0 : name = current_;
1757 0 : findNextMatch();
1758 : }
1759 0 : return manager_->resolve(name);
1760 : }
1761 :
1762 0 : bool Enumeration::matches(css::uno::TypeClass tc) const {
1763 0 : if (types_.getLength() == 0) {
1764 0 : return true;
1765 : }
1766 0 : for (sal_Int32 i = 0; i != types_.getLength(); ++i) {
1767 0 : if (types_[i] == tc) {
1768 0 : return true;
1769 : }
1770 : }
1771 0 : return false;
1772 : }
1773 :
1774 0 : void Enumeration::findNextMatch() {
1775 : try {
1776 : for (;;) {
1777 : assert(!positions_.empty());
1778 0 : rtl::OUString name;
1779 0 : if (positions_.top().cursor.is()) { // root or module
1780 : rtl::Reference< unoidl::Entity > ent(
1781 0 : positions_.top().cursor->getNext(&name));
1782 0 : if (!ent.is()) {
1783 0 : positions_.pop();
1784 0 : if (positions_.empty()) {
1785 0 : break;
1786 : }
1787 0 : continue;
1788 : }
1789 0 : name = positions_.top().prefix + name;
1790 : css::uno::TypeClass tc;
1791 0 : switch (ent->getSort()) {
1792 : case unoidl::Entity::SORT_MODULE:
1793 0 : tc = css::uno::TypeClass_MODULE;
1794 0 : if (deep_) {
1795 : positions_.push(
1796 : Position(
1797 : makePrefix(name),
1798 : static_cast< unoidl::ModuleEntity * >(
1799 0 : ent.get())->createCursor()));
1800 : }
1801 0 : break;
1802 : case unoidl::Entity::SORT_ENUM_TYPE:
1803 0 : tc = css::uno::TypeClass_ENUM;
1804 0 : break;
1805 : case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
1806 : case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
1807 0 : tc = css::uno::TypeClass_STRUCT;
1808 0 : break;
1809 : case unoidl::Entity::SORT_EXCEPTION_TYPE:
1810 0 : tc = css::uno::TypeClass_EXCEPTION;
1811 0 : break;
1812 : case unoidl::Entity::SORT_INTERFACE_TYPE:
1813 0 : tc = css::uno::TypeClass_INTERFACE;
1814 0 : break;
1815 : case unoidl::Entity::SORT_TYPEDEF:
1816 0 : tc = css::uno::TypeClass_TYPEDEF;
1817 0 : break;
1818 : case unoidl::Entity::SORT_CONSTANT_GROUP:
1819 0 : tc = css::uno::TypeClass_CONSTANTS;
1820 0 : if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
1821 : positions_.push(
1822 : Position(
1823 : makePrefix(name),
1824 : static_cast< unoidl::ConstantGroupEntity * >(
1825 0 : ent.get())));
1826 : }
1827 0 : break;
1828 : case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
1829 : case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
1830 0 : tc = css::uno::TypeClass_SERVICE;
1831 0 : break;
1832 : case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
1833 : case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
1834 0 : tc = css::uno::TypeClass_SINGLETON;
1835 0 : break;
1836 : default:
1837 0 : for (;;) { std::abort(); } // this cannot happen
1838 : }
1839 0 : if (matches(tc)) {
1840 0 : current_ = name;
1841 0 : break;
1842 0 : }
1843 : } else { // constant group
1844 0 : if (positions_.top().constantGroupIndex
1845 0 : == positions_.top().constantGroup->getMembers().end())
1846 : {
1847 0 : positions_.pop();
1848 0 : if (positions_.empty()) {
1849 0 : break;
1850 : }
1851 0 : continue;
1852 : }
1853 0 : current_ = positions_.top().prefix
1854 0 : + positions_.top().constantGroupIndex++->name;
1855 0 : break;
1856 : }
1857 0 : }
1858 0 : } catch (unoidl::FileFormatException & e) {
1859 : throw css::uno::DeploymentException(
1860 0 : e.getUri() + ": " + e.getDetail(),
1861 0 : static_cast< cppu::OWeakObject * >(this));
1862 : }
1863 0 : }
1864 :
1865 : }
1866 :
1867 1 : cppuhelper::TypeManager::TypeManager():
1868 : TypeManager_Base(m_aMutex),
1869 1 : manager_(new unoidl::Manager)
1870 1 : {}
1871 :
1872 1 : void cppuhelper::TypeManager::init(rtl::OUString const & rdbUris) {
1873 1 : readRdbs(rdbUris);
1874 1 : }
1875 :
1876 14 : css::uno::Any cppuhelper::TypeManager::find(rtl::OUString const & name) {
1877 : //TODO: caching? (here or in unoidl::Manager?)
1878 : struct Simple {
1879 : char const * name; sal_Int32 length;
1880 : css::uno::TypeClass typeClass;
1881 : };
1882 : static Simple const simple[] = {
1883 : { RTL_CONSTASCII_STRINGPARAM("void"), css::uno::TypeClass_VOID },
1884 : { RTL_CONSTASCII_STRINGPARAM("boolean"), css::uno::TypeClass_BOOLEAN },
1885 : { RTL_CONSTASCII_STRINGPARAM("byte"), css::uno::TypeClass_BYTE },
1886 : { RTL_CONSTASCII_STRINGPARAM("short"), css::uno::TypeClass_SHORT },
1887 : { RTL_CONSTASCII_STRINGPARAM("unsigned short"),
1888 : css::uno::TypeClass_UNSIGNED_SHORT },
1889 : { RTL_CONSTASCII_STRINGPARAM("long"), css::uno::TypeClass_LONG },
1890 : { RTL_CONSTASCII_STRINGPARAM("unsigned long"),
1891 : css::uno::TypeClass_UNSIGNED_LONG },
1892 : { RTL_CONSTASCII_STRINGPARAM("hyper"), css::uno::TypeClass_HYPER },
1893 : { RTL_CONSTASCII_STRINGPARAM("unsigned hyper"),
1894 : css::uno::TypeClass_UNSIGNED_HYPER },
1895 : { RTL_CONSTASCII_STRINGPARAM("float"), css::uno::TypeClass_FLOAT },
1896 : { RTL_CONSTASCII_STRINGPARAM("double"), css::uno::TypeClass_DOUBLE },
1897 : { RTL_CONSTASCII_STRINGPARAM("char"), css::uno::TypeClass_CHAR },
1898 : { RTL_CONSTASCII_STRINGPARAM("string"), css::uno::TypeClass_STRING },
1899 : { RTL_CONSTASCII_STRINGPARAM("type"), css::uno::TypeClass_TYPE },
1900 : { RTL_CONSTASCII_STRINGPARAM("any"), css::uno::TypeClass_ANY } };
1901 195 : for (std::size_t i = 0; i != SAL_N_ELEMENTS(simple); ++i) {
1902 184 : if (name.equalsAsciiL(simple[i].name, simple[i].length)) {
1903 : return css::uno::makeAny<
1904 : css::uno::Reference< css::reflection::XTypeDescription > >(
1905 3 : new SimpleTypeDescription(simple[i].typeClass, name));
1906 : }
1907 : }
1908 11 : if (name.startsWith("[]")) {
1909 0 : return getSequenceType(name);
1910 : }
1911 11 : sal_Int32 i = name.indexOf('<');
1912 11 : if (i != -1) {
1913 1 : return getInstantiatedStruct(name, i);
1914 : }
1915 10 : i = name.indexOf("::");
1916 10 : if (i != -1) {
1917 0 : return getInterfaceMember(name, i);
1918 : }
1919 10 : rtl::Reference< unoidl::Entity > ent(findEntity(name));
1920 10 : if (ent.is()) {
1921 10 : return getNamed(name, ent);
1922 : }
1923 0 : i = name.lastIndexOf('.');
1924 0 : if (i != -1) {
1925 0 : rtl::OUString parent(name.copy(0, i));
1926 0 : ent = findEntity(parent);
1927 0 : if (ent.is()) {
1928 0 : switch (ent->getSort()) {
1929 : case unoidl::Entity::SORT_ENUM_TYPE:
1930 : return getEnumMember(
1931 0 : static_cast< unoidl::EnumTypeEntity * >(ent.get()),
1932 0 : name.copy(i + 1));
1933 : case unoidl::Entity::SORT_CONSTANT_GROUP:
1934 : return getConstant(
1935 : parent,
1936 0 : static_cast< unoidl::ConstantGroupEntity * >(ent.get()),
1937 0 : name.copy(i + 1));
1938 : default:
1939 0 : break;
1940 : }
1941 0 : }
1942 : }
1943 0 : return css::uno::Any();
1944 : }
1945 :
1946 : css::uno::Reference< css::reflection::XTypeDescription >
1947 9 : cppuhelper::TypeManager::resolve(rtl::OUString const & name) {
1948 : css::uno::Reference< css::reflection::XTypeDescription > desc(
1949 9 : find(name), css::uno::UNO_QUERY);
1950 9 : if (!desc.is()) {
1951 : throw css::uno::DeploymentException(
1952 0 : "cannot resolve type \"" + name + "\"",
1953 0 : static_cast< cppu::OWeakObject * >(this));
1954 : }
1955 9 : return desc;
1956 : }
1957 :
1958 2 : cppuhelper::TypeManager::~TypeManager() throw () {}
1959 :
1960 1 : void cppuhelper::TypeManager::disposing() {} //TODO
1961 :
1962 0 : rtl::OUString cppuhelper::TypeManager::getImplementationName()
1963 : throw (css::uno::RuntimeException, std::exception)
1964 : {
1965 : return rtl::OUString(
1966 0 : "com.sun.star.comp.cppuhelper.bootstrap.TypeManager");
1967 : }
1968 :
1969 0 : sal_Bool cppuhelper::TypeManager::supportsService(
1970 : rtl::OUString const & ServiceName)
1971 : throw (css::uno::RuntimeException, std::exception)
1972 : {
1973 0 : return cppu::supportsService(this, ServiceName);
1974 : }
1975 :
1976 : css::uno::Sequence< rtl::OUString >
1977 0 : cppuhelper::TypeManager::getSupportedServiceNames()
1978 : throw (css::uno::RuntimeException, std::exception)
1979 : {
1980 0 : css::uno::Sequence< rtl::OUString > names(1);
1981 0 : names[0] = "com.sun.star.reflection.TypeDescriptionManager"; //TODO
1982 0 : return names;
1983 : }
1984 :
1985 5 : css::uno::Any cppuhelper::TypeManager::getByHierarchicalName(
1986 : rtl::OUString const & aName)
1987 : throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
1988 : {
1989 5 : css::uno::Any desc(find(aName));
1990 5 : if (!desc.hasValue()) {
1991 : throw css::container::NoSuchElementException(
1992 0 : aName, static_cast< cppu::OWeakObject * >(this));
1993 : }
1994 5 : return desc;
1995 : }
1996 :
1997 0 : sal_Bool cppuhelper::TypeManager::hasByHierarchicalName(
1998 : rtl::OUString const & aName)
1999 : throw (css::uno::RuntimeException, std::exception)
2000 : {
2001 0 : return find(aName).hasValue();
2002 : }
2003 :
2004 0 : css::uno::Type cppuhelper::TypeManager::getElementType()
2005 : throw (css::uno::RuntimeException, std::exception)
2006 : {
2007 0 : return cppu::UnoType< rtl::OUString >::get();
2008 : }
2009 :
2010 0 : sal_Bool cppuhelper::TypeManager::hasElements()
2011 : throw (css::uno::RuntimeException, std::exception)
2012 : {
2013 : throw css::uno::RuntimeException(
2014 : "TypeManager hasElements: method not supported",
2015 0 : static_cast< cppu::OWeakObject * >(this));
2016 : }
2017 :
2018 : css::uno::Reference< css::container::XEnumeration >
2019 0 : cppuhelper::TypeManager::createEnumeration()
2020 : throw (css::uno::RuntimeException, std::exception)
2021 : {
2022 : throw css::uno::RuntimeException(
2023 : "TypeManager createEnumeration: method not supported",
2024 0 : static_cast< cppu::OWeakObject * >(this));
2025 : }
2026 :
2027 0 : sal_Bool cppuhelper::TypeManager::has(css::uno::Any const &)
2028 : throw (css::uno::RuntimeException, std::exception)
2029 : {
2030 : throw css::uno::RuntimeException(
2031 : "TypeManager has: method not supported",
2032 0 : static_cast< cppu::OWeakObject * >(this));
2033 : }
2034 :
2035 0 : void cppuhelper::TypeManager::insert(css::uno::Any const & aElement)
2036 : throw (
2037 : css::lang::IllegalArgumentException,
2038 : css::container::ElementExistException, css::uno::RuntimeException, std::exception)
2039 : {
2040 0 : rtl::OUString uri;
2041 0 : if (!(aElement >>= uri)) {
2042 : throw css::lang::IllegalArgumentException(
2043 : ("css.uno.theTypeDescriptionManager.insert expects a string URI"
2044 : " argument"),
2045 0 : static_cast< cppu::OWeakObject * >(this), 0);
2046 : }
2047 : //TODO: check for ElementExistException
2048 : //TODO: check for consistency with existing data
2049 0 : readRdbFile(uri, false);
2050 0 : }
2051 :
2052 0 : void cppuhelper::TypeManager::remove(css::uno::Any const & aElement)
2053 : throw (
2054 : css::lang::IllegalArgumentException,
2055 : css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
2056 : {
2057 0 : rtl::OUString uri;
2058 0 : if (!(aElement >>= uri)) {
2059 : throw css::lang::IllegalArgumentException(
2060 : ("css.uno.theTypeDescriptionManager.remove expects a string URI"
2061 : " argument"),
2062 0 : static_cast< cppu::OWeakObject * >(this), 0);
2063 0 : }
2064 : //TODO: remove requests are silently ignored for now
2065 0 : }
2066 :
2067 : css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
2068 0 : cppuhelper::TypeManager::createTypeDescriptionEnumeration(
2069 : rtl::OUString const & moduleName,
2070 : css::uno::Sequence< css::uno::TypeClass > const & types,
2071 : css::reflection::TypeDescriptionSearchDepth depth)
2072 : throw (
2073 : css::reflection::NoSuchTypeNameException,
2074 : css::reflection::InvalidTypeNameException,
2075 : css::uno::RuntimeException, std::exception)
2076 : {
2077 0 : rtl::Reference< unoidl::MapCursor > cursor;
2078 : try {
2079 0 : cursor = manager_->createCursor(moduleName);
2080 0 : } catch (unoidl::FileFormatException & e) {
2081 : throw css::uno::DeploymentException(
2082 0 : ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2083 0 : + e.getDetail()),
2084 0 : static_cast< cppu::OWeakObject * >(this));
2085 : }
2086 0 : if (!cursor.is()) {
2087 : //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2088 : // non-module
2089 : throw css::reflection::NoSuchTypeNameException(
2090 0 : moduleName, static_cast< cppu::OWeakObject * >(this));
2091 : }
2092 : return new Enumeration(
2093 : this, makePrefix(moduleName), cursor, types,
2094 0 : depth == css::reflection::TypeDescriptionSearchDepth_INFINITE);
2095 : }
2096 :
2097 1 : void cppuhelper::TypeManager::readRdbs(rtl::OUString const & uris) {
2098 7 : for (sal_Int32 i = 0; i != -1;) {
2099 5 : rtl::OUString uri(uris.getToken(0, ' ', i));
2100 5 : if (uri.isEmpty()) {
2101 3 : continue;
2102 : }
2103 : bool optional;
2104 : bool directory;
2105 2 : cppu::decodeRdbUri(&uri, &optional, &directory);
2106 2 : if (directory) {
2107 1 : readRdbDirectory(uri, optional);
2108 : } else {
2109 1 : readRdbFile(uri, optional);
2110 : }
2111 2 : }
2112 1 : }
2113 :
2114 1 : void cppuhelper::TypeManager::readRdbDirectory(
2115 : rtl::OUString const & uri, bool optional)
2116 : {
2117 1 : osl::Directory dir(uri);
2118 1 : switch (dir.open()) {
2119 : case osl::FileBase::E_None:
2120 1 : break;
2121 : case osl::FileBase::E_NOENT:
2122 0 : if (optional) {
2123 : SAL_INFO("cppuhelper", "Ignored optional " << uri);
2124 1 : return;
2125 : }
2126 : // fall through
2127 : default:
2128 : throw css::uno::DeploymentException(
2129 0 : "Cannot open directory " + uri,
2130 0 : static_cast< cppu::OWeakObject * >(this));
2131 : }
2132 : for (;;) {
2133 3 : rtl::OUString url;
2134 3 : if (!cppu::nextDirectoryItem(dir, &url)) {
2135 1 : break;
2136 : }
2137 2 : readRdbFile(url, false);
2138 2 : }
2139 : }
2140 :
2141 3 : void cppuhelper::TypeManager::readRdbFile(
2142 : rtl::OUString const & uri, bool optional)
2143 : {
2144 : try {
2145 3 : manager_->addProvider(unoidl::loadProvider(manager_, uri));
2146 0 : } catch (unoidl::NoSuchFileException &) {
2147 0 : if (!optional) {
2148 : throw css::uno::DeploymentException(
2149 0 : uri + ": no such file",
2150 0 : static_cast< cppu::OWeakObject * >(this));
2151 : }
2152 : SAL_INFO("cppuhelper", "Ignored optional " << uri);
2153 0 : } catch (unoidl::FileFormatException & e) {
2154 : throw css::uno::DeploymentException(
2155 0 : ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2156 0 : + e.getDetail()),
2157 0 : static_cast< cppu::OWeakObject * >(this));
2158 : }
2159 3 : }
2160 :
2161 0 : css::uno::Any cppuhelper::TypeManager::getSequenceType(
2162 : rtl::OUString const & name)
2163 : {
2164 : assert(name.startsWith("[]"));
2165 : return css::uno::makeAny<
2166 : css::uno::Reference< css::reflection::XTypeDescription > >(
2167 : new SequenceTypeDescription(
2168 0 : this, name, name.copy(std::strlen("[]"))));
2169 : }
2170 :
2171 1 : css::uno::Any cppuhelper::TypeManager::getInstantiatedStruct(
2172 : rtl::OUString const & name, sal_Int32 separator)
2173 : {
2174 : assert(name.indexOf('<') == separator && separator != -1);
2175 1 : rtl::Reference< unoidl::Entity > ent(findEntity(name.copy(0, separator)));
2176 2 : if (!ent.is()
2177 1 : || (ent->getSort()
2178 : != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE))
2179 : {
2180 0 : return css::uno::Any();
2181 : }
2182 : rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
2183 : static_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
2184 2 : ent.get()));
2185 2 : std::vector< rtl::OUString > args;
2186 1 : sal_Int32 i = separator;
2187 1 : do {
2188 1 : ++i; // skip '<' or ','
2189 1 : sal_Int32 j = i;
2190 4 : for (sal_Int32 level = 0; j != name.getLength(); ++j) {
2191 4 : sal_Unicode c = name[j];
2192 4 : if (c == ',') {
2193 0 : if (level == 0) {
2194 0 : break;
2195 : }
2196 4 : } else if (c == '<') {
2197 0 : ++level;
2198 4 : } else if (c == '>') {
2199 1 : if (level == 0) {
2200 1 : break;
2201 : }
2202 0 : --level;
2203 : }
2204 : }
2205 1 : if (j != name.getLength()) {
2206 1 : args.push_back(name.copy(i, j - i));
2207 : }
2208 1 : i = j;
2209 1 : } while (i != name.getLength() && name[i] != '>');
2210 3 : if (i != name.getLength() - 1 || name[i] != '>'
2211 2 : || args.size() != ent2->getTypeParameters().size())
2212 : {
2213 0 : return css::uno::Any();
2214 : }
2215 : return css::uno::makeAny<
2216 : css::uno::Reference< css::reflection::XTypeDescription > >(
2217 : new InstantiatedPolymorphicStructTypeDescription(
2218 2 : this, name, ent2, args));
2219 : }
2220 :
2221 0 : css::uno::Any cppuhelper::TypeManager::getInterfaceMember(
2222 : rtl::OUString const & name, sal_Int32 separator)
2223 : {
2224 : assert(name.indexOf("::") == separator && separator != -1);
2225 : css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
2226 0 : resolveTypedefs(find(name.copy(0, separator))), css::uno::UNO_QUERY);
2227 0 : if (!ifc.is()) {
2228 0 : return css::uno::Any();
2229 : }
2230 0 : rtl::OUString member(name.copy(separator + std::strlen("::")));
2231 : css::uno::Sequence<
2232 : css::uno::Reference<
2233 : css::reflection::XInterfaceMemberTypeDescription > > mems(
2234 0 : ifc->getMembers());
2235 0 : for (sal_Int32 i = 0; i != mems.getLength(); ++i) {
2236 0 : if (mems[i]->getMemberName() == member) {
2237 : return css::uno::makeAny<
2238 : css::uno::Reference< css::reflection::XTypeDescription > >(
2239 0 : mems[i]);
2240 : }
2241 : }
2242 0 : return css::uno::Any();
2243 : }
2244 :
2245 10 : css::uno::Any cppuhelper::TypeManager::getNamed(
2246 : rtl::OUString const & name, rtl::Reference< unoidl::Entity > const & entity)
2247 : {
2248 : assert(entity.is());
2249 10 : switch (entity->getSort()) {
2250 : case unoidl::Entity::SORT_MODULE:
2251 : return css::uno::makeAny<
2252 : css::uno::Reference< css::reflection::XTypeDescription > >(
2253 : new ModuleDescription(
2254 : this, name,
2255 0 : static_cast< unoidl::ModuleEntity * >(entity.get())));
2256 : case unoidl::Entity::SORT_ENUM_TYPE:
2257 : return css::uno::makeAny<
2258 : css::uno::Reference< css::reflection::XTypeDescription > >(
2259 : new EnumTypeDescription(
2260 : name,
2261 0 : static_cast< unoidl::EnumTypeEntity * >(entity.get())));
2262 : case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
2263 : return css::uno::makeAny<
2264 : css::uno::Reference< css::reflection::XTypeDescription > >(
2265 : new PlainStructTypeDescription(
2266 : this, name,
2267 : static_cast< unoidl::PlainStructTypeEntity * >(
2268 0 : entity.get())));
2269 : case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
2270 : return css::uno::makeAny<
2271 : css::uno::Reference< css::reflection::XTypeDescription > >(
2272 : new PolymorphicStructTypeTemplateDescription(
2273 : this, name,
2274 : static_cast<
2275 : unoidl::PolymorphicStructTypeTemplateEntity * >(
2276 1 : entity.get())));
2277 : case unoidl::Entity::SORT_EXCEPTION_TYPE:
2278 : return css::uno::makeAny<
2279 : css::uno::Reference< css::reflection::XTypeDescription > >(
2280 : new ExceptionTypeDescription(
2281 : this, name,
2282 : static_cast< unoidl::ExceptionTypeEntity * >(
2283 0 : entity.get())));
2284 : case unoidl::Entity::SORT_INTERFACE_TYPE:
2285 : return css::uno::makeAny<
2286 : css::uno::Reference< css::reflection::XTypeDescription > >(
2287 : new InterfaceTypeDescription(
2288 : this, name,
2289 : static_cast< unoidl::InterfaceTypeEntity * >(
2290 9 : entity.get())));
2291 : case unoidl::Entity::SORT_TYPEDEF:
2292 : return css::uno::makeAny<
2293 : css::uno::Reference< css::reflection::XTypeDescription > >(
2294 : new TypedefDescription(
2295 : this, name,
2296 0 : static_cast< unoidl::TypedefEntity * >(entity.get())));
2297 : case unoidl::Entity::SORT_CONSTANT_GROUP:
2298 : return css::uno::makeAny<
2299 : css::uno::Reference< css::reflection::XTypeDescription > >(
2300 : new ConstantGroupDescription(
2301 : name,
2302 : static_cast< unoidl::ConstantGroupEntity * >(
2303 0 : entity.get())));
2304 : case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
2305 : return css::uno::makeAny<
2306 : css::uno::Reference< css::reflection::XTypeDescription > >(
2307 : new SingleInterfaceBasedServiceDescription(
2308 : this, name,
2309 : static_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
2310 0 : entity.get())));
2311 : case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
2312 : return css::uno::makeAny<
2313 : css::uno::Reference< css::reflection::XTypeDescription > >(
2314 : new AccumulationBasedServiceDescription(
2315 : this, name,
2316 : static_cast< unoidl::AccumulationBasedServiceEntity * >(
2317 0 : entity.get())));
2318 : case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
2319 : return css::uno::makeAny<
2320 : css::uno::Reference< css::reflection::XTypeDescription > >(
2321 : new InterfaceBasedSingletonDescription(
2322 : this, name,
2323 : static_cast< unoidl::InterfaceBasedSingletonEntity * >(
2324 0 : entity.get())));
2325 : case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
2326 : return css::uno::makeAny<
2327 : css::uno::Reference< css::reflection::XTypeDescription > >(
2328 : new ServiceBasedSingletonDescription(
2329 : this, name,
2330 : static_cast< unoidl::ServiceBasedSingletonEntity * >(
2331 0 : entity.get())));
2332 : default:
2333 0 : for (;;) { std::abort(); } // this cannot happen
2334 : }
2335 : }
2336 :
2337 0 : css::uno::Any cppuhelper::TypeManager::getEnumMember(
2338 : rtl::Reference< unoidl::EnumTypeEntity > const & entity,
2339 : rtl::OUString const & member)
2340 : {
2341 0 : for (std::vector< unoidl::EnumTypeEntity::Member >::const_iterator i(
2342 0 : entity->getMembers().begin());
2343 0 : i != entity->getMembers().end(); ++i)
2344 : {
2345 0 : if (i->name == member) {
2346 0 : return css::uno::makeAny(i->value);
2347 : }
2348 : }
2349 0 : return css::uno::Any();
2350 : }
2351 :
2352 0 : css::uno::Any cppuhelper::TypeManager::getConstant(
2353 : rtl::OUString const & constantGroupName,
2354 : rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
2355 : rtl::OUString const & member)
2356 : {
2357 0 : for (std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator i(
2358 0 : entity->getMembers().begin());
2359 0 : i != entity->getMembers().end(); ++i)
2360 : {
2361 0 : if (i->name == member) {
2362 : return css::uno::makeAny<
2363 : css::uno::Reference< css::reflection::XTypeDescription > >(
2364 0 : new ConstantDescription(constantGroupName, *i));
2365 : }
2366 : }
2367 0 : return css::uno::Any();
2368 : }
2369 :
2370 11 : rtl::Reference< unoidl::Entity > cppuhelper::TypeManager::findEntity(
2371 : rtl::OUString const & name)
2372 : {
2373 : try {
2374 11 : return manager_->findEntity(name);
2375 0 : } catch (unoidl::FileFormatException & e) {
2376 : throw css::uno::DeploymentException(
2377 0 : ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2378 0 : + e.getDetail()),
2379 0 : static_cast< cppu::OWeakObject * >(this));
2380 : }
2381 : }
2382 :
2383 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|