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>
18 #include <string_view>
21 #include <com/sun/star/container/NoSuchElementException.hpp>
22 #include <com/sun/star/lang/IllegalArgumentException.hpp>
23 #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
24 #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
25 #include <com/sun/star/reflection/XConstantTypeDescription.hpp>
26 #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
27 #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
28 #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
29 #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
30 #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
31 #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
32 #include <com/sun/star/reflection/XModuleTypeDescription.hpp>
33 #include <com/sun/star/reflection/XPublished.hpp>
34 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
35 #include <com/sun/star/reflection/XSingletonTypeDescription2.hpp>
36 #include <com/sun/star/reflection/XStructTypeDescription.hpp>
37 #include <com/sun/star/reflection/XTypeDescription.hpp>
38 #include <com/sun/star/uno/Any.hxx>
39 #include <com/sun/star/uno/DeploymentException.hpp>
40 #include <com/sun/star/uno/Reference.hxx>
41 #include <com/sun/star/uno/RuntimeException.hpp>
42 #include <com/sun/star/uno/Sequence.hxx>
43 #include <com/sun/star/uno/Type.hxx>
44 #include <com/sun/star/uno/TypeClass.hpp>
45 #include <cppu/unotype.hxx>
46 #include <cppuhelper/implbase.hxx>
47 #include <cppuhelper/supportsservice.hxx>
48 #include <osl/file.hxx>
49 #include <osl/mutex.hxx>
50 #include <rtl/ref.hxx>
51 #include <rtl/ustring.hxx>
52 #include <sal/log.hxx>
53 #include <sal/macros.h>
54 #include <sal/types.h>
56 #include <unoidl/unoidl.hxx>
59 #include "typemanager.hxx"
63 OUString
makePrefix(OUString
const & name
) {
64 return name
.isEmpty() ? name
: name
+ ".";
67 css::uno::Any
resolveTypedefs(css::uno::Any
const & type
) {
68 for (css::uno::Any
t(type
);;) {
69 css::uno::Reference
< css::reflection::XIndirectTypeDescription
> ind(
70 type
, css::uno::UNO_QUERY
);
71 if (!ind
.is() || ind
->getTypeClass() != css::uno::TypeClass_TYPEDEF
) {
74 t
<<= ind
->getReferencedType();
78 class SimpleTypeDescription
:
79 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
82 SimpleTypeDescription(
83 css::uno::TypeClass typeClass
, OUString
const & name
):
84 typeClass_(typeClass
), name_(name
)
88 virtual ~SimpleTypeDescription() override
{}
90 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
91 { return typeClass_
; }
93 virtual OUString SAL_CALL
getName() override
96 css::uno::TypeClass typeClass_
;
100 class SequenceTypeDescription
:
101 public cppu::WeakImplHelper
< css::reflection::XIndirectTypeDescription
>
104 SequenceTypeDescription(
105 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
106 OUString
const & name
, OUString
const & componentType
):
107 manager_(manager
), name_(name
), componentType_(componentType
)
108 { assert(manager
.is()); }
111 virtual ~SequenceTypeDescription() override
{}
113 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
114 { return css::uno::TypeClass_SEQUENCE
; }
116 virtual OUString SAL_CALL
getName() override
119 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
120 getReferencedType() override
121 { return manager_
->resolve(componentType_
); }
123 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
125 OUString componentType_
;
128 class PublishableDescription
:
129 public cppu::WeakImplHelper
< css::reflection::XPublished
>
132 explicit PublishableDescription(bool published
): published_(published
) {}
134 virtual ~PublishableDescription() override
{}
137 virtual sal_Bool SAL_CALL
isPublished() override
138 { return published_
; }
143 class ModuleDescription
:
144 public cppu::WeakImplHelper
< css::reflection::XModuleTypeDescription
>
148 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
149 OUString
const & name
,
150 rtl::Reference
< unoidl::ModuleEntity
> const & entity
):
151 manager_(manager
), name_(name
), entity_(entity
)
152 { assert(manager
.is()); assert(entity
.is()); }
155 virtual ~ModuleDescription() override
{}
157 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
158 { return css::uno::TypeClass_MODULE
; }
160 virtual OUString SAL_CALL
getName() override
165 css::uno::Reference
< css::reflection::XTypeDescription
> >
166 SAL_CALL
getMembers() override
;
168 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
170 rtl::Reference
< unoidl::ModuleEntity
> entity_
;
173 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
174 ModuleDescription::getMembers() {
176 std::vector
< OUString
> names(entity_
->getMemberNames());
177 assert(names
.size() <= SAL_MAX_INT32
);
178 sal_Int32 n
= static_cast< sal_Int32
>(names
.size());
180 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
181 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
182 s
[i
] = manager_
->resolve(makePrefix(name_
) + names
[i
]);
185 } catch (unoidl::FileFormatException
& e
) {
186 throw css::uno::DeploymentException(
187 e
.getUri() + ": " + e
.getDetail(),
188 static_cast< cppu::OWeakObject
* >(this));
192 typedef cppu::ImplInheritanceHelper
<
193 PublishableDescription
, css::reflection::XEnumTypeDescription
>
194 EnumTypeDescription_Base
;
196 class EnumTypeDescription
: public EnumTypeDescription_Base
{
199 OUString
const & name
,
200 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
):
201 EnumTypeDescription_Base(entity
->isPublished()), name_(name
),
203 { assert(entity
.is()); }
206 virtual ~EnumTypeDescription() override
{}
208 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
209 { return css::uno::TypeClass_ENUM
; }
211 virtual OUString SAL_CALL
getName() override
214 virtual sal_Int32 SAL_CALL
getDefaultEnumValue() override
215 { return entity_
->getMembers()[0].value
; }
217 virtual css::uno::Sequence
< OUString
> SAL_CALL
getEnumNames() override
;
219 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getEnumValues() override
;
222 rtl::Reference
< unoidl::EnumTypeEntity
> entity_
;
225 css::uno::Sequence
< OUString
> EnumTypeDescription::getEnumNames()
227 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
228 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
229 css::uno::Sequence
< OUString
> s(n
);
230 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
231 s
[i
] = entity_
->getMembers()[i
].name
;
236 css::uno::Sequence
< sal_Int32
> EnumTypeDescription::getEnumValues()
238 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
239 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
240 css::uno::Sequence
< sal_Int32
> s(n
);
241 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
242 s
[i
] = entity_
->getMembers()[i
].value
;
247 typedef cppu::ImplInheritanceHelper
<
248 PublishableDescription
, css::reflection::XStructTypeDescription
>
249 PlainStructTypeDescription_Base
;
251 class PlainStructTypeDescription
: public PlainStructTypeDescription_Base
{
253 PlainStructTypeDescription(
254 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
255 OUString
const & name
,
256 rtl::Reference
< unoidl::PlainStructTypeEntity
> const & entity
):
257 PlainStructTypeDescription_Base(entity
->isPublished()),
258 manager_(manager
), name_(name
), entity_(entity
)
259 { assert(manager
.is()); assert(entity
.is()); }
262 virtual ~PlainStructTypeDescription() override
{}
264 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
265 { return css::uno::TypeClass_STRUCT
; }
267 virtual OUString SAL_CALL
getName() override
270 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
271 getBaseType() override
{
272 return entity_
->getDirectBase().isEmpty()
273 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
274 : manager_
->resolve(entity_
->getDirectBase());
279 css::uno::Reference
< css::reflection::XTypeDescription
> >
280 SAL_CALL
getMemberTypes() override
;
282 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
284 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
285 { return css::uno::Sequence
< OUString
>(); }
289 css::uno::Reference
< css::reflection::XTypeDescription
> >
290 SAL_CALL
getTypeArguments() override
{
291 return css::uno::Sequence
<
292 css::uno::Reference
< css::reflection::XTypeDescription
> >();
295 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
297 rtl::Reference
< unoidl::PlainStructTypeEntity
> entity_
;
300 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
301 PlainStructTypeDescription::getMemberTypes()
303 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
304 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
306 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
307 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
308 s
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
313 css::uno::Sequence
< OUString
> PlainStructTypeDescription::getMemberNames()
315 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
316 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
317 css::uno::Sequence
< OUString
> s(n
);
318 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
319 s
[i
] = entity_
->getDirectMembers()[i
].name
;
324 class ParameterizedMemberTypeDescription
:
325 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
328 explicit ParameterizedMemberTypeDescription(
329 OUString
const & typeParameterName
):
330 typeParameterName_(typeParameterName
)
334 virtual ~ParameterizedMemberTypeDescription() override
{}
336 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
337 { return css::uno::TypeClass_UNKNOWN
; }
339 virtual OUString SAL_CALL
getName() override
340 { return typeParameterName_
; }
342 OUString typeParameterName_
;
345 typedef cppu::ImplInheritanceHelper
<
346 PublishableDescription
, css::reflection::XStructTypeDescription
>
347 PolymorphicStructTypeTemplateDescription_Base
;
349 class PolymorphicStructTypeTemplateDescription
:
350 public PolymorphicStructTypeTemplateDescription_Base
353 PolymorphicStructTypeTemplateDescription(
354 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
355 OUString
const & name
,
356 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
358 PolymorphicStructTypeTemplateDescription_Base(entity
->isPublished()),
359 manager_(manager
), name_(name
), entity_(entity
)
360 { assert(manager
.is()); assert(entity
.is()); }
363 virtual ~PolymorphicStructTypeTemplateDescription() override
{}
365 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
366 { return css::uno::TypeClass_STRUCT
; }
368 virtual OUString SAL_CALL
getName() override
371 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
372 getBaseType() override
373 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
377 css::uno::Reference
< css::reflection::XTypeDescription
> >
378 SAL_CALL
getMemberTypes() override
;
380 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
382 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
;
386 css::uno::Reference
< css::reflection::XTypeDescription
> >
387 SAL_CALL
getTypeArguments() override
{
388 return css::uno::Sequence
<
389 css::uno::Reference
< css::reflection::XTypeDescription
> >();
392 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
394 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
397 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
398 PolymorphicStructTypeTemplateDescription::getMemberTypes()
400 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
401 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
403 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
404 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
405 s
[i
] = entity_
->getMembers()[i
].parameterized
406 ? new ParameterizedMemberTypeDescription(
407 entity_
->getMembers()[i
].type
)
408 : manager_
->resolve(entity_
->getMembers()[i
].type
);
413 css::uno::Sequence
< OUString
>
414 PolymorphicStructTypeTemplateDescription::getMemberNames()
416 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
417 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
418 css::uno::Sequence
< OUString
> s(n
);
419 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
420 s
[i
] = entity_
->getMembers()[i
].name
;
425 css::uno::Sequence
< OUString
>
426 PolymorphicStructTypeTemplateDescription::getTypeParameters()
428 assert(entity_
->getTypeParameters().size() <= SAL_MAX_INT32
);
429 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getTypeParameters().size());
430 css::uno::Sequence
< OUString
> s(n
);
431 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
432 s
[i
] = entity_
->getTypeParameters()[i
];
437 class InstantiatedPolymorphicStructTypeDescription
:
438 public cppu::WeakImplHelper
< css::reflection::XStructTypeDescription
>
441 InstantiatedPolymorphicStructTypeDescription(
442 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
443 OUString
const & name
,
444 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
446 std::vector
< OUString
> const & arguments
):
447 manager_(manager
), name_(name
), entity_(entity
), arguments_(arguments
)
449 assert(manager
.is());
451 assert(arguments
.size() == entity
->getTypeParameters().size());
455 virtual ~InstantiatedPolymorphicStructTypeDescription() override
{}
457 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
458 { return css::uno::TypeClass_STRUCT
; }
460 virtual OUString SAL_CALL
getName() override
463 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
464 getBaseType() override
465 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
469 css::uno::Reference
< css::reflection::XTypeDescription
> >
470 SAL_CALL
getMemberTypes() override
;
472 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
474 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
475 { return css::uno::Sequence
< OUString
>(); }
479 css::uno::Reference
< css::reflection::XTypeDescription
> >
480 SAL_CALL
getTypeArguments() override
;
482 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
484 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
485 std::vector
< OUString
> arguments_
;
488 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
489 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
491 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
492 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
494 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
495 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
496 OUString
type(entity_
->getMembers()[i
].type
);
497 if (entity_
->getMembers()[i
].parameterized
) {
498 auto j
= std::find(entity_
->getTypeParameters().begin(), entity_
->getTypeParameters().end(), type
);
499 if (j
!= entity_
->getTypeParameters().end()) {
500 type
= arguments_
[j
- entity_
->getTypeParameters().begin()];
503 assert(false); // this cannot happen //TODO!
506 s
[i
] = manager_
->resolve(type
);
511 css::uno::Sequence
< OUString
>
512 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
514 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
515 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
516 css::uno::Sequence
< OUString
> s(n
);
517 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
518 s
[i
] = entity_
->getMembers()[i
].name
;
522 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
523 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
525 assert(arguments_
.size() <= SAL_MAX_INT32
);
526 sal_Int32 n
= static_cast< sal_Int32
>(arguments_
.size());
528 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
529 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
530 s
[i
] = manager_
->resolve(arguments_
[i
]);
535 typedef cppu::ImplInheritanceHelper
<
536 PublishableDescription
, css::reflection::XCompoundTypeDescription
>
537 ExceptionTypeDescription_Base
;
539 class ExceptionTypeDescription
: public ExceptionTypeDescription_Base
{
541 ExceptionTypeDescription(
542 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
543 OUString
const & name
,
544 rtl::Reference
< unoidl::ExceptionTypeEntity
> const & entity
):
545 ExceptionTypeDescription_Base(entity
->isPublished()), manager_(manager
),
546 name_(name
), entity_(entity
)
547 { assert(manager
.is()); assert(entity
.is()); }
550 virtual ~ExceptionTypeDescription() override
{}
552 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
553 { return css::uno::TypeClass_EXCEPTION
; }
555 virtual OUString SAL_CALL
getName() override
558 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
559 getBaseType() override
{
560 return entity_
->getDirectBase().isEmpty()
561 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
562 : manager_
->resolve(entity_
->getDirectBase());
567 css::uno::Reference
< css::reflection::XTypeDescription
> >
568 SAL_CALL
getMemberTypes() override
;
570 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
572 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
574 rtl::Reference
< unoidl::ExceptionTypeEntity
> entity_
;
577 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
578 ExceptionTypeDescription::getMemberTypes() {
579 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
580 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
582 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
583 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
584 s
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
589 css::uno::Sequence
< OUString
> ExceptionTypeDescription::getMemberNames()
591 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
592 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
593 css::uno::Sequence
< OUString
> s(n
);
594 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
595 s
[i
] = entity_
->getDirectMembers()[i
].name
;
600 class AttributeDescription
:
601 public cppu::WeakImplHelper
<
602 css::reflection::XInterfaceAttributeTypeDescription2
>
605 AttributeDescription(
606 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
607 OUString
const & name
,
608 unoidl::InterfaceTypeEntity::Attribute
const & attribute
,
610 manager_(manager
), name_(name
), attribute_(attribute
),
612 { assert(manager
.is()); }
615 virtual ~AttributeDescription() override
{}
617 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
618 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE
; }
620 virtual OUString SAL_CALL
getName() override
623 virtual OUString SAL_CALL
getMemberName() override
624 { return attribute_
.name
; }
626 virtual sal_Int32 SAL_CALL
getPosition() override
627 { return position_
; }
629 virtual sal_Bool SAL_CALL
isReadOnly() override
630 { return attribute_
.readOnly
; }
632 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
634 { return manager_
->resolve(attribute_
.type
); }
636 virtual sal_Bool SAL_CALL
isBound() override
637 { return attribute_
.bound
; }
641 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
642 SAL_CALL
getGetExceptions() override
;
646 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
647 SAL_CALL
getSetExceptions() override
;
649 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
651 unoidl::InterfaceTypeEntity::Attribute attribute_
;
656 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
657 AttributeDescription::getGetExceptions() {
658 assert(attribute_
.getExceptions
.size() <= SAL_MAX_INT32
);
659 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.getExceptions
.size());
661 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
662 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
664 manager_
->resolve(attribute_
.getExceptions
[i
]),
665 css::uno::UNO_QUERY_THROW
);
671 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
672 AttributeDescription::getSetExceptions() {
673 assert(attribute_
.setExceptions
.size() <= SAL_MAX_INT32
);
674 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.setExceptions
.size());
676 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
677 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
679 manager_
->resolve(attribute_
.setExceptions
[i
]),
680 css::uno::UNO_QUERY_THROW
);
685 class MethodParameter
:
686 public cppu::WeakImplHelper
< css::reflection::XMethodParameter
>
690 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
691 unoidl::InterfaceTypeEntity::Method::Parameter
const & parameter
,
693 manager_(manager
), parameter_(parameter
), position_(position
)
694 { assert(manager
.is()); }
697 virtual ~MethodParameter() override
{}
699 virtual OUString SAL_CALL
getName() override
700 { return parameter_
.name
; }
702 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
704 { return manager_
->resolve(parameter_
.type
); }
706 virtual sal_Bool SAL_CALL
isIn() override
{
708 (parameter_
.direction
709 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
710 || (parameter_
.direction
711 == unoidl::InterfaceTypeEntity::Method::Parameter::
715 virtual sal_Bool SAL_CALL
isOut() override
{
717 (parameter_
.direction
718 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
)
719 || (parameter_
.direction
720 == unoidl::InterfaceTypeEntity::Method::Parameter::
724 virtual sal_Int32 SAL_CALL
getPosition() override
725 { return position_
; }
727 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
728 unoidl::InterfaceTypeEntity::Method::Parameter parameter_
;
732 class MethodDescription
:
733 public cppu::WeakImplHelper
<
734 css::reflection::XInterfaceMethodTypeDescription
>
738 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
739 OUString
const & name
,
740 unoidl::InterfaceTypeEntity::Method
const & method
, sal_Int32 position
):
741 manager_(manager
), name_(name
), method_(method
), position_(position
)
742 { assert(manager
.is()); }
745 virtual ~MethodDescription() override
{}
747 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
748 { return css::uno::TypeClass_INTERFACE_METHOD
; }
750 virtual OUString SAL_CALL
getName() override
753 virtual OUString SAL_CALL
getMemberName() override
754 { return method_
.name
; }
756 virtual sal_Int32 SAL_CALL
getPosition() override
757 { return position_
; }
759 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
760 getReturnType() override
761 { return manager_
->resolve(method_
.returnType
); }
763 virtual sal_Bool SAL_CALL
isOneway() override
768 css::uno::Reference
< css::reflection::XMethodParameter
> >
769 SAL_CALL
getParameters() override
;
773 css::uno::Reference
< css::reflection::XTypeDescription
> >
774 SAL_CALL
getExceptions() override
;
776 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
778 unoidl::InterfaceTypeEntity::Method method_
;
782 css::uno::Sequence
< css::uno::Reference
< css::reflection::XMethodParameter
> >
783 MethodDescription::getParameters() {
784 assert(method_
.parameters
.size() <= SAL_MAX_INT32
);
785 sal_Int32 n
= static_cast< sal_Int32
>(method_
.parameters
.size());
787 css::uno::Reference
< css::reflection::XMethodParameter
> > s(n
);
788 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
789 s
[i
] = new MethodParameter(manager_
, method_
.parameters
[i
], i
);
794 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
795 MethodDescription::getExceptions() {
796 assert(method_
.exceptions
.size() <= SAL_MAX_INT32
);
797 sal_Int32 n
= static_cast< sal_Int32
>(method_
.exceptions
.size());
799 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
800 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
801 s
[i
] = manager_
->resolve(method_
.exceptions
[i
]);
809 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
810 const & description
);
812 BaseOffset(const BaseOffset
&) = delete;
813 const BaseOffset
& operator=(const BaseOffset
&) = delete;
815 sal_Int32
get() const { return offset_
; }
819 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
820 const & description
);
823 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
824 const & description
);
826 std::set
< OUString
> set_
;
830 BaseOffset::BaseOffset(
831 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
835 calculateBases(description
);
838 void BaseOffset::calculateBases(
839 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
842 const css::uno::Sequence
<
843 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
844 description
->getBaseTypes());
845 for (const auto & i
: bases
) {
847 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
848 resolveTypedefs(css::uno::makeAny(i
)),
849 css::uno::UNO_QUERY_THROW
));
853 void BaseOffset::calculate(
854 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
857 if (set_
.insert(description
->getName()).second
) {
858 calculateBases(description
);
859 offset_
+= description
->getMembers().getLength();
863 typedef cppu::ImplInheritanceHelper
<
864 PublishableDescription
, css::reflection::XInterfaceTypeDescription2
>
865 InterfaceTypeDescription_Base
;
867 class InterfaceTypeDescription
: public InterfaceTypeDescription_Base
{
869 InterfaceTypeDescription(
870 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
871 OUString
const & name
,
872 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
873 InterfaceTypeDescription_Base(entity
->isPublished()), manager_(manager
),
874 name_(name
), entity_(entity
)
875 { assert(manager
.is()); assert(entity
.is()); }
878 virtual ~InterfaceTypeDescription() override
{}
880 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
881 { return css::uno::TypeClass_INTERFACE
; }
883 virtual OUString SAL_CALL
getName() override
886 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
887 getBaseType() override
{
888 return entity_
->getDirectMandatoryBases().empty()
889 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
890 : manager_
->resolve(entity_
->getDirectMandatoryBases()[0].name
);
893 virtual css::uno::Uik SAL_CALL
getUik() override
894 { return css::uno::Uik(); }
899 css::reflection::XInterfaceMemberTypeDescription
> >
900 SAL_CALL
getMembers() override
;
904 css::uno::Reference
< css::reflection::XTypeDescription
> >
905 SAL_CALL
getBaseTypes() override
;
909 css::uno::Reference
< css::reflection::XTypeDescription
> >
910 SAL_CALL
getOptionalBaseTypes() override
;
912 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
914 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
918 css::uno::Reference
< css::reflection::XInterfaceMemberTypeDescription
> >
919 InterfaceTypeDescription::getMembers() {
921 entity_
->getDirectAttributes().size() <= SAL_MAX_INT32
922 && (entity_
->getDirectMethods().size()
923 <= SAL_MAX_INT32
- entity_
->getDirectAttributes().size()));
924 sal_Int32 n1
= static_cast< sal_Int32
>(
925 entity_
->getDirectAttributes().size());
926 sal_Int32 n2
= static_cast< sal_Int32
>(entity_
->getDirectMethods().size());
929 css::reflection::XInterfaceMemberTypeDescription
> > s(n1
+ n2
);
930 sal_Int32 off
= BaseOffset(this).get();
931 for (sal_Int32 i
= 0; i
!= n1
; ++i
) {
932 s
[i
] = new AttributeDescription(
933 manager_
, name_
+ "::" + entity_
->getDirectAttributes()[i
].name
,
934 entity_
->getDirectAttributes()[i
], off
+ i
);
936 for (sal_Int32 i
= 0; i
!= n2
; ++i
) {
937 s
[n1
+ i
] = new MethodDescription(
938 manager_
, name_
+ "::" + entity_
->getDirectMethods()[i
].name
,
939 entity_
->getDirectMethods()[i
], off
+ n1
+ i
);
944 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
945 InterfaceTypeDescription::getBaseTypes() {
946 assert(entity_
->getDirectMandatoryBases().size() <= SAL_MAX_INT32
);
947 sal_Int32 n
= static_cast< sal_Int32
>(
948 entity_
->getDirectMandatoryBases().size());
950 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
951 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
952 s
[i
] = manager_
->resolve(entity_
->getDirectMandatoryBases()[i
].name
);
957 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
958 InterfaceTypeDescription::getOptionalBaseTypes()
960 assert(entity_
->getDirectOptionalBases().size() <= SAL_MAX_INT32
);
961 sal_Int32 n
= static_cast< sal_Int32
>(
962 entity_
->getDirectOptionalBases().size());
964 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
965 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
966 s
[i
] = manager_
->resolve(entity_
->getDirectOptionalBases()[i
].name
);
971 class ConstantDescription
:
972 public cppu::WeakImplHelper
< css::reflection::XConstantTypeDescription
>
976 OUString
const & constantGroupName
,
977 unoidl::ConstantGroupEntity::Member
const & member
);
980 virtual ~ConstantDescription() override
{}
982 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
983 { return css::uno::TypeClass_CONSTANT
; }
985 virtual OUString SAL_CALL
getName() override
988 virtual css::uno::Any SAL_CALL
getConstantValue() override
992 css::uno::Any value_
;
995 ConstantDescription::ConstantDescription(
996 OUString
const & constantGroupName
,
997 unoidl::ConstantGroupEntity::Member
const & member
):
998 name_(makePrefix(constantGroupName
) + member
.name
)
1000 switch (member
.value
.type
) {
1001 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1002 value_
<<= member
.value
.booleanValue
;
1004 case unoidl::ConstantValue::TYPE_BYTE
:
1005 value_
<<= member
.value
.byteValue
;
1007 case unoidl::ConstantValue::TYPE_SHORT
:
1008 value_
<<= member
.value
.shortValue
;
1010 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1011 value_
<<= member
.value
.unsignedShortValue
;
1013 case unoidl::ConstantValue::TYPE_LONG
:
1014 value_
<<= member
.value
.longValue
;
1016 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1017 value_
<<= member
.value
.unsignedLongValue
;
1019 case unoidl::ConstantValue::TYPE_HYPER
:
1020 value_
<<= member
.value
.hyperValue
;
1022 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1023 value_
<<= member
.value
.unsignedHyperValue
;
1025 case unoidl::ConstantValue::TYPE_FLOAT
:
1026 value_
<<= member
.value
.floatValue
;
1028 case unoidl::ConstantValue::TYPE_DOUBLE
:
1029 value_
<<= member
.value
.doubleValue
;
1032 for (;;) { std::abort(); } // this cannot happen
1036 typedef cppu::ImplInheritanceHelper
<
1037 PublishableDescription
, css::reflection::XConstantsTypeDescription
>
1038 ConstantGroupDescription_Base
;
1040 class ConstantGroupDescription
: public ConstantGroupDescription_Base
{
1042 ConstantGroupDescription(
1043 OUString
const & name
,
1044 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
):
1045 ConstantGroupDescription_Base(entity
->isPublished()), name_(name
),
1047 { assert(entity
.is()); }
1050 virtual ~ConstantGroupDescription() override
{}
1052 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1053 { return css::uno::TypeClass_CONSTANTS
; }
1055 virtual OUString SAL_CALL
getName() override
1060 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1061 SAL_CALL
getConstants() override
;
1064 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1068 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1069 ConstantGroupDescription::getConstants() {
1070 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
1071 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
1073 css::uno::Reference
< css::reflection::XConstantTypeDescription
> > s(n
);
1074 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1075 s
[i
] = new ConstantDescription(name_
, entity_
->getMembers()[i
]);
1080 typedef cppu::ImplInheritanceHelper
<
1081 PublishableDescription
, css::reflection::XIndirectTypeDescription
>
1082 TypedefDescription_Base
;
1084 class TypedefDescription
: public TypedefDescription_Base
{
1087 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1088 OUString
const & name
,
1089 rtl::Reference
< unoidl::TypedefEntity
> const & entity
):
1090 TypedefDescription_Base(entity
->isPublished()), manager_(manager
),
1091 name_(name
), entity_(entity
)
1092 { assert(manager
.is()); assert(entity
.is()); }
1095 virtual ~TypedefDescription() override
{}
1097 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1098 { return css::uno::TypeClass_TYPEDEF
; }
1100 virtual OUString SAL_CALL
getName() override
1103 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1104 getReferencedType() override
1105 { return manager_
->resolve(entity_
->getType()); }
1107 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1109 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
1112 class ConstructorParameter
:
1113 public cppu::WeakImplHelper
< css::reflection::XParameter
>
1116 ConstructorParameter(
1117 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1118 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1120 sal_Int32 position
):
1121 manager_(manager
), parameter_(parameter
), position_(position
)
1122 { assert(manager
.is()); }
1125 virtual ~ConstructorParameter() override
{}
1127 virtual OUString SAL_CALL
getName() override
1128 { return parameter_
.name
; }
1130 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1132 { return manager_
->resolve(parameter_
.type
); }
1134 virtual sal_Bool SAL_CALL
isIn() override
1137 virtual sal_Bool SAL_CALL
isOut() override
1140 virtual sal_Int32 SAL_CALL
getPosition() override
1141 { return position_
; }
1143 virtual sal_Bool SAL_CALL
isRestParameter() override
1144 { return parameter_
.rest
; }
1146 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1147 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1149 sal_Int32 position_
;
1152 class ConstructorDescription
:
1153 public cppu::WeakImplHelper
<
1154 css::reflection::XServiceConstructorDescription
>
1157 ConstructorDescription(
1158 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1159 unoidl::SingleInterfaceBasedServiceEntity::Constructor
const &
1161 manager_(manager
), constructor_(constructor
)
1162 { assert(manager
.is()); }
1165 virtual ~ConstructorDescription() override
{}
1167 virtual sal_Bool SAL_CALL
isDefaultConstructor() override
1168 { return constructor_
.defaultConstructor
; }
1170 virtual OUString SAL_CALL
getName() override
1171 { return constructor_
.name
; }
1175 css::uno::Reference
< css::reflection::XParameter
> >
1176 SAL_CALL
getParameters() override
;
1180 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1181 SAL_CALL
getExceptions() override
;
1183 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1184 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_
;
1187 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> >
1188 ConstructorDescription::getParameters() {
1189 assert(constructor_
.parameters
.size() <= SAL_MAX_INT32
);
1190 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.parameters
.size());
1191 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> > s(
1193 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1194 s
[i
] = new ConstructorParameter(
1195 manager_
, constructor_
.parameters
[i
], i
);
1201 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1202 ConstructorDescription::getExceptions() {
1203 assert(constructor_
.exceptions
.size() <= SAL_MAX_INT32
);
1204 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.exceptions
.size());
1206 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
1207 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1209 manager_
->resolve(constructor_
.exceptions
[i
]),
1210 css::uno::UNO_QUERY_THROW
);
1215 typedef cppu::ImplInheritanceHelper
<
1216 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1217 SingleInterfaceBasedServiceDescription_Base
;
1219 class SingleInterfaceBasedServiceDescription
:
1220 public SingleInterfaceBasedServiceDescription_Base
1223 SingleInterfaceBasedServiceDescription(
1224 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1225 OUString
const & name
,
1226 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
1228 SingleInterfaceBasedServiceDescription_Base(entity
->isPublished()),
1229 manager_(manager
), name_(name
), entity_(entity
)
1230 { assert(manager
.is()); assert(entity
.is()); }
1233 virtual ~SingleInterfaceBasedServiceDescription() override
{}
1235 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1236 { return css::uno::TypeClass_SERVICE
; }
1238 virtual OUString SAL_CALL
getName() override
1243 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1244 SAL_CALL
getMandatoryServices() override
1246 return css::uno::Sequence
<
1247 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1252 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1253 SAL_CALL
getOptionalServices() override
1255 return css::uno::Sequence
<
1256 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1261 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1262 SAL_CALL
getMandatoryInterfaces() override
1264 return css::uno::Sequence
<
1265 css::uno::Reference
<
1266 css::reflection::XInterfaceTypeDescription
> >();
1271 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1272 SAL_CALL
getOptionalInterfaces() override
1274 return css::uno::Sequence
<
1275 css::uno::Reference
<
1276 css::reflection::XInterfaceTypeDescription
> >();
1281 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1282 SAL_CALL
getProperties() override
1284 return css::uno::Sequence
<
1285 css::uno::Reference
<
1286 css::reflection::XPropertyTypeDescription
> >();
1289 virtual sal_Bool SAL_CALL
isSingleInterfaceBased() override
1292 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1293 getInterface() override
1294 { return manager_
->resolve(entity_
->getBase()); }
1298 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1299 SAL_CALL
getConstructors() override
;
1301 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1303 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> entity_
;
1307 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1308 SingleInterfaceBasedServiceDescription::getConstructors()
1310 assert(entity_
->getConstructors().size() <= SAL_MAX_INT32
);
1311 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getConstructors().size());
1313 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1315 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1316 s
[i
] = new ConstructorDescription(
1317 manager_
, entity_
->getConstructors()[i
]);
1322 class PropertyDescription
:
1323 public cppu::WeakImplHelper
< css::reflection::XPropertyTypeDescription
>
1326 PropertyDescription(
1327 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1328 unoidl::AccumulationBasedServiceEntity::Property
const & property
):
1329 manager_(manager
), property_(property
)
1330 { assert(manager
.is()); }
1333 virtual ~PropertyDescription() override
{}
1335 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1336 { return css::uno::TypeClass_PROPERTY
; }
1338 virtual OUString SAL_CALL
getName() override
1339 { return property_
.name
; }
1341 virtual sal_Int16 SAL_CALL
getPropertyFlags() override
1342 { return property_
.attributes
; }
1344 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1345 getPropertyTypeDescription() override
1346 { return manager_
->resolve(property_
.type
); }
1348 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1349 unoidl::AccumulationBasedServiceEntity::Property property_
;
1352 typedef cppu::ImplInheritanceHelper
<
1353 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1354 AccumulationBasedServiceDescription_Base
;
1356 class AccumulationBasedServiceDescription
:
1357 public AccumulationBasedServiceDescription_Base
1360 AccumulationBasedServiceDescription(
1361 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1362 OUString
const & name
,
1363 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const &
1365 AccumulationBasedServiceDescription_Base(entity
->isPublished()),
1366 manager_(manager
), name_(name
), entity_(entity
)
1367 { assert(manager
.is()); assert(entity
.is()); }
1370 virtual ~AccumulationBasedServiceDescription() override
{}
1372 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1373 { return css::uno::TypeClass_SERVICE
; }
1375 virtual OUString SAL_CALL
getName() override
1380 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1381 SAL_CALL
getMandatoryServices() override
;
1385 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1386 SAL_CALL
getOptionalServices() override
;
1390 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1391 SAL_CALL
getMandatoryInterfaces() override
;
1395 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1396 SAL_CALL
getOptionalInterfaces() override
;
1400 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1401 SAL_CALL
getProperties() override
;
1403 virtual sal_Bool SAL_CALL
isSingleInterfaceBased() override
1406 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1407 getInterface() override
1408 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1412 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1413 SAL_CALL
getConstructors() override
1415 return css::uno::Sequence
<
1416 css::uno::Reference
<
1417 css::reflection::XServiceConstructorDescription
> >();
1420 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1422 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> entity_
;
1426 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1427 AccumulationBasedServiceDescription::getMandatoryServices()
1429 assert(entity_
->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32
);
1430 sal_Int32 n
= static_cast< sal_Int32
>(
1431 entity_
->getDirectMandatoryBaseServices().size());
1433 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1434 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1437 entity_
->getDirectMandatoryBaseServices()[i
].name
),
1438 css::uno::UNO_QUERY_THROW
);
1444 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1445 AccumulationBasedServiceDescription::getOptionalServices()
1447 assert(entity_
->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32
);
1448 sal_Int32 n
= static_cast< sal_Int32
>(
1449 entity_
->getDirectOptionalBaseServices().size());
1451 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1452 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1454 manager_
->resolve(entity_
->getDirectOptionalBaseServices()[i
].name
),
1455 css::uno::UNO_QUERY_THROW
);
1461 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1462 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1464 assert(entity_
->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32
);
1465 sal_Int32 n
= static_cast< sal_Int32
>(
1466 entity_
->getDirectMandatoryBaseInterfaces().size());
1468 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1470 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1474 entity_
->getDirectMandatoryBaseInterfaces()[i
].name
)),
1475 css::uno::UNO_QUERY_THROW
);
1481 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1482 AccumulationBasedServiceDescription::getOptionalInterfaces()
1484 assert(entity_
->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32
);
1485 sal_Int32 n
= static_cast< sal_Int32
>(
1486 entity_
->getDirectOptionalBaseInterfaces().size());
1488 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1490 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1494 entity_
->getDirectOptionalBaseInterfaces()[i
].name
)),
1495 css::uno::UNO_QUERY_THROW
);
1501 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1502 AccumulationBasedServiceDescription::getProperties()
1504 assert(entity_
->getDirectProperties().size() <= SAL_MAX_INT32
);
1505 sal_Int32 n
= static_cast< sal_Int32
>(
1506 entity_
->getDirectProperties().size());
1508 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> > s(n
);
1509 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1510 s
[i
] = new PropertyDescription(
1511 manager_
, entity_
->getDirectProperties()[i
]);
1516 typedef cppu::ImplInheritanceHelper
<
1517 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1518 InterfaceBasedSingletonDescription_Base
;
1520 class InterfaceBasedSingletonDescription
:
1521 public InterfaceBasedSingletonDescription_Base
1524 InterfaceBasedSingletonDescription(
1525 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1526 OUString
const & name
,
1527 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
):
1528 InterfaceBasedSingletonDescription_Base(entity
->isPublished()),
1529 manager_(manager
), name_(name
), entity_(entity
)
1530 { assert(manager
.is()); assert(entity
.is()); }
1533 virtual ~InterfaceBasedSingletonDescription() override
{}
1535 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1536 { return css::uno::TypeClass_SINGLETON
; }
1538 virtual OUString SAL_CALL
getName() override
1541 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1542 SAL_CALL
getService() override
1545 css::uno::Reference
< css::reflection::XServiceTypeDescription
>();
1548 virtual sal_Bool SAL_CALL
isInterfaceBased() override
1551 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1552 SAL_CALL
getInterface() override
1553 { return manager_
->resolve(entity_
->getBase()); }
1555 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1557 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> entity_
;
1560 typedef cppu::ImplInheritanceHelper
<
1561 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1562 ServiceBasedSingletonDescription_Base
;
1564 class ServiceBasedSingletonDescription
:
1565 public ServiceBasedSingletonDescription_Base
1568 ServiceBasedSingletonDescription(
1569 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1570 OUString
const & name
,
1571 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> const & entity
):
1572 ServiceBasedSingletonDescription_Base(entity
->isPublished()),
1573 manager_(manager
), name_(name
), entity_(entity
)
1574 { assert(manager
.is()); assert(entity
.is()); }
1577 virtual ~ServiceBasedSingletonDescription() override
{}
1579 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1580 { return css::uno::TypeClass_SINGLETON
; }
1582 virtual OUString SAL_CALL
getName() override
1585 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1586 SAL_CALL
getService() override
1588 return css::uno::Reference
< css::reflection::XServiceTypeDescription
>(
1589 manager_
->resolve(entity_
->getBase()), css::uno::UNO_QUERY_THROW
);
1592 virtual sal_Bool SAL_CALL
isInterfaceBased() override
1595 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1596 SAL_CALL
getInterface() override
1597 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1599 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1601 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> entity_
;
1605 public cppu::WeakImplHelper
< css::reflection::XTypeDescriptionEnumeration
>
1609 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1610 OUString
const & prefix
,
1611 rtl::Reference
< unoidl::MapCursor
> const & cursor
,
1612 css::uno::Sequence
< css::uno::TypeClass
> const & types
, bool deep
):
1613 manager_(manager
), types_(types
), deep_(deep
)
1615 assert(manager
.is());
1616 positions_
.push(Position(prefix
, cursor
));
1621 virtual ~Enumeration() override
{}
1623 virtual sal_Bool SAL_CALL
hasMoreElements() override
1624 { return !positions_
.empty(); }
1626 virtual css::uno::Any SAL_CALL
nextElement() override
1627 { return css::uno::makeAny(nextTypeDescription()); }
1629 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1630 nextTypeDescription() override
;
1632 bool matches(css::uno::TypeClass tc
) const;
1634 void findNextMatch();
1638 OUString
const & thePrefix
,
1639 rtl::Reference
< unoidl::MapCursor
> const & theCursor
):
1640 prefix(thePrefix
), cursor(theCursor
)
1641 { assert(theCursor
.is()); }
1644 OUString
const & thePrefix
,
1645 rtl::Reference
< unoidl::ConstantGroupEntity
> const &
1647 prefix(thePrefix
), constantGroup(theConstantGroup
),
1648 constantGroupIndex(constantGroup
->getMembers().begin())
1649 { assert(theConstantGroup
.is()); }
1651 Position(Position
const & other
):
1652 prefix(other
.prefix
), cursor(other
.cursor
),
1653 constantGroup(other
.constantGroup
)
1655 if (constantGroup
.is()) {
1656 constantGroupIndex
= other
.constantGroupIndex
;
1661 rtl::Reference
< unoidl::MapCursor
> cursor
;
1662 rtl::Reference
< unoidl::ConstantGroupEntity
> constantGroup
;
1663 std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
1667 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1668 css::uno::Sequence
< css::uno::TypeClass
> types_
;
1672 std::stack
< Position
> positions_
;
1676 css::uno::Reference
< css::reflection::XTypeDescription
>
1677 Enumeration::nextTypeDescription()
1681 osl::MutexGuard
g(mutex_
);
1682 if (positions_
.empty()) {
1683 throw css::container::NoSuchElementException(
1684 "exhausted XTypeDescriptionEnumeration",
1685 static_cast< cppu::OWeakObject
* >(this));
1690 return manager_
->resolve(name
);
1693 bool Enumeration::matches(css::uno::TypeClass tc
) const {
1694 if (!types_
.hasElements()) {
1697 for (const auto & i
: types_
) {
1705 void Enumeration::findNextMatch() {
1708 assert(!positions_
.empty());
1710 if (positions_
.top().cursor
.is()) { // root or module
1711 rtl::Reference
< unoidl::Entity
> ent(
1712 positions_
.top().cursor
->getNext(&name
));
1715 if (positions_
.empty()) {
1720 name
= positions_
.top().prefix
+ name
;
1721 css::uno::TypeClass tc
;
1722 switch (ent
->getSort()) {
1723 case unoidl::Entity::SORT_MODULE
:
1724 tc
= css::uno::TypeClass_MODULE
;
1729 static_cast< unoidl::ModuleEntity
* >(
1730 ent
.get())->createCursor()));
1733 case unoidl::Entity::SORT_ENUM_TYPE
:
1734 tc
= css::uno::TypeClass_ENUM
;
1736 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
1737 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
1738 tc
= css::uno::TypeClass_STRUCT
;
1740 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
1741 tc
= css::uno::TypeClass_EXCEPTION
;
1743 case unoidl::Entity::SORT_INTERFACE_TYPE
:
1744 tc
= css::uno::TypeClass_INTERFACE
;
1746 case unoidl::Entity::SORT_TYPEDEF
:
1747 tc
= css::uno::TypeClass_TYPEDEF
;
1749 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1750 tc
= css::uno::TypeClass_CONSTANTS
;
1751 if (deep_
&& matches(css::uno::TypeClass_CONSTANT
)) {
1755 static_cast< unoidl::ConstantGroupEntity
* >(
1759 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
1760 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
1761 tc
= css::uno::TypeClass_SERVICE
;
1763 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
1764 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
1765 tc
= css::uno::TypeClass_SINGLETON
;
1768 for (;;) { std::abort(); } // this cannot happen
1774 } else { // constant group
1775 if (positions_
.top().constantGroupIndex
1776 == positions_
.top().constantGroup
->getMembers().end())
1779 if (positions_
.empty()) {
1784 current_
= positions_
.top().prefix
1785 + positions_
.top().constantGroupIndex
++->name
;
1789 } catch (unoidl::FileFormatException
& e
) {
1790 throw css::uno::DeploymentException(
1791 e
.getUri() + ": " + e
.getDetail(),
1792 static_cast< cppu::OWeakObject
* >(this));
1798 cppuhelper::TypeManager::TypeManager():
1799 TypeManager_Base(m_aMutex
),
1800 manager_(new unoidl::Manager
)
1803 css::uno::Any
cppuhelper::TypeManager::find(OUString
const & name
) {
1804 //TODO: caching? (here or in unoidl::Manager?)
1806 std::u16string_view name
;
1807 css::uno::TypeClass typeClass
;
1809 static Simple
const simple
[] = {
1810 { std::u16string_view(u
"void"), css::uno::TypeClass_VOID
},
1811 { std::u16string_view(u
"boolean"), css::uno::TypeClass_BOOLEAN
},
1812 { std::u16string_view(u
"byte"), css::uno::TypeClass_BYTE
},
1813 { std::u16string_view(u
"short"), css::uno::TypeClass_SHORT
},
1814 { std::u16string_view(u
"unsigned short"),
1815 css::uno::TypeClass_UNSIGNED_SHORT
},
1816 { std::u16string_view(u
"long"), css::uno::TypeClass_LONG
},
1817 { std::u16string_view(u
"unsigned long"), css::uno::TypeClass_UNSIGNED_LONG
},
1818 { std::u16string_view(u
"hyper"), css::uno::TypeClass_HYPER
},
1819 { std::u16string_view(u
"unsigned hyper"),
1820 css::uno::TypeClass_UNSIGNED_HYPER
},
1821 { std::u16string_view(u
"float"), css::uno::TypeClass_FLOAT
},
1822 { std::u16string_view(u
"double"), css::uno::TypeClass_DOUBLE
},
1823 { std::u16string_view(u
"char"), css::uno::TypeClass_CHAR
},
1824 { std::u16string_view(u
"string"), css::uno::TypeClass_STRING
},
1825 { std::u16string_view(u
"type"), css::uno::TypeClass_TYPE
},
1826 { std::u16string_view(u
"any"), css::uno::TypeClass_ANY
} };
1827 for (std::size_t i
= 0; i
!= SAL_N_ELEMENTS(simple
); ++i
) {
1828 if (name
== simple
[i
].name
) {
1829 return css::uno::makeAny
<
1830 css::uno::Reference
< css::reflection::XTypeDescription
> >(
1831 new SimpleTypeDescription(simple
[i
].typeClass
, name
));
1834 if (name
.startsWith("[]")) {
1835 return getSequenceType(name
);
1837 sal_Int32 i
= name
.indexOf('<');
1839 return getInstantiatedStruct(name
, i
);
1841 i
= name
.indexOf("::");
1843 return getInterfaceMember(name
, i
);
1845 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
));
1847 return getNamed(name
, ent
);
1849 i
= name
.lastIndexOf('.');
1851 OUString
parent(name
.copy(0, i
));
1852 ent
= findEntity(parent
);
1854 switch (ent
->getSort()) {
1855 case unoidl::Entity::SORT_ENUM_TYPE
:
1856 return getEnumMember(
1857 static_cast< unoidl::EnumTypeEntity
* >(ent
.get()),
1859 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1862 static_cast< unoidl::ConstantGroupEntity
* >(ent
.get()),
1869 return css::uno::Any();
1872 css::uno::Reference
< css::reflection::XTypeDescription
>
1873 cppuhelper::TypeManager::resolve(OUString
const & name
) {
1874 css::uno::Reference
< css::reflection::XTypeDescription
> desc(
1875 find(name
), css::uno::UNO_QUERY
);
1877 throw css::uno::DeploymentException(
1878 "cannot resolve type \"" + name
+ "\"",
1879 static_cast< cppu::OWeakObject
* >(this));
1884 cppuhelper::TypeManager::~TypeManager() throw () {}
1886 void cppuhelper::TypeManager::disposing() {} //TODO
1888 OUString
cppuhelper::TypeManager::getImplementationName()
1891 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager";
1894 sal_Bool
cppuhelper::TypeManager::supportsService(
1895 OUString
const & ServiceName
)
1897 return cppu::supportsService(this, ServiceName
);
1900 css::uno::Sequence
< OUString
>
1901 cppuhelper::TypeManager::getSupportedServiceNames()
1903 return { "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1906 css::uno::Any
cppuhelper::TypeManager::getByHierarchicalName(
1907 OUString
const & aName
)
1909 css::uno::Any
desc(find(aName
));
1910 if (!desc
.hasValue()) {
1911 throw css::container::NoSuchElementException(
1912 aName
, static_cast< cppu::OWeakObject
* >(this));
1917 sal_Bool
cppuhelper::TypeManager::hasByHierarchicalName(
1918 OUString
const & aName
)
1920 return find(aName
).hasValue();
1923 css::uno::Type
cppuhelper::TypeManager::getElementType()
1925 return cppu::UnoType
< OUString
>::get();
1928 sal_Bool
cppuhelper::TypeManager::hasElements()
1930 throw css::uno::RuntimeException(
1931 "TypeManager hasElements: method not supported",
1932 static_cast< cppu::OWeakObject
* >(this));
1935 css::uno::Reference
< css::container::XEnumeration
>
1936 cppuhelper::TypeManager::createEnumeration()
1938 throw css::uno::RuntimeException(
1939 "TypeManager createEnumeration: method not supported",
1940 static_cast< cppu::OWeakObject
* >(this));
1943 sal_Bool
cppuhelper::TypeManager::has(css::uno::Any
const &)
1945 throw css::uno::RuntimeException(
1946 "TypeManager has: method not supported",
1947 static_cast< cppu::OWeakObject
* >(this));
1950 void cppuhelper::TypeManager::insert(css::uno::Any
const & aElement
)
1953 if (!(aElement
>>= uri
)) {
1954 throw css::lang::IllegalArgumentException(
1955 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
1957 static_cast< cppu::OWeakObject
* >(this), 0);
1959 //TODO: check for ElementExistException
1960 //TODO: check for consistency with existing data
1961 readRdbFile(uri
, false);
1964 void cppuhelper::TypeManager::remove(css::uno::Any
const & aElement
)
1967 if (!(aElement
>>= uri
)) {
1968 throw css::lang::IllegalArgumentException(
1969 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
1971 static_cast< cppu::OWeakObject
* >(this), 0);
1973 //TODO: remove requests are silently ignored for now
1976 css::uno::Reference
< css::reflection::XTypeDescriptionEnumeration
>
1977 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
1978 OUString
const & moduleName
,
1979 css::uno::Sequence
< css::uno::TypeClass
> const & types
,
1980 css::reflection::TypeDescriptionSearchDepth depth
)
1982 rtl::Reference
< unoidl::MapCursor
> cursor
;
1984 cursor
= manager_
->createCursor(moduleName
);
1985 } catch (unoidl::FileFormatException
& e
) {
1986 throw css::uno::DeploymentException(
1987 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
1989 static_cast< cppu::OWeakObject
* >(this));
1992 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
1994 throw css::reflection::NoSuchTypeNameException(
1995 moduleName
, static_cast< cppu::OWeakObject
* >(this));
1997 return new Enumeration(
1998 this, makePrefix(moduleName
), cursor
, types
,
1999 depth
== css::reflection::TypeDescriptionSearchDepth_INFINITE
);
2002 void cppuhelper::TypeManager::init(OUString
const & rdbUris
) {
2003 for (sal_Int32 i
= 0; i
!= -1;) {
2004 OUString
uri(rdbUris
.getToken(0, ' ', i
));
2005 if (uri
.isEmpty()) {
2010 cppu::decodeRdbUri(&uri
, &optional
, &directory
);
2012 readRdbDirectory(uri
, optional
);
2014 readRdbFile(uri
, optional
);
2019 void cppuhelper::TypeManager::readRdbDirectory(
2020 OUString
const & uri
, bool optional
)
2022 osl::Directory
dir(uri
);
2023 switch (dir
.open()) {
2024 case osl::FileBase::E_None
:
2026 case osl::FileBase::E_NOENT
:
2028 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2033 throw css::uno::DeploymentException(
2034 "Cannot open directory " + uri
,
2035 static_cast< cppu::OWeakObject
* >(this));
2039 if (!cppu::nextDirectoryItem(dir
, &url
)) {
2042 readRdbFile(url
, false);
2046 void cppuhelper::TypeManager::readRdbFile(
2047 OUString
const & uri
, bool optional
)
2050 manager_
->addProvider(uri
);
2051 } catch (unoidl::NoSuchFileException
&) {
2053 throw css::uno::DeploymentException(
2054 uri
+ ": no such file",
2055 static_cast< cppu::OWeakObject
* >(this));
2057 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2058 } catch (unoidl::FileFormatException
& e
) {
2059 throw css::uno::DeploymentException(
2060 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2062 static_cast< cppu::OWeakObject
* >(this));
2066 css::uno::Any
cppuhelper::TypeManager::getSequenceType(
2067 OUString
const & name
)
2069 assert(name
.startsWith("[]"));
2070 return css::uno::makeAny
<
2071 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2072 new SequenceTypeDescription(
2073 this, name
, name
.copy(std::strlen("[]"))));
2076 css::uno::Any
cppuhelper::TypeManager::getInstantiatedStruct(
2077 OUString
const & name
, sal_Int32 separator
)
2079 assert(name
.indexOf('<') == separator
&& separator
!= -1);
2080 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
.copy(0, separator
)));
2083 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
))
2085 return css::uno::Any();
2087 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
2088 static_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
2090 std::vector
< OUString
> args
;
2091 sal_Int32 i
= separator
;
2093 ++i
; // skip '<' or ','
2095 for (sal_Int32 level
= 0; j
!= name
.getLength(); ++j
) {
2096 sal_Unicode c
= name
[j
];
2101 } else if (c
== '<') {
2103 } else if (c
== '>') {
2110 if (j
!= name
.getLength()) {
2111 args
.push_back(name
.copy(i
, j
- i
));
2114 } while (i
!= name
.getLength() && name
[i
] != '>');
2115 if (i
!= name
.getLength() - 1 || name
[i
] != '>'
2116 || args
.size() != ent2
->getTypeParameters().size())
2118 return css::uno::Any();
2120 return css::uno::makeAny
<
2121 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2122 new InstantiatedPolymorphicStructTypeDescription(
2123 this, name
, ent2
, args
));
2126 css::uno::Any
cppuhelper::TypeManager::getInterfaceMember(
2127 OUString
const & name
, sal_Int32 separator
)
2129 assert(name
.indexOf("::") == separator
&& separator
!= -1);
2130 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> ifc(
2131 resolveTypedefs(find(name
.copy(0, separator
))), css::uno::UNO_QUERY
);
2133 return css::uno::Any();
2135 OUString
member(name
.copy(separator
+ std::strlen("::")));
2136 const css::uno::Sequence
<
2137 css::uno::Reference
<
2138 css::reflection::XInterfaceMemberTypeDescription
> > mems(
2140 for (const auto & m
: mems
) {
2141 if (m
->getMemberName() == member
) {
2142 return css::uno::makeAny
<
2143 css::uno::Reference
< css::reflection::XTypeDescription
> >(m
);
2146 return css::uno::Any();
2149 css::uno::Any
cppuhelper::TypeManager::getNamed(
2150 OUString
const & name
, rtl::Reference
< unoidl::Entity
> const & entity
)
2152 assert(entity
.is());
2153 switch (entity
->getSort()) {
2154 case unoidl::Entity::SORT_MODULE
:
2155 return css::uno::makeAny
<
2156 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2157 new ModuleDescription(
2159 static_cast< unoidl::ModuleEntity
* >(entity
.get())));
2160 case unoidl::Entity::SORT_ENUM_TYPE
:
2161 return css::uno::makeAny
<
2162 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2163 new EnumTypeDescription(
2165 static_cast< unoidl::EnumTypeEntity
* >(entity
.get())));
2166 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
2167 return css::uno::makeAny
<
2168 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2169 new PlainStructTypeDescription(
2171 static_cast< unoidl::PlainStructTypeEntity
* >(
2173 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
2174 return css::uno::makeAny
<
2175 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2176 new PolymorphicStructTypeTemplateDescription(
2179 unoidl::PolymorphicStructTypeTemplateEntity
* >(
2181 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
2182 return css::uno::makeAny
<
2183 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2184 new ExceptionTypeDescription(
2186 static_cast< unoidl::ExceptionTypeEntity
* >(
2188 case unoidl::Entity::SORT_INTERFACE_TYPE
:
2189 return css::uno::makeAny
<
2190 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2191 new InterfaceTypeDescription(
2193 static_cast< unoidl::InterfaceTypeEntity
* >(
2195 case unoidl::Entity::SORT_TYPEDEF
:
2196 return css::uno::makeAny
<
2197 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2198 new TypedefDescription(
2200 static_cast< unoidl::TypedefEntity
* >(entity
.get())));
2201 case unoidl::Entity::SORT_CONSTANT_GROUP
:
2202 return css::uno::makeAny
<
2203 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2204 new ConstantGroupDescription(
2206 static_cast< unoidl::ConstantGroupEntity
* >(
2208 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
2209 return css::uno::makeAny
<
2210 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2211 new SingleInterfaceBasedServiceDescription(
2213 static_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
2215 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
2216 return css::uno::makeAny
<
2217 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2218 new AccumulationBasedServiceDescription(
2220 static_cast< unoidl::AccumulationBasedServiceEntity
* >(
2222 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
2223 return css::uno::makeAny
<
2224 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2225 new InterfaceBasedSingletonDescription(
2227 static_cast< unoidl::InterfaceBasedSingletonEntity
* >(
2229 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
2230 return css::uno::makeAny
<
2231 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2232 new ServiceBasedSingletonDescription(
2234 static_cast< unoidl::ServiceBasedSingletonEntity
* >(
2237 for (;;) { std::abort(); } // this cannot happen
2241 css::uno::Any
cppuhelper::TypeManager::getEnumMember(
2242 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
2243 OUString
const & member
)
2245 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2246 [&member
](const unoidl::EnumTypeEntity::Member
& rMember
) { return rMember
.name
== member
; });
2247 if (i
!= entity
->getMembers().end())
2248 return css::uno::makeAny(i
->value
);
2249 return css::uno::Any();
2252 css::uno::Any
cppuhelper::TypeManager::getConstant(
2253 OUString
const & constantGroupName
,
2254 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
2255 OUString
const & member
)
2257 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2258 [&member
](const unoidl::ConstantGroupEntity::Member
& rMember
) { return rMember
.name
== member
; });
2259 if (i
!= entity
->getMembers().end())
2260 return css::uno::makeAny
<
2261 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2262 new ConstantDescription(constantGroupName
, *i
));
2263 return css::uno::Any();
2266 rtl::Reference
< unoidl::Entity
> cppuhelper::TypeManager::findEntity(
2267 OUString
const & name
)
2270 return manager_
->findEntity(name
);
2271 } catch (unoidl::FileFormatException
& e
) {
2272 throw css::uno::DeploymentException(
2273 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2275 static_cast< cppu::OWeakObject
* >(this));
2279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */