Bump version to 5.0-43
[LibreOffice.git] / cppuhelper / source / typemanager.cxx
blob2e32c5b337647975cd70a2b85da9b219d2ea7b23
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/log.hxx>
56 #include <sal/macros.h>
57 #include <sal/types.h>
59 using rtl::OUString;
61 #include <unoidl/unoidl.hxx>
63 #include "paths.hxx"
64 #include "typemanager.hxx"
66 namespace {
68 rtl::OUString makePrefix(rtl::OUString const & name) {
69 return name.isEmpty() ? name : name + ".";
72 css::uno::Any resolveTypedefs(css::uno::Any const & type) {
73 for (css::uno::Any t(type);;) {
74 css::uno::Reference< css::reflection::XIndirectTypeDescription > ind(
75 type, css::uno::UNO_QUERY);
76 if (!ind.is() || ind->getTypeClass() != css::uno::TypeClass_TYPEDEF) {
77 return t;
79 t = css::uno::makeAny(ind->getReferencedType());
83 class SimpleTypeDescription:
84 public cppu::WeakImplHelper1< css::reflection::XTypeDescription >
86 public:
87 SimpleTypeDescription(
88 css::uno::TypeClass typeClass, rtl::OUString const & name):
89 typeClass_(typeClass), name_(name)
92 private:
93 virtual ~SimpleTypeDescription() {}
95 virtual css::uno::TypeClass SAL_CALL getTypeClass()
96 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
97 { return typeClass_; }
99 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
100 { return name_; }
102 css::uno::TypeClass typeClass_;
103 rtl::OUString name_;
106 class SequenceTypeDescription:
107 public cppu::WeakImplHelper1< css::reflection::XIndirectTypeDescription >
109 public:
110 SequenceTypeDescription(
111 rtl::Reference< cppuhelper::TypeManager > const & manager,
112 rtl::OUString const & name, rtl::OUString const & componentType):
113 manager_(manager), name_(name), componentType_(componentType)
114 { assert(manager.is()); }
116 private:
117 virtual ~SequenceTypeDescription() {}
119 virtual css::uno::TypeClass SAL_CALL getTypeClass()
120 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
121 { return css::uno::TypeClass_SEQUENCE; }
123 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
124 { return name_; }
126 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
127 getReferencedType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
128 { return manager_->resolve(componentType_); }
130 rtl::Reference< cppuhelper::TypeManager > manager_;
131 rtl::OUString name_;
132 rtl::OUString componentType_;
135 class PublishableDescription:
136 public cppu::WeakImplHelper1< css::reflection::XPublished >
138 protected:
139 PublishableDescription(bool published): published_(published) {}
141 virtual ~PublishableDescription() {}
143 private:
144 virtual sal_Bool SAL_CALL isPublished() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
145 { return published_; }
147 bool published_;
150 class ModuleDescription:
151 public cppu::WeakImplHelper1< css::reflection::XModuleTypeDescription >
153 public:
154 ModuleDescription(
155 rtl::Reference< cppuhelper::TypeManager > const & manager,
156 rtl::OUString const & name,
157 rtl::Reference< unoidl::ModuleEntity > const & entity):
158 manager_(manager), name_(name), entity_(entity)
159 { assert(manager.is()); assert(entity.is()); }
161 private:
162 virtual ~ModuleDescription() {}
164 virtual css::uno::TypeClass SAL_CALL getTypeClass()
165 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
166 { return css::uno::TypeClass_MODULE; }
168 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
169 { return name_; }
171 virtual
172 css::uno::Sequence<
173 css::uno::Reference< css::reflection::XTypeDescription > >
174 SAL_CALL getMembers() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 rtl::Reference< cppuhelper::TypeManager > manager_;
177 rtl::OUString name_;
178 rtl::Reference< unoidl::ModuleEntity > entity_;
181 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
182 ModuleDescription::getMembers() throw (css::uno::RuntimeException, std::exception) {
183 try {
184 std::vector< rtl::OUString > names(entity_->getMemberNames());
185 assert(names.size() <= SAL_MAX_INT32);
186 sal_Int32 n = static_cast< sal_Int32 >(names.size());
187 css::uno::Sequence<
188 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
189 for (sal_Int32 i = 0; i != n; ++i) {
190 s[i] = manager_->resolve(makePrefix(name_) + names[i]);
192 return s;
193 } catch (unoidl::FileFormatException & e) {
194 throw css::uno::DeploymentException(
195 e.getUri() + ": " + e.getDetail(),
196 static_cast< cppu::OWeakObject * >(this));
200 typedef cppu::ImplInheritanceHelper1<
201 PublishableDescription, css::reflection::XEnumTypeDescription >
202 EnumTypeDescription_Base;
204 class EnumTypeDescription: public EnumTypeDescription_Base {
205 public:
206 EnumTypeDescription(
207 rtl::OUString const & name,
208 rtl::Reference< unoidl::EnumTypeEntity > const & entity):
209 EnumTypeDescription_Base(entity->isPublished()), name_(name),
210 entity_(entity)
211 { assert(entity.is()); }
213 private:
214 virtual ~EnumTypeDescription() {}
216 virtual css::uno::TypeClass SAL_CALL getTypeClass()
217 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
218 { return css::uno::TypeClass_ENUM; }
220 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
221 { return name_; }
223 virtual sal_Int32 SAL_CALL getDefaultEnumValue()
224 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
225 { return entity_->getMembers()[0].value; }
227 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getEnumNames()
228 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
230 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getEnumValues()
231 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
233 rtl::OUString name_;
234 rtl::Reference< unoidl::EnumTypeEntity > entity_;
237 css::uno::Sequence< rtl::OUString > EnumTypeDescription::getEnumNames()
238 throw (css::uno::RuntimeException, std::exception)
240 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
241 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
242 css::uno::Sequence< rtl::OUString > s(n);
243 for (sal_Int32 i = 0; i != n; ++i) {
244 s[i] = entity_->getMembers()[i].name;
246 return s;
249 css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
250 throw (css::uno::RuntimeException, std::exception)
252 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
253 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
254 css::uno::Sequence< sal_Int32 > s(n);
255 for (sal_Int32 i = 0; i != n; ++i) {
256 s[i] = entity_->getMembers()[i].value;
258 return s;
261 typedef cppu::ImplInheritanceHelper1<
262 PublishableDescription, css::reflection::XStructTypeDescription >
263 PlainStructTypeDescription_Base;
265 class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
266 public:
267 PlainStructTypeDescription(
268 rtl::Reference< cppuhelper::TypeManager > const & manager,
269 rtl::OUString const & name,
270 rtl::Reference< unoidl::PlainStructTypeEntity > const & entity):
271 PlainStructTypeDescription_Base(entity->isPublished()),
272 manager_(manager), name_(name), entity_(entity)
273 { assert(manager.is()); assert(entity.is()); }
275 private:
276 virtual ~PlainStructTypeDescription() {}
278 virtual css::uno::TypeClass SAL_CALL getTypeClass()
279 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
280 { return css::uno::TypeClass_STRUCT; }
282 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
283 { return name_; }
285 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
286 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
287 return entity_->getDirectBase().isEmpty()
288 ? css::uno::Reference< css::reflection::XTypeDescription >()
289 : manager_->resolve(entity_->getDirectBase());
292 virtual
293 css::uno::Sequence<
294 css::uno::Reference< css::reflection::XTypeDescription > >
295 SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
297 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
298 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
300 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
301 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
302 { return css::uno::Sequence< rtl::OUString >(); }
304 virtual
305 css::uno::Sequence<
306 css::uno::Reference< css::reflection::XTypeDescription > >
307 SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
308 return css::uno::Sequence<
309 css::uno::Reference< css::reflection::XTypeDescription > >();
312 rtl::Reference< cppuhelper::TypeManager > manager_;
313 rtl::OUString name_;
314 rtl::Reference< unoidl::PlainStructTypeEntity > entity_;
317 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
318 PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException, std::exception)
320 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
321 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
322 css::uno::Sequence<
323 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
324 for (sal_Int32 i = 0; i != n; ++i) {
325 s[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
327 return s;
330 css::uno::Sequence< rtl::OUString > PlainStructTypeDescription::getMemberNames()
331 throw (css::uno::RuntimeException, std::exception)
333 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
334 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
335 css::uno::Sequence< rtl::OUString > s(n);
336 for (sal_Int32 i = 0; i != n; ++i) {
337 s[i] = entity_->getDirectMembers()[i].name;
339 return s;
342 class ParameterizedMemberTypeDescription:
343 public cppu::WeakImplHelper1< css::reflection::XTypeDescription >
345 public:
346 explicit ParameterizedMemberTypeDescription(
347 rtl::OUString const & typeParameterName):
348 typeParameterName_(typeParameterName)
351 private:
352 virtual ~ParameterizedMemberTypeDescription() {}
354 virtual css::uno::TypeClass SAL_CALL getTypeClass()
355 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
356 { return css::uno::TypeClass_UNKNOWN; }
358 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
359 { return typeParameterName_; }
361 rtl::OUString typeParameterName_;
364 typedef cppu::ImplInheritanceHelper1<
365 PublishableDescription, css::reflection::XStructTypeDescription >
366 PolymorphicStructTypeTemplateDescription_Base;
368 class PolymorphicStructTypeTemplateDescription:
369 public PolymorphicStructTypeTemplateDescription_Base
371 public:
372 PolymorphicStructTypeTemplateDescription(
373 rtl::Reference< cppuhelper::TypeManager > const & manager,
374 rtl::OUString const & name,
375 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > const &
376 entity):
377 PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
378 manager_(manager), name_(name), entity_(entity)
379 { assert(manager.is()); assert(entity.is()); }
381 private:
382 virtual ~PolymorphicStructTypeTemplateDescription() {}
384 virtual css::uno::TypeClass SAL_CALL getTypeClass()
385 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
386 { return css::uno::TypeClass_STRUCT; }
388 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
389 { return name_; }
391 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
392 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
393 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
395 virtual
396 css::uno::Sequence<
397 css::uno::Reference< css::reflection::XTypeDescription > >
398 SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
400 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
401 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
403 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
404 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
406 virtual
407 css::uno::Sequence<
408 css::uno::Reference< css::reflection::XTypeDescription > >
409 SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
410 return css::uno::Sequence<
411 css::uno::Reference< css::reflection::XTypeDescription > >();
414 rtl::Reference< cppuhelper::TypeManager > manager_;
415 rtl::OUString name_;
416 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_;
419 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
420 PolymorphicStructTypeTemplateDescription::getMemberTypes()
421 throw (css::uno::RuntimeException, std::exception)
423 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
424 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
425 css::uno::Sequence<
426 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
427 for (sal_Int32 i = 0; i != n; ++i) {
428 s[i] = entity_->getMembers()[i].parameterized
429 ? new ParameterizedMemberTypeDescription(
430 entity_->getMembers()[i].type)
431 : manager_->resolve(entity_->getMembers()[i].type);
433 return s;
436 css::uno::Sequence< rtl::OUString >
437 PolymorphicStructTypeTemplateDescription::getMemberNames()
438 throw (css::uno::RuntimeException, std::exception)
440 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
441 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
442 css::uno::Sequence< rtl::OUString > s(n);
443 for (sal_Int32 i = 0; i != n; ++i) {
444 s[i] = entity_->getMembers()[i].name;
446 return s;
449 css::uno::Sequence< rtl::OUString >
450 PolymorphicStructTypeTemplateDescription::getTypeParameters()
451 throw (css::uno::RuntimeException, std::exception)
453 assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32);
454 sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size());
455 css::uno::Sequence< rtl::OUString > s(n);
456 for (sal_Int32 i = 0; i != n; ++i) {
457 s[i] = entity_->getTypeParameters()[i];
459 return s;
462 class InstantiatedPolymorphicStructTypeDescription:
463 public cppu::WeakImplHelper1< css::reflection::XStructTypeDescription >
465 public:
466 InstantiatedPolymorphicStructTypeDescription(
467 rtl::Reference< cppuhelper::TypeManager > const & manager,
468 rtl::OUString const & name,
469 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > const &
470 entity,
471 std::vector< rtl::OUString > const & arguments):
472 manager_(manager), name_(name), entity_(entity), arguments_(arguments)
474 assert(manager.is());
475 assert(entity.is());
476 assert(arguments.size() == entity->getTypeParameters().size());
479 private:
480 virtual ~InstantiatedPolymorphicStructTypeDescription() {}
482 virtual css::uno::TypeClass SAL_CALL getTypeClass()
483 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
484 { return css::uno::TypeClass_STRUCT; }
486 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
487 { return name_; }
489 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
490 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
491 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
493 virtual
494 css::uno::Sequence<
495 css::uno::Reference< css::reflection::XTypeDescription > >
496 SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
498 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
499 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
501 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
502 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
503 { return css::uno::Sequence< rtl::OUString >(); }
505 virtual
506 css::uno::Sequence<
507 css::uno::Reference< css::reflection::XTypeDescription > >
508 SAL_CALL getTypeArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
510 rtl::Reference< cppuhelper::TypeManager > manager_;
511 rtl::OUString name_;
512 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_;
513 std::vector< rtl::OUString > arguments_;
516 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
517 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
518 throw (css::uno::RuntimeException, std::exception)
520 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
521 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
522 css::uno::Sequence<
523 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
524 for (sal_Int32 i = 0; i != n; ++i) {
525 rtl::OUString type(entity_->getMembers()[i].type);
526 if (entity_->getMembers()[i].parameterized) {
527 for (std::vector< rtl::OUString >::const_iterator j(
528 entity_->getTypeParameters().begin());
529 j != entity_->getTypeParameters().end(); ++j)
531 if (*j == type) {
532 type = arguments_[j - entity_->getTypeParameters().begin()];
533 goto found;
536 assert(false); // this cannot happen //TODO!
537 found:;
539 s[i] = manager_->resolve(type);
541 return s;
544 css::uno::Sequence< rtl::OUString >
545 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
546 throw (css::uno::RuntimeException, std::exception)
548 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
549 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
550 css::uno::Sequence< rtl::OUString > s(n);
551 for (sal_Int32 i = 0; i != n; ++i) {
552 s[i] = entity_->getMembers()[i].name;
554 return s;
556 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
557 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
558 throw (css::uno::RuntimeException, std::exception)
560 assert(arguments_.size() <= SAL_MAX_INT32);
561 sal_Int32 n = static_cast< sal_Int32 >(arguments_.size());
562 css::uno::Sequence<
563 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
564 for (sal_Int32 i = 0; i != n; ++i) {
565 s[i] = manager_->resolve(arguments_[i]);
567 return s;
570 typedef cppu::ImplInheritanceHelper1<
571 PublishableDescription, css::reflection::XCompoundTypeDescription >
572 ExceptionTypeDescription_Base;
574 class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
575 public:
576 ExceptionTypeDescription(
577 rtl::Reference< cppuhelper::TypeManager > const & manager,
578 rtl::OUString const & name,
579 rtl::Reference< unoidl::ExceptionTypeEntity > const & entity):
580 ExceptionTypeDescription_Base(entity->isPublished()), manager_(manager),
581 name_(name), entity_(entity)
582 { assert(manager.is()); assert(entity.is()); }
584 private:
585 virtual ~ExceptionTypeDescription() {}
587 virtual css::uno::TypeClass SAL_CALL getTypeClass()
588 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
589 { return css::uno::TypeClass_EXCEPTION; }
591 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
592 { return name_; }
594 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
595 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
596 return entity_->getDirectBase().isEmpty()
597 ? css::uno::Reference< css::reflection::XTypeDescription >()
598 : manager_->resolve(entity_->getDirectBase());
601 virtual
602 css::uno::Sequence<
603 css::uno::Reference< css::reflection::XTypeDescription > >
604 SAL_CALL getMemberTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
606 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
607 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
609 rtl::Reference< cppuhelper::TypeManager > manager_;
610 rtl::OUString name_;
611 rtl::Reference< unoidl::ExceptionTypeEntity > entity_;
614 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
615 ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException, std::exception) {
616 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
617 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
618 css::uno::Sequence<
619 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
620 for (sal_Int32 i = 0; i != n; ++i) {
621 s[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
623 return s;
626 css::uno::Sequence< rtl::OUString > ExceptionTypeDescription::getMemberNames()
627 throw (css::uno::RuntimeException, std::exception)
629 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
630 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
631 css::uno::Sequence< rtl::OUString > s(n);
632 for (sal_Int32 i = 0; i != n; ++i) {
633 s[i] = entity_->getDirectMembers()[i].name;
635 return s;
638 class AttributeDescription:
639 public cppu::WeakImplHelper1<
640 css::reflection::XInterfaceAttributeTypeDescription2 >
642 public:
643 AttributeDescription(
644 rtl::Reference< cppuhelper::TypeManager > const & manager,
645 rtl::OUString const & name,
646 unoidl::InterfaceTypeEntity::Attribute const & attribute,
647 sal_Int32 position):
648 manager_(manager), name_(name), attribute_(attribute),
649 position_(position)
650 { assert(manager.is()); }
652 private:
653 virtual ~AttributeDescription() {}
655 virtual css::uno::TypeClass SAL_CALL getTypeClass()
656 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
657 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE; }
659 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
660 { return name_; }
662 virtual rtl::OUString SAL_CALL getMemberName()
663 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
664 { return attribute_.name; }
666 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
667 { return position_; }
669 virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
670 { return attribute_.readOnly; }
672 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
673 getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
674 { return manager_->resolve(attribute_.type); }
676 virtual sal_Bool SAL_CALL isBound() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
677 { return attribute_.bound; }
679 virtual
680 css::uno::Sequence<
681 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
682 SAL_CALL getGetExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
684 virtual
685 css::uno::Sequence<
686 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
687 SAL_CALL getSetExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
689 rtl::Reference< cppuhelper::TypeManager > manager_;
690 rtl::OUString name_;
691 unoidl::InterfaceTypeEntity::Attribute attribute_;
692 sal_Int32 position_;
695 css::uno::Sequence<
696 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
697 AttributeDescription::getGetExceptions() throw (css::uno::RuntimeException, std::exception) {
698 assert(attribute_.getExceptions.size() <= SAL_MAX_INT32);
699 sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size());
700 css::uno::Sequence<
701 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
702 for (sal_Int32 i = 0; i != n; ++i) {
703 s[i].set(
704 manager_->resolve(attribute_.getExceptions[i]),
705 css::uno::UNO_QUERY_THROW);
707 return s;
710 css::uno::Sequence<
711 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
712 AttributeDescription::getSetExceptions() throw (css::uno::RuntimeException, std::exception) {
713 assert(attribute_.setExceptions.size() <= SAL_MAX_INT32);
714 sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size());
715 css::uno::Sequence<
716 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
717 for (sal_Int32 i = 0; i != n; ++i) {
718 s[i].set(
719 manager_->resolve(attribute_.setExceptions[i]),
720 css::uno::UNO_QUERY_THROW);
722 return s;
725 class MethodParameter:
726 public cppu::WeakImplHelper1< css::reflection::XMethodParameter >
728 public:
729 MethodParameter(
730 rtl::Reference< cppuhelper::TypeManager > const & manager,
731 unoidl::InterfaceTypeEntity::Method::Parameter const & parameter,
732 sal_Int32 position):
733 manager_(manager), parameter_(parameter), position_(position)
734 { assert(manager.is()); }
736 private:
737 virtual ~MethodParameter() {}
739 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
740 { return parameter_.name; }
742 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
743 getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
744 { return manager_->resolve(parameter_.type); }
746 virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
747 return
748 (parameter_.direction
749 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
750 || (parameter_.direction
751 == unoidl::InterfaceTypeEntity::Method::Parameter::
752 DIRECTION_IN_OUT);
755 virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
756 return
757 (parameter_.direction
758 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT)
759 || (parameter_.direction
760 == unoidl::InterfaceTypeEntity::Method::Parameter::
761 DIRECTION_IN_OUT);
764 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
765 { return position_; }
767 rtl::Reference< cppuhelper::TypeManager > manager_;
768 unoidl::InterfaceTypeEntity::Method::Parameter parameter_;
769 sal_Int32 position_;
772 class MethodDescription:
773 public cppu::WeakImplHelper1<
774 css::reflection::XInterfaceMethodTypeDescription >
776 public:
777 MethodDescription(
778 rtl::Reference< cppuhelper::TypeManager > const & manager,
779 rtl::OUString const & name,
780 unoidl::InterfaceTypeEntity::Method const & method, sal_Int32 position):
781 manager_(manager), name_(name), method_(method), position_(position)
782 { assert(manager.is()); }
784 private:
785 virtual ~MethodDescription() {}
787 virtual css::uno::TypeClass SAL_CALL getTypeClass()
788 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
789 { return css::uno::TypeClass_INTERFACE_METHOD; }
791 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
792 { return name_; }
794 virtual rtl::OUString SAL_CALL getMemberName()
795 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
796 { return method_.name; }
798 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
799 { return position_; }
801 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
802 getReturnType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
803 { return manager_->resolve(method_.returnType); }
805 virtual sal_Bool SAL_CALL isOneway() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
806 { return false; }
808 virtual
809 css::uno::Sequence<
810 css::uno::Reference< css::reflection::XMethodParameter > >
811 SAL_CALL getParameters() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
813 virtual
814 css::uno::Sequence<
815 css::uno::Reference< css::reflection::XTypeDescription > >
816 SAL_CALL getExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
818 rtl::Reference< cppuhelper::TypeManager > manager_;
819 rtl::OUString name_;
820 unoidl::InterfaceTypeEntity::Method method_;
821 sal_Int32 position_;
824 css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > >
825 MethodDescription::getParameters() throw (css::uno::RuntimeException, std::exception) {
826 assert(method_.parameters.size() <= SAL_MAX_INT32);
827 sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size());
828 css::uno::Sequence<
829 css::uno::Reference< css::reflection::XMethodParameter > > s(n);
830 for (sal_Int32 i = 0; i != n; ++i) {
831 s[i] = new MethodParameter(manager_, method_.parameters[i], i);
833 return s;
836 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
837 MethodDescription::getExceptions() throw (css::uno::RuntimeException, std::exception) {
838 assert(method_.exceptions.size() <= SAL_MAX_INT32);
839 sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size());
840 css::uno::Sequence<
841 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
842 for (sal_Int32 i = 0; i != n; ++i) {
843 s[i] = manager_->resolve(method_.exceptions[i]);
845 return s;
848 class BaseOffset: private boost::noncopyable {
849 public:
850 BaseOffset(
851 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
852 const & description);
854 sal_Int32 get() const { return offset_; }
856 private:
857 void calculateBases(
858 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
859 const & description);
861 void calculate(
862 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
863 const & description);
865 std::set< rtl::OUString > set_;
866 sal_Int32 offset_;
869 BaseOffset::BaseOffset(
870 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
871 description):
872 offset_(0)
874 calculateBases(description);
877 void BaseOffset::calculateBases(
878 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
879 description)
881 css::uno::Sequence<
882 css::uno::Reference < css::reflection::XTypeDescription > > bases(
883 description->getBaseTypes());
884 for (sal_Int32 i = 0; i != bases.getLength(); ++i) {
885 calculate(
886 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
887 resolveTypedefs(css::uno::makeAny(bases[i])),
888 css::uno::UNO_QUERY_THROW));
892 void BaseOffset::calculate(
893 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
894 description)
896 if (set_.insert(description->getName()).second) {
897 calculateBases(description);
898 offset_ += description->getMembers().getLength();
902 typedef cppu::ImplInheritanceHelper1<
903 PublishableDescription, css::reflection::XInterfaceTypeDescription2 >
904 InterfaceTypeDescription_Base;
906 class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
907 public:
908 InterfaceTypeDescription(
909 rtl::Reference< cppuhelper::TypeManager > const & manager,
910 rtl::OUString const & name,
911 rtl::Reference< unoidl::InterfaceTypeEntity > const & entity):
912 InterfaceTypeDescription_Base(entity->isPublished()), manager_(manager),
913 name_(name), entity_(entity)
914 { assert(manager.is()); assert(entity.is()); }
916 private:
917 virtual ~InterfaceTypeDescription() {}
919 virtual css::uno::TypeClass SAL_CALL getTypeClass()
920 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
921 { return css::uno::TypeClass_INTERFACE; }
923 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
924 { return name_; }
926 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
927 getBaseType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE {
928 return entity_->getDirectMandatoryBases().empty()
929 ? css::uno::Reference< css::reflection::XTypeDescription >()
930 : manager_->resolve(entity_->getDirectMandatoryBases()[0].name);
933 virtual css::uno::Uik SAL_CALL getUik() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
934 { return css::uno::Uik(); }
936 virtual
937 css::uno::Sequence<
938 css::uno::Reference<
939 css::reflection::XInterfaceMemberTypeDescription > >
940 SAL_CALL getMembers() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
942 virtual
943 css::uno::Sequence<
944 css::uno::Reference< css::reflection::XTypeDescription > >
945 SAL_CALL getBaseTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
947 virtual
948 css::uno::Sequence<
949 css::uno::Reference< css::reflection::XTypeDescription > >
950 SAL_CALL getOptionalBaseTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
952 rtl::Reference< cppuhelper::TypeManager > manager_;
953 rtl::OUString name_;
954 rtl::Reference< unoidl::InterfaceTypeEntity > entity_;
957 css::uno::Sequence<
958 css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
959 InterfaceTypeDescription::getMembers() throw (css::uno::RuntimeException, std::exception) {
960 assert(
961 entity_->getDirectAttributes().size() <= SAL_MAX_INT32
962 && (entity_->getDirectMethods().size()
963 <= SAL_MAX_INT32 - entity_->getDirectAttributes().size()));
964 sal_Int32 n1 = static_cast< sal_Int32 >(
965 entity_->getDirectAttributes().size());
966 sal_Int32 n2 = static_cast< sal_Int32 >(entity_->getDirectMethods().size());
967 css::uno::Sequence<
968 css::uno::Reference<
969 css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2);
970 sal_Int32 off = BaseOffset(this).get();
971 for (sal_Int32 i = 0; i != n1; ++i) {
972 s[i] = new AttributeDescription(
973 manager_, name_ + "::" + entity_->getDirectAttributes()[i].name,
974 entity_->getDirectAttributes()[i], off + i);
976 for (sal_Int32 i = 0; i != n2; ++i) {
977 s[n1 + i] = new MethodDescription(
978 manager_, name_ + "::" + entity_->getDirectMethods()[i].name,
979 entity_->getDirectMethods()[i], off + n1 + i);
981 return s;
984 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
985 InterfaceTypeDescription::getBaseTypes() throw (css::uno::RuntimeException, std::exception) {
986 assert(entity_->getDirectMandatoryBases().size() <= SAL_MAX_INT32);
987 sal_Int32 n = static_cast< sal_Int32 >(
988 entity_->getDirectMandatoryBases().size());
989 css::uno::Sequence<
990 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
991 for (sal_Int32 i = 0; i != n; ++i) {
992 s[i] = manager_->resolve(entity_->getDirectMandatoryBases()[i].name);
994 return s;
997 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
998 InterfaceTypeDescription::getOptionalBaseTypes()
999 throw (css::uno::RuntimeException, std::exception)
1001 assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
1002 sal_Int32 n = static_cast< sal_Int32 >(
1003 entity_->getDirectOptionalBases().size());
1004 css::uno::Sequence<
1005 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
1006 for (sal_Int32 i = 0; i != n; ++i) {
1007 s[i] = manager_->resolve(entity_->getDirectOptionalBases()[i].name);
1009 return s;
1012 class ConstantDescription:
1013 public cppu::WeakImplHelper1< css::reflection::XConstantTypeDescription >
1015 public:
1016 ConstantDescription(
1017 rtl::OUString const & constantGroupName,
1018 unoidl::ConstantGroupEntity::Member const & member);
1020 private:
1021 virtual ~ConstantDescription() {}
1023 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1024 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1025 { return css::uno::TypeClass_CONSTANT; }
1027 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1028 { return name_; }
1030 virtual css::uno::Any SAL_CALL getConstantValue()
1031 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1032 { return value_; }
1034 rtl::OUString name_;
1035 css::uno::Any value_;
1038 ConstantDescription::ConstantDescription(
1039 rtl::OUString const & constantGroupName,
1040 unoidl::ConstantGroupEntity::Member const & member):
1041 name_(makePrefix(constantGroupName) + member.name)
1043 switch (member.value.type) {
1044 case unoidl::ConstantValue::TYPE_BOOLEAN:
1045 value_ <<= member.value.booleanValue;
1046 break;
1047 case unoidl::ConstantValue::TYPE_BYTE:
1048 value_ <<= member.value.byteValue;
1049 break;
1050 case unoidl::ConstantValue::TYPE_SHORT:
1051 value_ <<= member.value.shortValue;
1052 break;
1053 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT:
1054 value_ <<= member.value.unsignedShortValue;
1055 break;
1056 case unoidl::ConstantValue::TYPE_LONG:
1057 value_ <<= member.value.longValue;
1058 break;
1059 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG:
1060 value_ <<= member.value.unsignedLongValue;
1061 break;
1062 case unoidl::ConstantValue::TYPE_HYPER:
1063 value_ <<= member.value.hyperValue;
1064 break;
1065 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER:
1066 value_ <<= member.value.unsignedHyperValue;
1067 break;
1068 case unoidl::ConstantValue::TYPE_FLOAT:
1069 value_ <<= member.value.floatValue;
1070 break;
1071 case unoidl::ConstantValue::TYPE_DOUBLE:
1072 value_ <<= member.value.doubleValue;
1073 break;
1074 default:
1075 for (;;) { std::abort(); } // this cannot happen
1079 typedef cppu::ImplInheritanceHelper1<
1080 PublishableDescription, css::reflection::XConstantsTypeDescription >
1081 ConstantGroupDescription_Base;
1083 class ConstantGroupDescription: public ConstantGroupDescription_Base {
1084 public:
1085 ConstantGroupDescription(
1086 rtl::OUString const & name,
1087 rtl::Reference< unoidl::ConstantGroupEntity > const & entity):
1088 ConstantGroupDescription_Base(entity->isPublished()), name_(name),
1089 entity_(entity)
1090 { assert(entity.is()); }
1092 private:
1093 virtual ~ConstantGroupDescription() {}
1095 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1096 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1097 { return css::uno::TypeClass_CONSTANTS; }
1099 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1100 { return name_; }
1102 virtual
1103 css::uno::Sequence<
1104 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1105 SAL_CALL getConstants() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1107 rtl::OUString name_;
1108 rtl::Reference< unoidl::ConstantGroupEntity > entity_;
1111 css::uno::Sequence<
1112 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1113 ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException, std::exception) {
1114 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
1115 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
1116 css::uno::Sequence<
1117 css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n);
1118 for (sal_Int32 i = 0; i != n; ++i) {
1119 s[i] = new ConstantDescription(name_, entity_->getMembers()[i]);
1121 return s;
1124 typedef cppu::ImplInheritanceHelper1<
1125 PublishableDescription, css::reflection::XIndirectTypeDescription >
1126 TypedefDescription_Base;
1128 class TypedefDescription: public TypedefDescription_Base {
1129 public:
1130 TypedefDescription(
1131 rtl::Reference< cppuhelper::TypeManager > const & manager,
1132 rtl::OUString const & name,
1133 rtl::Reference< unoidl::TypedefEntity > const & entity):
1134 TypedefDescription_Base(entity->isPublished()), manager_(manager),
1135 name_(name), entity_(entity)
1136 { assert(manager.is()); assert(entity.is()); }
1138 private:
1139 virtual ~TypedefDescription() {}
1141 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1142 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1143 { return css::uno::TypeClass_TYPEDEF; }
1145 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1146 { return name_; }
1148 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1149 getReferencedType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1150 { return manager_->resolve(entity_->getType()); }
1152 rtl::Reference< cppuhelper::TypeManager > manager_;
1153 rtl::OUString name_;
1154 rtl::Reference< unoidl::TypedefEntity > entity_;
1157 class ConstructorParameter:
1158 public cppu::WeakImplHelper1< css::reflection::XParameter >
1160 public:
1161 ConstructorParameter(
1162 rtl::Reference< cppuhelper::TypeManager > const & manager,
1163 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1164 const & parameter,
1165 sal_Int32 position):
1166 manager_(manager), parameter_(parameter), position_(position)
1167 { assert(manager.is()); }
1169 private:
1170 virtual ~ConstructorParameter() {}
1172 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1173 { return parameter_.name; }
1175 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1176 getType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1177 { return manager_->resolve(parameter_.type); }
1179 virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1180 { return true; }
1182 virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1183 { return false; }
1185 virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1186 { return position_; }
1188 virtual sal_Bool SAL_CALL isRestParameter()
1189 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1190 { return parameter_.rest; }
1192 rtl::Reference< cppuhelper::TypeManager > manager_;
1193 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1194 parameter_;
1195 sal_Int32 position_;
1198 class ConstructorDescription:
1199 public cppu::WeakImplHelper1<
1200 css::reflection::XServiceConstructorDescription >
1202 public:
1203 ConstructorDescription(
1204 rtl::Reference< cppuhelper::TypeManager > const & manager,
1205 unoidl::SingleInterfaceBasedServiceEntity::Constructor const &
1206 constructor):
1207 manager_(manager), constructor_(constructor)
1208 { assert(manager.is()); }
1210 private:
1211 virtual ~ConstructorDescription() {}
1213 virtual sal_Bool SAL_CALL isDefaultConstructor()
1214 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1215 { return constructor_.defaultConstructor; }
1217 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1218 { return constructor_.name; }
1220 virtual
1221 css::uno::Sequence<
1222 css::uno::Reference< css::reflection::XParameter > >
1223 SAL_CALL getParameters() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1225 virtual
1226 css::uno::Sequence<
1227 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1228 SAL_CALL getExceptions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1230 rtl::Reference< cppuhelper::TypeManager > manager_;
1231 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_;
1234 css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
1235 ConstructorDescription::getParameters() throw (css::uno::RuntimeException, std::exception) {
1236 assert(constructor_.parameters.size() <= SAL_MAX_INT32);
1237 sal_Int32 n = static_cast< sal_Int32 >(constructor_.parameters.size());
1238 css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > > s(
1240 for (sal_Int32 i = 0; i != n; ++i) {
1241 s[i] = new ConstructorParameter(
1242 manager_, constructor_.parameters[i], i);
1244 return s;
1247 css::uno::Sequence<
1248 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1249 ConstructorDescription::getExceptions() throw (css::uno::RuntimeException, std::exception) {
1250 assert(constructor_.exceptions.size() <= SAL_MAX_INT32);
1251 sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size());
1252 css::uno::Sequence<
1253 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
1254 for (sal_Int32 i = 0; i != n; ++i) {
1255 s[i].set(
1256 manager_->resolve(constructor_.exceptions[i]),
1257 css::uno::UNO_QUERY_THROW);
1259 return s;
1262 typedef cppu::ImplInheritanceHelper1<
1263 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1264 SingleInterfaceBasedServiceDescription_Base;
1266 class SingleInterfaceBasedServiceDescription:
1267 public SingleInterfaceBasedServiceDescription_Base
1269 public:
1270 SingleInterfaceBasedServiceDescription(
1271 rtl::Reference< cppuhelper::TypeManager > const & manager,
1272 rtl::OUString const & name,
1273 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > const &
1274 entity):
1275 SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
1276 manager_(manager), name_(name), entity_(entity)
1277 { assert(manager.is()); assert(entity.is()); }
1279 private:
1280 virtual ~SingleInterfaceBasedServiceDescription() {}
1282 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1283 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1284 { return css::uno::TypeClass_SERVICE; }
1286 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1287 { return name_; }
1289 virtual
1290 css::uno::Sequence<
1291 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1292 SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1294 return css::uno::Sequence<
1295 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1298 virtual
1299 css::uno::Sequence<
1300 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1301 SAL_CALL getOptionalServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1303 return css::uno::Sequence<
1304 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1307 virtual
1308 css::uno::Sequence<
1309 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1310 SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1312 return css::uno::Sequence<
1313 css::uno::Reference<
1314 css::reflection::XInterfaceTypeDescription > >();
1317 virtual
1318 css::uno::Sequence<
1319 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1320 SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1322 return css::uno::Sequence<
1323 css::uno::Reference<
1324 css::reflection::XInterfaceTypeDescription > >();
1327 virtual
1328 css::uno::Sequence<
1329 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1330 SAL_CALL getProperties() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1332 return css::uno::Sequence<
1333 css::uno::Reference<
1334 css::reflection::XPropertyTypeDescription > >();
1337 virtual sal_Bool SAL_CALL isSingleInterfaceBased()
1338 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1339 { return true; }
1341 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1342 getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1343 { return manager_->resolve(entity_->getBase()); }
1345 virtual
1346 css::uno::Sequence<
1347 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1348 SAL_CALL getConstructors() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1350 rtl::Reference< cppuhelper::TypeManager > manager_;
1351 rtl::OUString name_;
1352 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > entity_;
1355 css::uno::Sequence<
1356 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1357 SingleInterfaceBasedServiceDescription::getConstructors()
1358 throw (css::uno::RuntimeException, std::exception)
1360 assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
1361 sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
1362 css::uno::Sequence<
1363 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1364 s(n);
1365 for (sal_Int32 i = 0; i != n; ++i) {
1366 s[i] = new ConstructorDescription(
1367 manager_, entity_->getConstructors()[i]);
1369 return s;
1372 class PropertyDescription:
1373 public cppu::WeakImplHelper1< css::reflection::XPropertyTypeDescription >
1375 public:
1376 PropertyDescription(
1377 rtl::Reference< cppuhelper::TypeManager > const & manager,
1378 unoidl::AccumulationBasedServiceEntity::Property const & property):
1379 manager_(manager), property_(property)
1380 { assert(manager.is()); }
1382 private:
1383 virtual ~PropertyDescription() {}
1385 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1386 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1387 { return css::uno::TypeClass_PROPERTY; }
1389 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1390 { return property_.name; }
1392 virtual sal_Int16 SAL_CALL getPropertyFlags()
1393 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1394 { return property_.attributes; }
1396 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1397 getPropertyTypeDescription() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1398 { return manager_->resolve(property_.type); }
1400 rtl::Reference< cppuhelper::TypeManager > manager_;
1401 unoidl::AccumulationBasedServiceEntity::Property property_;
1404 typedef cppu::ImplInheritanceHelper1<
1405 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1406 AccumulationBasedServiceDescription_Base;
1408 class AccumulationBasedServiceDescription:
1409 public AccumulationBasedServiceDescription_Base
1411 public:
1412 AccumulationBasedServiceDescription(
1413 rtl::Reference< cppuhelper::TypeManager > const & manager,
1414 rtl::OUString const & name,
1415 rtl::Reference< unoidl::AccumulationBasedServiceEntity > const &
1416 entity):
1417 AccumulationBasedServiceDescription_Base(entity->isPublished()),
1418 manager_(manager), name_(name), entity_(entity)
1419 { assert(manager.is()); assert(entity.is()); }
1421 private:
1422 virtual ~AccumulationBasedServiceDescription() {}
1424 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1425 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1426 { return css::uno::TypeClass_SERVICE; }
1428 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1429 { return name_; }
1431 virtual
1432 css::uno::Sequence<
1433 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1434 SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1436 virtual
1437 css::uno::Sequence<
1438 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1439 SAL_CALL getOptionalServices() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1441 virtual
1442 css::uno::Sequence<
1443 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1444 SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1446 virtual
1447 css::uno::Sequence<
1448 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1449 SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1451 virtual
1452 css::uno::Sequence<
1453 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1454 SAL_CALL getProperties() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1456 virtual sal_Bool SAL_CALL isSingleInterfaceBased()
1457 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1458 { return false; }
1460 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1461 getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1462 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1464 virtual
1465 css::uno::Sequence<
1466 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1467 SAL_CALL getConstructors() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1469 return css::uno::Sequence<
1470 css::uno::Reference<
1471 css::reflection::XServiceConstructorDescription > >();
1474 rtl::Reference< cppuhelper::TypeManager > manager_;
1475 rtl::OUString name_;
1476 rtl::Reference< unoidl::AccumulationBasedServiceEntity > entity_;
1479 css::uno::Sequence<
1480 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1481 AccumulationBasedServiceDescription::getMandatoryServices()
1482 throw (css::uno::RuntimeException, std::exception)
1484 assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
1485 sal_Int32 n = static_cast< sal_Int32 >(
1486 entity_->getDirectMandatoryBaseServices().size());
1487 css::uno::Sequence<
1488 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1489 for (sal_Int32 i = 0; i != n; ++i) {
1490 s[i].set(
1491 manager_->resolve(
1492 entity_->getDirectMandatoryBaseServices()[i].name),
1493 css::uno::UNO_QUERY_THROW);
1495 return s;
1498 css::uno::Sequence<
1499 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1500 AccumulationBasedServiceDescription::getOptionalServices()
1501 throw (css::uno::RuntimeException, std::exception)
1503 assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
1504 sal_Int32 n = static_cast< sal_Int32 >(
1505 entity_->getDirectOptionalBaseServices().size());
1506 css::uno::Sequence<
1507 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1508 for (sal_Int32 i = 0; i != n; ++i) {
1509 s[i].set(
1510 manager_->resolve(entity_->getDirectOptionalBaseServices()[i].name),
1511 css::uno::UNO_QUERY_THROW);
1513 return s;
1516 css::uno::Sequence<
1517 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1518 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1519 throw (css::uno::RuntimeException, std::exception)
1521 assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
1522 sal_Int32 n = static_cast< sal_Int32 >(
1523 entity_->getDirectMandatoryBaseInterfaces().size());
1524 css::uno::Sequence<
1525 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1527 for (sal_Int32 i = 0; i != n; ++i) {
1528 s[i].set(
1529 resolveTypedefs(
1530 manager_->find(
1531 entity_->getDirectMandatoryBaseInterfaces()[i].name)),
1532 css::uno::UNO_QUERY_THROW);
1534 return s;
1537 css::uno::Sequence<
1538 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1539 AccumulationBasedServiceDescription::getOptionalInterfaces()
1540 throw (css::uno::RuntimeException, std::exception)
1542 assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
1543 sal_Int32 n = static_cast< sal_Int32 >(
1544 entity_->getDirectOptionalBaseInterfaces().size());
1545 css::uno::Sequence<
1546 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1548 for (sal_Int32 i = 0; i != n; ++i) {
1549 s[i].set(
1550 resolveTypedefs(
1551 manager_->find(
1552 entity_->getDirectOptionalBaseInterfaces()[i].name)),
1553 css::uno::UNO_QUERY_THROW);
1555 return s;
1558 css::uno::Sequence<
1559 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1560 AccumulationBasedServiceDescription::getProperties()
1561 throw (css::uno::RuntimeException, std::exception)
1563 assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
1564 sal_Int32 n = static_cast< sal_Int32 >(
1565 entity_->getDirectProperties().size());
1566 css::uno::Sequence<
1567 css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n);
1568 for (sal_Int32 i = 0; i != n; ++i) {
1569 s[i] = new PropertyDescription(
1570 manager_, entity_->getDirectProperties()[i]);
1572 return s;
1575 typedef cppu::ImplInheritanceHelper1<
1576 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1577 InterfaceBasedSingletonDescription_Base;
1579 class InterfaceBasedSingletonDescription:
1580 public InterfaceBasedSingletonDescription_Base
1582 public:
1583 InterfaceBasedSingletonDescription(
1584 rtl::Reference< cppuhelper::TypeManager > const & manager,
1585 rtl::OUString const & name,
1586 rtl::Reference< unoidl::InterfaceBasedSingletonEntity > const & entity):
1587 InterfaceBasedSingletonDescription_Base(entity->isPublished()),
1588 manager_(manager), name_(name), entity_(entity)
1589 { assert(manager.is()); assert(entity.is()); }
1591 private:
1592 virtual ~InterfaceBasedSingletonDescription() {}
1594 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1595 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1596 { return css::uno::TypeClass_SINGLETON; }
1598 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1599 { return name_; }
1601 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1602 SAL_CALL getService() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1604 return
1605 css::uno::Reference< css::reflection::XServiceTypeDescription >();
1608 virtual sal_Bool SAL_CALL isInterfaceBased()
1609 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1610 { return true; }
1612 virtual css::uno::Reference< css::reflection::XTypeDescription >
1613 SAL_CALL getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1614 { return manager_->resolve(entity_->getBase()); }
1616 rtl::Reference< cppuhelper::TypeManager > manager_;
1617 rtl::OUString name_;
1618 rtl::Reference< unoidl::InterfaceBasedSingletonEntity > entity_;
1621 typedef cppu::ImplInheritanceHelper1<
1622 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1623 ServiceBasedSingletonDescription_Base;
1625 class ServiceBasedSingletonDescription:
1626 public ServiceBasedSingletonDescription_Base
1628 public:
1629 ServiceBasedSingletonDescription(
1630 rtl::Reference< cppuhelper::TypeManager > const & manager,
1631 rtl::OUString const & name,
1632 rtl::Reference< unoidl::ServiceBasedSingletonEntity > const & entity):
1633 ServiceBasedSingletonDescription_Base(entity_->isPublished()),
1634 manager_(manager), name_(name), entity_(entity)
1635 { assert(manager.is()); assert(entity.is()); }
1637 private:
1638 virtual ~ServiceBasedSingletonDescription() {}
1640 virtual css::uno::TypeClass SAL_CALL getTypeClass()
1641 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1642 { return css::uno::TypeClass_SINGLETON; }
1644 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1645 { return name_; }
1647 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1648 SAL_CALL getService() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1650 return css::uno::Reference< css::reflection::XServiceTypeDescription >(
1651 manager_->resolve(entity_->getBase()), css::uno::UNO_QUERY_THROW);
1654 virtual sal_Bool SAL_CALL isInterfaceBased()
1655 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1656 { return false; }
1658 virtual css::uno::Reference< css::reflection::XTypeDescription >
1659 SAL_CALL getInterface() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1660 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1662 rtl::Reference< cppuhelper::TypeManager > manager_;
1663 rtl::OUString name_;
1664 rtl::Reference< unoidl::ServiceBasedSingletonEntity > entity_;
1667 class Enumeration:
1668 public cppu::WeakImplHelper1< css::reflection::XTypeDescriptionEnumeration >
1670 public:
1671 Enumeration(
1672 rtl::Reference< cppuhelper::TypeManager > const & manager,
1673 rtl::OUString const & prefix,
1674 rtl::Reference< unoidl::MapCursor > const & cursor,
1675 css::uno::Sequence< css::uno::TypeClass > const & types, bool deep):
1676 manager_(manager), types_(types), deep_(deep)
1678 assert(manager.is());
1679 positions_.push(Position(prefix, cursor));
1680 findNextMatch();
1683 private:
1684 virtual ~Enumeration() {}
1686 virtual sal_Bool SAL_CALL hasMoreElements()
1687 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1688 { return !positions_.empty(); }
1690 virtual css::uno::Any SAL_CALL nextElement()
1691 throw (
1692 css::container::NoSuchElementException,
1693 css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
1694 { return css::uno::makeAny(nextTypeDescription()); }
1696 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1697 nextTypeDescription()
1698 throw (
1699 css::container::NoSuchElementException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
1701 bool matches(css::uno::TypeClass tc) const;
1703 void findNextMatch();
1705 struct Position {
1706 Position(
1707 rtl::OUString const & thePrefix,
1708 rtl::Reference< unoidl::MapCursor > const & theCursor):
1709 prefix(thePrefix), cursor(theCursor)
1710 { assert(theCursor.is()); }
1712 Position(
1713 rtl::OUString const & thePrefix,
1714 rtl::Reference< unoidl::ConstantGroupEntity > const &
1715 theConstantGroup):
1716 prefix(thePrefix), constantGroup(theConstantGroup),
1717 constantGroupIndex(constantGroup->getMembers().begin())
1718 { assert(theConstantGroup.is()); }
1720 Position(Position const & other):
1721 prefix(other.prefix), cursor(other.cursor),
1722 constantGroup(other.constantGroup)
1724 if (constantGroup.is()) {
1725 constantGroupIndex = other.constantGroupIndex;
1729 rtl::OUString prefix;
1730 rtl::Reference< unoidl::MapCursor > cursor;
1731 rtl::Reference< unoidl::ConstantGroupEntity > constantGroup;
1732 std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator
1733 constantGroupIndex;
1736 rtl::Reference< cppuhelper::TypeManager > manager_;
1737 css::uno::Sequence< css::uno::TypeClass > types_;
1738 bool deep_;
1740 osl::Mutex mutex_;
1741 std::stack< Position > positions_;
1742 rtl::OUString current_;
1745 css::uno::Reference< css::reflection::XTypeDescription >
1746 Enumeration::nextTypeDescription()
1747 throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
1749 rtl::OUString name;
1751 osl::MutexGuard g(mutex_);
1752 if (positions_.empty()) {
1753 throw css::container::NoSuchElementException(
1754 "exhausted XTypeDescriptionEnumeration",
1755 static_cast< cppu::OWeakObject * >(this));
1757 name = current_;
1758 findNextMatch();
1760 return manager_->resolve(name);
1763 bool Enumeration::matches(css::uno::TypeClass tc) const {
1764 if (types_.getLength() == 0) {
1765 return true;
1767 for (sal_Int32 i = 0; i != types_.getLength(); ++i) {
1768 if (types_[i] == tc) {
1769 return true;
1772 return false;
1775 void Enumeration::findNextMatch() {
1776 try {
1777 for (;;) {
1778 assert(!positions_.empty());
1779 rtl::OUString name;
1780 if (positions_.top().cursor.is()) { // root or module
1781 rtl::Reference< unoidl::Entity > ent(
1782 positions_.top().cursor->getNext(&name));
1783 if (!ent.is()) {
1784 positions_.pop();
1785 if (positions_.empty()) {
1786 break;
1788 continue;
1790 name = positions_.top().prefix + name;
1791 css::uno::TypeClass tc;
1792 switch (ent->getSort()) {
1793 case unoidl::Entity::SORT_MODULE:
1794 tc = css::uno::TypeClass_MODULE;
1795 if (deep_) {
1796 positions_.push(
1797 Position(
1798 makePrefix(name),
1799 static_cast< unoidl::ModuleEntity * >(
1800 ent.get())->createCursor()));
1802 break;
1803 case unoidl::Entity::SORT_ENUM_TYPE:
1804 tc = css::uno::TypeClass_ENUM;
1805 break;
1806 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
1807 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
1808 tc = css::uno::TypeClass_STRUCT;
1809 break;
1810 case unoidl::Entity::SORT_EXCEPTION_TYPE:
1811 tc = css::uno::TypeClass_EXCEPTION;
1812 break;
1813 case unoidl::Entity::SORT_INTERFACE_TYPE:
1814 tc = css::uno::TypeClass_INTERFACE;
1815 break;
1816 case unoidl::Entity::SORT_TYPEDEF:
1817 tc = css::uno::TypeClass_TYPEDEF;
1818 break;
1819 case unoidl::Entity::SORT_CONSTANT_GROUP:
1820 tc = css::uno::TypeClass_CONSTANTS;
1821 if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
1822 positions_.push(
1823 Position(
1824 makePrefix(name),
1825 static_cast< unoidl::ConstantGroupEntity * >(
1826 ent.get())));
1828 break;
1829 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
1830 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
1831 tc = css::uno::TypeClass_SERVICE;
1832 break;
1833 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
1834 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
1835 tc = css::uno::TypeClass_SINGLETON;
1836 break;
1837 default:
1838 for (;;) { std::abort(); } // this cannot happen
1840 if (matches(tc)) {
1841 current_ = name;
1842 break;
1844 } else { // constant group
1845 if (positions_.top().constantGroupIndex
1846 == positions_.top().constantGroup->getMembers().end())
1848 positions_.pop();
1849 if (positions_.empty()) {
1850 break;
1852 continue;
1854 current_ = positions_.top().prefix
1855 + positions_.top().constantGroupIndex++->name;
1856 break;
1859 } catch (unoidl::FileFormatException & e) {
1860 throw css::uno::DeploymentException(
1861 e.getUri() + ": " + e.getDetail(),
1862 static_cast< cppu::OWeakObject * >(this));
1868 cppuhelper::TypeManager::TypeManager():
1869 TypeManager_Base(m_aMutex),
1870 manager_(new unoidl::Manager)
1873 void cppuhelper::TypeManager::init(rtl::OUString const & rdbUris) {
1874 readRdbs(rdbUris);
1877 css::uno::Any cppuhelper::TypeManager::find(rtl::OUString const & name) {
1878 //TODO: caching? (here or in unoidl::Manager?)
1879 struct Simple {
1880 char const * name; sal_Int32 length;
1881 css::uno::TypeClass typeClass;
1883 static Simple const simple[] = {
1884 { RTL_CONSTASCII_STRINGPARAM("void"), css::uno::TypeClass_VOID },
1885 { RTL_CONSTASCII_STRINGPARAM("boolean"), css::uno::TypeClass_BOOLEAN },
1886 { RTL_CONSTASCII_STRINGPARAM("byte"), css::uno::TypeClass_BYTE },
1887 { RTL_CONSTASCII_STRINGPARAM("short"), css::uno::TypeClass_SHORT },
1888 { RTL_CONSTASCII_STRINGPARAM("unsigned short"),
1889 css::uno::TypeClass_UNSIGNED_SHORT },
1890 { RTL_CONSTASCII_STRINGPARAM("long"), css::uno::TypeClass_LONG },
1891 { RTL_CONSTASCII_STRINGPARAM("unsigned long"),
1892 css::uno::TypeClass_UNSIGNED_LONG },
1893 { RTL_CONSTASCII_STRINGPARAM("hyper"), css::uno::TypeClass_HYPER },
1894 { RTL_CONSTASCII_STRINGPARAM("unsigned hyper"),
1895 css::uno::TypeClass_UNSIGNED_HYPER },
1896 { RTL_CONSTASCII_STRINGPARAM("float"), css::uno::TypeClass_FLOAT },
1897 { RTL_CONSTASCII_STRINGPARAM("double"), css::uno::TypeClass_DOUBLE },
1898 { RTL_CONSTASCII_STRINGPARAM("char"), css::uno::TypeClass_CHAR },
1899 { RTL_CONSTASCII_STRINGPARAM("string"), css::uno::TypeClass_STRING },
1900 { RTL_CONSTASCII_STRINGPARAM("type"), css::uno::TypeClass_TYPE },
1901 { RTL_CONSTASCII_STRINGPARAM("any"), css::uno::TypeClass_ANY } };
1902 for (std::size_t i = 0; i != SAL_N_ELEMENTS(simple); ++i) {
1903 if (name.equalsAsciiL(simple[i].name, simple[i].length)) {
1904 return css::uno::makeAny<
1905 css::uno::Reference< css::reflection::XTypeDescription > >(
1906 new SimpleTypeDescription(simple[i].typeClass, name));
1909 if (name.startsWith("[]")) {
1910 return getSequenceType(name);
1912 sal_Int32 i = name.indexOf('<');
1913 if (i != -1) {
1914 return getInstantiatedStruct(name, i);
1916 i = name.indexOf("::");
1917 if (i != -1) {
1918 return getInterfaceMember(name, i);
1920 rtl::Reference< unoidl::Entity > ent(findEntity(name));
1921 if (ent.is()) {
1922 return getNamed(name, ent);
1924 i = name.lastIndexOf('.');
1925 if (i != -1) {
1926 rtl::OUString parent(name.copy(0, i));
1927 ent = findEntity(parent);
1928 if (ent.is()) {
1929 switch (ent->getSort()) {
1930 case unoidl::Entity::SORT_ENUM_TYPE:
1931 return getEnumMember(
1932 static_cast< unoidl::EnumTypeEntity * >(ent.get()),
1933 name.copy(i + 1));
1934 case unoidl::Entity::SORT_CONSTANT_GROUP:
1935 return getConstant(
1936 parent,
1937 static_cast< unoidl::ConstantGroupEntity * >(ent.get()),
1938 name.copy(i + 1));
1939 default:
1940 break;
1944 return css::uno::Any();
1947 css::uno::Reference< css::reflection::XTypeDescription >
1948 cppuhelper::TypeManager::resolve(rtl::OUString const & name) {
1949 css::uno::Reference< css::reflection::XTypeDescription > desc(
1950 find(name), css::uno::UNO_QUERY);
1951 if (!desc.is()) {
1952 throw css::uno::DeploymentException(
1953 "cannot resolve type \"" + name + "\"",
1954 static_cast< cppu::OWeakObject * >(this));
1956 return desc;
1959 cppuhelper::TypeManager::~TypeManager() throw () {}
1961 void cppuhelper::TypeManager::disposing() {} //TODO
1963 rtl::OUString cppuhelper::TypeManager::getImplementationName()
1964 throw (css::uno::RuntimeException, std::exception)
1966 return rtl::OUString(
1967 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager");
1970 sal_Bool cppuhelper::TypeManager::supportsService(
1971 rtl::OUString const & ServiceName)
1972 throw (css::uno::RuntimeException, std::exception)
1974 return cppu::supportsService(this, ServiceName);
1977 css::uno::Sequence< rtl::OUString >
1978 cppuhelper::TypeManager::getSupportedServiceNames()
1979 throw (css::uno::RuntimeException, std::exception)
1981 css::uno::Sequence< rtl::OUString > names(1);
1982 names[0] = "com.sun.star.reflection.TypeDescriptionManager"; //TODO
1983 return names;
1986 css::uno::Any cppuhelper::TypeManager::getByHierarchicalName(
1987 rtl::OUString const & aName)
1988 throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
1990 css::uno::Any desc(find(aName));
1991 if (!desc.hasValue()) {
1992 throw css::container::NoSuchElementException(
1993 aName, static_cast< cppu::OWeakObject * >(this));
1995 return desc;
1998 sal_Bool cppuhelper::TypeManager::hasByHierarchicalName(
1999 rtl::OUString const & aName)
2000 throw (css::uno::RuntimeException, std::exception)
2002 return find(aName).hasValue();
2005 css::uno::Type cppuhelper::TypeManager::getElementType()
2006 throw (css::uno::RuntimeException, std::exception)
2008 return cppu::UnoType< rtl::OUString >::get();
2011 sal_Bool cppuhelper::TypeManager::hasElements()
2012 throw (css::uno::RuntimeException, std::exception)
2014 throw css::uno::RuntimeException(
2015 "TypeManager hasElements: method not supported",
2016 static_cast< cppu::OWeakObject * >(this));
2019 css::uno::Reference< css::container::XEnumeration >
2020 cppuhelper::TypeManager::createEnumeration()
2021 throw (css::uno::RuntimeException, std::exception)
2023 throw css::uno::RuntimeException(
2024 "TypeManager createEnumeration: method not supported",
2025 static_cast< cppu::OWeakObject * >(this));
2028 sal_Bool cppuhelper::TypeManager::has(css::uno::Any const &)
2029 throw (css::uno::RuntimeException, std::exception)
2031 throw css::uno::RuntimeException(
2032 "TypeManager has: method not supported",
2033 static_cast< cppu::OWeakObject * >(this));
2036 void cppuhelper::TypeManager::insert(css::uno::Any const & aElement)
2037 throw (
2038 css::lang::IllegalArgumentException,
2039 css::container::ElementExistException, css::uno::RuntimeException, std::exception)
2041 rtl::OUString uri;
2042 if (!(aElement >>= uri)) {
2043 throw css::lang::IllegalArgumentException(
2044 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
2045 " argument"),
2046 static_cast< cppu::OWeakObject * >(this), 0);
2048 //TODO: check for ElementExistException
2049 //TODO: check for consistency with existing data
2050 readRdbFile(uri, false);
2053 void cppuhelper::TypeManager::remove(css::uno::Any const & aElement)
2054 throw (
2055 css::lang::IllegalArgumentException,
2056 css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
2058 rtl::OUString uri;
2059 if (!(aElement >>= uri)) {
2060 throw css::lang::IllegalArgumentException(
2061 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
2062 " argument"),
2063 static_cast< cppu::OWeakObject * >(this), 0);
2065 //TODO: remove requests are silently ignored for now
2068 css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
2069 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
2070 rtl::OUString const & moduleName,
2071 css::uno::Sequence< css::uno::TypeClass > const & types,
2072 css::reflection::TypeDescriptionSearchDepth depth)
2073 throw (
2074 css::reflection::NoSuchTypeNameException,
2075 css::reflection::InvalidTypeNameException,
2076 css::uno::RuntimeException, std::exception)
2078 rtl::Reference< unoidl::MapCursor > cursor;
2079 try {
2080 cursor = manager_->createCursor(moduleName);
2081 } catch (unoidl::FileFormatException & e) {
2082 throw css::uno::DeploymentException(
2083 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2084 + e.getDetail()),
2085 static_cast< cppu::OWeakObject * >(this));
2087 if (!cursor.is()) {
2088 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2089 // non-module
2090 throw css::reflection::NoSuchTypeNameException(
2091 moduleName, static_cast< cppu::OWeakObject * >(this));
2093 return new Enumeration(
2094 this, makePrefix(moduleName), cursor, types,
2095 depth == css::reflection::TypeDescriptionSearchDepth_INFINITE);
2098 void cppuhelper::TypeManager::readRdbs(rtl::OUString const & uris) {
2099 for (sal_Int32 i = 0; i != -1;) {
2100 rtl::OUString uri(uris.getToken(0, ' ', i));
2101 if (uri.isEmpty()) {
2102 continue;
2104 bool optional;
2105 bool directory;
2106 cppu::decodeRdbUri(&uri, &optional, &directory);
2107 if (directory) {
2108 readRdbDirectory(uri, optional);
2109 } else {
2110 readRdbFile(uri, optional);
2115 void cppuhelper::TypeManager::readRdbDirectory(
2116 rtl::OUString const & uri, bool optional)
2118 osl::Directory dir(uri);
2119 switch (dir.open()) {
2120 case osl::FileBase::E_None:
2121 break;
2122 case osl::FileBase::E_NOENT:
2123 if (optional) {
2124 SAL_INFO("cppuhelper", "Ignored optional " << uri);
2125 return;
2127 // fall through
2128 default:
2129 throw css::uno::DeploymentException(
2130 "Cannot open directory " + uri,
2131 static_cast< cppu::OWeakObject * >(this));
2133 for (;;) {
2134 rtl::OUString url;
2135 if (!cppu::nextDirectoryItem(dir, &url)) {
2136 break;
2138 readRdbFile(url, false);
2142 void cppuhelper::TypeManager::readRdbFile(
2143 rtl::OUString const & uri, bool optional)
2145 try {
2146 manager_->addProvider(uri);
2147 } catch (unoidl::NoSuchFileException &) {
2148 if (!optional) {
2149 throw css::uno::DeploymentException(
2150 uri + ": no such file",
2151 static_cast< cppu::OWeakObject * >(this));
2153 SAL_INFO("cppuhelper", "Ignored optional " << uri);
2154 } catch (unoidl::FileFormatException & e) {
2155 throw css::uno::DeploymentException(
2156 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2157 + e.getDetail()),
2158 static_cast< cppu::OWeakObject * >(this));
2162 css::uno::Any cppuhelper::TypeManager::getSequenceType(
2163 rtl::OUString const & name)
2165 assert(name.startsWith("[]"));
2166 return css::uno::makeAny<
2167 css::uno::Reference< css::reflection::XTypeDescription > >(
2168 new SequenceTypeDescription(
2169 this, name, name.copy(std::strlen("[]"))));
2172 css::uno::Any cppuhelper::TypeManager::getInstantiatedStruct(
2173 rtl::OUString const & name, sal_Int32 separator)
2175 assert(name.indexOf('<') == separator && separator != -1);
2176 rtl::Reference< unoidl::Entity > ent(findEntity(name.copy(0, separator)));
2177 if (!ent.is()
2178 || (ent->getSort()
2179 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE))
2181 return css::uno::Any();
2183 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
2184 static_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
2185 ent.get()));
2186 std::vector< rtl::OUString > args;
2187 sal_Int32 i = separator;
2188 do {
2189 ++i; // skip '<' or ','
2190 sal_Int32 j = i;
2191 for (sal_Int32 level = 0; j != name.getLength(); ++j) {
2192 sal_Unicode c = name[j];
2193 if (c == ',') {
2194 if (level == 0) {
2195 break;
2197 } else if (c == '<') {
2198 ++level;
2199 } else if (c == '>') {
2200 if (level == 0) {
2201 break;
2203 --level;
2206 if (j != name.getLength()) {
2207 args.push_back(name.copy(i, j - i));
2209 i = j;
2210 } while (i != name.getLength() && name[i] != '>');
2211 if (i != name.getLength() - 1 || name[i] != '>'
2212 || args.size() != ent2->getTypeParameters().size())
2214 return css::uno::Any();
2216 return css::uno::makeAny<
2217 css::uno::Reference< css::reflection::XTypeDescription > >(
2218 new InstantiatedPolymorphicStructTypeDescription(
2219 this, name, ent2, args));
2222 css::uno::Any cppuhelper::TypeManager::getInterfaceMember(
2223 rtl::OUString const & name, sal_Int32 separator)
2225 assert(name.indexOf("::") == separator && separator != -1);
2226 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
2227 resolveTypedefs(find(name.copy(0, separator))), css::uno::UNO_QUERY);
2228 if (!ifc.is()) {
2229 return css::uno::Any();
2231 rtl::OUString member(name.copy(separator + std::strlen("::")));
2232 css::uno::Sequence<
2233 css::uno::Reference<
2234 css::reflection::XInterfaceMemberTypeDescription > > mems(
2235 ifc->getMembers());
2236 for (sal_Int32 i = 0; i != mems.getLength(); ++i) {
2237 if (mems[i]->getMemberName() == member) {
2238 return css::uno::makeAny<
2239 css::uno::Reference< css::reflection::XTypeDescription > >(
2240 mems[i]);
2243 return css::uno::Any();
2246 css::uno::Any cppuhelper::TypeManager::getNamed(
2247 rtl::OUString const & name, rtl::Reference< unoidl::Entity > const & entity)
2249 assert(entity.is());
2250 switch (entity->getSort()) {
2251 case unoidl::Entity::SORT_MODULE:
2252 return css::uno::makeAny<
2253 css::uno::Reference< css::reflection::XTypeDescription > >(
2254 new ModuleDescription(
2255 this, name,
2256 static_cast< unoidl::ModuleEntity * >(entity.get())));
2257 case unoidl::Entity::SORT_ENUM_TYPE:
2258 return css::uno::makeAny<
2259 css::uno::Reference< css::reflection::XTypeDescription > >(
2260 new EnumTypeDescription(
2261 name,
2262 static_cast< unoidl::EnumTypeEntity * >(entity.get())));
2263 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
2264 return css::uno::makeAny<
2265 css::uno::Reference< css::reflection::XTypeDescription > >(
2266 new PlainStructTypeDescription(
2267 this, name,
2268 static_cast< unoidl::PlainStructTypeEntity * >(
2269 entity.get())));
2270 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
2271 return css::uno::makeAny<
2272 css::uno::Reference< css::reflection::XTypeDescription > >(
2273 new PolymorphicStructTypeTemplateDescription(
2274 this, name,
2275 static_cast<
2276 unoidl::PolymorphicStructTypeTemplateEntity * >(
2277 entity.get())));
2278 case unoidl::Entity::SORT_EXCEPTION_TYPE:
2279 return css::uno::makeAny<
2280 css::uno::Reference< css::reflection::XTypeDescription > >(
2281 new ExceptionTypeDescription(
2282 this, name,
2283 static_cast< unoidl::ExceptionTypeEntity * >(
2284 entity.get())));
2285 case unoidl::Entity::SORT_INTERFACE_TYPE:
2286 return css::uno::makeAny<
2287 css::uno::Reference< css::reflection::XTypeDescription > >(
2288 new InterfaceTypeDescription(
2289 this, name,
2290 static_cast< unoidl::InterfaceTypeEntity * >(
2291 entity.get())));
2292 case unoidl::Entity::SORT_TYPEDEF:
2293 return css::uno::makeAny<
2294 css::uno::Reference< css::reflection::XTypeDescription > >(
2295 new TypedefDescription(
2296 this, name,
2297 static_cast< unoidl::TypedefEntity * >(entity.get())));
2298 case unoidl::Entity::SORT_CONSTANT_GROUP:
2299 return css::uno::makeAny<
2300 css::uno::Reference< css::reflection::XTypeDescription > >(
2301 new ConstantGroupDescription(
2302 name,
2303 static_cast< unoidl::ConstantGroupEntity * >(
2304 entity.get())));
2305 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
2306 return css::uno::makeAny<
2307 css::uno::Reference< css::reflection::XTypeDescription > >(
2308 new SingleInterfaceBasedServiceDescription(
2309 this, name,
2310 static_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
2311 entity.get())));
2312 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
2313 return css::uno::makeAny<
2314 css::uno::Reference< css::reflection::XTypeDescription > >(
2315 new AccumulationBasedServiceDescription(
2316 this, name,
2317 static_cast< unoidl::AccumulationBasedServiceEntity * >(
2318 entity.get())));
2319 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
2320 return css::uno::makeAny<
2321 css::uno::Reference< css::reflection::XTypeDescription > >(
2322 new InterfaceBasedSingletonDescription(
2323 this, name,
2324 static_cast< unoidl::InterfaceBasedSingletonEntity * >(
2325 entity.get())));
2326 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
2327 return css::uno::makeAny<
2328 css::uno::Reference< css::reflection::XTypeDescription > >(
2329 new ServiceBasedSingletonDescription(
2330 this, name,
2331 static_cast< unoidl::ServiceBasedSingletonEntity * >(
2332 entity.get())));
2333 default:
2334 for (;;) { std::abort(); } // this cannot happen
2338 css::uno::Any cppuhelper::TypeManager::getEnumMember(
2339 rtl::Reference< unoidl::EnumTypeEntity > const & entity,
2340 rtl::OUString const & member)
2342 for (std::vector< unoidl::EnumTypeEntity::Member >::const_iterator i(
2343 entity->getMembers().begin());
2344 i != entity->getMembers().end(); ++i)
2346 if (i->name == member) {
2347 return css::uno::makeAny(i->value);
2350 return css::uno::Any();
2353 css::uno::Any cppuhelper::TypeManager::getConstant(
2354 rtl::OUString const & constantGroupName,
2355 rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
2356 rtl::OUString const & member)
2358 for (std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator i(
2359 entity->getMembers().begin());
2360 i != entity->getMembers().end(); ++i)
2362 if (i->name == member) {
2363 return css::uno::makeAny<
2364 css::uno::Reference< css::reflection::XTypeDescription > >(
2365 new ConstantDescription(constantGroupName, *i));
2368 return css::uno::Any();
2371 rtl::Reference< unoidl::Entity > cppuhelper::TypeManager::findEntity(
2372 rtl::OUString const & name)
2374 try {
2375 return manager_->findEntity(name);
2376 } catch (unoidl::FileFormatException & e) {
2377 throw css::uno::DeploymentException(
2378 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2379 + e.getDetail()),
2380 static_cast< cppu::OWeakObject * >(this));
2384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */