Bump version to 4.3-4
[LibreOffice.git] / cppuhelper / source / typemanager.cxx
blobe3e38e5669bddca65335ca4706c936654ef1db5e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "sal/config.h"
12 #include <cassert>
13 #include <cstddef>
14 #include <cstdlib>
15 #include <cstring>
16 #include <set>
17 #include <stack>
18 #include <vector>
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"
58 using rtl::OUString;
60 #include "unoidl/unoidl.hxx"
62 #include "paths.hxx"
63 #include "typemanager.hxx"
65 namespace {
67 rtl::OUString makePrefix(rtl::OUString const & name) {
68 return name.isEmpty() ? name : name + ".";
71 css::uno::Any resolveTypedefs(css::uno::Any const & type) {
72 for (css::uno::Any t(type);;) {
73 css::uno::Reference< css::reflection::XIndirectTypeDescription > ind(
74 type, css::uno::UNO_QUERY);
75 if (!ind.is() || ind->getTypeClass() != css::uno::TypeClass_TYPEDEF) {
76 return t;
78 t = css::uno::makeAny(ind->getReferencedType());
82 class SimpleTypeDescription:
83 public cppu::WeakImplHelper1< css::reflection::XTypeDescription >
85 public:
86 SimpleTypeDescription(
87 css::uno::TypeClass typeClass, rtl::OUString const & name):
88 typeClass_(typeClass), name_(name)
91 private:
92 virtual ~SimpleTypeDescription() {}
94 virtual css::uno::TypeClass SAL_CALL getTypeClass()
95 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
96 { return typeClass_; }
98 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
99 { return name_; }
101 css::uno::TypeClass typeClass_;
102 rtl::OUString name_;
105 class SequenceTypeDescription:
106 public cppu::WeakImplHelper1< css::reflection::XIndirectTypeDescription >
108 public:
109 SequenceTypeDescription(
110 rtl::Reference< cppuhelper::TypeManager > const & manager,
111 rtl::OUString const & name, rtl::OUString const & componentType):
112 manager_(manager), name_(name), componentType_(componentType)
113 { assert(manager.is()); }
115 private:
116 virtual ~SequenceTypeDescription() {}
118 virtual css::uno::TypeClass SAL_CALL getTypeClass()
119 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
120 { return css::uno::TypeClass_SEQUENCE; }
122 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
123 { return name_; }
125 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
126 getReferencedType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
127 { return manager_->resolve(componentType_); }
129 rtl::Reference< cppuhelper::TypeManager > manager_;
130 rtl::OUString name_;
131 rtl::OUString componentType_;
134 class PublishableDescription:
135 public cppu::WeakImplHelper1< css::reflection::XPublished >
137 protected:
138 PublishableDescription(bool published): published_(published) {}
140 virtual ~PublishableDescription() {}
142 private:
143 virtual sal_Bool SAL_CALL isPublished() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
144 { return published_; }
146 bool published_;
149 class ModuleDescription:
150 public cppu::WeakImplHelper1< css::reflection::XModuleTypeDescription >
152 public:
153 ModuleDescription(
154 rtl::Reference< cppuhelper::TypeManager > const & manager,
155 rtl::OUString const & name,
156 rtl::Reference< unoidl::ModuleEntity > const & entity):
157 manager_(manager), name_(name), entity_(entity)
158 { assert(manager.is()); assert(entity.is()); }
160 private:
161 virtual ~ModuleDescription() {}
163 virtual css::uno::TypeClass SAL_CALL getTypeClass()
164 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
165 { return css::uno::TypeClass_MODULE; }
167 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
168 { return name_; }
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;
175 rtl::Reference< cppuhelper::TypeManager > manager_;
176 rtl::OUString name_;
177 rtl::Reference< unoidl::ModuleEntity > entity_;
180 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
181 ModuleDescription::getMembers() throw (css::uno::RuntimeException, std::exception) {
182 try {
183 std::vector< rtl::OUString > names(entity_->getMemberNames());
184 assert(names.size() <= SAL_MAX_INT32);
185 sal_Int32 n = static_cast< sal_Int32 >(names.size());
186 css::uno::Sequence<
187 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
188 for (sal_Int32 i = 0; i != n; ++i) {
189 s[i] = manager_->resolve(makePrefix(name_) + names[i]);
191 return s;
192 } catch (unoidl::FileFormatException & e) {
193 throw css::uno::DeploymentException(
194 e.getUri() + ": " + e.getDetail(),
195 static_cast< cppu::OWeakObject * >(this));
199 typedef cppu::ImplInheritanceHelper1<
200 PublishableDescription, css::reflection::XEnumTypeDescription >
201 EnumTypeDescription_Base;
203 class EnumTypeDescription: public EnumTypeDescription_Base {
204 public:
205 EnumTypeDescription(
206 rtl::OUString const & name,
207 rtl::Reference< unoidl::EnumTypeEntity > const & entity):
208 EnumTypeDescription_Base(entity->isPublished()), name_(name),
209 entity_(entity)
210 { assert(entity.is()); }
212 private:
213 virtual ~EnumTypeDescription() {}
215 virtual css::uno::TypeClass SAL_CALL getTypeClass()
216 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
217 { return css::uno::TypeClass_ENUM; }
219 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
220 { return name_; }
222 virtual sal_Int32 SAL_CALL getDefaultEnumValue()
223 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
224 { return entity_->getMembers()[0].value; }
226 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getEnumNames()
227 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
229 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getEnumValues()
230 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
232 rtl::OUString name_;
233 rtl::Reference< unoidl::EnumTypeEntity > entity_;
236 css::uno::Sequence< rtl::OUString > EnumTypeDescription::getEnumNames()
237 throw (css::uno::RuntimeException, std::exception)
239 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
240 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
241 css::uno::Sequence< rtl::OUString > s(n);
242 for (sal_Int32 i = 0; i != n; ++i) {
243 s[i] = entity_->getMembers()[i].name;
245 return s;
248 css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
249 throw (css::uno::RuntimeException, std::exception)
251 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
252 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
253 css::uno::Sequence< sal_Int32 > s(n);
254 for (sal_Int32 i = 0; i != n; ++i) {
255 s[i] = entity_->getMembers()[i].value;
257 return s;
260 typedef cppu::ImplInheritanceHelper1<
261 PublishableDescription, css::reflection::XStructTypeDescription >
262 PlainStructTypeDescription_Base;
264 class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
265 public:
266 PlainStructTypeDescription(
267 rtl::Reference< cppuhelper::TypeManager > const & manager,
268 rtl::OUString const & name,
269 rtl::Reference< unoidl::PlainStructTypeEntity > const & entity):
270 PlainStructTypeDescription_Base(entity->isPublished()),
271 manager_(manager), name_(name), entity_(entity)
272 { assert(manager.is()); assert(entity.is()); }
274 private:
275 virtual ~PlainStructTypeDescription() {}
277 virtual css::uno::TypeClass SAL_CALL getTypeClass()
278 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
279 { return css::uno::TypeClass_STRUCT; }
281 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
282 { return name_; }
284 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
285 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
286 return entity_->getDirectBase().isEmpty()
287 ? css::uno::Reference< css::reflection::XTypeDescription >()
288 : manager_->resolve(entity_->getDirectBase());
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;
296 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
297 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
299 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
300 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
301 { return css::uno::Sequence< rtl::OUString >(); }
303 virtual
304 css::uno::Sequence<
305 css::uno::Reference< css::reflection::XTypeDescription > >
306 SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
307 return css::uno::Sequence<
308 css::uno::Reference< css::reflection::XTypeDescription > >();
311 rtl::Reference< cppuhelper::TypeManager > manager_;
312 rtl::OUString name_;
313 rtl::Reference< unoidl::PlainStructTypeEntity > entity_;
316 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
317 PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException, std::exception)
319 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
320 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
321 css::uno::Sequence<
322 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
323 for (sal_Int32 i = 0; i != n; ++i) {
324 s[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
326 return s;
329 css::uno::Sequence< rtl::OUString > PlainStructTypeDescription::getMemberNames()
330 throw (css::uno::RuntimeException, std::exception)
332 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
333 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
334 css::uno::Sequence< rtl::OUString > s(n);
335 for (sal_Int32 i = 0; i != n; ++i) {
336 s[i] = entity_->getDirectMembers()[i].name;
338 return s;
341 class ParameterizedMemberTypeDescription:
342 public cppu::WeakImplHelper1< css::reflection::XTypeDescription >
344 public:
345 explicit ParameterizedMemberTypeDescription(
346 rtl::OUString const & typeParameterName):
347 typeParameterName_(typeParameterName)
350 private:
351 virtual ~ParameterizedMemberTypeDescription() {}
353 virtual css::uno::TypeClass SAL_CALL getTypeClass()
354 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
355 { return css::uno::TypeClass_UNKNOWN; }
357 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
358 { return typeParameterName_; }
360 rtl::OUString typeParameterName_;
363 typedef cppu::ImplInheritanceHelper1<
364 PublishableDescription, css::reflection::XStructTypeDescription >
365 PolymorphicStructTypeTemplateDescription_Base;
367 class PolymorphicStructTypeTemplateDescription:
368 public PolymorphicStructTypeTemplateDescription_Base
370 public:
371 PolymorphicStructTypeTemplateDescription(
372 rtl::Reference< cppuhelper::TypeManager > const & manager,
373 rtl::OUString const & name,
374 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > const &
375 entity):
376 PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
377 manager_(manager), name_(name), entity_(entity)
378 { assert(manager.is()); assert(entity.is()); }
380 private:
381 virtual ~PolymorphicStructTypeTemplateDescription() {}
383 virtual css::uno::TypeClass SAL_CALL getTypeClass()
384 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
385 { return css::uno::TypeClass_STRUCT; }
387 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
388 { return name_; }
390 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
391 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
392 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
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;
399 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
400 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
402 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
403 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
405 virtual
406 css::uno::Sequence<
407 css::uno::Reference< css::reflection::XTypeDescription > >
408 SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
409 return css::uno::Sequence<
410 css::uno::Reference< css::reflection::XTypeDescription > >();
413 rtl::Reference< cppuhelper::TypeManager > manager_;
414 rtl::OUString name_;
415 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_;
418 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
419 PolymorphicStructTypeTemplateDescription::getMemberTypes()
420 throw (css::uno::RuntimeException, std::exception)
422 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
423 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
424 css::uno::Sequence<
425 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
426 for (sal_Int32 i = 0; i != n; ++i) {
427 s[i] = entity_->getMembers()[i].parameterized
428 ? new ParameterizedMemberTypeDescription(
429 entity_->getMembers()[i].type)
430 : manager_->resolve(entity_->getMembers()[i].type);
432 return s;
435 css::uno::Sequence< rtl::OUString >
436 PolymorphicStructTypeTemplateDescription::getMemberNames()
437 throw (css::uno::RuntimeException, std::exception)
439 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
440 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
441 css::uno::Sequence< rtl::OUString > s(n);
442 for (sal_Int32 i = 0; i != n; ++i) {
443 s[i] = entity_->getMembers()[i].name;
445 return s;
448 css::uno::Sequence< rtl::OUString >
449 PolymorphicStructTypeTemplateDescription::getTypeParameters()
450 throw (css::uno::RuntimeException, std::exception)
452 assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32);
453 sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size());
454 css::uno::Sequence< rtl::OUString > s(n);
455 for (sal_Int32 i = 0; i != n; ++i) {
456 s[i] = entity_->getTypeParameters()[i];
458 return s;
461 class InstantiatedPolymorphicStructTypeDescription:
462 public cppu::WeakImplHelper1< css::reflection::XStructTypeDescription >
464 public:
465 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 manager_(manager), name_(name), entity_(entity), arguments_(arguments)
473 assert(manager.is());
474 assert(entity.is());
475 assert(arguments.size() == entity->getTypeParameters().size());
478 private:
479 virtual ~InstantiatedPolymorphicStructTypeDescription() {}
481 virtual css::uno::TypeClass SAL_CALL getTypeClass()
482 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
483 { return css::uno::TypeClass_STRUCT; }
485 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
486 { return name_; }
488 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
489 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
490 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
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;
497 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
498 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
500 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
501 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
502 { return css::uno::Sequence< rtl::OUString >(); }
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;
509 rtl::Reference< cppuhelper::TypeManager > manager_;
510 rtl::OUString name_;
511 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_;
512 std::vector< rtl::OUString > arguments_;
515 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
516 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
517 throw (css::uno::RuntimeException, std::exception)
519 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
520 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
521 css::uno::Sequence<
522 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
523 for (sal_Int32 i = 0; i != n; ++i) {
524 rtl::OUString type(entity_->getMembers()[i].type);
525 if (entity_->getMembers()[i].parameterized) {
526 for (std::vector< rtl::OUString >::const_iterator j(
527 entity_->getTypeParameters().begin());
528 j != entity_->getTypeParameters().end(); ++j)
530 if (*j == type) {
531 type = arguments_[j - entity_->getTypeParameters().begin()];
532 goto found;
535 assert(false); // this cannot happen //TODO!
536 found:;
538 s[i] = manager_->resolve(type);
540 return s;
543 css::uno::Sequence< rtl::OUString >
544 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
545 throw (css::uno::RuntimeException, std::exception)
547 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
548 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
549 css::uno::Sequence< rtl::OUString > s(n);
550 for (sal_Int32 i = 0; i != n; ++i) {
551 s[i] = entity_->getMembers()[i].name;
553 return s;
555 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
556 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
557 throw (css::uno::RuntimeException, std::exception)
559 assert(arguments_.size() <= SAL_MAX_INT32);
560 sal_Int32 n = static_cast< sal_Int32 >(arguments_.size());
561 css::uno::Sequence<
562 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
563 for (sal_Int32 i = 0; i != n; ++i) {
564 s[i] = manager_->resolve(arguments_[i]);
566 return s;
569 typedef cppu::ImplInheritanceHelper1<
570 PublishableDescription, css::reflection::XCompoundTypeDescription >
571 ExceptionTypeDescription_Base;
573 class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
574 public:
575 ExceptionTypeDescription(
576 rtl::Reference< cppuhelper::TypeManager > const & manager,
577 rtl::OUString const & name,
578 rtl::Reference< unoidl::ExceptionTypeEntity > const & entity):
579 ExceptionTypeDescription_Base(entity->isPublished()), manager_(manager),
580 name_(name), entity_(entity)
581 { assert(manager.is()); assert(entity.is()); }
583 private:
584 virtual ~ExceptionTypeDescription() {}
586 virtual css::uno::TypeClass SAL_CALL getTypeClass()
587 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
588 { return css::uno::TypeClass_EXCEPTION; }
590 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
591 { return name_; }
593 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
594 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
595 return entity_->getDirectBase().isEmpty()
596 ? css::uno::Reference< css::reflection::XTypeDescription >()
597 : manager_->resolve(entity_->getDirectBase());
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;
605 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
606 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
608 rtl::Reference< cppuhelper::TypeManager > manager_;
609 rtl::OUString name_;
610 rtl::Reference< unoidl::ExceptionTypeEntity > entity_;
613 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
614 ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException, std::exception) {
615 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
616 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
617 css::uno::Sequence<
618 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
619 for (sal_Int32 i = 0; i != n; ++i) {
620 s[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
622 return s;
625 css::uno::Sequence< rtl::OUString > ExceptionTypeDescription::getMemberNames()
626 throw (css::uno::RuntimeException, std::exception)
628 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
629 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
630 css::uno::Sequence< rtl::OUString > s(n);
631 for (sal_Int32 i = 0; i != n; ++i) {
632 s[i] = entity_->getDirectMembers()[i].name;
634 return s;
637 class AttributeDescription:
638 public cppu::WeakImplHelper1<
639 css::reflection::XInterfaceAttributeTypeDescription2 >
641 public:
642 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 position_(position)
649 { assert(manager.is()); }
651 private:
652 virtual ~AttributeDescription() {}
654 virtual css::uno::TypeClass SAL_CALL getTypeClass()
655 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
656 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE; }
658 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
659 { return name_; }
661 virtual rtl::OUString SAL_CALL getMemberName()
662 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
663 { return attribute_.name; }
665 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
666 { return position_; }
668 virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
669 { return attribute_.readOnly; }
671 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
672 getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
673 { return manager_->resolve(attribute_.type); }
675 virtual sal_Bool SAL_CALL isBound() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
676 { return attribute_.bound; }
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;
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;
688 rtl::Reference< cppuhelper::TypeManager > manager_;
689 rtl::OUString name_;
690 unoidl::InterfaceTypeEntity::Attribute attribute_;
691 sal_Int32 position_;
694 css::uno::Sequence<
695 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
696 AttributeDescription::getGetExceptions() throw (css::uno::RuntimeException, std::exception) {
697 assert(attribute_.getExceptions.size() <= SAL_MAX_INT32);
698 sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size());
699 css::uno::Sequence<
700 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
701 for (sal_Int32 i = 0; i != n; ++i) {
702 s[i].set(
703 manager_->resolve(attribute_.getExceptions[i]),
704 css::uno::UNO_QUERY_THROW);
706 return s;
709 css::uno::Sequence<
710 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
711 AttributeDescription::getSetExceptions() throw (css::uno::RuntimeException, std::exception) {
712 assert(attribute_.setExceptions.size() <= SAL_MAX_INT32);
713 sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size());
714 css::uno::Sequence<
715 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
716 for (sal_Int32 i = 0; i != n; ++i) {
717 s[i].set(
718 manager_->resolve(attribute_.setExceptions[i]),
719 css::uno::UNO_QUERY_THROW);
721 return s;
724 class MethodParameter:
725 public cppu::WeakImplHelper1< css::reflection::XMethodParameter >
727 public:
728 MethodParameter(
729 rtl::Reference< cppuhelper::TypeManager > const & manager,
730 unoidl::InterfaceTypeEntity::Method::Parameter const & parameter,
731 sal_Int32 position):
732 manager_(manager), parameter_(parameter), position_(position)
733 { assert(manager.is()); }
735 private:
736 virtual ~MethodParameter() {}
738 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
739 { return parameter_.name; }
741 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
742 getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
743 { return manager_->resolve(parameter_.type); }
745 virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
746 return
747 (parameter_.direction
748 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
749 || (parameter_.direction
750 == unoidl::InterfaceTypeEntity::Method::Parameter::
751 DIRECTION_IN_OUT);
754 virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
755 return
756 (parameter_.direction
757 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT)
758 || (parameter_.direction
759 == unoidl::InterfaceTypeEntity::Method::Parameter::
760 DIRECTION_IN_OUT);
763 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
764 { return position_; }
766 rtl::Reference< cppuhelper::TypeManager > manager_;
767 unoidl::InterfaceTypeEntity::Method::Parameter parameter_;
768 sal_Int32 position_;
771 class MethodDescription:
772 public cppu::WeakImplHelper1<
773 css::reflection::XInterfaceMethodTypeDescription >
775 public:
776 MethodDescription(
777 rtl::Reference< cppuhelper::TypeManager > const & manager,
778 rtl::OUString const & name,
779 unoidl::InterfaceTypeEntity::Method const & method, sal_Int32 position):
780 manager_(manager), name_(name), method_(method), position_(position)
781 { assert(manager.is()); }
783 private:
784 virtual ~MethodDescription() {}
786 virtual css::uno::TypeClass SAL_CALL getTypeClass()
787 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
788 { return css::uno::TypeClass_INTERFACE_METHOD; }
790 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
791 { return name_; }
793 virtual rtl::OUString SAL_CALL getMemberName()
794 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
795 { return method_.name; }
797 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
798 { return position_; }
800 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
801 getReturnType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
802 { return manager_->resolve(method_.returnType); }
804 virtual sal_Bool SAL_CALL isOneway() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
805 { return false; }
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;
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;
817 rtl::Reference< cppuhelper::TypeManager > manager_;
818 rtl::OUString name_;
819 unoidl::InterfaceTypeEntity::Method method_;
820 sal_Int32 position_;
823 css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > >
824 MethodDescription::getParameters() throw (css::uno::RuntimeException, std::exception) {
825 assert(method_.parameters.size() <= SAL_MAX_INT32);
826 sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size());
827 css::uno::Sequence<
828 css::uno::Reference< css::reflection::XMethodParameter > > s(n);
829 for (sal_Int32 i = 0; i != n; ++i) {
830 s[i] = new MethodParameter(manager_, method_.parameters[i], i);
832 return s;
835 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
836 MethodDescription::getExceptions() throw (css::uno::RuntimeException, std::exception) {
837 assert(method_.exceptions.size() <= SAL_MAX_INT32);
838 sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size());
839 css::uno::Sequence<
840 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
841 for (sal_Int32 i = 0; i != n; ++i) {
842 s[i] = manager_->resolve(method_.exceptions[i]);
844 return s;
847 class BaseOffset: private boost::noncopyable {
848 public:
849 BaseOffset(
850 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
851 const & description);
853 sal_Int32 get() const { return offset_; }
855 private:
856 void calculateBases(
857 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
858 const & description);
860 void calculate(
861 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
862 const & description);
864 std::set< rtl::OUString > set_;
865 sal_Int32 offset_;
868 BaseOffset::BaseOffset(
869 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
870 description):
871 offset_(0)
873 calculateBases(description);
876 void BaseOffset::calculateBases(
877 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
878 description)
880 css::uno::Sequence<
881 css::uno::Reference < css::reflection::XTypeDescription > > bases(
882 description->getBaseTypes());
883 for (sal_Int32 i = 0; i != bases.getLength(); ++i) {
884 calculate(
885 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
886 resolveTypedefs(css::uno::makeAny(bases[i])),
887 css::uno::UNO_QUERY_THROW));
891 void BaseOffset::calculate(
892 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
893 description)
895 if (set_.insert(description->getName()).second) {
896 calculateBases(description);
897 offset_ += description->getMembers().getLength();
901 typedef cppu::ImplInheritanceHelper1<
902 PublishableDescription, css::reflection::XInterfaceTypeDescription2 >
903 InterfaceTypeDescription_Base;
905 class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
906 public:
907 InterfaceTypeDescription(
908 rtl::Reference< cppuhelper::TypeManager > const & manager,
909 rtl::OUString const & name,
910 rtl::Reference< unoidl::InterfaceTypeEntity > const & entity):
911 InterfaceTypeDescription_Base(entity->isPublished()), manager_(manager),
912 name_(name), entity_(entity)
913 { assert(manager.is()); assert(entity.is()); }
915 private:
916 virtual ~InterfaceTypeDescription() {}
918 virtual css::uno::TypeClass SAL_CALL getTypeClass()
919 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
920 { return css::uno::TypeClass_INTERFACE; }
922 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
923 { return name_; }
925 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
926 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
927 return entity_->getDirectMandatoryBases().empty()
928 ? css::uno::Reference< css::reflection::XTypeDescription >()
929 : manager_->resolve(entity_->getDirectMandatoryBases()[0].name);
932 virtual css::uno::Uik SAL_CALL getUik() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
933 { return css::uno::Uik(); }
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;
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;
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;
951 rtl::Reference< cppuhelper::TypeManager > manager_;
952 rtl::OUString name_;
953 rtl::Reference< unoidl::InterfaceTypeEntity > entity_;
956 css::uno::Sequence<
957 css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
958 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 entity_->getDirectAttributes().size());
965 sal_Int32 n2 = static_cast< sal_Int32 >(entity_->getDirectMethods().size());
966 css::uno::Sequence<
967 css::uno::Reference<
968 css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2);
969 sal_Int32 off = BaseOffset(this).get();
970 for (sal_Int32 i = 0; i != n1; ++i) {
971 s[i] = new AttributeDescription(
972 manager_, name_ + "::" + entity_->getDirectAttributes()[i].name,
973 entity_->getDirectAttributes()[i], off + i);
975 for (sal_Int32 i = 0; i != n2; ++i) {
976 s[n1 + i] = new MethodDescription(
977 manager_, name_ + "::" + entity_->getDirectMethods()[i].name,
978 entity_->getDirectMethods()[i], off + n1 + i);
980 return s;
983 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
984 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 entity_->getDirectMandatoryBases().size());
988 css::uno::Sequence<
989 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
990 for (sal_Int32 i = 0; i != n; ++i) {
991 s[i] = manager_->resolve(entity_->getDirectMandatoryBases()[i].name);
993 return s;
996 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
997 InterfaceTypeDescription::getOptionalBaseTypes()
998 throw (css::uno::RuntimeException, std::exception)
1000 assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
1001 sal_Int32 n = static_cast< sal_Int32 >(
1002 entity_->getDirectOptionalBases().size());
1003 css::uno::Sequence<
1004 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
1005 for (sal_Int32 i = 0; i != n; ++i) {
1006 s[i] = manager_->resolve(entity_->getDirectOptionalBases()[i].name);
1008 return s;
1011 class ConstantDescription:
1012 public cppu::WeakImplHelper1< css::reflection::XConstantTypeDescription >
1014 public:
1015 ConstantDescription(
1016 rtl::OUString const & constantGroupName,
1017 unoidl::ConstantGroupEntity::Member const & member);
1019 private:
1020 virtual ~ConstantDescription() {}
1022 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1023 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1024 { return css::uno::TypeClass_CONSTANT; }
1026 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1027 { return name_; }
1029 virtual css::uno::Any SAL_CALL getConstantValue()
1030 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1031 { return value_; }
1033 rtl::OUString name_;
1034 css::uno::Any value_;
1037 ConstantDescription::ConstantDescription(
1038 rtl::OUString const & constantGroupName,
1039 unoidl::ConstantGroupEntity::Member const & member):
1040 name_(makePrefix(constantGroupName) + member.name)
1042 switch (member.value.type) {
1043 case unoidl::ConstantValue::TYPE_BOOLEAN:
1044 value_ <<= member.value.booleanValue;
1045 break;
1046 case unoidl::ConstantValue::TYPE_BYTE:
1047 value_ <<= member.value.byteValue;
1048 break;
1049 case unoidl::ConstantValue::TYPE_SHORT:
1050 value_ <<= member.value.shortValue;
1051 break;
1052 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT:
1053 value_ <<= member.value.unsignedShortValue;
1054 break;
1055 case unoidl::ConstantValue::TYPE_LONG:
1056 value_ <<= member.value.longValue;
1057 break;
1058 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG:
1059 value_ <<= member.value.unsignedLongValue;
1060 break;
1061 case unoidl::ConstantValue::TYPE_HYPER:
1062 value_ <<= member.value.hyperValue;
1063 break;
1064 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER:
1065 value_ <<= member.value.unsignedHyperValue;
1066 break;
1067 case unoidl::ConstantValue::TYPE_FLOAT:
1068 value_ <<= member.value.floatValue;
1069 break;
1070 case unoidl::ConstantValue::TYPE_DOUBLE:
1071 value_ <<= member.value.doubleValue;
1072 break;
1073 default:
1074 for (;;) { std::abort(); } // this cannot happen
1078 typedef cppu::ImplInheritanceHelper1<
1079 PublishableDescription, css::reflection::XConstantsTypeDescription >
1080 ConstantGroupDescription_Base;
1082 class ConstantGroupDescription: public ConstantGroupDescription_Base {
1083 public:
1084 ConstantGroupDescription(
1085 rtl::OUString const & name,
1086 rtl::Reference< unoidl::ConstantGroupEntity > const & entity):
1087 ConstantGroupDescription_Base(entity->isPublished()), name_(name),
1088 entity_(entity)
1089 { assert(entity.is()); }
1091 private:
1092 virtual ~ConstantGroupDescription() {}
1094 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1095 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1096 { return css::uno::TypeClass_CONSTANTS; }
1098 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1099 { return name_; }
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;
1106 rtl::OUString name_;
1107 rtl::Reference< unoidl::ConstantGroupEntity > entity_;
1110 css::uno::Sequence<
1111 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1112 ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException, std::exception) {
1113 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
1114 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
1115 css::uno::Sequence<
1116 css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n);
1117 for (sal_Int32 i = 0; i != n; ++i) {
1118 s[i] = new ConstantDescription(name_, entity_->getMembers()[i]);
1120 return s;
1123 typedef cppu::ImplInheritanceHelper1<
1124 PublishableDescription, css::reflection::XIndirectTypeDescription >
1125 TypedefDescription_Base;
1127 class TypedefDescription: public TypedefDescription_Base {
1128 public:
1129 TypedefDescription(
1130 rtl::Reference< cppuhelper::TypeManager > const & manager,
1131 rtl::OUString const & name,
1132 rtl::Reference< unoidl::TypedefEntity > const & entity):
1133 TypedefDescription_Base(entity->isPublished()), manager_(manager),
1134 name_(name), entity_(entity)
1135 { assert(manager.is()); assert(entity.is()); }
1137 private:
1138 virtual ~TypedefDescription() {}
1140 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1141 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1142 { return css::uno::TypeClass_TYPEDEF; }
1144 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1145 { return name_; }
1147 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1148 getReferencedType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1149 { return manager_->resolve(entity_->getType()); }
1151 rtl::Reference< cppuhelper::TypeManager > manager_;
1152 rtl::OUString name_;
1153 rtl::Reference< unoidl::TypedefEntity > entity_;
1156 class ConstructorParameter:
1157 public cppu::WeakImplHelper1< css::reflection::XParameter >
1159 public:
1160 ConstructorParameter(
1161 rtl::Reference< cppuhelper::TypeManager > const & manager,
1162 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1163 const & parameter,
1164 sal_Int32 position):
1165 manager_(manager), parameter_(parameter), position_(position)
1166 { assert(manager.is()); }
1168 private:
1169 virtual ~ConstructorParameter() {}
1171 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1172 { return parameter_.name; }
1174 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1175 getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1176 { return manager_->resolve(parameter_.type); }
1178 virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1179 { return true; }
1181 virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1182 { return false; }
1184 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1185 { return position_; }
1187 virtual sal_Bool SAL_CALL isRestParameter()
1188 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1189 { return parameter_.rest; }
1191 rtl::Reference< cppuhelper::TypeManager > manager_;
1192 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1193 parameter_;
1194 sal_Int32 position_;
1197 class ConstructorDescription:
1198 public cppu::WeakImplHelper1<
1199 css::reflection::XServiceConstructorDescription >
1201 public:
1202 ConstructorDescription(
1203 rtl::Reference< cppuhelper::TypeManager > const & manager,
1204 unoidl::SingleInterfaceBasedServiceEntity::Constructor const &
1205 constructor):
1206 manager_(manager), constructor_(constructor)
1207 { assert(manager.is()); }
1209 private:
1210 virtual ~ConstructorDescription() {}
1212 virtual sal_Bool SAL_CALL isDefaultConstructor()
1213 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1214 { return constructor_.defaultConstructor; }
1216 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1217 { return constructor_.name; }
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;
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;
1229 rtl::Reference< cppuhelper::TypeManager > manager_;
1230 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_;
1233 css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
1234 ConstructorDescription::getParameters() throw (css::uno::RuntimeException, std::exception) {
1235 assert(constructor_.parameters.size() <= SAL_MAX_INT32);
1236 sal_Int32 n = static_cast< sal_Int32 >(constructor_.parameters.size());
1237 css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > > s(
1239 for (sal_Int32 i = 0; i != n; ++i) {
1240 s[i] = new ConstructorParameter(
1241 manager_, constructor_.parameters[i], i);
1243 return s;
1246 css::uno::Sequence<
1247 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1248 ConstructorDescription::getExceptions() throw (css::uno::RuntimeException, std::exception) {
1249 assert(constructor_.exceptions.size() <= SAL_MAX_INT32);
1250 sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size());
1251 css::uno::Sequence<
1252 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
1253 for (sal_Int32 i = 0; i != n; ++i) {
1254 s[i].set(
1255 manager_->resolve(constructor_.exceptions[i]),
1256 css::uno::UNO_QUERY_THROW);
1258 return s;
1261 typedef cppu::ImplInheritanceHelper1<
1262 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1263 SingleInterfaceBasedServiceDescription_Base;
1265 class SingleInterfaceBasedServiceDescription:
1266 public SingleInterfaceBasedServiceDescription_Base
1268 public:
1269 SingleInterfaceBasedServiceDescription(
1270 rtl::Reference< cppuhelper::TypeManager > const & manager,
1271 rtl::OUString const & name,
1272 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > const &
1273 entity):
1274 SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
1275 manager_(manager), name_(name), entity_(entity)
1276 { assert(manager.is()); assert(entity.is()); }
1278 private:
1279 virtual ~SingleInterfaceBasedServiceDescription() {}
1281 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1282 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1283 { return css::uno::TypeClass_SERVICE; }
1285 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1286 { return name_; }
1288 virtual
1289 css::uno::Sequence<
1290 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1291 SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1293 return css::uno::Sequence<
1294 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1297 virtual
1298 css::uno::Sequence<
1299 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1300 SAL_CALL getOptionalServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1302 return css::uno::Sequence<
1303 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1306 virtual
1307 css::uno::Sequence<
1308 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1309 SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1311 return css::uno::Sequence<
1312 css::uno::Reference<
1313 css::reflection::XInterfaceTypeDescription > >();
1316 virtual
1317 css::uno::Sequence<
1318 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1319 SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1321 return css::uno::Sequence<
1322 css::uno::Reference<
1323 css::reflection::XInterfaceTypeDescription > >();
1326 virtual
1327 css::uno::Sequence<
1328 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1329 SAL_CALL getProperties() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1331 return css::uno::Sequence<
1332 css::uno::Reference<
1333 css::reflection::XPropertyTypeDescription > >();
1336 virtual sal_Bool SAL_CALL isSingleInterfaceBased()
1337 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1338 { return true; }
1340 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1341 getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1342 { return manager_->resolve(entity_->getBase()); }
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;
1349 rtl::Reference< cppuhelper::TypeManager > manager_;
1350 rtl::OUString name_;
1351 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > entity_;
1354 css::uno::Sequence<
1355 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1356 SingleInterfaceBasedServiceDescription::getConstructors()
1357 throw (css::uno::RuntimeException, std::exception)
1359 assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
1360 sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
1361 css::uno::Sequence<
1362 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1363 s(n);
1364 for (sal_Int32 i = 0; i != n; ++i) {
1365 s[i] = new ConstructorDescription(
1366 manager_, entity_->getConstructors()[i]);
1368 return s;
1371 class PropertyDescription:
1372 public cppu::WeakImplHelper1< css::reflection::XPropertyTypeDescription >
1374 public:
1375 PropertyDescription(
1376 rtl::Reference< cppuhelper::TypeManager > const & manager,
1377 unoidl::AccumulationBasedServiceEntity::Property const & property):
1378 manager_(manager), property_(property)
1379 { assert(manager.is()); }
1381 private:
1382 virtual ~PropertyDescription() {}
1384 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1385 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1386 { return css::uno::TypeClass_PROPERTY; }
1388 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1389 { return property_.name; }
1391 virtual sal_Int16 SAL_CALL getPropertyFlags()
1392 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1393 { return property_.attributes; }
1395 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1396 getPropertyTypeDescription() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1397 { return manager_->resolve(property_.type); }
1399 rtl::Reference< cppuhelper::TypeManager > manager_;
1400 unoidl::AccumulationBasedServiceEntity::Property property_;
1403 typedef cppu::ImplInheritanceHelper1<
1404 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1405 AccumulationBasedServiceDescription_Base;
1407 class AccumulationBasedServiceDescription:
1408 public AccumulationBasedServiceDescription_Base
1410 public:
1411 AccumulationBasedServiceDescription(
1412 rtl::Reference< cppuhelper::TypeManager > const & manager,
1413 rtl::OUString const & name,
1414 rtl::Reference< unoidl::AccumulationBasedServiceEntity > const &
1415 entity):
1416 AccumulationBasedServiceDescription_Base(entity->isPublished()),
1417 manager_(manager), name_(name), entity_(entity)
1418 { assert(manager.is()); assert(entity.is()); }
1420 private:
1421 virtual ~AccumulationBasedServiceDescription() {}
1423 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1424 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1425 { return css::uno::TypeClass_SERVICE; }
1427 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1428 { return name_; }
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;
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;
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;
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;
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;
1455 virtual sal_Bool SAL_CALL isSingleInterfaceBased()
1456 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1457 { return false; }
1459 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1460 getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1461 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1463 virtual
1464 css::uno::Sequence<
1465 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1466 SAL_CALL getConstructors() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1468 return css::uno::Sequence<
1469 css::uno::Reference<
1470 css::reflection::XServiceConstructorDescription > >();
1473 rtl::Reference< cppuhelper::TypeManager > manager_;
1474 rtl::OUString name_;
1475 rtl::Reference< unoidl::AccumulationBasedServiceEntity > entity_;
1478 css::uno::Sequence<
1479 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1480 AccumulationBasedServiceDescription::getMandatoryServices()
1481 throw (css::uno::RuntimeException, std::exception)
1483 assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
1484 sal_Int32 n = static_cast< sal_Int32 >(
1485 entity_->getDirectMandatoryBaseServices().size());
1486 css::uno::Sequence<
1487 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1488 for (sal_Int32 i = 0; i != n; ++i) {
1489 s[i].set(
1490 manager_->resolve(
1491 entity_->getDirectMandatoryBaseServices()[i].name),
1492 css::uno::UNO_QUERY_THROW);
1494 return s;
1497 css::uno::Sequence<
1498 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1499 AccumulationBasedServiceDescription::getOptionalServices()
1500 throw (css::uno::RuntimeException, std::exception)
1502 assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
1503 sal_Int32 n = static_cast< sal_Int32 >(
1504 entity_->getDirectOptionalBaseServices().size());
1505 css::uno::Sequence<
1506 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1507 for (sal_Int32 i = 0; i != n; ++i) {
1508 s[i].set(
1509 manager_->resolve(entity_->getDirectOptionalBaseServices()[i].name),
1510 css::uno::UNO_QUERY_THROW);
1512 return s;
1515 css::uno::Sequence<
1516 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1517 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1518 throw (css::uno::RuntimeException, std::exception)
1520 assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
1521 sal_Int32 n = static_cast< sal_Int32 >(
1522 entity_->getDirectMandatoryBaseInterfaces().size());
1523 css::uno::Sequence<
1524 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1526 for (sal_Int32 i = 0; i != n; ++i) {
1527 s[i].set(
1528 resolveTypedefs(
1529 manager_->find(
1530 entity_->getDirectMandatoryBaseInterfaces()[i].name)),
1531 css::uno::UNO_QUERY_THROW);
1533 return s;
1536 css::uno::Sequence<
1537 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1538 AccumulationBasedServiceDescription::getOptionalInterfaces()
1539 throw (css::uno::RuntimeException, std::exception)
1541 assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
1542 sal_Int32 n = static_cast< sal_Int32 >(
1543 entity_->getDirectOptionalBaseInterfaces().size());
1544 css::uno::Sequence<
1545 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1547 for (sal_Int32 i = 0; i != n; ++i) {
1548 s[i].set(
1549 resolveTypedefs(
1550 manager_->find(
1551 entity_->getDirectOptionalBaseInterfaces()[i].name)),
1552 css::uno::UNO_QUERY_THROW);
1554 return s;
1557 css::uno::Sequence<
1558 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1559 AccumulationBasedServiceDescription::getProperties()
1560 throw (css::uno::RuntimeException, std::exception)
1562 assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
1563 sal_Int32 n = static_cast< sal_Int32 >(
1564 entity_->getDirectProperties().size());
1565 css::uno::Sequence<
1566 css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n);
1567 for (sal_Int32 i = 0; i != n; ++i) {
1568 s[i] = new PropertyDescription(
1569 manager_, entity_->getDirectProperties()[i]);
1571 return s;
1574 typedef cppu::ImplInheritanceHelper1<
1575 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1576 InterfaceBasedSingletonDescription_Base;
1578 class InterfaceBasedSingletonDescription:
1579 public InterfaceBasedSingletonDescription_Base
1581 public:
1582 InterfaceBasedSingletonDescription(
1583 rtl::Reference< cppuhelper::TypeManager > const & manager,
1584 rtl::OUString const & name,
1585 rtl::Reference< unoidl::InterfaceBasedSingletonEntity > const & entity):
1586 InterfaceBasedSingletonDescription_Base(entity->isPublished()),
1587 manager_(manager), name_(name), entity_(entity)
1588 { assert(manager.is()); assert(entity.is()); }
1590 private:
1591 virtual ~InterfaceBasedSingletonDescription() {}
1593 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1594 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1595 { return css::uno::TypeClass_SINGLETON; }
1597 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1598 { return name_; }
1600 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1601 SAL_CALL getService() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1603 return
1604 css::uno::Reference< css::reflection::XServiceTypeDescription >();
1607 virtual sal_Bool SAL_CALL isInterfaceBased()
1608 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1609 { return true; }
1611 virtual css::uno::Reference< css::reflection::XTypeDescription >
1612 SAL_CALL getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1613 { return manager_->resolve(entity_->getBase()); }
1615 rtl::Reference< cppuhelper::TypeManager > manager_;
1616 rtl::OUString name_;
1617 rtl::Reference< unoidl::InterfaceBasedSingletonEntity > entity_;
1620 typedef cppu::ImplInheritanceHelper1<
1621 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1622 ServiceBasedSingletonDescription_Base;
1624 class ServiceBasedSingletonDescription:
1625 public ServiceBasedSingletonDescription_Base
1627 public:
1628 ServiceBasedSingletonDescription(
1629 rtl::Reference< cppuhelper::TypeManager > const & manager,
1630 rtl::OUString const & name,
1631 rtl::Reference< unoidl::ServiceBasedSingletonEntity > const & entity):
1632 ServiceBasedSingletonDescription_Base(entity_->isPublished()),
1633 manager_(manager), name_(name), entity_(entity)
1634 { assert(manager.is()); assert(entity.is()); }
1636 private:
1637 virtual ~ServiceBasedSingletonDescription() {}
1639 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1640 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1641 { return css::uno::TypeClass_SINGLETON; }
1643 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1644 { return name_; }
1646 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1647 SAL_CALL getService() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1649 return css::uno::Reference< css::reflection::XServiceTypeDescription >(
1650 manager_->resolve(entity_->getBase()), css::uno::UNO_QUERY_THROW);
1653 virtual sal_Bool SAL_CALL isInterfaceBased()
1654 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1655 { return false; }
1657 virtual css::uno::Reference< css::reflection::XTypeDescription >
1658 SAL_CALL getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1659 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1661 rtl::Reference< cppuhelper::TypeManager > manager_;
1662 rtl::OUString name_;
1663 rtl::Reference< unoidl::ServiceBasedSingletonEntity > entity_;
1666 class Enumeration:
1667 public cppu::WeakImplHelper1< css::reflection::XTypeDescriptionEnumeration >
1669 public:
1670 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 manager_(manager), types_(types), deep_(deep)
1677 assert(manager.is());
1678 positions_.push(Position(prefix, cursor));
1679 findNextMatch();
1682 private:
1683 virtual ~Enumeration() {}
1685 virtual sal_Bool SAL_CALL hasMoreElements()
1686 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1687 { return !positions_.empty(); }
1689 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 { return css::uno::makeAny(nextTypeDescription()); }
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;
1700 bool matches(css::uno::TypeClass tc) const;
1702 void findNextMatch();
1704 struct Position {
1705 Position(
1706 rtl::OUString const & thePrefix,
1707 rtl::Reference< unoidl::MapCursor > const & theCursor):
1708 prefix(thePrefix), cursor(theCursor)
1709 { assert(theCursor.is()); }
1711 Position(
1712 rtl::OUString const & thePrefix,
1713 rtl::Reference< unoidl::ConstantGroupEntity > const &
1714 theConstantGroup):
1715 prefix(thePrefix), constantGroup(theConstantGroup),
1716 constantGroupIndex(constantGroup->getMembers().begin())
1717 { assert(theConstantGroup.is()); }
1719 Position(Position const & other):
1720 prefix(other.prefix), cursor(other.cursor),
1721 constantGroup(other.constantGroup)
1723 if (constantGroup.is()) {
1724 constantGroupIndex = other.constantGroupIndex;
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;
1735 rtl::Reference< cppuhelper::TypeManager > manager_;
1736 css::uno::Sequence< css::uno::TypeClass > types_;
1737 bool deep_;
1739 osl::Mutex mutex_;
1740 std::stack< Position > positions_;
1741 rtl::OUString current_;
1744 css::uno::Reference< css::reflection::XTypeDescription >
1745 Enumeration::nextTypeDescription()
1746 throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
1748 rtl::OUString name;
1750 osl::MutexGuard g(mutex_);
1751 if (positions_.empty()) {
1752 throw css::container::NoSuchElementException(
1753 "exhausted XTypeDescriptionEnumeration",
1754 static_cast< cppu::OWeakObject * >(this));
1756 name = current_;
1757 findNextMatch();
1759 return manager_->resolve(name);
1762 bool Enumeration::matches(css::uno::TypeClass tc) const {
1763 if (types_.getLength() == 0) {
1764 return true;
1766 for (sal_Int32 i = 0; i != types_.getLength(); ++i) {
1767 if (types_[i] == tc) {
1768 return true;
1771 return false;
1774 void Enumeration::findNextMatch() {
1775 try {
1776 for (;;) {
1777 assert(!positions_.empty());
1778 rtl::OUString name;
1779 if (positions_.top().cursor.is()) { // root or module
1780 rtl::Reference< unoidl::Entity > ent(
1781 positions_.top().cursor->getNext(&name));
1782 if (!ent.is()) {
1783 positions_.pop();
1784 if (positions_.empty()) {
1785 break;
1787 continue;
1789 name = positions_.top().prefix + name;
1790 css::uno::TypeClass tc;
1791 switch (ent->getSort()) {
1792 case unoidl::Entity::SORT_MODULE:
1793 tc = css::uno::TypeClass_MODULE;
1794 if (deep_) {
1795 positions_.push(
1796 Position(
1797 makePrefix(name),
1798 static_cast< unoidl::ModuleEntity * >(
1799 ent.get())->createCursor()));
1801 break;
1802 case unoidl::Entity::SORT_ENUM_TYPE:
1803 tc = css::uno::TypeClass_ENUM;
1804 break;
1805 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
1806 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
1807 tc = css::uno::TypeClass_STRUCT;
1808 break;
1809 case unoidl::Entity::SORT_EXCEPTION_TYPE:
1810 tc = css::uno::TypeClass_EXCEPTION;
1811 break;
1812 case unoidl::Entity::SORT_INTERFACE_TYPE:
1813 tc = css::uno::TypeClass_INTERFACE;
1814 break;
1815 case unoidl::Entity::SORT_TYPEDEF:
1816 tc = css::uno::TypeClass_TYPEDEF;
1817 break;
1818 case unoidl::Entity::SORT_CONSTANT_GROUP:
1819 tc = css::uno::TypeClass_CONSTANTS;
1820 if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
1821 positions_.push(
1822 Position(
1823 makePrefix(name),
1824 static_cast< unoidl::ConstantGroupEntity * >(
1825 ent.get())));
1827 break;
1828 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
1829 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
1830 tc = css::uno::TypeClass_SERVICE;
1831 break;
1832 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
1833 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
1834 tc = css::uno::TypeClass_SINGLETON;
1835 break;
1836 default:
1837 for (;;) { std::abort(); } // this cannot happen
1839 if (matches(tc)) {
1840 current_ = name;
1841 break;
1843 } else { // constant group
1844 if (positions_.top().constantGroupIndex
1845 == positions_.top().constantGroup->getMembers().end())
1847 positions_.pop();
1848 if (positions_.empty()) {
1849 break;
1851 continue;
1853 current_ = positions_.top().prefix
1854 + positions_.top().constantGroupIndex++->name;
1855 break;
1858 } catch (unoidl::FileFormatException & e) {
1859 throw css::uno::DeploymentException(
1860 e.getUri() + ": " + e.getDetail(),
1861 static_cast< cppu::OWeakObject * >(this));
1867 cppuhelper::TypeManager::TypeManager():
1868 TypeManager_Base(m_aMutex),
1869 manager_(new unoidl::Manager)
1872 void cppuhelper::TypeManager::init(rtl::OUString const & rdbUris) {
1873 readRdbs(rdbUris);
1876 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;
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 for (std::size_t i = 0; i != SAL_N_ELEMENTS(simple); ++i) {
1902 if (name.equalsAsciiL(simple[i].name, simple[i].length)) {
1903 return css::uno::makeAny<
1904 css::uno::Reference< css::reflection::XTypeDescription > >(
1905 new SimpleTypeDescription(simple[i].typeClass, name));
1908 if (name.startsWith("[]")) {
1909 return getSequenceType(name);
1911 sal_Int32 i = name.indexOf('<');
1912 if (i != -1) {
1913 return getInstantiatedStruct(name, i);
1915 i = name.indexOf("::");
1916 if (i != -1) {
1917 return getInterfaceMember(name, i);
1919 rtl::Reference< unoidl::Entity > ent(findEntity(name));
1920 if (ent.is()) {
1921 return getNamed(name, ent);
1923 i = name.lastIndexOf('.');
1924 if (i != -1) {
1925 rtl::OUString parent(name.copy(0, i));
1926 ent = findEntity(parent);
1927 if (ent.is()) {
1928 switch (ent->getSort()) {
1929 case unoidl::Entity::SORT_ENUM_TYPE:
1930 return getEnumMember(
1931 static_cast< unoidl::EnumTypeEntity * >(ent.get()),
1932 name.copy(i + 1));
1933 case unoidl::Entity::SORT_CONSTANT_GROUP:
1934 return getConstant(
1935 parent,
1936 static_cast< unoidl::ConstantGroupEntity * >(ent.get()),
1937 name.copy(i + 1));
1938 default:
1939 break;
1943 return css::uno::Any();
1946 css::uno::Reference< css::reflection::XTypeDescription >
1947 cppuhelper::TypeManager::resolve(rtl::OUString const & name) {
1948 css::uno::Reference< css::reflection::XTypeDescription > desc(
1949 find(name), css::uno::UNO_QUERY);
1950 if (!desc.is()) {
1951 throw css::uno::DeploymentException(
1952 "cannot resolve type \"" + name + "\"",
1953 static_cast< cppu::OWeakObject * >(this));
1955 return desc;
1958 cppuhelper::TypeManager::~TypeManager() throw () {}
1960 void cppuhelper::TypeManager::disposing() {} //TODO
1962 rtl::OUString cppuhelper::TypeManager::getImplementationName()
1963 throw (css::uno::RuntimeException, std::exception)
1965 return rtl::OUString(
1966 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager");
1969 sal_Bool cppuhelper::TypeManager::supportsService(
1970 rtl::OUString const & ServiceName)
1971 throw (css::uno::RuntimeException, std::exception)
1973 return cppu::supportsService(this, ServiceName);
1976 css::uno::Sequence< rtl::OUString >
1977 cppuhelper::TypeManager::getSupportedServiceNames()
1978 throw (css::uno::RuntimeException, std::exception)
1980 css::uno::Sequence< rtl::OUString > names(1);
1981 names[0] = "com.sun.star.reflection.TypeDescriptionManager"; //TODO
1982 return names;
1985 css::uno::Any cppuhelper::TypeManager::getByHierarchicalName(
1986 rtl::OUString const & aName)
1987 throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
1989 css::uno::Any desc(find(aName));
1990 if (!desc.hasValue()) {
1991 throw css::container::NoSuchElementException(
1992 aName, static_cast< cppu::OWeakObject * >(this));
1994 return desc;
1997 sal_Bool cppuhelper::TypeManager::hasByHierarchicalName(
1998 rtl::OUString const & aName)
1999 throw (css::uno::RuntimeException, std::exception)
2001 return find(aName).hasValue();
2004 css::uno::Type cppuhelper::TypeManager::getElementType()
2005 throw (css::uno::RuntimeException, std::exception)
2007 return cppu::UnoType< rtl::OUString >::get();
2010 sal_Bool cppuhelper::TypeManager::hasElements()
2011 throw (css::uno::RuntimeException, std::exception)
2013 throw css::uno::RuntimeException(
2014 "TypeManager hasElements: method not supported",
2015 static_cast< cppu::OWeakObject * >(this));
2018 css::uno::Reference< css::container::XEnumeration >
2019 cppuhelper::TypeManager::createEnumeration()
2020 throw (css::uno::RuntimeException, std::exception)
2022 throw css::uno::RuntimeException(
2023 "TypeManager createEnumeration: method not supported",
2024 static_cast< cppu::OWeakObject * >(this));
2027 sal_Bool cppuhelper::TypeManager::has(css::uno::Any const &)
2028 throw (css::uno::RuntimeException, std::exception)
2030 throw css::uno::RuntimeException(
2031 "TypeManager has: method not supported",
2032 static_cast< cppu::OWeakObject * >(this));
2035 void cppuhelper::TypeManager::insert(css::uno::Any const & aElement)
2036 throw (
2037 css::lang::IllegalArgumentException,
2038 css::container::ElementExistException, css::uno::RuntimeException, std::exception)
2040 rtl::OUString uri;
2041 if (!(aElement >>= uri)) {
2042 throw css::lang::IllegalArgumentException(
2043 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
2044 " argument"),
2045 static_cast< cppu::OWeakObject * >(this), 0);
2047 //TODO: check for ElementExistException
2048 //TODO: check for consistency with existing data
2049 readRdbFile(uri, false);
2052 void cppuhelper::TypeManager::remove(css::uno::Any const & aElement)
2053 throw (
2054 css::lang::IllegalArgumentException,
2055 css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
2057 rtl::OUString uri;
2058 if (!(aElement >>= uri)) {
2059 throw css::lang::IllegalArgumentException(
2060 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
2061 " argument"),
2062 static_cast< cppu::OWeakObject * >(this), 0);
2064 //TODO: remove requests are silently ignored for now
2067 css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
2068 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)
2077 rtl::Reference< unoidl::MapCursor > cursor;
2078 try {
2079 cursor = manager_->createCursor(moduleName);
2080 } catch (unoidl::FileFormatException & e) {
2081 throw css::uno::DeploymentException(
2082 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2083 + e.getDetail()),
2084 static_cast< cppu::OWeakObject * >(this));
2086 if (!cursor.is()) {
2087 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2088 // non-module
2089 throw css::reflection::NoSuchTypeNameException(
2090 moduleName, static_cast< cppu::OWeakObject * >(this));
2092 return new Enumeration(
2093 this, makePrefix(moduleName), cursor, types,
2094 depth == css::reflection::TypeDescriptionSearchDepth_INFINITE);
2097 void cppuhelper::TypeManager::readRdbs(rtl::OUString const & uris) {
2098 for (sal_Int32 i = 0; i != -1;) {
2099 rtl::OUString uri(uris.getToken(0, ' ', i));
2100 if (uri.isEmpty()) {
2101 continue;
2103 bool optional;
2104 bool directory;
2105 cppu::decodeRdbUri(&uri, &optional, &directory);
2106 if (directory) {
2107 readRdbDirectory(uri, optional);
2108 } else {
2109 readRdbFile(uri, optional);
2114 void cppuhelper::TypeManager::readRdbDirectory(
2115 rtl::OUString const & uri, bool optional)
2117 osl::Directory dir(uri);
2118 switch (dir.open()) {
2119 case osl::FileBase::E_None:
2120 break;
2121 case osl::FileBase::E_NOENT:
2122 if (optional) {
2123 SAL_INFO("cppuhelper", "Ignored optional " << uri);
2124 return;
2126 // fall through
2127 default:
2128 throw css::uno::DeploymentException(
2129 "Cannot open directory " + uri,
2130 static_cast< cppu::OWeakObject * >(this));
2132 for (;;) {
2133 rtl::OUString url;
2134 if (!cppu::nextDirectoryItem(dir, &url)) {
2135 break;
2137 readRdbFile(url, false);
2141 void cppuhelper::TypeManager::readRdbFile(
2142 rtl::OUString const & uri, bool optional)
2144 try {
2145 manager_->addProvider(unoidl::loadProvider(manager_, uri));
2146 } catch (unoidl::NoSuchFileException &) {
2147 if (!optional) {
2148 throw css::uno::DeploymentException(
2149 uri + ": no such file",
2150 static_cast< cppu::OWeakObject * >(this));
2152 SAL_INFO("cppuhelper", "Ignored optional " << uri);
2153 } catch (unoidl::FileFormatException & e) {
2154 throw css::uno::DeploymentException(
2155 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2156 + e.getDetail()),
2157 static_cast< cppu::OWeakObject * >(this));
2161 css::uno::Any cppuhelper::TypeManager::getSequenceType(
2162 rtl::OUString const & name)
2164 assert(name.startsWith("[]"));
2165 return css::uno::makeAny<
2166 css::uno::Reference< css::reflection::XTypeDescription > >(
2167 new SequenceTypeDescription(
2168 this, name, name.copy(std::strlen("[]"))));
2171 css::uno::Any cppuhelper::TypeManager::getInstantiatedStruct(
2172 rtl::OUString const & name, sal_Int32 separator)
2174 assert(name.indexOf('<') == separator && separator != -1);
2175 rtl::Reference< unoidl::Entity > ent(findEntity(name.copy(0, separator)));
2176 if (!ent.is()
2177 || (ent->getSort()
2178 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE))
2180 return css::uno::Any();
2182 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
2183 static_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
2184 ent.get()));
2185 std::vector< rtl::OUString > args;
2186 sal_Int32 i = separator;
2187 do {
2188 ++i; // skip '<' or ','
2189 sal_Int32 j = i;
2190 for (sal_Int32 level = 0; j != name.getLength(); ++j) {
2191 sal_Unicode c = name[j];
2192 if (c == ',') {
2193 if (level == 0) {
2194 break;
2196 } else if (c == '<') {
2197 ++level;
2198 } else if (c == '>') {
2199 if (level == 0) {
2200 break;
2202 --level;
2205 if (j != name.getLength()) {
2206 args.push_back(name.copy(i, j - i));
2208 i = j;
2209 } while (i != name.getLength() && name[i] != '>');
2210 if (i != name.getLength() - 1 || name[i] != '>'
2211 || args.size() != ent2->getTypeParameters().size())
2213 return css::uno::Any();
2215 return css::uno::makeAny<
2216 css::uno::Reference< css::reflection::XTypeDescription > >(
2217 new InstantiatedPolymorphicStructTypeDescription(
2218 this, name, ent2, args));
2221 css::uno::Any cppuhelper::TypeManager::getInterfaceMember(
2222 rtl::OUString const & name, sal_Int32 separator)
2224 assert(name.indexOf("::") == separator && separator != -1);
2225 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
2226 resolveTypedefs(find(name.copy(0, separator))), css::uno::UNO_QUERY);
2227 if (!ifc.is()) {
2228 return css::uno::Any();
2230 rtl::OUString member(name.copy(separator + std::strlen("::")));
2231 css::uno::Sequence<
2232 css::uno::Reference<
2233 css::reflection::XInterfaceMemberTypeDescription > > mems(
2234 ifc->getMembers());
2235 for (sal_Int32 i = 0; i != mems.getLength(); ++i) {
2236 if (mems[i]->getMemberName() == member) {
2237 return css::uno::makeAny<
2238 css::uno::Reference< css::reflection::XTypeDescription > >(
2239 mems[i]);
2242 return css::uno::Any();
2245 css::uno::Any cppuhelper::TypeManager::getNamed(
2246 rtl::OUString const & name, rtl::Reference< unoidl::Entity > const & entity)
2248 assert(entity.is());
2249 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 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 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 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 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 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 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 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 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 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 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 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 entity.get())));
2332 default:
2333 for (;;) { std::abort(); } // this cannot happen
2337 css::uno::Any cppuhelper::TypeManager::getEnumMember(
2338 rtl::Reference< unoidl::EnumTypeEntity > const & entity,
2339 rtl::OUString const & member)
2341 for (std::vector< unoidl::EnumTypeEntity::Member >::const_iterator i(
2342 entity->getMembers().begin());
2343 i != entity->getMembers().end(); ++i)
2345 if (i->name == member) {
2346 return css::uno::makeAny(i->value);
2349 return css::uno::Any();
2352 css::uno::Any cppuhelper::TypeManager::getConstant(
2353 rtl::OUString const & constantGroupName,
2354 rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
2355 rtl::OUString const & member)
2357 for (std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator i(
2358 entity->getMembers().begin());
2359 i != entity->getMembers().end(); ++i)
2361 if (i->name == member) {
2362 return css::uno::makeAny<
2363 css::uno::Reference< css::reflection::XTypeDescription > >(
2364 new ConstantDescription(constantGroupName, *i));
2367 return css::uno::Any();
2370 rtl::Reference< unoidl::Entity > cppuhelper::TypeManager::findEntity(
2371 rtl::OUString const & name)
2373 try {
2374 return manager_->findEntity(name);
2375 } catch (unoidl::FileFormatException & e) {
2376 throw css::uno::DeploymentException(
2377 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2378 + e.getDetail()),
2379 static_cast< cppu::OWeakObject * >(this));
2383 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */