1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <sal/config.h>
20 #include <com/sun/star/container/ElementExistException.hpp>
21 #include <com/sun/star/container/NoSuchElementException.hpp>
22 #include <com/sun/star/lang/IllegalArgumentException.hpp>
23 #include <com/sun/star/reflection/InvalidTypeNameException.hpp>
24 #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
25 #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
26 #include <com/sun/star/reflection/XConstantTypeDescription.hpp>
27 #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
28 #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
29 #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
30 #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
31 #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
32 #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
33 #include <com/sun/star/reflection/XModuleTypeDescription.hpp>
34 #include <com/sun/star/reflection/XPublished.hpp>
35 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
36 #include <com/sun/star/reflection/XSingletonTypeDescription2.hpp>
37 #include <com/sun/star/reflection/XStructTypeDescription.hpp>
38 #include <com/sun/star/reflection/XTypeDescription.hpp>
39 #include <com/sun/star/uno/Any.hxx>
40 #include <com/sun/star/uno/DeploymentException.hpp>
41 #include <com/sun/star/uno/Reference.hxx>
42 #include <com/sun/star/uno/RuntimeException.hpp>
43 #include <com/sun/star/uno/Sequence.hxx>
44 #include <com/sun/star/uno/Type.hxx>
45 #include <com/sun/star/uno/TypeClass.hpp>
46 #include <cppu/unotype.hxx>
47 #include <cppuhelper/implbase1.hxx>
48 #include <cppuhelper/supportsservice.hxx>
49 #include <osl/file.hxx>
50 #include <osl/mutex.hxx>
51 #include <rtl/ref.hxx>
52 #include <rtl/string.h>
53 #include <rtl/ustring.hxx>
54 #include <sal/log.hxx>
55 #include <sal/macros.h>
56 #include <sal/types.h>
60 #include <unoidl/unoidl.hxx>
63 #include "typemanager.hxx"
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
) {
78 t
= css::uno::makeAny(ind
->getReferencedType());
82 class SimpleTypeDescription
:
83 public cppu::WeakImplHelper1
< css::reflection::XTypeDescription
>
86 SimpleTypeDescription(
87 css::uno::TypeClass typeClass
, rtl::OUString
const & name
):
88 typeClass_(typeClass
), name_(name
)
92 virtual ~SimpleTypeDescription() override
{}
94 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
95 throw (css::uno::RuntimeException
, std::exception
) override
96 { return typeClass_
; }
98 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
101 css::uno::TypeClass typeClass_
;
105 class SequenceTypeDescription
:
106 public cppu::WeakImplHelper1
< css::reflection::XIndirectTypeDescription
>
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()); }
116 virtual ~SequenceTypeDescription() override
{}
118 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
119 throw (css::uno::RuntimeException
, std::exception
) override
120 { return css::uno::TypeClass_SEQUENCE
; }
122 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
125 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
126 getReferencedType() throw (css::uno::RuntimeException
, std::exception
) override
127 { return manager_
->resolve(componentType_
); }
129 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
131 rtl::OUString componentType_
;
134 class PublishableDescription
:
135 public cppu::WeakImplHelper1
< css::reflection::XPublished
>
138 explicit PublishableDescription(bool published
): published_(published
) {}
140 virtual ~PublishableDescription() override
{}
143 virtual sal_Bool SAL_CALL
isPublished() throw (css::uno::RuntimeException
, std::exception
) override
144 { return published_
; }
149 class ModuleDescription
:
150 public cppu::WeakImplHelper1
< css::reflection::XModuleTypeDescription
>
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()); }
161 virtual ~ModuleDescription() override
{}
163 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
164 throw (css::uno::RuntimeException
, std::exception
) override
165 { return css::uno::TypeClass_MODULE
; }
167 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
172 css::uno::Reference
< css::reflection::XTypeDescription
> >
173 SAL_CALL
getMembers() throw (css::uno::RuntimeException
, std::exception
) override
;
175 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
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
) {
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());
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
]);
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
{
206 rtl::OUString
const & name
,
207 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
):
208 EnumTypeDescription_Base(entity
->isPublished()), name_(name
),
210 { assert(entity
.is()); }
213 virtual ~EnumTypeDescription() override
{}
215 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
216 throw (css::uno::RuntimeException
, std::exception
) override
217 { return css::uno::TypeClass_ENUM
; }
219 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
222 virtual sal_Int32 SAL_CALL
getDefaultEnumValue()
223 throw (css::uno::RuntimeException
, std::exception
) override
224 { return entity_
->getMembers()[0].value
; }
226 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getEnumNames()
227 throw (css::uno::RuntimeException
, std::exception
) override
;
229 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getEnumValues()
230 throw (css::uno::RuntimeException
, std::exception
) override
;
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
;
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
;
260 typedef cppu::ImplInheritanceHelper1
<
261 PublishableDescription
, css::reflection::XStructTypeDescription
>
262 PlainStructTypeDescription_Base
;
264 class PlainStructTypeDescription
: public PlainStructTypeDescription_Base
{
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()); }
275 virtual ~PlainStructTypeDescription() override
{}
277 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
278 throw (css::uno::RuntimeException
, std::exception
) override
279 { return css::uno::TypeClass_STRUCT
; }
281 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
284 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
285 getBaseType() throw (css::uno::RuntimeException
, std::exception
) override
{
286 return entity_
->getDirectBase().isEmpty()
287 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
288 : manager_
->resolve(entity_
->getDirectBase());
293 css::uno::Reference
< css::reflection::XTypeDescription
> >
294 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
296 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
297 throw (css::uno::RuntimeException
, std::exception
) override
;
299 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getTypeParameters()
300 throw (css::uno::RuntimeException
, std::exception
) override
301 { return css::uno::Sequence
< rtl::OUString
>(); }
305 css::uno::Reference
< css::reflection::XTypeDescription
> >
306 SAL_CALL
getTypeArguments() throw (css::uno::RuntimeException
, std::exception
) override
{
307 return css::uno::Sequence
<
308 css::uno::Reference
< css::reflection::XTypeDescription
> >();
311 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
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());
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
);
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
;
341 class ParameterizedMemberTypeDescription
:
342 public cppu::WeakImplHelper1
< css::reflection::XTypeDescription
>
345 explicit ParameterizedMemberTypeDescription(
346 rtl::OUString
const & typeParameterName
):
347 typeParameterName_(typeParameterName
)
351 virtual ~ParameterizedMemberTypeDescription() override
{}
353 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
354 throw (css::uno::RuntimeException
, std::exception
) override
355 { return css::uno::TypeClass_UNKNOWN
; }
357 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) 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
371 PolymorphicStructTypeTemplateDescription(
372 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
373 rtl::OUString
const & name
,
374 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
376 PolymorphicStructTypeTemplateDescription_Base(entity
->isPublished()),
377 manager_(manager
), name_(name
), entity_(entity
)
378 { assert(manager
.is()); assert(entity
.is()); }
381 virtual ~PolymorphicStructTypeTemplateDescription() override
{}
383 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
384 throw (css::uno::RuntimeException
, std::exception
) override
385 { return css::uno::TypeClass_STRUCT
; }
387 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
390 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
391 getBaseType() throw (css::uno::RuntimeException
, std::exception
) override
392 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
396 css::uno::Reference
< css::reflection::XTypeDescription
> >
397 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
399 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
400 throw (css::uno::RuntimeException
, std::exception
) override
;
402 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getTypeParameters()
403 throw (css::uno::RuntimeException
, std::exception
) override
;
407 css::uno::Reference
< css::reflection::XTypeDescription
> >
408 SAL_CALL
getTypeArguments() throw (css::uno::RuntimeException
, std::exception
) override
{
409 return css::uno::Sequence
<
410 css::uno::Reference
< css::reflection::XTypeDescription
> >();
413 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
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());
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
);
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
;
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
];
461 class InstantiatedPolymorphicStructTypeDescription
:
462 public cppu::WeakImplHelper1
< css::reflection::XStructTypeDescription
>
465 InstantiatedPolymorphicStructTypeDescription(
466 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
467 rtl::OUString
const & name
,
468 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
470 std::vector
< rtl::OUString
> const & arguments
):
471 manager_(manager
), name_(name
), entity_(entity
), arguments_(arguments
)
473 assert(manager
.is());
475 assert(arguments
.size() == entity
->getTypeParameters().size());
479 virtual ~InstantiatedPolymorphicStructTypeDescription() override
{}
481 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
482 throw (css::uno::RuntimeException
, std::exception
) override
483 { return css::uno::TypeClass_STRUCT
; }
485 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
488 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
489 getBaseType() throw (css::uno::RuntimeException
, std::exception
) override
490 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
494 css::uno::Reference
< css::reflection::XTypeDescription
> >
495 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
497 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
498 throw (css::uno::RuntimeException
, std::exception
) override
;
500 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getTypeParameters()
501 throw (css::uno::RuntimeException
, std::exception
) override
502 { return css::uno::Sequence
< rtl::OUString
>(); }
506 css::uno::Reference
< css::reflection::XTypeDescription
> >
507 SAL_CALL
getTypeArguments() throw (css::uno::RuntimeException
, std::exception
) override
;
509 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
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());
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
)
531 type
= arguments_
[j
- entity_
->getTypeParameters().begin()];
535 assert(false); // this cannot happen //TODO!
538 s
[i
] = manager_
->resolve(type
);
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
;
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());
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
]);
569 typedef cppu::ImplInheritanceHelper1
<
570 PublishableDescription
, css::reflection::XCompoundTypeDescription
>
571 ExceptionTypeDescription_Base
;
573 class ExceptionTypeDescription
: public ExceptionTypeDescription_Base
{
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()); }
584 virtual ~ExceptionTypeDescription() override
{}
586 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
587 throw (css::uno::RuntimeException
, std::exception
) override
588 { return css::uno::TypeClass_EXCEPTION
; }
590 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
593 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
594 getBaseType() throw (css::uno::RuntimeException
, std::exception
) override
{
595 return entity_
->getDirectBase().isEmpty()
596 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
597 : manager_
->resolve(entity_
->getDirectBase());
602 css::uno::Reference
< css::reflection::XTypeDescription
> >
603 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
605 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
606 throw (css::uno::RuntimeException
, std::exception
) override
;
608 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
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());
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
);
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
;
637 class AttributeDescription
:
638 public cppu::WeakImplHelper1
<
639 css::reflection::XInterfaceAttributeTypeDescription2
>
642 AttributeDescription(
643 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
644 rtl::OUString
const & name
,
645 unoidl::InterfaceTypeEntity::Attribute
const & attribute
,
647 manager_(manager
), name_(name
), attribute_(attribute
),
649 { assert(manager
.is()); }
652 virtual ~AttributeDescription() override
{}
654 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
655 throw (css::uno::RuntimeException
, std::exception
) override
656 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE
; }
658 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
661 virtual rtl::OUString SAL_CALL
getMemberName()
662 throw (css::uno::RuntimeException
, std::exception
) override
663 { return attribute_
.name
; }
665 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) override
666 { return position_
; }
668 virtual sal_Bool SAL_CALL
isReadOnly() throw (css::uno::RuntimeException
, std::exception
) override
669 { return attribute_
.readOnly
; }
671 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
672 getType() throw (css::uno::RuntimeException
, std::exception
) override
673 { return manager_
->resolve(attribute_
.type
); }
675 virtual sal_Bool SAL_CALL
isBound() throw (css::uno::RuntimeException
, std::exception
) override
676 { return attribute_
.bound
; }
680 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
681 SAL_CALL
getGetExceptions() throw (css::uno::RuntimeException
, std::exception
) override
;
685 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
686 SAL_CALL
getSetExceptions() throw (css::uno::RuntimeException
, std::exception
) override
;
688 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
690 unoidl::InterfaceTypeEntity::Attribute attribute_
;
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());
700 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
701 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
703 manager_
->resolve(attribute_
.getExceptions
[i
]),
704 css::uno::UNO_QUERY_THROW
);
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());
715 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
716 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
718 manager_
->resolve(attribute_
.setExceptions
[i
]),
719 css::uno::UNO_QUERY_THROW
);
724 class MethodParameter
:
725 public cppu::WeakImplHelper1
< css::reflection::XMethodParameter
>
729 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
730 unoidl::InterfaceTypeEntity::Method::Parameter
const & parameter
,
732 manager_(manager
), parameter_(parameter
), position_(position
)
733 { assert(manager
.is()); }
736 virtual ~MethodParameter() override
{}
738 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
739 { return parameter_
.name
; }
741 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
742 getType() throw (css::uno::RuntimeException
, std::exception
) override
743 { return manager_
->resolve(parameter_
.type
); }
745 virtual sal_Bool SAL_CALL
isIn() throw (css::uno::RuntimeException
, std::exception
) override
{
747 (parameter_
.direction
748 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
749 || (parameter_
.direction
750 == unoidl::InterfaceTypeEntity::Method::Parameter::
754 virtual sal_Bool SAL_CALL
isOut() throw (css::uno::RuntimeException
, std::exception
) override
{
756 (parameter_
.direction
757 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
)
758 || (parameter_
.direction
759 == unoidl::InterfaceTypeEntity::Method::Parameter::
763 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) override
764 { return position_
; }
766 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
767 unoidl::InterfaceTypeEntity::Method::Parameter parameter_
;
771 class MethodDescription
:
772 public cppu::WeakImplHelper1
<
773 css::reflection::XInterfaceMethodTypeDescription
>
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()); }
784 virtual ~MethodDescription() override
{}
786 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
787 throw (css::uno::RuntimeException
, std::exception
) override
788 { return css::uno::TypeClass_INTERFACE_METHOD
; }
790 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
793 virtual rtl::OUString SAL_CALL
getMemberName()
794 throw (css::uno::RuntimeException
, std::exception
) override
795 { return method_
.name
; }
797 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) override
798 { return position_
; }
800 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
801 getReturnType() throw (css::uno::RuntimeException
, std::exception
) override
802 { return manager_
->resolve(method_
.returnType
); }
804 virtual sal_Bool SAL_CALL
isOneway() throw (css::uno::RuntimeException
, std::exception
) override
809 css::uno::Reference
< css::reflection::XMethodParameter
> >
810 SAL_CALL
getParameters() throw (css::uno::RuntimeException
, std::exception
) override
;
814 css::uno::Reference
< css::reflection::XTypeDescription
> >
815 SAL_CALL
getExceptions() throw (css::uno::RuntimeException
, std::exception
) override
;
817 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
819 unoidl::InterfaceTypeEntity::Method method_
;
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());
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
);
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());
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
]);
850 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
851 const & description
);
853 BaseOffset(const BaseOffset
&) = delete;
854 const BaseOffset
& operator=(const BaseOffset
&) = delete;
856 sal_Int32
get() const { return offset_
; }
860 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
861 const & description
);
864 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
865 const & description
);
867 std::set
< rtl::OUString
> set_
;
871 BaseOffset::BaseOffset(
872 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
876 calculateBases(description
);
879 void BaseOffset::calculateBases(
880 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
884 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
885 description
->getBaseTypes());
886 for (sal_Int32 i
= 0; i
!= bases
.getLength(); ++i
) {
888 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
889 resolveTypedefs(css::uno::makeAny(bases
[i
])),
890 css::uno::UNO_QUERY_THROW
));
894 void BaseOffset::calculate(
895 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
898 if (set_
.insert(description
->getName()).second
) {
899 calculateBases(description
);
900 offset_
+= description
->getMembers().getLength();
904 typedef cppu::ImplInheritanceHelper1
<
905 PublishableDescription
, css::reflection::XInterfaceTypeDescription2
>
906 InterfaceTypeDescription_Base
;
908 class InterfaceTypeDescription
: public InterfaceTypeDescription_Base
{
910 InterfaceTypeDescription(
911 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
912 rtl::OUString
const & name
,
913 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
914 InterfaceTypeDescription_Base(entity
->isPublished()), manager_(manager
),
915 name_(name
), entity_(entity
)
916 { assert(manager
.is()); assert(entity
.is()); }
919 virtual ~InterfaceTypeDescription() override
{}
921 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
922 throw (css::uno::RuntimeException
, std::exception
) override
923 { return css::uno::TypeClass_INTERFACE
; }
925 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
928 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
929 getBaseType() throw (css::uno::RuntimeException
, std::exception
) override
{
930 return entity_
->getDirectMandatoryBases().empty()
931 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
932 : manager_
->resolve(entity_
->getDirectMandatoryBases()[0].name
);
935 virtual css::uno::Uik SAL_CALL
getUik() throw (css::uno::RuntimeException
, std::exception
) override
936 { return css::uno::Uik(); }
941 css::reflection::XInterfaceMemberTypeDescription
> >
942 SAL_CALL
getMembers() throw (css::uno::RuntimeException
, std::exception
) override
;
946 css::uno::Reference
< css::reflection::XTypeDescription
> >
947 SAL_CALL
getBaseTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
951 css::uno::Reference
< css::reflection::XTypeDescription
> >
952 SAL_CALL
getOptionalBaseTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
954 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
956 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
960 css::uno::Reference
< css::reflection::XInterfaceMemberTypeDescription
> >
961 InterfaceTypeDescription::getMembers() throw (css::uno::RuntimeException
, std::exception
) {
963 entity_
->getDirectAttributes().size() <= SAL_MAX_INT32
964 && (entity_
->getDirectMethods().size()
965 <= SAL_MAX_INT32
- entity_
->getDirectAttributes().size()));
966 sal_Int32 n1
= static_cast< sal_Int32
>(
967 entity_
->getDirectAttributes().size());
968 sal_Int32 n2
= static_cast< sal_Int32
>(entity_
->getDirectMethods().size());
971 css::reflection::XInterfaceMemberTypeDescription
> > s(n1
+ n2
);
972 sal_Int32 off
= BaseOffset(this).get();
973 for (sal_Int32 i
= 0; i
!= n1
; ++i
) {
974 s
[i
] = new AttributeDescription(
975 manager_
, name_
+ "::" + entity_
->getDirectAttributes()[i
].name
,
976 entity_
->getDirectAttributes()[i
], off
+ i
);
978 for (sal_Int32 i
= 0; i
!= n2
; ++i
) {
979 s
[n1
+ i
] = new MethodDescription(
980 manager_
, name_
+ "::" + entity_
->getDirectMethods()[i
].name
,
981 entity_
->getDirectMethods()[i
], off
+ n1
+ i
);
986 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
987 InterfaceTypeDescription::getBaseTypes() throw (css::uno::RuntimeException
, std::exception
) {
988 assert(entity_
->getDirectMandatoryBases().size() <= SAL_MAX_INT32
);
989 sal_Int32 n
= static_cast< sal_Int32
>(
990 entity_
->getDirectMandatoryBases().size());
992 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
993 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
994 s
[i
] = manager_
->resolve(entity_
->getDirectMandatoryBases()[i
].name
);
999 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
1000 InterfaceTypeDescription::getOptionalBaseTypes()
1001 throw (css::uno::RuntimeException
, std::exception
)
1003 assert(entity_
->getDirectOptionalBases().size() <= SAL_MAX_INT32
);
1004 sal_Int32 n
= static_cast< sal_Int32
>(
1005 entity_
->getDirectOptionalBases().size());
1007 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
1008 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1009 s
[i
] = manager_
->resolve(entity_
->getDirectOptionalBases()[i
].name
);
1014 class ConstantDescription
:
1015 public cppu::WeakImplHelper1
< css::reflection::XConstantTypeDescription
>
1018 ConstantDescription(
1019 rtl::OUString
const & constantGroupName
,
1020 unoidl::ConstantGroupEntity::Member
const & member
);
1023 virtual ~ConstantDescription() override
{}
1025 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1026 throw (css::uno::RuntimeException
, std::exception
) override
1027 { return css::uno::TypeClass_CONSTANT
; }
1029 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1032 virtual css::uno::Any SAL_CALL
getConstantValue()
1033 throw (css::uno::RuntimeException
, std::exception
) override
1036 rtl::OUString name_
;
1037 css::uno::Any value_
;
1040 ConstantDescription::ConstantDescription(
1041 rtl::OUString
const & constantGroupName
,
1042 unoidl::ConstantGroupEntity::Member
const & member
):
1043 name_(makePrefix(constantGroupName
) + member
.name
)
1045 switch (member
.value
.type
) {
1046 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1047 value_
<<= member
.value
.booleanValue
;
1049 case unoidl::ConstantValue::TYPE_BYTE
:
1050 value_
<<= member
.value
.byteValue
;
1052 case unoidl::ConstantValue::TYPE_SHORT
:
1053 value_
<<= member
.value
.shortValue
;
1055 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1056 value_
<<= member
.value
.unsignedShortValue
;
1058 case unoidl::ConstantValue::TYPE_LONG
:
1059 value_
<<= member
.value
.longValue
;
1061 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1062 value_
<<= member
.value
.unsignedLongValue
;
1064 case unoidl::ConstantValue::TYPE_HYPER
:
1065 value_
<<= member
.value
.hyperValue
;
1067 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1068 value_
<<= member
.value
.unsignedHyperValue
;
1070 case unoidl::ConstantValue::TYPE_FLOAT
:
1071 value_
<<= member
.value
.floatValue
;
1073 case unoidl::ConstantValue::TYPE_DOUBLE
:
1074 value_
<<= member
.value
.doubleValue
;
1077 for (;;) { std::abort(); } // this cannot happen
1081 typedef cppu::ImplInheritanceHelper1
<
1082 PublishableDescription
, css::reflection::XConstantsTypeDescription
>
1083 ConstantGroupDescription_Base
;
1085 class ConstantGroupDescription
: public ConstantGroupDescription_Base
{
1087 ConstantGroupDescription(
1088 rtl::OUString
const & name
,
1089 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
):
1090 ConstantGroupDescription_Base(entity
->isPublished()), name_(name
),
1092 { assert(entity
.is()); }
1095 virtual ~ConstantGroupDescription() override
{}
1097 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1098 throw (css::uno::RuntimeException
, std::exception
) override
1099 { return css::uno::TypeClass_CONSTANTS
; }
1101 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1106 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1107 SAL_CALL
getConstants() throw (css::uno::RuntimeException
, std::exception
) override
;
1109 rtl::OUString name_
;
1110 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1114 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1115 ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException
, std::exception
) {
1116 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
1117 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
1119 css::uno::Reference
< css::reflection::XConstantTypeDescription
> > s(n
);
1120 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1121 s
[i
] = new ConstantDescription(name_
, entity_
->getMembers()[i
]);
1126 typedef cppu::ImplInheritanceHelper1
<
1127 PublishableDescription
, css::reflection::XIndirectTypeDescription
>
1128 TypedefDescription_Base
;
1130 class TypedefDescription
: public TypedefDescription_Base
{
1133 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1134 rtl::OUString
const & name
,
1135 rtl::Reference
< unoidl::TypedefEntity
> const & entity
):
1136 TypedefDescription_Base(entity
->isPublished()), manager_(manager
),
1137 name_(name
), entity_(entity
)
1138 { assert(manager
.is()); assert(entity
.is()); }
1141 virtual ~TypedefDescription() override
{}
1143 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1144 throw (css::uno::RuntimeException
, std::exception
) override
1145 { return css::uno::TypeClass_TYPEDEF
; }
1147 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1150 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1151 getReferencedType() throw (css::uno::RuntimeException
, std::exception
) override
1152 { return manager_
->resolve(entity_
->getType()); }
1154 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1155 rtl::OUString name_
;
1156 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
1159 class ConstructorParameter
:
1160 public cppu::WeakImplHelper1
< css::reflection::XParameter
>
1163 ConstructorParameter(
1164 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1165 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1167 sal_Int32 position
):
1168 manager_(manager
), parameter_(parameter
), position_(position
)
1169 { assert(manager
.is()); }
1172 virtual ~ConstructorParameter() override
{}
1174 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1175 { return parameter_
.name
; }
1177 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1178 getType() throw (css::uno::RuntimeException
, std::exception
) override
1179 { return manager_
->resolve(parameter_
.type
); }
1181 virtual sal_Bool SAL_CALL
isIn() throw (css::uno::RuntimeException
, std::exception
) override
1184 virtual sal_Bool SAL_CALL
isOut() throw (css::uno::RuntimeException
, std::exception
) override
1187 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) override
1188 { return position_
; }
1190 virtual sal_Bool SAL_CALL
isRestParameter()
1191 throw (css::uno::RuntimeException
, std::exception
) override
1192 { return parameter_
.rest
; }
1194 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1195 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1197 sal_Int32 position_
;
1200 class ConstructorDescription
:
1201 public cppu::WeakImplHelper1
<
1202 css::reflection::XServiceConstructorDescription
>
1205 ConstructorDescription(
1206 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1207 unoidl::SingleInterfaceBasedServiceEntity::Constructor
const &
1209 manager_(manager
), constructor_(constructor
)
1210 { assert(manager
.is()); }
1213 virtual ~ConstructorDescription() override
{}
1215 virtual sal_Bool SAL_CALL
isDefaultConstructor()
1216 throw (css::uno::RuntimeException
, std::exception
) override
1217 { return constructor_
.defaultConstructor
; }
1219 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1220 { return constructor_
.name
; }
1224 css::uno::Reference
< css::reflection::XParameter
> >
1225 SAL_CALL
getParameters() throw (css::uno::RuntimeException
, std::exception
) override
;
1229 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1230 SAL_CALL
getExceptions() throw (css::uno::RuntimeException
, std::exception
) override
;
1232 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1233 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_
;
1236 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> >
1237 ConstructorDescription::getParameters() throw (css::uno::RuntimeException
, std::exception
) {
1238 assert(constructor_
.parameters
.size() <= SAL_MAX_INT32
);
1239 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.parameters
.size());
1240 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> > s(
1242 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1243 s
[i
] = new ConstructorParameter(
1244 manager_
, constructor_
.parameters
[i
], i
);
1250 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1251 ConstructorDescription::getExceptions() throw (css::uno::RuntimeException
, std::exception
) {
1252 assert(constructor_
.exceptions
.size() <= SAL_MAX_INT32
);
1253 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.exceptions
.size());
1255 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
1256 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1258 manager_
->resolve(constructor_
.exceptions
[i
]),
1259 css::uno::UNO_QUERY_THROW
);
1264 typedef cppu::ImplInheritanceHelper1
<
1265 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1266 SingleInterfaceBasedServiceDescription_Base
;
1268 class SingleInterfaceBasedServiceDescription
:
1269 public SingleInterfaceBasedServiceDescription_Base
1272 SingleInterfaceBasedServiceDescription(
1273 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1274 rtl::OUString
const & name
,
1275 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
1277 SingleInterfaceBasedServiceDescription_Base(entity
->isPublished()),
1278 manager_(manager
), name_(name
), entity_(entity
)
1279 { assert(manager
.is()); assert(entity
.is()); }
1282 virtual ~SingleInterfaceBasedServiceDescription() override
{}
1284 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1285 throw (css::uno::RuntimeException
, std::exception
) override
1286 { return css::uno::TypeClass_SERVICE
; }
1288 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1293 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1294 SAL_CALL
getMandatoryServices() throw (css::uno::RuntimeException
, std::exception
) override
1296 return css::uno::Sequence
<
1297 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1302 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1303 SAL_CALL
getOptionalServices() throw (css::uno::RuntimeException
, std::exception
) override
1305 return css::uno::Sequence
<
1306 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1311 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1312 SAL_CALL
getMandatoryInterfaces() throw (css::uno::RuntimeException
, std::exception
) override
1314 return css::uno::Sequence
<
1315 css::uno::Reference
<
1316 css::reflection::XInterfaceTypeDescription
> >();
1321 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1322 SAL_CALL
getOptionalInterfaces() throw (css::uno::RuntimeException
, std::exception
) override
1324 return css::uno::Sequence
<
1325 css::uno::Reference
<
1326 css::reflection::XInterfaceTypeDescription
> >();
1331 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1332 SAL_CALL
getProperties() throw (css::uno::RuntimeException
, std::exception
) override
1334 return css::uno::Sequence
<
1335 css::uno::Reference
<
1336 css::reflection::XPropertyTypeDescription
> >();
1339 virtual sal_Bool SAL_CALL
isSingleInterfaceBased()
1340 throw (css::uno::RuntimeException
, std::exception
) override
1343 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1344 getInterface() throw (css::uno::RuntimeException
, std::exception
) override
1345 { return manager_
->resolve(entity_
->getBase()); }
1349 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1350 SAL_CALL
getConstructors() throw (css::uno::RuntimeException
, std::exception
) override
;
1352 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1353 rtl::OUString name_
;
1354 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> entity_
;
1358 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1359 SingleInterfaceBasedServiceDescription::getConstructors()
1360 throw (css::uno::RuntimeException
, std::exception
)
1362 assert(entity_
->getConstructors().size() <= SAL_MAX_INT32
);
1363 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getConstructors().size());
1365 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1367 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1368 s
[i
] = new ConstructorDescription(
1369 manager_
, entity_
->getConstructors()[i
]);
1374 class PropertyDescription
:
1375 public cppu::WeakImplHelper1
< css::reflection::XPropertyTypeDescription
>
1378 PropertyDescription(
1379 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1380 unoidl::AccumulationBasedServiceEntity::Property
const & property
):
1381 manager_(manager
), property_(property
)
1382 { assert(manager
.is()); }
1385 virtual ~PropertyDescription() override
{}
1387 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1388 throw (css::uno::RuntimeException
, std::exception
) override
1389 { return css::uno::TypeClass_PROPERTY
; }
1391 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1392 { return property_
.name
; }
1394 virtual sal_Int16 SAL_CALL
getPropertyFlags()
1395 throw (css::uno::RuntimeException
, std::exception
) override
1396 { return property_
.attributes
; }
1398 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1399 getPropertyTypeDescription() throw (css::uno::RuntimeException
, std::exception
) override
1400 { return manager_
->resolve(property_
.type
); }
1402 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1403 unoidl::AccumulationBasedServiceEntity::Property property_
;
1406 typedef cppu::ImplInheritanceHelper1
<
1407 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1408 AccumulationBasedServiceDescription_Base
;
1410 class AccumulationBasedServiceDescription
:
1411 public AccumulationBasedServiceDescription_Base
1414 AccumulationBasedServiceDescription(
1415 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1416 rtl::OUString
const & name
,
1417 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const &
1419 AccumulationBasedServiceDescription_Base(entity
->isPublished()),
1420 manager_(manager
), name_(name
), entity_(entity
)
1421 { assert(manager
.is()); assert(entity
.is()); }
1424 virtual ~AccumulationBasedServiceDescription() override
{}
1426 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1427 throw (css::uno::RuntimeException
, std::exception
) override
1428 { return css::uno::TypeClass_SERVICE
; }
1430 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1435 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1436 SAL_CALL
getMandatoryServices() throw (css::uno::RuntimeException
, std::exception
) override
;
1440 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1441 SAL_CALL
getOptionalServices() throw (css::uno::RuntimeException
, std::exception
) override
;
1445 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1446 SAL_CALL
getMandatoryInterfaces() throw (css::uno::RuntimeException
, std::exception
) override
;
1450 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1451 SAL_CALL
getOptionalInterfaces() throw (css::uno::RuntimeException
, std::exception
) override
;
1455 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1456 SAL_CALL
getProperties() throw (css::uno::RuntimeException
, std::exception
) override
;
1458 virtual sal_Bool SAL_CALL
isSingleInterfaceBased()
1459 throw (css::uno::RuntimeException
, std::exception
) override
1462 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1463 getInterface() throw (css::uno::RuntimeException
, std::exception
) override
1464 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1468 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1469 SAL_CALL
getConstructors() throw (css::uno::RuntimeException
, std::exception
) override
1471 return css::uno::Sequence
<
1472 css::uno::Reference
<
1473 css::reflection::XServiceConstructorDescription
> >();
1476 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1477 rtl::OUString name_
;
1478 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> entity_
;
1482 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1483 AccumulationBasedServiceDescription::getMandatoryServices()
1484 throw (css::uno::RuntimeException
, std::exception
)
1486 assert(entity_
->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32
);
1487 sal_Int32 n
= static_cast< sal_Int32
>(
1488 entity_
->getDirectMandatoryBaseServices().size());
1490 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1491 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1494 entity_
->getDirectMandatoryBaseServices()[i
].name
),
1495 css::uno::UNO_QUERY_THROW
);
1501 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1502 AccumulationBasedServiceDescription::getOptionalServices()
1503 throw (css::uno::RuntimeException
, std::exception
)
1505 assert(entity_
->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32
);
1506 sal_Int32 n
= static_cast< sal_Int32
>(
1507 entity_
->getDirectOptionalBaseServices().size());
1509 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1510 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1512 manager_
->resolve(entity_
->getDirectOptionalBaseServices()[i
].name
),
1513 css::uno::UNO_QUERY_THROW
);
1519 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1520 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1521 throw (css::uno::RuntimeException
, std::exception
)
1523 assert(entity_
->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32
);
1524 sal_Int32 n
= static_cast< sal_Int32
>(
1525 entity_
->getDirectMandatoryBaseInterfaces().size());
1527 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1529 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1533 entity_
->getDirectMandatoryBaseInterfaces()[i
].name
)),
1534 css::uno::UNO_QUERY_THROW
);
1540 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1541 AccumulationBasedServiceDescription::getOptionalInterfaces()
1542 throw (css::uno::RuntimeException
, std::exception
)
1544 assert(entity_
->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32
);
1545 sal_Int32 n
= static_cast< sal_Int32
>(
1546 entity_
->getDirectOptionalBaseInterfaces().size());
1548 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1550 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1554 entity_
->getDirectOptionalBaseInterfaces()[i
].name
)),
1555 css::uno::UNO_QUERY_THROW
);
1561 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1562 AccumulationBasedServiceDescription::getProperties()
1563 throw (css::uno::RuntimeException
, std::exception
)
1565 assert(entity_
->getDirectProperties().size() <= SAL_MAX_INT32
);
1566 sal_Int32 n
= static_cast< sal_Int32
>(
1567 entity_
->getDirectProperties().size());
1569 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> > s(n
);
1570 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1571 s
[i
] = new PropertyDescription(
1572 manager_
, entity_
->getDirectProperties()[i
]);
1577 typedef cppu::ImplInheritanceHelper1
<
1578 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1579 InterfaceBasedSingletonDescription_Base
;
1581 class InterfaceBasedSingletonDescription
:
1582 public InterfaceBasedSingletonDescription_Base
1585 InterfaceBasedSingletonDescription(
1586 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1587 rtl::OUString
const & name
,
1588 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
):
1589 InterfaceBasedSingletonDescription_Base(entity
->isPublished()),
1590 manager_(manager
), name_(name
), entity_(entity
)
1591 { assert(manager
.is()); assert(entity
.is()); }
1594 virtual ~InterfaceBasedSingletonDescription() override
{}
1596 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1597 throw (css::uno::RuntimeException
, std::exception
) override
1598 { return css::uno::TypeClass_SINGLETON
; }
1600 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1603 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1604 SAL_CALL
getService() throw (css::uno::RuntimeException
, std::exception
) override
1607 css::uno::Reference
< css::reflection::XServiceTypeDescription
>();
1610 virtual sal_Bool SAL_CALL
isInterfaceBased()
1611 throw (css::uno::RuntimeException
, std::exception
) override
1614 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1615 SAL_CALL
getInterface() throw (css::uno::RuntimeException
, std::exception
) override
1616 { return manager_
->resolve(entity_
->getBase()); }
1618 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1619 rtl::OUString name_
;
1620 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> entity_
;
1623 typedef cppu::ImplInheritanceHelper1
<
1624 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1625 ServiceBasedSingletonDescription_Base
;
1627 class ServiceBasedSingletonDescription
:
1628 public ServiceBasedSingletonDescription_Base
1631 ServiceBasedSingletonDescription(
1632 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1633 rtl::OUString
const & name
,
1634 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> const & entity
):
1635 ServiceBasedSingletonDescription_Base(entity_
->isPublished()),
1636 manager_(manager
), name_(name
), entity_(entity
)
1637 { assert(manager
.is()); assert(entity
.is()); }
1640 virtual ~ServiceBasedSingletonDescription() override
{}
1642 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1643 throw (css::uno::RuntimeException
, std::exception
) override
1644 { return css::uno::TypeClass_SINGLETON
; }
1646 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) override
1649 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1650 SAL_CALL
getService() throw (css::uno::RuntimeException
, std::exception
) override
1652 return css::uno::Reference
< css::reflection::XServiceTypeDescription
>(
1653 manager_
->resolve(entity_
->getBase()), css::uno::UNO_QUERY_THROW
);
1656 virtual sal_Bool SAL_CALL
isInterfaceBased()
1657 throw (css::uno::RuntimeException
, std::exception
) override
1660 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1661 SAL_CALL
getInterface() throw (css::uno::RuntimeException
, std::exception
) override
1662 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1664 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1665 rtl::OUString name_
;
1666 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> entity_
;
1670 public cppu::WeakImplHelper1
< css::reflection::XTypeDescriptionEnumeration
>
1674 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1675 rtl::OUString
const & prefix
,
1676 rtl::Reference
< unoidl::MapCursor
> const & cursor
,
1677 css::uno::Sequence
< css::uno::TypeClass
> const & types
, bool deep
):
1678 manager_(manager
), types_(types
), deep_(deep
)
1680 assert(manager
.is());
1681 positions_
.push(Position(prefix
, cursor
));
1686 virtual ~Enumeration() override
{}
1688 virtual sal_Bool SAL_CALL
hasMoreElements()
1689 throw (css::uno::RuntimeException
, std::exception
) override
1690 { return !positions_
.empty(); }
1692 virtual css::uno::Any SAL_CALL
nextElement()
1694 css::container::NoSuchElementException
,
1695 css::lang::WrappedTargetException
, css::uno::RuntimeException
, std::exception
) override
1696 { return css::uno::makeAny(nextTypeDescription()); }
1698 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1699 nextTypeDescription()
1701 css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
) override
;
1703 bool matches(css::uno::TypeClass tc
) const;
1705 void findNextMatch();
1709 rtl::OUString
const & thePrefix
,
1710 rtl::Reference
< unoidl::MapCursor
> const & theCursor
):
1711 prefix(thePrefix
), cursor(theCursor
)
1712 { assert(theCursor
.is()); }
1715 rtl::OUString
const & thePrefix
,
1716 rtl::Reference
< unoidl::ConstantGroupEntity
> const &
1718 prefix(thePrefix
), constantGroup(theConstantGroup
),
1719 constantGroupIndex(constantGroup
->getMembers().begin())
1720 { assert(theConstantGroup
.is()); }
1722 Position(Position
const & other
):
1723 prefix(other
.prefix
), cursor(other
.cursor
),
1724 constantGroup(other
.constantGroup
)
1726 if (constantGroup
.is()) {
1727 constantGroupIndex
= other
.constantGroupIndex
;
1731 rtl::OUString prefix
;
1732 rtl::Reference
< unoidl::MapCursor
> cursor
;
1733 rtl::Reference
< unoidl::ConstantGroupEntity
> constantGroup
;
1734 std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
1738 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1739 css::uno::Sequence
< css::uno::TypeClass
> types_
;
1743 std::stack
< Position
> positions_
;
1744 rtl::OUString current_
;
1747 css::uno::Reference
< css::reflection::XTypeDescription
>
1748 Enumeration::nextTypeDescription()
1749 throw (css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
)
1753 osl::MutexGuard
g(mutex_
);
1754 if (positions_
.empty()) {
1755 throw css::container::NoSuchElementException(
1756 "exhausted XTypeDescriptionEnumeration",
1757 static_cast< cppu::OWeakObject
* >(this));
1762 return manager_
->resolve(name
);
1765 bool Enumeration::matches(css::uno::TypeClass tc
) const {
1766 if (types_
.getLength() == 0) {
1769 for (sal_Int32 i
= 0; i
!= types_
.getLength(); ++i
) {
1770 if (types_
[i
] == tc
) {
1777 void Enumeration::findNextMatch() {
1780 assert(!positions_
.empty());
1782 if (positions_
.top().cursor
.is()) { // root or module
1783 rtl::Reference
< unoidl::Entity
> ent(
1784 positions_
.top().cursor
->getNext(&name
));
1787 if (positions_
.empty()) {
1792 name
= positions_
.top().prefix
+ name
;
1793 css::uno::TypeClass tc
;
1794 switch (ent
->getSort()) {
1795 case unoidl::Entity::SORT_MODULE
:
1796 tc
= css::uno::TypeClass_MODULE
;
1801 static_cast< unoidl::ModuleEntity
* >(
1802 ent
.get())->createCursor()));
1805 case unoidl::Entity::SORT_ENUM_TYPE
:
1806 tc
= css::uno::TypeClass_ENUM
;
1808 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
1809 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
1810 tc
= css::uno::TypeClass_STRUCT
;
1812 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
1813 tc
= css::uno::TypeClass_EXCEPTION
;
1815 case unoidl::Entity::SORT_INTERFACE_TYPE
:
1816 tc
= css::uno::TypeClass_INTERFACE
;
1818 case unoidl::Entity::SORT_TYPEDEF
:
1819 tc
= css::uno::TypeClass_TYPEDEF
;
1821 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1822 tc
= css::uno::TypeClass_CONSTANTS
;
1823 if (deep_
&& matches(css::uno::TypeClass_CONSTANT
)) {
1827 static_cast< unoidl::ConstantGroupEntity
* >(
1831 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
1832 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
1833 tc
= css::uno::TypeClass_SERVICE
;
1835 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
1836 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
1837 tc
= css::uno::TypeClass_SINGLETON
;
1840 for (;;) { std::abort(); } // this cannot happen
1846 } else { // constant group
1847 if (positions_
.top().constantGroupIndex
1848 == positions_
.top().constantGroup
->getMembers().end())
1851 if (positions_
.empty()) {
1856 current_
= positions_
.top().prefix
1857 + positions_
.top().constantGroupIndex
++->name
;
1861 } catch (unoidl::FileFormatException
& e
) {
1862 throw css::uno::DeploymentException(
1863 e
.getUri() + ": " + e
.getDetail(),
1864 static_cast< cppu::OWeakObject
* >(this));
1870 cppuhelper::TypeManager::TypeManager():
1871 TypeManager_Base(m_aMutex
),
1872 manager_(new unoidl::Manager
)
1875 css::uno::Any
cppuhelper::TypeManager::find(rtl::OUString
const & name
) {
1876 //TODO: caching? (here or in unoidl::Manager?)
1878 char const * name
; sal_Int32 length
;
1879 css::uno::TypeClass typeClass
;
1881 static Simple
const simple
[] = {
1882 { RTL_CONSTASCII_STRINGPARAM("void"), css::uno::TypeClass_VOID
},
1883 { RTL_CONSTASCII_STRINGPARAM("boolean"), css::uno::TypeClass_BOOLEAN
},
1884 { RTL_CONSTASCII_STRINGPARAM("byte"), css::uno::TypeClass_BYTE
},
1885 { RTL_CONSTASCII_STRINGPARAM("short"), css::uno::TypeClass_SHORT
},
1886 { RTL_CONSTASCII_STRINGPARAM("unsigned short"),
1887 css::uno::TypeClass_UNSIGNED_SHORT
},
1888 { RTL_CONSTASCII_STRINGPARAM("long"), css::uno::TypeClass_LONG
},
1889 { RTL_CONSTASCII_STRINGPARAM("unsigned long"),
1890 css::uno::TypeClass_UNSIGNED_LONG
},
1891 { RTL_CONSTASCII_STRINGPARAM("hyper"), css::uno::TypeClass_HYPER
},
1892 { RTL_CONSTASCII_STRINGPARAM("unsigned hyper"),
1893 css::uno::TypeClass_UNSIGNED_HYPER
},
1894 { RTL_CONSTASCII_STRINGPARAM("float"), css::uno::TypeClass_FLOAT
},
1895 { RTL_CONSTASCII_STRINGPARAM("double"), css::uno::TypeClass_DOUBLE
},
1896 { RTL_CONSTASCII_STRINGPARAM("char"), css::uno::TypeClass_CHAR
},
1897 { RTL_CONSTASCII_STRINGPARAM("string"), css::uno::TypeClass_STRING
},
1898 { RTL_CONSTASCII_STRINGPARAM("type"), css::uno::TypeClass_TYPE
},
1899 { RTL_CONSTASCII_STRINGPARAM("any"), css::uno::TypeClass_ANY
} };
1900 for (std::size_t i
= 0; i
!= SAL_N_ELEMENTS(simple
); ++i
) {
1901 if (name
.equalsAsciiL(simple
[i
].name
, simple
[i
].length
)) {
1902 return css::uno::makeAny
<
1903 css::uno::Reference
< css::reflection::XTypeDescription
> >(
1904 new SimpleTypeDescription(simple
[i
].typeClass
, name
));
1907 if (name
.startsWith("[]")) {
1908 return getSequenceType(name
);
1910 sal_Int32 i
= name
.indexOf('<');
1912 return getInstantiatedStruct(name
, i
);
1914 i
= name
.indexOf("::");
1916 return getInterfaceMember(name
, i
);
1918 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
));
1920 return getNamed(name
, ent
);
1922 i
= name
.lastIndexOf('.');
1924 rtl::OUString
parent(name
.copy(0, i
));
1925 ent
= findEntity(parent
);
1927 switch (ent
->getSort()) {
1928 case unoidl::Entity::SORT_ENUM_TYPE
:
1929 return getEnumMember(
1930 static_cast< unoidl::EnumTypeEntity
* >(ent
.get()),
1932 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1935 static_cast< unoidl::ConstantGroupEntity
* >(ent
.get()),
1942 return css::uno::Any();
1945 css::uno::Reference
< css::reflection::XTypeDescription
>
1946 cppuhelper::TypeManager::resolve(rtl::OUString
const & name
) {
1947 css::uno::Reference
< css::reflection::XTypeDescription
> desc(
1948 find(name
), css::uno::UNO_QUERY
);
1950 throw css::uno::DeploymentException(
1951 "cannot resolve type \"" + name
+ "\"",
1952 static_cast< cppu::OWeakObject
* >(this));
1957 cppuhelper::TypeManager::~TypeManager() throw () {}
1959 void cppuhelper::TypeManager::disposing() {} //TODO
1961 rtl::OUString
cppuhelper::TypeManager::getImplementationName()
1962 throw (css::uno::RuntimeException
, std::exception
)
1964 return rtl::OUString(
1965 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager");
1968 sal_Bool
cppuhelper::TypeManager::supportsService(
1969 rtl::OUString
const & ServiceName
)
1970 throw (css::uno::RuntimeException
, std::exception
)
1972 return cppu::supportsService(this, ServiceName
);
1975 css::uno::Sequence
< rtl::OUString
>
1976 cppuhelper::TypeManager::getSupportedServiceNames()
1977 throw (css::uno::RuntimeException
, std::exception
)
1979 css::uno::Sequence
<OUString
> names
{ "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1983 css::uno::Any
cppuhelper::TypeManager::getByHierarchicalName(
1984 rtl::OUString
const & aName
)
1985 throw (css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
)
1987 css::uno::Any
desc(find(aName
));
1988 if (!desc
.hasValue()) {
1989 throw css::container::NoSuchElementException(
1990 aName
, static_cast< cppu::OWeakObject
* >(this));
1995 sal_Bool
cppuhelper::TypeManager::hasByHierarchicalName(
1996 rtl::OUString
const & aName
)
1997 throw (css::uno::RuntimeException
, std::exception
)
1999 return find(aName
).hasValue();
2002 css::uno::Type
cppuhelper::TypeManager::getElementType()
2003 throw (css::uno::RuntimeException
, std::exception
)
2005 return cppu::UnoType
< rtl::OUString
>::get();
2008 sal_Bool
cppuhelper::TypeManager::hasElements()
2009 throw (css::uno::RuntimeException
, std::exception
)
2011 throw css::uno::RuntimeException(
2012 "TypeManager hasElements: method not supported",
2013 static_cast< cppu::OWeakObject
* >(this));
2016 css::uno::Reference
< css::container::XEnumeration
>
2017 cppuhelper::TypeManager::createEnumeration()
2018 throw (css::uno::RuntimeException
, std::exception
)
2020 throw css::uno::RuntimeException(
2021 "TypeManager createEnumeration: method not supported",
2022 static_cast< cppu::OWeakObject
* >(this));
2025 sal_Bool
cppuhelper::TypeManager::has(css::uno::Any
const &)
2026 throw (css::uno::RuntimeException
, std::exception
)
2028 throw css::uno::RuntimeException(
2029 "TypeManager has: method not supported",
2030 static_cast< cppu::OWeakObject
* >(this));
2033 void cppuhelper::TypeManager::insert(css::uno::Any
const & aElement
)
2035 css::lang::IllegalArgumentException
,
2036 css::container::ElementExistException
, css::uno::RuntimeException
, std::exception
)
2039 if (!(aElement
>>= uri
)) {
2040 throw css::lang::IllegalArgumentException(
2041 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
2043 static_cast< cppu::OWeakObject
* >(this), 0);
2045 //TODO: check for ElementExistException
2046 //TODO: check for consistency with existing data
2047 readRdbFile(uri
, false);
2050 void cppuhelper::TypeManager::remove(css::uno::Any
const & aElement
)
2052 css::lang::IllegalArgumentException
,
2053 css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
)
2056 if (!(aElement
>>= uri
)) {
2057 throw css::lang::IllegalArgumentException(
2058 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
2060 static_cast< cppu::OWeakObject
* >(this), 0);
2062 //TODO: remove requests are silently ignored for now
2065 css::uno::Reference
< css::reflection::XTypeDescriptionEnumeration
>
2066 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
2067 rtl::OUString
const & moduleName
,
2068 css::uno::Sequence
< css::uno::TypeClass
> const & types
,
2069 css::reflection::TypeDescriptionSearchDepth depth
)
2071 css::reflection::NoSuchTypeNameException
,
2072 css::reflection::InvalidTypeNameException
,
2073 css::uno::RuntimeException
, std::exception
)
2075 rtl::Reference
< unoidl::MapCursor
> cursor
;
2077 cursor
= manager_
->createCursor(moduleName
);
2078 } catch (unoidl::FileFormatException
& e
) {
2079 throw css::uno::DeploymentException(
2080 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2082 static_cast< cppu::OWeakObject
* >(this));
2085 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2087 throw css::reflection::NoSuchTypeNameException(
2088 moduleName
, static_cast< cppu::OWeakObject
* >(this));
2090 return new Enumeration(
2091 this, makePrefix(moduleName
), cursor
, types
,
2092 depth
== css::reflection::TypeDescriptionSearchDepth_INFINITE
);
2095 void cppuhelper::TypeManager::init(rtl::OUString
const & rdbUris
) {
2096 for (sal_Int32 i
= 0; i
!= -1;) {
2097 rtl::OUString
uri(rdbUris
.getToken(0, ' ', i
));
2098 if (uri
.isEmpty()) {
2103 cppu::decodeRdbUri(&uri
, &optional
, &directory
);
2105 readRdbDirectory(uri
, optional
);
2107 readRdbFile(uri
, optional
);
2112 void cppuhelper::TypeManager::readRdbDirectory(
2113 rtl::OUString
const & uri
, bool optional
)
2115 osl::Directory
dir(uri
);
2116 switch (dir
.open()) {
2117 case osl::FileBase::E_None
:
2119 case osl::FileBase::E_NOENT
:
2121 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2126 throw css::uno::DeploymentException(
2127 "Cannot open directory " + uri
,
2128 static_cast< cppu::OWeakObject
* >(this));
2132 if (!cppu::nextDirectoryItem(dir
, &url
)) {
2135 readRdbFile(url
, false);
2139 void cppuhelper::TypeManager::readRdbFile(
2140 rtl::OUString
const & uri
, bool optional
)
2143 manager_
->addProvider(uri
);
2144 } catch (unoidl::NoSuchFileException
&) {
2146 throw css::uno::DeploymentException(
2147 uri
+ ": no such file",
2148 static_cast< cppu::OWeakObject
* >(this));
2150 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2151 } catch (unoidl::FileFormatException
& e
) {
2152 throw css::uno::DeploymentException(
2153 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2155 static_cast< cppu::OWeakObject
* >(this));
2159 css::uno::Any
cppuhelper::TypeManager::getSequenceType(
2160 rtl::OUString
const & name
)
2162 assert(name
.startsWith("[]"));
2163 return css::uno::makeAny
<
2164 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2165 new SequenceTypeDescription(
2166 this, name
, name
.copy(std::strlen("[]"))));
2169 css::uno::Any
cppuhelper::TypeManager::getInstantiatedStruct(
2170 rtl::OUString
const & name
, sal_Int32 separator
)
2172 assert(name
.indexOf('<') == separator
&& separator
!= -1);
2173 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
.copy(0, separator
)));
2176 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
))
2178 return css::uno::Any();
2180 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
2181 static_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
2183 std::vector
< rtl::OUString
> args
;
2184 sal_Int32 i
= separator
;
2186 ++i
; // skip '<' or ','
2188 for (sal_Int32 level
= 0; j
!= name
.getLength(); ++j
) {
2189 sal_Unicode c
= name
[j
];
2194 } else if (c
== '<') {
2196 } else if (c
== '>') {
2203 if (j
!= name
.getLength()) {
2204 args
.push_back(name
.copy(i
, j
- i
));
2207 } while (i
!= name
.getLength() && name
[i
] != '>');
2208 if (i
!= name
.getLength() - 1 || name
[i
] != '>'
2209 || args
.size() != ent2
->getTypeParameters().size())
2211 return css::uno::Any();
2213 return css::uno::makeAny
<
2214 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2215 new InstantiatedPolymorphicStructTypeDescription(
2216 this, name
, ent2
, args
));
2219 css::uno::Any
cppuhelper::TypeManager::getInterfaceMember(
2220 rtl::OUString
const & name
, sal_Int32 separator
)
2222 assert(name
.indexOf("::") == separator
&& separator
!= -1);
2223 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> ifc(
2224 resolveTypedefs(find(name
.copy(0, separator
))), css::uno::UNO_QUERY
);
2226 return css::uno::Any();
2228 rtl::OUString
member(name
.copy(separator
+ std::strlen("::")));
2230 css::uno::Reference
<
2231 css::reflection::XInterfaceMemberTypeDescription
> > mems(
2233 for (sal_Int32 i
= 0; i
!= mems
.getLength(); ++i
) {
2234 if (mems
[i
]->getMemberName() == member
) {
2235 return css::uno::makeAny
<
2236 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2240 return css::uno::Any();
2243 css::uno::Any
cppuhelper::TypeManager::getNamed(
2244 rtl::OUString
const & name
, rtl::Reference
< unoidl::Entity
> const & entity
)
2246 assert(entity
.is());
2247 switch (entity
->getSort()) {
2248 case unoidl::Entity::SORT_MODULE
:
2249 return css::uno::makeAny
<
2250 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2251 new ModuleDescription(
2253 static_cast< unoidl::ModuleEntity
* >(entity
.get())));
2254 case unoidl::Entity::SORT_ENUM_TYPE
:
2255 return css::uno::makeAny
<
2256 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2257 new EnumTypeDescription(
2259 static_cast< unoidl::EnumTypeEntity
* >(entity
.get())));
2260 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
2261 return css::uno::makeAny
<
2262 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2263 new PlainStructTypeDescription(
2265 static_cast< unoidl::PlainStructTypeEntity
* >(
2267 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
2268 return css::uno::makeAny
<
2269 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2270 new PolymorphicStructTypeTemplateDescription(
2273 unoidl::PolymorphicStructTypeTemplateEntity
* >(
2275 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
2276 return css::uno::makeAny
<
2277 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2278 new ExceptionTypeDescription(
2280 static_cast< unoidl::ExceptionTypeEntity
* >(
2282 case unoidl::Entity::SORT_INTERFACE_TYPE
:
2283 return css::uno::makeAny
<
2284 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2285 new InterfaceTypeDescription(
2287 static_cast< unoidl::InterfaceTypeEntity
* >(
2289 case unoidl::Entity::SORT_TYPEDEF
:
2290 return css::uno::makeAny
<
2291 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2292 new TypedefDescription(
2294 static_cast< unoidl::TypedefEntity
* >(entity
.get())));
2295 case unoidl::Entity::SORT_CONSTANT_GROUP
:
2296 return css::uno::makeAny
<
2297 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2298 new ConstantGroupDescription(
2300 static_cast< unoidl::ConstantGroupEntity
* >(
2302 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
2303 return css::uno::makeAny
<
2304 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2305 new SingleInterfaceBasedServiceDescription(
2307 static_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
2309 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
2310 return css::uno::makeAny
<
2311 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2312 new AccumulationBasedServiceDescription(
2314 static_cast< unoidl::AccumulationBasedServiceEntity
* >(
2316 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
2317 return css::uno::makeAny
<
2318 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2319 new InterfaceBasedSingletonDescription(
2321 static_cast< unoidl::InterfaceBasedSingletonEntity
* >(
2323 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
2324 return css::uno::makeAny
<
2325 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2326 new ServiceBasedSingletonDescription(
2328 static_cast< unoidl::ServiceBasedSingletonEntity
* >(
2331 for (;;) { std::abort(); } // this cannot happen
2335 css::uno::Any
cppuhelper::TypeManager::getEnumMember(
2336 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
2337 rtl::OUString
const & member
)
2339 for (std::vector
< unoidl::EnumTypeEntity::Member
>::const_iterator
i(
2340 entity
->getMembers().begin());
2341 i
!= entity
->getMembers().end(); ++i
)
2343 if (i
->name
== member
) {
2344 return css::uno::makeAny(i
->value
);
2347 return css::uno::Any();
2350 css::uno::Any
cppuhelper::TypeManager::getConstant(
2351 rtl::OUString
const & constantGroupName
,
2352 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
2353 rtl::OUString
const & member
)
2355 for (std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
i(
2356 entity
->getMembers().begin());
2357 i
!= entity
->getMembers().end(); ++i
)
2359 if (i
->name
== member
) {
2360 return css::uno::makeAny
<
2361 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2362 new ConstantDescription(constantGroupName
, *i
));
2365 return css::uno::Any();
2368 rtl::Reference
< unoidl::Entity
> cppuhelper::TypeManager::findEntity(
2369 rtl::OUString
const & name
)
2372 return manager_
->findEntity(name
);
2373 } catch (unoidl::FileFormatException
& e
) {
2374 throw css::uno::DeploymentException(
2375 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2377 static_cast< cppu::OWeakObject
* >(this));
2381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */