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>
19 #include <string_view>
23 #include <com/sun/star/container/NoSuchElementException.hpp>
24 #include <com/sun/star/lang/IllegalArgumentException.hpp>
25 #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
26 #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
27 #include <com/sun/star/reflection/XConstantTypeDescription.hpp>
28 #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
29 #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
30 #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
31 #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
32 #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
33 #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
34 #include <com/sun/star/reflection/XModuleTypeDescription.hpp>
35 #include <com/sun/star/reflection/XPublished.hpp>
36 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
37 #include <com/sun/star/reflection/XSingletonTypeDescription2.hpp>
38 #include <com/sun/star/reflection/XStructTypeDescription.hpp>
39 #include <com/sun/star/reflection/XTypeDescription.hpp>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/DeploymentException.hpp>
42 #include <com/sun/star/uno/Reference.hxx>
43 #include <com/sun/star/uno/RuntimeException.hpp>
44 #include <com/sun/star/uno/Sequence.hxx>
45 #include <com/sun/star/uno/Type.hxx>
46 #include <com/sun/star/uno/TypeClass.hpp>
47 #include <cppu/unotype.hxx>
48 #include <cppuhelper/implbase.hxx>
49 #include <cppuhelper/supportsservice.hxx>
50 #include <osl/file.hxx>
51 #include <rtl/ref.hxx>
52 #include <rtl/ustring.hxx>
53 #include <sal/log.hxx>
54 #include <sal/macros.h>
55 #include <sal/types.h>
56 #include <o3tl/string_view.hxx>
58 #include <unoidl/unoidl.hxx>
61 #include "typemanager.hxx"
65 OUString
makePrefix(OUString
const & name
) {
66 return name
.isEmpty() ? name
: name
+ ".";
69 css::uno::Any
resolveTypedefs(css::uno::Any
const & type
) {
70 for (css::uno::Any
t(type
);;) {
71 css::uno::Reference
< css::reflection::XIndirectTypeDescription
> ind(
72 type
, css::uno::UNO_QUERY
);
73 if (!ind
.is() || ind
->getTypeClass() != css::uno::TypeClass_TYPEDEF
) {
76 t
<<= ind
->getReferencedType();
80 class SimpleTypeDescription
:
81 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
84 SimpleTypeDescription(
85 css::uno::TypeClass typeClass
, OUString name
):
86 typeClass_(typeClass
), name_(std::move(name
))
90 virtual ~SimpleTypeDescription() override
{}
92 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
93 { return typeClass_
; }
95 virtual OUString SAL_CALL
getName() override
98 css::uno::TypeClass typeClass_
;
102 class SequenceTypeDescription
:
103 public cppu::WeakImplHelper
< css::reflection::XIndirectTypeDescription
>
106 SequenceTypeDescription(
107 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
108 OUString name
, OUString componentType
):
109 manager_(manager
), name_(std::move(name
)), componentType_(std::move(componentType
))
110 { assert(manager
.is()); }
113 virtual ~SequenceTypeDescription() override
{}
115 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
116 { return css::uno::TypeClass_SEQUENCE
; }
118 virtual OUString SAL_CALL
getName() override
121 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
122 getReferencedType() override
123 { return manager_
->resolve(componentType_
); }
125 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
127 OUString componentType_
;
130 class PublishableDescription
:
131 public cppu::WeakImplHelper
< css::reflection::XPublished
>
134 explicit PublishableDescription(bool published
): published_(published
) {}
136 virtual ~PublishableDescription() override
{}
139 virtual sal_Bool SAL_CALL
isPublished() override
140 { return published_
; }
145 class ModuleDescription
:
146 public cppu::WeakImplHelper
< css::reflection::XModuleTypeDescription
>
150 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
152 rtl::Reference
< unoidl::ModuleEntity
> const & entity
):
153 manager_(manager
), name_(std::move(name
)), entity_(entity
)
154 { assert(manager
.is()); assert(entity
.is()); }
157 virtual ~ModuleDescription() override
{}
159 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
160 { return css::uno::TypeClass_MODULE
; }
162 virtual OUString SAL_CALL
getName() override
167 css::uno::Reference
< css::reflection::XTypeDescription
> >
168 SAL_CALL
getMembers() override
;
170 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
172 rtl::Reference
< unoidl::ModuleEntity
> entity_
;
175 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
176 ModuleDescription::getMembers() {
178 std::vector
< OUString
> names(entity_
->getMemberNames());
179 assert(names
.size() <= SAL_MAX_INT32
);
180 sal_Int32 n
= static_cast< sal_Int32
>(names
.size());
182 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
183 auto r
= asNonConstRange(s
);
184 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
185 r
[i
] = manager_
->resolve(makePrefix(name_
) + names
[i
]);
188 } catch (unoidl::FileFormatException
& e
) {
189 throw css::uno::DeploymentException(
190 e
.getUri() + ": " + e
.getDetail(),
191 static_cast< cppu::OWeakObject
* >(this));
195 typedef cppu::ImplInheritanceHelper
<
196 PublishableDescription
, css::reflection::XEnumTypeDescription
>
197 EnumTypeDescription_Base
;
199 class EnumTypeDescription
: public EnumTypeDescription_Base
{
203 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
):
204 EnumTypeDescription_Base(entity
->isPublished()), name_(std::move(name
)),
206 { assert(entity
.is()); }
209 virtual ~EnumTypeDescription() override
{}
211 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
212 { return css::uno::TypeClass_ENUM
; }
214 virtual OUString SAL_CALL
getName() override
217 virtual sal_Int32 SAL_CALL
getDefaultEnumValue() override
218 { return entity_
->getMembers()[0].value
; }
220 virtual css::uno::Sequence
< OUString
> SAL_CALL
getEnumNames() override
;
222 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getEnumValues() override
;
225 rtl::Reference
< unoidl::EnumTypeEntity
> entity_
;
228 css::uno::Sequence
< OUString
> EnumTypeDescription::getEnumNames()
230 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
231 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
232 css::uno::Sequence
< OUString
> s(n
);
233 auto r
= asNonConstRange(s
);
234 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
235 r
[i
] = entity_
->getMembers()[i
].name
;
240 css::uno::Sequence
< sal_Int32
> EnumTypeDescription::getEnumValues()
242 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
243 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
244 css::uno::Sequence
< sal_Int32
> s(n
);
245 auto r
= asNonConstRange(s
);
246 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
247 r
[i
] = entity_
->getMembers()[i
].value
;
252 typedef cppu::ImplInheritanceHelper
<
253 PublishableDescription
, css::reflection::XStructTypeDescription
>
254 PlainStructTypeDescription_Base
;
256 class PlainStructTypeDescription
: public PlainStructTypeDescription_Base
{
258 PlainStructTypeDescription(
259 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
261 rtl::Reference
< unoidl::PlainStructTypeEntity
> const & entity
):
262 PlainStructTypeDescription_Base(entity
->isPublished()),
263 manager_(manager
), name_(std::move(name
)), entity_(entity
)
264 { assert(manager
.is()); assert(entity
.is()); }
267 virtual ~PlainStructTypeDescription() override
{}
269 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
270 { return css::uno::TypeClass_STRUCT
; }
272 virtual OUString SAL_CALL
getName() override
275 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
276 getBaseType() override
{
277 return entity_
->getDirectBase().isEmpty()
278 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
279 : manager_
->resolve(entity_
->getDirectBase());
284 css::uno::Reference
< css::reflection::XTypeDescription
> >
285 SAL_CALL
getMemberTypes() override
;
287 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
289 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
290 { return css::uno::Sequence
< OUString
>(); }
294 css::uno::Reference
< css::reflection::XTypeDescription
> >
295 SAL_CALL
getTypeArguments() override
{
296 return css::uno::Sequence
<
297 css::uno::Reference
< css::reflection::XTypeDescription
> >();
300 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
302 rtl::Reference
< unoidl::PlainStructTypeEntity
> entity_
;
305 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
306 PlainStructTypeDescription::getMemberTypes()
308 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
309 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
311 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
312 auto r
= asNonConstRange(s
);
313 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
314 r
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
319 css::uno::Sequence
< OUString
> PlainStructTypeDescription::getMemberNames()
321 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
322 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
323 css::uno::Sequence
< OUString
> s(n
);
324 auto r
= asNonConstRange(s
);
325 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
326 r
[i
] = entity_
->getDirectMembers()[i
].name
;
331 class ParameterizedMemberTypeDescription
:
332 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
335 explicit ParameterizedMemberTypeDescription(
336 OUString typeParameterName
):
337 typeParameterName_(std::move(typeParameterName
))
341 virtual ~ParameterizedMemberTypeDescription() override
{}
343 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
344 { return css::uno::TypeClass_UNKNOWN
; }
346 virtual OUString SAL_CALL
getName() override
347 { return typeParameterName_
; }
349 OUString typeParameterName_
;
352 typedef cppu::ImplInheritanceHelper
<
353 PublishableDescription
, css::reflection::XStructTypeDescription
>
354 PolymorphicStructTypeTemplateDescription_Base
;
356 class PolymorphicStructTypeTemplateDescription
:
357 public PolymorphicStructTypeTemplateDescription_Base
360 PolymorphicStructTypeTemplateDescription(
361 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
363 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
365 PolymorphicStructTypeTemplateDescription_Base(entity
->isPublished()),
366 manager_(manager
), name_(std::move(name
)), entity_(entity
)
367 { assert(manager
.is()); assert(entity
.is()); }
370 virtual ~PolymorphicStructTypeTemplateDescription() override
{}
372 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
373 { return css::uno::TypeClass_STRUCT
; }
375 virtual OUString SAL_CALL
getName() override
378 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
379 getBaseType() override
380 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
384 css::uno::Reference
< css::reflection::XTypeDescription
> >
385 SAL_CALL
getMemberTypes() override
;
387 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
389 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
;
393 css::uno::Reference
< css::reflection::XTypeDescription
> >
394 SAL_CALL
getTypeArguments() override
{
395 return css::uno::Sequence
<
396 css::uno::Reference
< css::reflection::XTypeDescription
> >();
399 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
401 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
404 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
405 PolymorphicStructTypeTemplateDescription::getMemberTypes()
407 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
408 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
410 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
411 auto r
= asNonConstRange(s
);
412 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
413 r
[i
] = entity_
->getMembers()[i
].parameterized
414 ? new ParameterizedMemberTypeDescription(
415 entity_
->getMembers()[i
].type
)
416 : manager_
->resolve(entity_
->getMembers()[i
].type
);
421 css::uno::Sequence
< OUString
>
422 PolymorphicStructTypeTemplateDescription::getMemberNames()
424 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
425 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
426 css::uno::Sequence
< OUString
> s(n
);
427 auto r
= asNonConstRange(s
);
428 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
429 r
[i
] = entity_
->getMembers()[i
].name
;
434 css::uno::Sequence
< OUString
>
435 PolymorphicStructTypeTemplateDescription::getTypeParameters()
437 assert(entity_
->getTypeParameters().size() <= SAL_MAX_INT32
);
438 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getTypeParameters().size());
439 css::uno::Sequence
< OUString
> s(n
);
440 auto r
= asNonConstRange(s
);
441 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
442 r
[i
] = entity_
->getTypeParameters()[i
];
447 class InstantiatedPolymorphicStructTypeDescription
:
448 public cppu::WeakImplHelper
< css::reflection::XStructTypeDescription
>
451 InstantiatedPolymorphicStructTypeDescription(
452 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
454 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
456 std::vector
< OUString
>&& arguments
):
457 manager_(manager
), name_(std::move(name
)), entity_(entity
), arguments_(std::move(arguments
))
459 assert(manager
.is());
461 assert(arguments_
.size() == entity
->getTypeParameters().size());
465 virtual ~InstantiatedPolymorphicStructTypeDescription() override
{}
467 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
468 { return css::uno::TypeClass_STRUCT
; }
470 virtual OUString SAL_CALL
getName() override
473 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
474 getBaseType() override
475 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
479 css::uno::Reference
< css::reflection::XTypeDescription
> >
480 SAL_CALL
getMemberTypes() override
;
482 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
484 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
485 { return css::uno::Sequence
< OUString
>(); }
489 css::uno::Reference
< css::reflection::XTypeDescription
> >
490 SAL_CALL
getTypeArguments() override
;
492 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
494 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
495 std::vector
< OUString
> arguments_
;
498 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
499 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
501 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
502 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
504 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
505 auto r
= asNonConstRange(s
);
506 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
507 OUString
type(entity_
->getMembers()[i
].type
);
508 if (entity_
->getMembers()[i
].parameterized
) {
509 auto j
= std::find(entity_
->getTypeParameters().begin(), entity_
->getTypeParameters().end(), type
);
510 if (j
!= entity_
->getTypeParameters().end()) {
511 type
= arguments_
[j
- entity_
->getTypeParameters().begin()];
514 assert(false); // this cannot happen //TODO!
517 r
[i
] = manager_
->resolve(type
);
522 css::uno::Sequence
< OUString
>
523 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
525 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
526 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
527 css::uno::Sequence
< OUString
> s(n
);
528 auto r
= asNonConstRange(s
);
529 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
530 r
[i
] = entity_
->getMembers()[i
].name
;
534 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
535 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
537 assert(arguments_
.size() <= SAL_MAX_INT32
);
538 sal_Int32 n
= static_cast< sal_Int32
>(arguments_
.size());
540 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
541 auto r
= asNonConstRange(s
);
542 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
543 r
[i
] = manager_
->resolve(arguments_
[i
]);
548 typedef cppu::ImplInheritanceHelper
<
549 PublishableDescription
, css::reflection::XCompoundTypeDescription
>
550 ExceptionTypeDescription_Base
;
552 class ExceptionTypeDescription
: public ExceptionTypeDescription_Base
{
554 ExceptionTypeDescription(
555 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
557 rtl::Reference
< unoidl::ExceptionTypeEntity
> const & entity
):
558 ExceptionTypeDescription_Base(entity
->isPublished()), manager_(manager
),
559 name_(std::move(name
)), entity_(entity
)
560 { assert(manager
.is()); assert(entity
.is()); }
563 virtual ~ExceptionTypeDescription() override
{}
565 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
566 { return css::uno::TypeClass_EXCEPTION
; }
568 virtual OUString SAL_CALL
getName() override
571 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
572 getBaseType() override
{
573 return entity_
->getDirectBase().isEmpty()
574 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
575 : manager_
->resolve(entity_
->getDirectBase());
580 css::uno::Reference
< css::reflection::XTypeDescription
> >
581 SAL_CALL
getMemberTypes() override
;
583 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
585 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
587 rtl::Reference
< unoidl::ExceptionTypeEntity
> entity_
;
590 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
591 ExceptionTypeDescription::getMemberTypes() {
592 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
593 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
595 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
596 auto r
= asNonConstRange(s
);
597 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
598 r
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
603 css::uno::Sequence
< OUString
> ExceptionTypeDescription::getMemberNames()
605 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
606 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
607 css::uno::Sequence
< OUString
> s(n
);
608 auto r
= asNonConstRange(s
);
609 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
610 r
[i
] = entity_
->getDirectMembers()[i
].name
;
615 class AttributeDescription
:
616 public cppu::WeakImplHelper
<
617 css::reflection::XInterfaceAttributeTypeDescription2
>
620 AttributeDescription(
621 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
623 unoidl::InterfaceTypeEntity::Attribute attribute
,
625 manager_(manager
), name_(std::move(name
)), attribute_(std::move(attribute
)),
627 { assert(manager
.is()); }
630 virtual ~AttributeDescription() override
{}
632 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
633 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE
; }
635 virtual OUString SAL_CALL
getName() override
638 virtual OUString SAL_CALL
getMemberName() override
639 { return attribute_
.name
; }
641 virtual sal_Int32 SAL_CALL
getPosition() override
642 { return position_
; }
644 virtual sal_Bool SAL_CALL
isReadOnly() override
645 { return attribute_
.readOnly
; }
647 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
649 { return manager_
->resolve(attribute_
.type
); }
651 virtual sal_Bool SAL_CALL
isBound() override
652 { return attribute_
.bound
; }
656 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
657 SAL_CALL
getGetExceptions() override
;
661 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
662 SAL_CALL
getSetExceptions() override
;
664 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
666 unoidl::InterfaceTypeEntity::Attribute attribute_
;
671 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
672 AttributeDescription::getGetExceptions() {
673 assert(attribute_
.getExceptions
.size() <= SAL_MAX_INT32
);
674 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.getExceptions
.size());
676 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
677 auto r
= asNonConstRange(s
);
678 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
680 manager_
->resolve(attribute_
.getExceptions
[i
]),
681 css::uno::UNO_QUERY_THROW
);
687 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
688 AttributeDescription::getSetExceptions() {
689 assert(attribute_
.setExceptions
.size() <= SAL_MAX_INT32
);
690 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.setExceptions
.size());
692 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
693 auto r
= asNonConstRange(s
);
694 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
696 manager_
->resolve(attribute_
.setExceptions
[i
]),
697 css::uno::UNO_QUERY_THROW
);
702 class MethodParameter
:
703 public cppu::WeakImplHelper
< css::reflection::XMethodParameter
>
707 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
708 unoidl::InterfaceTypeEntity::Method::Parameter parameter
,
710 manager_(manager
), parameter_(std::move(parameter
)), position_(position
)
711 { assert(manager
.is()); }
714 virtual ~MethodParameter() override
{}
716 virtual OUString SAL_CALL
getName() override
717 { return parameter_
.name
; }
719 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
721 { return manager_
->resolve(parameter_
.type
); }
723 virtual sal_Bool SAL_CALL
isIn() override
{
725 (parameter_
.direction
726 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
727 || (parameter_
.direction
728 == unoidl::InterfaceTypeEntity::Method::Parameter::
732 virtual sal_Bool SAL_CALL
isOut() override
{
734 (parameter_
.direction
735 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
)
736 || (parameter_
.direction
737 == unoidl::InterfaceTypeEntity::Method::Parameter::
741 virtual sal_Int32 SAL_CALL
getPosition() override
742 { return position_
; }
744 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
745 unoidl::InterfaceTypeEntity::Method::Parameter parameter_
;
749 class MethodDescription
:
750 public cppu::WeakImplHelper
<
751 css::reflection::XInterfaceMethodTypeDescription
>
755 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
757 unoidl::InterfaceTypeEntity::Method method
, sal_Int32 position
):
758 manager_(manager
), name_(std::move(name
)), method_(std::move(method
)), position_(position
)
759 { assert(manager
.is()); }
762 virtual ~MethodDescription() override
{}
764 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
765 { return css::uno::TypeClass_INTERFACE_METHOD
; }
767 virtual OUString SAL_CALL
getName() override
770 virtual OUString SAL_CALL
getMemberName() override
771 { return method_
.name
; }
773 virtual sal_Int32 SAL_CALL
getPosition() override
774 { return position_
; }
776 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
777 getReturnType() override
778 { return manager_
->resolve(method_
.returnType
); }
780 virtual sal_Bool SAL_CALL
isOneway() override
785 css::uno::Reference
< css::reflection::XMethodParameter
> >
786 SAL_CALL
getParameters() override
;
790 css::uno::Reference
< css::reflection::XTypeDescription
> >
791 SAL_CALL
getExceptions() override
;
793 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
795 unoidl::InterfaceTypeEntity::Method method_
;
799 css::uno::Sequence
< css::uno::Reference
< css::reflection::XMethodParameter
> >
800 MethodDescription::getParameters() {
801 assert(method_
.parameters
.size() <= SAL_MAX_INT32
);
802 sal_Int32 n
= static_cast< sal_Int32
>(method_
.parameters
.size());
804 css::uno::Reference
< css::reflection::XMethodParameter
> > s(n
);
805 auto r
= asNonConstRange(s
);
806 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
807 r
[i
] = new MethodParameter(manager_
, method_
.parameters
[i
], i
);
812 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
813 MethodDescription::getExceptions() {
814 assert(method_
.exceptions
.size() <= SAL_MAX_INT32
);
815 sal_Int32 n
= static_cast< sal_Int32
>(method_
.exceptions
.size());
817 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
818 auto r
= asNonConstRange(s
);
819 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
820 r
[i
] = manager_
->resolve(method_
.exceptions
[i
]);
828 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
829 const & description
);
831 BaseOffset(const BaseOffset
&) = delete;
832 const BaseOffset
& operator=(const BaseOffset
&) = delete;
834 sal_Int32
get() const { return offset_
; }
838 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
839 const & description
);
842 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
843 const & description
);
845 std::set
< OUString
> set_
;
849 BaseOffset::BaseOffset(
850 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
854 calculateBases(description
);
857 void BaseOffset::calculateBases(
858 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
861 const css::uno::Sequence
<
862 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
863 description
->getBaseTypes());
864 for (const auto & i
: bases
) {
866 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
867 resolveTypedefs(css::uno::Any(i
)),
868 css::uno::UNO_QUERY_THROW
));
872 void BaseOffset::calculate(
873 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
876 if (set_
.insert(description
->getName()).second
) {
877 calculateBases(description
);
878 offset_
+= description
->getMembers().getLength();
882 typedef cppu::ImplInheritanceHelper
<
883 PublishableDescription
, css::reflection::XInterfaceTypeDescription2
>
884 InterfaceTypeDescription_Base
;
886 class InterfaceTypeDescription
: public InterfaceTypeDescription_Base
{
888 InterfaceTypeDescription(
889 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
891 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
892 InterfaceTypeDescription_Base(entity
->isPublished()), manager_(manager
),
893 name_(std::move(name
)), entity_(entity
)
894 { assert(manager
.is()); assert(entity
.is()); }
897 virtual ~InterfaceTypeDescription() override
{}
899 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
900 { return css::uno::TypeClass_INTERFACE
; }
902 virtual OUString SAL_CALL
getName() override
905 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
906 getBaseType() override
{
907 return entity_
->getDirectMandatoryBases().empty()
908 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
909 : manager_
->resolve(entity_
->getDirectMandatoryBases()[0].name
);
912 virtual css::uno::Uik SAL_CALL
getUik() override
913 { return css::uno::Uik(); }
918 css::reflection::XInterfaceMemberTypeDescription
> >
919 SAL_CALL
getMembers() override
;
923 css::uno::Reference
< css::reflection::XTypeDescription
> >
924 SAL_CALL
getBaseTypes() override
;
928 css::uno::Reference
< css::reflection::XTypeDescription
> >
929 SAL_CALL
getOptionalBaseTypes() override
;
931 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
933 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
937 css::uno::Reference
< css::reflection::XInterfaceMemberTypeDescription
> >
938 InterfaceTypeDescription::getMembers() {
940 entity_
->getDirectAttributes().size() <= SAL_MAX_INT32
941 && (entity_
->getDirectMethods().size()
942 <= SAL_MAX_INT32
- entity_
->getDirectAttributes().size()));
943 sal_Int32 n1
= static_cast< sal_Int32
>(
944 entity_
->getDirectAttributes().size());
945 sal_Int32 n2
= static_cast< sal_Int32
>(entity_
->getDirectMethods().size());
948 css::reflection::XInterfaceMemberTypeDescription
> > s(n1
+ n2
);
949 auto r
= asNonConstRange(s
);
950 sal_Int32 off
= BaseOffset(this).get();
951 for (sal_Int32 i
= 0; i
!= n1
; ++i
) {
952 r
[i
] = new AttributeDescription(
953 manager_
, name_
+ "::" + entity_
->getDirectAttributes()[i
].name
,
954 entity_
->getDirectAttributes()[i
], off
+ i
);
956 for (sal_Int32 i
= 0; i
!= n2
; ++i
) {
957 r
[n1
+ i
] = new MethodDescription(
958 manager_
, name_
+ "::" + entity_
->getDirectMethods()[i
].name
,
959 entity_
->getDirectMethods()[i
], off
+ n1
+ i
);
964 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
965 InterfaceTypeDescription::getBaseTypes() {
966 assert(entity_
->getDirectMandatoryBases().size() <= SAL_MAX_INT32
);
967 sal_Int32 n
= static_cast< sal_Int32
>(
968 entity_
->getDirectMandatoryBases().size());
970 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
971 auto r
= asNonConstRange(s
);
972 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
973 r
[i
] = manager_
->resolve(entity_
->getDirectMandatoryBases()[i
].name
);
978 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
979 InterfaceTypeDescription::getOptionalBaseTypes()
981 assert(entity_
->getDirectOptionalBases().size() <= SAL_MAX_INT32
);
982 sal_Int32 n
= static_cast< sal_Int32
>(
983 entity_
->getDirectOptionalBases().size());
985 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
986 auto r
= asNonConstRange(s
);
987 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
988 r
[i
] = manager_
->resolve(entity_
->getDirectOptionalBases()[i
].name
);
993 class ConstantDescription
:
994 public cppu::WeakImplHelper
< css::reflection::XConstantTypeDescription
>
998 OUString
const & constantGroupName
,
999 unoidl::ConstantGroupEntity::Member
const & member
);
1002 virtual ~ConstantDescription() override
{}
1004 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1005 { return css::uno::TypeClass_CONSTANT
; }
1007 virtual OUString SAL_CALL
getName() override
1010 virtual css::uno::Any SAL_CALL
getConstantValue() override
1014 css::uno::Any value_
;
1017 ConstantDescription::ConstantDescription(
1018 OUString
const & constantGroupName
,
1019 unoidl::ConstantGroupEntity::Member
const & member
):
1020 name_(makePrefix(constantGroupName
) + member
.name
)
1022 switch (member
.value
.type
) {
1023 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1024 value_
<<= member
.value
.booleanValue
;
1026 case unoidl::ConstantValue::TYPE_BYTE
:
1027 value_
<<= member
.value
.byteValue
;
1029 case unoidl::ConstantValue::TYPE_SHORT
:
1030 value_
<<= member
.value
.shortValue
;
1032 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1033 value_
<<= member
.value
.unsignedShortValue
;
1035 case unoidl::ConstantValue::TYPE_LONG
:
1036 value_
<<= member
.value
.longValue
;
1038 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1039 value_
<<= member
.value
.unsignedLongValue
;
1041 case unoidl::ConstantValue::TYPE_HYPER
:
1042 value_
<<= member
.value
.hyperValue
;
1044 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1045 value_
<<= member
.value
.unsignedHyperValue
;
1047 case unoidl::ConstantValue::TYPE_FLOAT
:
1048 value_
<<= member
.value
.floatValue
;
1050 case unoidl::ConstantValue::TYPE_DOUBLE
:
1051 value_
<<= member
.value
.doubleValue
;
1054 for (;;) { std::abort(); } // this cannot happen
1058 typedef cppu::ImplInheritanceHelper
<
1059 PublishableDescription
, css::reflection::XConstantsTypeDescription
>
1060 ConstantGroupDescription_Base
;
1062 class ConstantGroupDescription
: public ConstantGroupDescription_Base
{
1064 ConstantGroupDescription(
1066 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
):
1067 ConstantGroupDescription_Base(entity
->isPublished()), name_(std::move(name
)),
1069 { assert(entity
.is()); }
1072 virtual ~ConstantGroupDescription() override
{}
1074 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1075 { return css::uno::TypeClass_CONSTANTS
; }
1077 virtual OUString SAL_CALL
getName() override
1082 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1083 SAL_CALL
getConstants() override
;
1086 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1090 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1091 ConstantGroupDescription::getConstants() {
1092 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
1093 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
1095 css::uno::Reference
< css::reflection::XConstantTypeDescription
> > s(n
);
1096 auto r
= asNonConstRange(s
);
1097 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1098 r
[i
] = new ConstantDescription(name_
, entity_
->getMembers()[i
]);
1103 typedef cppu::ImplInheritanceHelper
<
1104 PublishableDescription
, css::reflection::XIndirectTypeDescription
>
1105 TypedefDescription_Base
;
1107 class TypedefDescription
: public TypedefDescription_Base
{
1110 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1112 rtl::Reference
< unoidl::TypedefEntity
> const & entity
):
1113 TypedefDescription_Base(entity
->isPublished()), manager_(manager
),
1114 name_(std::move(name
)), entity_(entity
)
1115 { assert(manager
.is()); assert(entity
.is()); }
1118 virtual ~TypedefDescription() override
{}
1120 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1121 { return css::uno::TypeClass_TYPEDEF
; }
1123 virtual OUString SAL_CALL
getName() override
1126 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1127 getReferencedType() override
1128 { return manager_
->resolve(entity_
->getType()); }
1130 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1132 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
1135 class ConstructorParameter
:
1136 public cppu::WeakImplHelper
< css::reflection::XParameter
>
1139 ConstructorParameter(
1140 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1141 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter parameter
,
1142 sal_Int32 position
):
1143 manager_(manager
), parameter_(std::move(parameter
)), position_(position
)
1144 { assert(manager
.is()); }
1147 virtual ~ConstructorParameter() override
{}
1149 virtual OUString SAL_CALL
getName() override
1150 { return parameter_
.name
; }
1152 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1154 { return manager_
->resolve(parameter_
.type
); }
1156 virtual sal_Bool SAL_CALL
isIn() override
1159 virtual sal_Bool SAL_CALL
isOut() override
1162 virtual sal_Int32 SAL_CALL
getPosition() override
1163 { return position_
; }
1165 virtual sal_Bool SAL_CALL
isRestParameter() override
1166 { return parameter_
.rest
; }
1168 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1169 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1171 sal_Int32 position_
;
1174 class ConstructorDescription
:
1175 public cppu::WeakImplHelper
<
1176 css::reflection::XServiceConstructorDescription
>
1179 ConstructorDescription(
1180 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1181 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor
):
1182 manager_(manager
), constructor_(std::move(constructor
))
1183 { assert(manager
.is()); }
1186 virtual ~ConstructorDescription() override
{}
1188 virtual sal_Bool SAL_CALL
isDefaultConstructor() override
1189 { return constructor_
.defaultConstructor
; }
1191 virtual OUString SAL_CALL
getName() override
1192 { return constructor_
.name
; }
1196 css::uno::Reference
< css::reflection::XParameter
> >
1197 SAL_CALL
getParameters() override
;
1201 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1202 SAL_CALL
getExceptions() override
;
1204 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1205 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_
;
1208 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> >
1209 ConstructorDescription::getParameters() {
1210 assert(constructor_
.parameters
.size() <= SAL_MAX_INT32
);
1211 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.parameters
.size());
1212 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> > s(
1214 auto r
= asNonConstRange(s
);
1215 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1216 r
[i
] = new ConstructorParameter(
1217 manager_
, constructor_
.parameters
[i
], i
);
1223 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1224 ConstructorDescription::getExceptions() {
1225 assert(constructor_
.exceptions
.size() <= SAL_MAX_INT32
);
1226 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.exceptions
.size());
1228 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
1229 auto r
= asNonConstRange(s
);
1230 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1232 manager_
->resolve(constructor_
.exceptions
[i
]),
1233 css::uno::UNO_QUERY_THROW
);
1238 typedef cppu::ImplInheritanceHelper
<
1239 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1240 SingleInterfaceBasedServiceDescription_Base
;
1242 class SingleInterfaceBasedServiceDescription
:
1243 public SingleInterfaceBasedServiceDescription_Base
1246 SingleInterfaceBasedServiceDescription(
1247 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1249 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
1251 SingleInterfaceBasedServiceDescription_Base(entity
->isPublished()),
1252 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1253 { assert(manager
.is()); assert(entity
.is()); }
1256 virtual ~SingleInterfaceBasedServiceDescription() override
{}
1258 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1259 { return css::uno::TypeClass_SERVICE
; }
1261 virtual OUString SAL_CALL
getName() override
1266 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1267 SAL_CALL
getMandatoryServices() override
1269 return css::uno::Sequence
<
1270 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1275 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1276 SAL_CALL
getOptionalServices() override
1278 return css::uno::Sequence
<
1279 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1284 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1285 SAL_CALL
getMandatoryInterfaces() override
1287 return css::uno::Sequence
<
1288 css::uno::Reference
<
1289 css::reflection::XInterfaceTypeDescription
> >();
1294 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1295 SAL_CALL
getOptionalInterfaces() override
1297 return css::uno::Sequence
<
1298 css::uno::Reference
<
1299 css::reflection::XInterfaceTypeDescription
> >();
1304 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1305 SAL_CALL
getProperties() override
1307 return css::uno::Sequence
<
1308 css::uno::Reference
<
1309 css::reflection::XPropertyTypeDescription
> >();
1312 virtual sal_Bool SAL_CALL
isSingleInterfaceBased() override
1315 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1316 getInterface() override
1317 { return manager_
->resolve(entity_
->getBase()); }
1321 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1322 SAL_CALL
getConstructors() override
;
1324 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1326 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> entity_
;
1330 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1331 SingleInterfaceBasedServiceDescription::getConstructors()
1333 assert(entity_
->getConstructors().size() <= SAL_MAX_INT32
);
1334 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getConstructors().size());
1336 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1338 auto r
= asNonConstRange(s
);
1339 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1340 r
[i
] = new ConstructorDescription(
1341 manager_
, entity_
->getConstructors()[i
]);
1346 class PropertyDescription
:
1347 public cppu::WeakImplHelper
< css::reflection::XPropertyTypeDescription
>
1350 PropertyDescription(
1351 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1352 unoidl::AccumulationBasedServiceEntity::Property property
):
1353 manager_(manager
), property_(std::move(property
))
1354 { assert(manager
.is()); }
1357 virtual ~PropertyDescription() override
{}
1359 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1360 { return css::uno::TypeClass_PROPERTY
; }
1362 virtual OUString SAL_CALL
getName() override
1363 { return property_
.name
; }
1365 virtual sal_Int16 SAL_CALL
getPropertyFlags() override
1366 { return property_
.attributes
; }
1368 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1369 getPropertyTypeDescription() override
1370 { return manager_
->resolve(property_
.type
); }
1372 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1373 unoidl::AccumulationBasedServiceEntity::Property property_
;
1376 typedef cppu::ImplInheritanceHelper
<
1377 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1378 AccumulationBasedServiceDescription_Base
;
1380 class AccumulationBasedServiceDescription
:
1381 public AccumulationBasedServiceDescription_Base
1384 AccumulationBasedServiceDescription(
1385 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1387 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const &
1389 AccumulationBasedServiceDescription_Base(entity
->isPublished()),
1390 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1391 { assert(manager
.is()); assert(entity
.is()); }
1394 virtual ~AccumulationBasedServiceDescription() override
{}
1396 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1397 { return css::uno::TypeClass_SERVICE
; }
1399 virtual OUString SAL_CALL
getName() override
1404 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1405 SAL_CALL
getMandatoryServices() override
;
1409 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1410 SAL_CALL
getOptionalServices() override
;
1414 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1415 SAL_CALL
getMandatoryInterfaces() override
;
1419 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1420 SAL_CALL
getOptionalInterfaces() override
;
1424 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1425 SAL_CALL
getProperties() override
;
1427 virtual sal_Bool SAL_CALL
isSingleInterfaceBased() override
1430 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1431 getInterface() override
1432 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1436 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1437 SAL_CALL
getConstructors() override
1439 return css::uno::Sequence
<
1440 css::uno::Reference
<
1441 css::reflection::XServiceConstructorDescription
> >();
1444 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1446 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> entity_
;
1450 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1451 AccumulationBasedServiceDescription::getMandatoryServices()
1453 assert(entity_
->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32
);
1454 sal_Int32 n
= static_cast< sal_Int32
>(
1455 entity_
->getDirectMandatoryBaseServices().size());
1457 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1458 auto r
= asNonConstRange(s
);
1459 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1462 entity_
->getDirectMandatoryBaseServices()[i
].name
),
1463 css::uno::UNO_QUERY_THROW
);
1469 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1470 AccumulationBasedServiceDescription::getOptionalServices()
1472 assert(entity_
->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32
);
1473 sal_Int32 n
= static_cast< sal_Int32
>(
1474 entity_
->getDirectOptionalBaseServices().size());
1476 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1477 auto r
= asNonConstRange(s
);
1478 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1480 manager_
->resolve(entity_
->getDirectOptionalBaseServices()[i
].name
),
1481 css::uno::UNO_QUERY_THROW
);
1487 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1488 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1490 assert(entity_
->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32
);
1491 sal_Int32 n
= static_cast< sal_Int32
>(
1492 entity_
->getDirectMandatoryBaseInterfaces().size());
1494 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1496 auto r
= asNonConstRange(s
);
1497 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1501 entity_
->getDirectMandatoryBaseInterfaces()[i
].name
)),
1502 css::uno::UNO_QUERY_THROW
);
1508 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1509 AccumulationBasedServiceDescription::getOptionalInterfaces()
1511 assert(entity_
->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32
);
1512 sal_Int32 n
= static_cast< sal_Int32
>(
1513 entity_
->getDirectOptionalBaseInterfaces().size());
1515 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1517 auto r
= asNonConstRange(s
);
1518 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1522 entity_
->getDirectOptionalBaseInterfaces()[i
].name
)),
1523 css::uno::UNO_QUERY_THROW
);
1529 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1530 AccumulationBasedServiceDescription::getProperties()
1532 assert(entity_
->getDirectProperties().size() <= SAL_MAX_INT32
);
1533 sal_Int32 n
= static_cast< sal_Int32
>(
1534 entity_
->getDirectProperties().size());
1536 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> > s(n
);
1537 auto r
= asNonConstRange(s
);
1538 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1539 r
[i
] = new PropertyDescription(
1540 manager_
, entity_
->getDirectProperties()[i
]);
1545 typedef cppu::ImplInheritanceHelper
<
1546 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1547 InterfaceBasedSingletonDescription_Base
;
1549 class InterfaceBasedSingletonDescription
:
1550 public InterfaceBasedSingletonDescription_Base
1553 InterfaceBasedSingletonDescription(
1554 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1556 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
):
1557 InterfaceBasedSingletonDescription_Base(entity
->isPublished()),
1558 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1559 { assert(manager
.is()); assert(entity
.is()); }
1562 virtual ~InterfaceBasedSingletonDescription() override
{}
1564 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1565 { return css::uno::TypeClass_SINGLETON
; }
1567 virtual OUString SAL_CALL
getName() override
1570 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1571 SAL_CALL
getService() override
1574 css::uno::Reference
< css::reflection::XServiceTypeDescription
>();
1577 virtual sal_Bool SAL_CALL
isInterfaceBased() override
1580 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1581 SAL_CALL
getInterface() override
1582 { return manager_
->resolve(entity_
->getBase()); }
1584 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1586 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> entity_
;
1589 typedef cppu::ImplInheritanceHelper
<
1590 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1591 ServiceBasedSingletonDescription_Base
;
1593 class ServiceBasedSingletonDescription
:
1594 public ServiceBasedSingletonDescription_Base
1597 ServiceBasedSingletonDescription(
1598 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1600 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> const & entity
):
1601 ServiceBasedSingletonDescription_Base(entity
->isPublished()),
1602 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1603 { assert(manager
.is()); assert(entity
.is()); }
1606 virtual ~ServiceBasedSingletonDescription() override
{}
1608 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1609 { return css::uno::TypeClass_SINGLETON
; }
1611 virtual OUString SAL_CALL
getName() override
1614 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1615 SAL_CALL
getService() override
1617 return css::uno::Reference
< css::reflection::XServiceTypeDescription
>(
1618 manager_
->resolve(entity_
->getBase()), css::uno::UNO_QUERY_THROW
);
1621 virtual sal_Bool SAL_CALL
isInterfaceBased() override
1624 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1625 SAL_CALL
getInterface() override
1626 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1628 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1630 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> entity_
;
1634 public cppu::WeakImplHelper
< css::reflection::XTypeDescriptionEnumeration
>
1638 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1639 OUString
const & prefix
,
1640 rtl::Reference
< unoidl::MapCursor
> const & cursor
,
1641 css::uno::Sequence
< css::uno::TypeClass
> const & types
, bool deep
):
1642 manager_(manager
), types_(types
), deep_(deep
)
1644 assert(manager
.is());
1645 positions_
.push(Position(prefix
, cursor
));
1650 virtual ~Enumeration() override
{}
1652 virtual sal_Bool SAL_CALL
hasMoreElements() override
1653 { return !positions_
.empty(); }
1655 virtual css::uno::Any SAL_CALL
nextElement() override
1656 { return css::uno::Any(nextTypeDescription()); }
1658 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1659 nextTypeDescription() override
;
1661 bool matches(css::uno::TypeClass tc
) const;
1663 void findNextMatch();
1668 rtl::Reference
< unoidl::MapCursor
> const & theCursor
):
1669 prefix(std::move(thePrefix
)), cursor(theCursor
)
1670 { assert(theCursor
.is()); }
1674 rtl::Reference
< unoidl::ConstantGroupEntity
> const &
1676 prefix(std::move(thePrefix
)), constantGroup(theConstantGroup
),
1677 constantGroupIndex(constantGroup
->getMembers().begin())
1678 { assert(theConstantGroup
.is()); }
1680 Position(Position
const & other
):
1681 prefix(other
.prefix
), cursor(other
.cursor
),
1682 constantGroup(other
.constantGroup
)
1684 if (constantGroup
.is()) {
1685 constantGroupIndex
= other
.constantGroupIndex
;
1690 rtl::Reference
< unoidl::MapCursor
> cursor
;
1691 rtl::Reference
< unoidl::ConstantGroupEntity
> constantGroup
;
1692 std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
1696 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1697 css::uno::Sequence
< css::uno::TypeClass
> types_
;
1701 std::stack
< Position
, std::vector
<Position
> > positions_
;
1705 css::uno::Reference
< css::reflection::XTypeDescription
>
1706 Enumeration::nextTypeDescription()
1710 std::scoped_lock
g(mutex_
);
1711 if (positions_
.empty()) {
1712 throw css::container::NoSuchElementException(
1713 "exhausted XTypeDescriptionEnumeration",
1714 static_cast< cppu::OWeakObject
* >(this));
1719 return manager_
->resolve(name
);
1722 bool Enumeration::matches(css::uno::TypeClass tc
) const {
1723 if (!types_
.hasElements()) {
1726 for (const auto & i
: types_
) {
1734 void Enumeration::findNextMatch() {
1737 assert(!positions_
.empty());
1739 if (positions_
.top().cursor
.is()) { // root or module
1740 rtl::Reference
< unoidl::Entity
> ent(
1741 positions_
.top().cursor
->getNext(&name
));
1744 if (positions_
.empty()) {
1749 name
= positions_
.top().prefix
+ name
;
1750 css::uno::TypeClass tc
;
1751 switch (ent
->getSort()) {
1752 case unoidl::Entity::SORT_MODULE
:
1753 tc
= css::uno::TypeClass_MODULE
;
1758 static_cast< unoidl::ModuleEntity
* >(
1759 ent
.get())->createCursor()));
1762 case unoidl::Entity::SORT_ENUM_TYPE
:
1763 tc
= css::uno::TypeClass_ENUM
;
1765 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
1766 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
1767 tc
= css::uno::TypeClass_STRUCT
;
1769 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
1770 tc
= css::uno::TypeClass_EXCEPTION
;
1772 case unoidl::Entity::SORT_INTERFACE_TYPE
:
1773 tc
= css::uno::TypeClass_INTERFACE
;
1775 case unoidl::Entity::SORT_TYPEDEF
:
1776 tc
= css::uno::TypeClass_TYPEDEF
;
1778 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1779 tc
= css::uno::TypeClass_CONSTANTS
;
1780 if (deep_
&& matches(css::uno::TypeClass_CONSTANT
)) {
1784 static_cast< unoidl::ConstantGroupEntity
* >(
1788 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
1789 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
1790 tc
= css::uno::TypeClass_SERVICE
;
1792 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
1793 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
1794 tc
= css::uno::TypeClass_SINGLETON
;
1797 for (;;) { std::abort(); } // this cannot happen
1803 } else { // constant group
1804 if (positions_
.top().constantGroupIndex
1805 == positions_
.top().constantGroup
->getMembers().end())
1808 if (positions_
.empty()) {
1813 current_
= positions_
.top().prefix
1814 + positions_
.top().constantGroupIndex
++->name
;
1818 } catch (unoidl::FileFormatException
& e
) {
1819 throw css::uno::DeploymentException(
1820 e
.getUri() + ": " + e
.getDetail(),
1821 static_cast< cppu::OWeakObject
* >(this));
1827 cppuhelper::TypeManager::TypeManager():
1828 manager_(new unoidl::Manager
)
1831 css::uno::Any
cppuhelper::TypeManager::find(OUString
const & name
) {
1832 //TODO: caching? (here or in unoidl::Manager?)
1833 static constexpr std::pair
<std::u16string_view
, css::uno::TypeClass
> const simple
[] = {
1834 { u
"void", css::uno::TypeClass_VOID
},
1835 { u
"boolean", css::uno::TypeClass_BOOLEAN
},
1836 { u
"byte", css::uno::TypeClass_BYTE
},
1837 { u
"short", css::uno::TypeClass_SHORT
},
1838 { u
"unsigned short", css::uno::TypeClass_UNSIGNED_SHORT
},
1839 { u
"long", css::uno::TypeClass_LONG
},
1840 { u
"unsigned long", css::uno::TypeClass_UNSIGNED_LONG
},
1841 { u
"hyper", css::uno::TypeClass_HYPER
},
1842 { u
"unsigned hyper", css::uno::TypeClass_UNSIGNED_HYPER
},
1843 { u
"float", css::uno::TypeClass_FLOAT
},
1844 { u
"double", css::uno::TypeClass_DOUBLE
},
1845 { u
"char", css::uno::TypeClass_CHAR
},
1846 { u
"string", css::uno::TypeClass_STRING
},
1847 { u
"type", css::uno::TypeClass_TYPE
},
1848 { u
"any", css::uno::TypeClass_ANY
} };
1849 for (const auto& [ rName
, rTypeClass
] : simple
) {
1850 if (name
== rName
) {
1851 return css::uno::Any(
1852 css::uno::Reference
< css::reflection::XTypeDescription
>(
1853 new SimpleTypeDescription(rTypeClass
, name
)));
1856 if (name
.startsWith("[]")) {
1857 return getSequenceType(name
);
1859 sal_Int32 i
= name
.indexOf('<');
1861 return getInstantiatedStruct(name
, i
);
1863 i
= name
.indexOf("::");
1865 return getInterfaceMember(name
, i
);
1867 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
));
1869 return getNamed(name
, ent
);
1871 i
= name
.lastIndexOf('.');
1873 OUString
parent(name
.copy(0, i
));
1874 ent
= findEntity(parent
);
1876 switch (ent
->getSort()) {
1877 case unoidl::Entity::SORT_ENUM_TYPE
:
1878 return getEnumMember(
1879 static_cast< unoidl::EnumTypeEntity
* >(ent
.get()),
1880 name
.subView(i
+ 1));
1881 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1884 static_cast< unoidl::ConstantGroupEntity
* >(ent
.get()),
1885 name
.subView(i
+ 1));
1891 return css::uno::Any();
1894 css::uno::Reference
< css::reflection::XTypeDescription
>
1895 cppuhelper::TypeManager::resolve(OUString
const & name
) {
1896 css::uno::Reference
< css::reflection::XTypeDescription
> desc(
1897 find(name
), css::uno::UNO_QUERY
);
1899 throw css::uno::DeploymentException(
1900 "cannot resolve type \"" + name
+ "\"",
1901 static_cast< cppu::OWeakObject
* >(this));
1906 cppuhelper::TypeManager::~TypeManager() noexcept
{}
1908 OUString
cppuhelper::TypeManager::getImplementationName()
1911 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager";
1914 sal_Bool
cppuhelper::TypeManager::supportsService(
1915 OUString
const & ServiceName
)
1917 return cppu::supportsService(this, ServiceName
);
1920 css::uno::Sequence
< OUString
>
1921 cppuhelper::TypeManager::getSupportedServiceNames()
1923 return { "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1926 css::uno::Any
cppuhelper::TypeManager::getByHierarchicalName(
1927 OUString
const & aName
)
1929 css::uno::Any
desc(find(aName
));
1930 if (!desc
.hasValue()) {
1931 throw css::container::NoSuchElementException(
1932 aName
, static_cast< cppu::OWeakObject
* >(this));
1937 sal_Bool
cppuhelper::TypeManager::hasByHierarchicalName(
1938 OUString
const & aName
)
1940 return find(aName
).hasValue();
1943 css::uno::Type
cppuhelper::TypeManager::getElementType()
1945 return cppu::UnoType
< OUString
>::get();
1948 sal_Bool
cppuhelper::TypeManager::hasElements()
1950 throw css::uno::RuntimeException(
1951 "TypeManager hasElements: method not supported",
1952 static_cast< cppu::OWeakObject
* >(this));
1955 css::uno::Reference
< css::container::XEnumeration
>
1956 cppuhelper::TypeManager::createEnumeration()
1958 throw css::uno::RuntimeException(
1959 "TypeManager createEnumeration: method not supported",
1960 static_cast< cppu::OWeakObject
* >(this));
1963 sal_Bool
cppuhelper::TypeManager::has(css::uno::Any
const &)
1965 throw css::uno::RuntimeException(
1966 "TypeManager has: method not supported",
1967 static_cast< cppu::OWeakObject
* >(this));
1970 void cppuhelper::TypeManager::insert(css::uno::Any
const & aElement
)
1973 if (!(aElement
>>= uri
)) {
1974 throw css::lang::IllegalArgumentException(
1975 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
1977 static_cast< cppu::OWeakObject
* >(this), 0);
1979 //TODO: check for ElementExistException
1980 //TODO: check for consistency with existing data
1981 readRdbFile(uri
, false);
1984 void cppuhelper::TypeManager::remove(css::uno::Any
const & aElement
)
1987 if (!(aElement
>>= uri
)) {
1988 throw css::lang::IllegalArgumentException(
1989 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
1991 static_cast< cppu::OWeakObject
* >(this), 0);
1993 //TODO: remove requests are silently ignored for now
1996 css::uno::Reference
< css::reflection::XTypeDescriptionEnumeration
>
1997 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
1998 OUString
const & moduleName
,
1999 css::uno::Sequence
< css::uno::TypeClass
> const & types
,
2000 css::reflection::TypeDescriptionSearchDepth depth
)
2002 rtl::Reference
< unoidl::MapCursor
> cursor
;
2004 cursor
= manager_
->createCursor(moduleName
);
2005 } catch (unoidl::FileFormatException
& e
) {
2006 throw css::uno::DeploymentException(
2007 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2009 static_cast< cppu::OWeakObject
* >(this));
2012 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2014 throw css::reflection::NoSuchTypeNameException(
2015 moduleName
, static_cast< cppu::OWeakObject
* >(this));
2017 return new Enumeration(
2018 this, makePrefix(moduleName
), cursor
, types
,
2019 depth
== css::reflection::TypeDescriptionSearchDepth_INFINITE
);
2022 void cppuhelper::TypeManager::init(std::u16string_view rdbUris
) {
2023 for (sal_Int32 i
= 0; i
!= -1;) {
2024 std::u16string_view
uri(o3tl::getToken(rdbUris
, 0, ' ', i
));
2030 cppu::decodeRdbUri(&uri
, &optional
, &directory
);
2032 readRdbDirectory(uri
, optional
);
2034 readRdbFile(uri
, optional
);
2039 void cppuhelper::TypeManager::readRdbDirectory(
2040 std::u16string_view uri
, bool optional
)
2042 osl::Directory dir
= OUString(uri
);
2043 switch (dir
.open()) {
2044 case osl::FileBase::E_None
:
2046 case osl::FileBase::E_NOENT
:
2048 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri
));
2053 throw css::uno::DeploymentException(
2054 OUString::Concat("Cannot open directory ") + uri
,
2055 static_cast< cppu::OWeakObject
* >(this));
2059 if (!cppu::nextDirectoryItem(dir
, &url
)) {
2062 readRdbFile(url
, false);
2066 void cppuhelper::TypeManager::readRdbFile(
2067 std::u16string_view uri
, bool optional
)
2070 manager_
->addProvider(OUString(uri
));
2071 } catch (unoidl::NoSuchFileException
&) {
2073 throw css::uno::DeploymentException(
2074 OUString::Concat(uri
) + ": no such file",
2075 static_cast< cppu::OWeakObject
* >(this));
2077 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri
));
2078 } catch (unoidl::FileFormatException
& e
) {
2079 throw css::uno::DeploymentException(
2080 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2082 static_cast< cppu::OWeakObject
* >(this));
2086 css::uno::Any
cppuhelper::TypeManager::getSequenceType(
2087 OUString
const & name
)
2089 assert(name
.startsWith("[]"));
2090 return css::uno::Any(
2091 css::uno::Reference
< css::reflection::XTypeDescription
>(
2092 new SequenceTypeDescription(
2093 this, name
, name
.copy(std::strlen("[]")))));
2096 css::uno::Any
cppuhelper::TypeManager::getInstantiatedStruct(
2097 OUString
const & name
, sal_Int32 separator
)
2099 assert(name
.indexOf('<') == separator
&& separator
!= -1);
2100 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
.copy(0, separator
)));
2103 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
))
2105 return css::uno::Any();
2107 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
2108 static_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
2110 std::vector
< OUString
> args
;
2111 sal_Int32 i
= separator
;
2113 ++i
; // skip '<' or ','
2115 for (sal_Int32 level
= 0; j
!= name
.getLength(); ++j
) {
2116 sal_Unicode c
= name
[j
];
2121 } else if (c
== '<') {
2123 } else if (c
== '>') {
2130 if (j
!= name
.getLength()) {
2131 args
.push_back(name
.copy(i
, j
- i
));
2134 } while (i
!= name
.getLength() && name
[i
] != '>');
2135 if (i
!= name
.getLength() - 1 || name
[i
] != '>'
2136 || args
.size() != ent2
->getTypeParameters().size())
2138 return css::uno::Any();
2140 return css::uno::Any(
2141 css::uno::Reference
< css::reflection::XTypeDescription
>(
2142 new InstantiatedPolymorphicStructTypeDescription(
2143 this, name
, ent2
, std::move(args
))));
2146 css::uno::Any
cppuhelper::TypeManager::getInterfaceMember(
2147 std::u16string_view name
, std::size_t separator
)
2149 assert(name
.find(u
"::") == separator
&& separator
!= std::u16string_view::npos
);
2150 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> ifc(
2151 resolveTypedefs(find(OUString(name
.substr(0, separator
)))), css::uno::UNO_QUERY
);
2153 return css::uno::Any();
2155 std::u16string_view member
= name
.substr(separator
+ std::strlen("::"));
2156 const css::uno::Sequence
<
2157 css::uno::Reference
<
2158 css::reflection::XInterfaceMemberTypeDescription
> > mems(
2160 for (const auto & m
: mems
) {
2161 if (m
->getMemberName() == member
) {
2162 return css::uno::Any(
2163 css::uno::Reference
< css::reflection::XTypeDescription
>(m
));
2166 return css::uno::Any();
2169 css::uno::Any
cppuhelper::TypeManager::getNamed(
2170 OUString
const & name
, rtl::Reference
< unoidl::Entity
> const & entity
)
2172 assert(entity
.is());
2173 switch (entity
->getSort()) {
2174 case unoidl::Entity::SORT_MODULE
:
2175 return css::uno::Any(
2176 css::uno::Reference
< css::reflection::XTypeDescription
>(
2177 new ModuleDescription(
2179 static_cast< unoidl::ModuleEntity
* >(entity
.get()))));
2180 case unoidl::Entity::SORT_ENUM_TYPE
:
2181 return css::uno::Any(
2182 css::uno::Reference
< css::reflection::XTypeDescription
>(
2183 new EnumTypeDescription(
2185 static_cast< unoidl::EnumTypeEntity
* >(entity
.get()))));
2186 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
2187 return css::uno::Any(
2188 css::uno::Reference
< css::reflection::XTypeDescription
>(
2189 new PlainStructTypeDescription(
2191 static_cast< unoidl::PlainStructTypeEntity
* >(
2193 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
2194 return css::uno::Any(
2195 css::uno::Reference
< css::reflection::XTypeDescription
>(
2196 new PolymorphicStructTypeTemplateDescription(
2199 unoidl::PolymorphicStructTypeTemplateEntity
* >(
2201 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
2202 return css::uno::Any(
2203 css::uno::Reference
< css::reflection::XTypeDescription
>(
2204 new ExceptionTypeDescription(
2206 static_cast< unoidl::ExceptionTypeEntity
* >(
2208 case unoidl::Entity::SORT_INTERFACE_TYPE
:
2209 return css::uno::Any(
2210 css::uno::Reference
< css::reflection::XTypeDescription
>(
2211 new InterfaceTypeDescription(
2213 static_cast< unoidl::InterfaceTypeEntity
* >(
2215 case unoidl::Entity::SORT_TYPEDEF
:
2216 return css::uno::Any(
2217 css::uno::Reference
< css::reflection::XTypeDescription
>(
2218 new TypedefDescription(
2220 static_cast< unoidl::TypedefEntity
* >(entity
.get()))));
2221 case unoidl::Entity::SORT_CONSTANT_GROUP
:
2222 return css::uno::Any(
2223 css::uno::Reference
< css::reflection::XTypeDescription
>(
2224 new ConstantGroupDescription(
2226 static_cast< unoidl::ConstantGroupEntity
* >(
2228 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
2229 return css::uno::Any(
2230 css::uno::Reference
< css::reflection::XTypeDescription
>(
2231 new SingleInterfaceBasedServiceDescription(
2233 static_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
2235 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
2236 return css::uno::Any(
2237 css::uno::Reference
< css::reflection::XTypeDescription
>(
2238 new AccumulationBasedServiceDescription(
2240 static_cast< unoidl::AccumulationBasedServiceEntity
* >(
2242 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
2243 return css::uno::Any(
2244 css::uno::Reference
< css::reflection::XTypeDescription
>(
2245 new InterfaceBasedSingletonDescription(
2247 static_cast< unoidl::InterfaceBasedSingletonEntity
* >(
2249 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
2250 return css::uno::Any(
2251 css::uno::Reference
< css::reflection::XTypeDescription
>(
2252 new ServiceBasedSingletonDescription(
2254 static_cast< unoidl::ServiceBasedSingletonEntity
* >(
2257 for (;;) { std::abort(); } // this cannot happen
2261 css::uno::Any
cppuhelper::TypeManager::getEnumMember(
2262 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
2263 std::u16string_view member
)
2265 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2266 [&member
](const unoidl::EnumTypeEntity::Member
& rMember
) { return rMember
.name
== member
; });
2267 if (i
!= entity
->getMembers().end())
2268 return css::uno::Any(i
->value
);
2269 return css::uno::Any();
2272 css::uno::Any
cppuhelper::TypeManager::getConstant(
2273 std::u16string_view constantGroupName
,
2274 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
2275 std::u16string_view member
)
2277 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2278 [&member
](const unoidl::ConstantGroupEntity::Member
& rMember
) { return rMember
.name
== member
; });
2279 if (i
!= entity
->getMembers().end())
2280 return css::uno::Any(
2281 css::uno::Reference
< css::reflection::XTypeDescription
>(
2282 new ConstantDescription(OUString(constantGroupName
), *i
)));
2283 return css::uno::Any();
2286 rtl::Reference
< unoidl::Entity
> cppuhelper::TypeManager::findEntity(
2287 OUString
const & name
)
2290 return manager_
->findEntity(name
);
2291 } catch (unoidl::FileFormatException
& e
) {
2292 throw css::uno::DeploymentException(
2293 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2295 static_cast< cppu::OWeakObject
* >(this));
2299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */