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>
24 #include <com/sun/star/container/NoSuchElementException.hpp>
25 #include <com/sun/star/lang/IllegalArgumentException.hpp>
26 #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
27 #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
28 #include <com/sun/star/reflection/XConstantTypeDescription.hpp>
29 #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
30 #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
31 #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
32 #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
33 #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
34 #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
35 #include <com/sun/star/reflection/XModuleTypeDescription.hpp>
36 #include <com/sun/star/reflection/XPublished.hpp>
37 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
38 #include <com/sun/star/reflection/XSingletonTypeDescription2.hpp>
39 #include <com/sun/star/reflection/XStructTypeDescription.hpp>
40 #include <com/sun/star/reflection/XTypeDescription.hpp>
41 #include <com/sun/star/uno/Any.hxx>
42 #include <com/sun/star/uno/DeploymentException.hpp>
43 #include <com/sun/star/uno/Reference.hxx>
44 #include <com/sun/star/uno/RuntimeException.hpp>
45 #include <com/sun/star/uno/Sequence.hxx>
46 #include <com/sun/star/uno/Type.hxx>
47 #include <com/sun/star/uno/TypeClass.hpp>
48 #include <cppu/unotype.hxx>
49 #include <cppuhelper/implbase.hxx>
50 #include <cppuhelper/supportsservice.hxx>
51 #include <osl/file.hxx>
52 #include <rtl/ref.hxx>
53 #include <rtl/ustring.hxx>
54 #include <sal/log.hxx>
55 #include <sal/macros.h>
56 #include <sal/types.h>
57 #include <o3tl/string_view.hxx>
59 #include <unoidl/unoidl.hxx>
62 #include "typemanager.hxx"
66 OUString
makePrefix(OUString
const & name
) {
67 return name
.isEmpty() ? name
: name
+ ".";
70 css::uno::Any
resolveTypedefs(css::uno::Any
const & type
) {
71 for (css::uno::Any
t(type
);;) {
72 css::uno::Reference
< css::reflection::XIndirectTypeDescription
> ind(
73 type
, css::uno::UNO_QUERY
);
74 if (!ind
.is() || ind
->getTypeClass() != css::uno::TypeClass_TYPEDEF
) {
77 t
<<= ind
->getReferencedType();
81 class SimpleTypeDescription
:
82 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
85 SimpleTypeDescription(
86 css::uno::TypeClass typeClass
, OUString name
):
87 typeClass_(typeClass
), name_(std::move(name
))
91 virtual ~SimpleTypeDescription() override
{}
93 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
94 { return typeClass_
; }
96 virtual OUString SAL_CALL
getName() override
99 css::uno::TypeClass typeClass_
;
103 class SequenceTypeDescription
:
104 public cppu::WeakImplHelper
< css::reflection::XIndirectTypeDescription
>
107 SequenceTypeDescription(
108 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
109 OUString name
, OUString componentType
):
110 manager_(manager
), name_(std::move(name
)), componentType_(std::move(componentType
))
111 { assert(manager
.is()); }
114 virtual ~SequenceTypeDescription() override
{}
116 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
117 { return css::uno::TypeClass_SEQUENCE
; }
119 virtual OUString SAL_CALL
getName() override
122 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
123 getReferencedType() override
124 { return manager_
->resolve(componentType_
); }
126 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
128 OUString componentType_
;
131 class PublishableDescription
:
132 public cppu::WeakImplHelper
< css::reflection::XPublished
>
135 explicit PublishableDescription(bool published
): published_(published
) {}
137 virtual ~PublishableDescription() override
{}
140 virtual sal_Bool SAL_CALL
isPublished() override
141 { return published_
; }
146 class ModuleDescription
:
147 public cppu::WeakImplHelper
< css::reflection::XModuleTypeDescription
>
151 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
153 rtl::Reference
< unoidl::ModuleEntity
> const & entity
):
154 manager_(manager
), name_(std::move(name
)), entity_(entity
)
155 { assert(manager
.is()); assert(entity
.is()); }
158 virtual ~ModuleDescription() override
{}
160 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
161 { return css::uno::TypeClass_MODULE
; }
163 virtual OUString SAL_CALL
getName() override
168 css::uno::Reference
< css::reflection::XTypeDescription
> >
169 SAL_CALL
getMembers() override
;
171 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
173 rtl::Reference
< unoidl::ModuleEntity
> entity_
;
176 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
177 ModuleDescription::getMembers() {
179 std::vector
< OUString
> names(entity_
->getMemberNames());
180 assert(names
.size() <= SAL_MAX_INT32
);
181 sal_Int32 n
= static_cast< sal_Int32
>(names
.size());
183 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
184 auto r
= asNonConstRange(s
);
185 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
186 r
[i
] = manager_
->resolve(makePrefix(name_
) + names
[i
]);
189 } catch (unoidl::FileFormatException
& e
) {
190 throw css::uno::DeploymentException(
191 e
.getUri() + ": " + e
.getDetail(),
192 static_cast< cppu::OWeakObject
* >(this));
196 typedef cppu::ImplInheritanceHelper
<
197 PublishableDescription
, css::reflection::XEnumTypeDescription
>
198 EnumTypeDescription_Base
;
200 class EnumTypeDescription
: public EnumTypeDescription_Base
{
204 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
):
205 EnumTypeDescription_Base(entity
->isPublished()), name_(std::move(name
)),
207 { assert(entity
.is()); }
210 virtual ~EnumTypeDescription() override
{}
212 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
213 { return css::uno::TypeClass_ENUM
; }
215 virtual OUString SAL_CALL
getName() override
218 virtual sal_Int32 SAL_CALL
getDefaultEnumValue() override
219 { return entity_
->getMembers()[0].value
; }
221 virtual css::uno::Sequence
< OUString
> SAL_CALL
getEnumNames() override
;
223 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getEnumValues() override
;
226 rtl::Reference
< unoidl::EnumTypeEntity
> entity_
;
229 css::uno::Sequence
< OUString
> EnumTypeDescription::getEnumNames()
231 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
232 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
233 css::uno::Sequence
< OUString
> s(n
);
234 auto r
= asNonConstRange(s
);
235 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
236 r
[i
] = entity_
->getMembers()[i
].name
;
241 css::uno::Sequence
< sal_Int32
> EnumTypeDescription::getEnumValues()
243 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
244 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
245 css::uno::Sequence
< sal_Int32
> s(n
);
246 auto r
= asNonConstRange(s
);
247 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
248 r
[i
] = entity_
->getMembers()[i
].value
;
253 typedef cppu::ImplInheritanceHelper
<
254 PublishableDescription
, css::reflection::XStructTypeDescription
>
255 PlainStructTypeDescription_Base
;
257 class PlainStructTypeDescription
: public PlainStructTypeDescription_Base
{
259 PlainStructTypeDescription(
260 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
262 rtl::Reference
< unoidl::PlainStructTypeEntity
> const & entity
):
263 PlainStructTypeDescription_Base(entity
->isPublished()),
264 manager_(manager
), name_(std::move(name
)), entity_(entity
)
265 { assert(manager
.is()); assert(entity
.is()); }
268 virtual ~PlainStructTypeDescription() override
{}
270 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
271 { return css::uno::TypeClass_STRUCT
; }
273 virtual OUString SAL_CALL
getName() override
276 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
277 getBaseType() override
{
278 return entity_
->getDirectBase().isEmpty()
279 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
280 : manager_
->resolve(entity_
->getDirectBase());
285 css::uno::Reference
< css::reflection::XTypeDescription
> >
286 SAL_CALL
getMemberTypes() override
;
288 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
290 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
291 { return css::uno::Sequence
< OUString
>(); }
295 css::uno::Reference
< css::reflection::XTypeDescription
> >
296 SAL_CALL
getTypeArguments() override
{
297 return css::uno::Sequence
<
298 css::uno::Reference
< css::reflection::XTypeDescription
> >();
301 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
303 rtl::Reference
< unoidl::PlainStructTypeEntity
> entity_
;
306 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
307 PlainStructTypeDescription::getMemberTypes()
309 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
310 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
312 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
313 auto r
= asNonConstRange(s
);
314 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
315 r
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
320 css::uno::Sequence
< OUString
> PlainStructTypeDescription::getMemberNames()
322 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
323 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
324 css::uno::Sequence
< OUString
> s(n
);
325 auto r
= asNonConstRange(s
);
326 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
327 r
[i
] = entity_
->getDirectMembers()[i
].name
;
332 class ParameterizedMemberTypeDescription
:
333 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
336 explicit ParameterizedMemberTypeDescription(
337 OUString typeParameterName
):
338 typeParameterName_(std::move(typeParameterName
))
342 virtual ~ParameterizedMemberTypeDescription() override
{}
344 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
345 { return css::uno::TypeClass_UNKNOWN
; }
347 virtual OUString SAL_CALL
getName() override
348 { return typeParameterName_
; }
350 OUString typeParameterName_
;
353 typedef cppu::ImplInheritanceHelper
<
354 PublishableDescription
, css::reflection::XStructTypeDescription
>
355 PolymorphicStructTypeTemplateDescription_Base
;
357 class PolymorphicStructTypeTemplateDescription
:
358 public PolymorphicStructTypeTemplateDescription_Base
361 PolymorphicStructTypeTemplateDescription(
362 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
364 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
366 PolymorphicStructTypeTemplateDescription_Base(entity
->isPublished()),
367 manager_(manager
), name_(std::move(name
)), entity_(entity
)
368 { assert(manager
.is()); assert(entity
.is()); }
371 virtual ~PolymorphicStructTypeTemplateDescription() override
{}
373 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
374 { return css::uno::TypeClass_STRUCT
; }
376 virtual OUString SAL_CALL
getName() override
379 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
380 getBaseType() override
381 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
385 css::uno::Reference
< css::reflection::XTypeDescription
> >
386 SAL_CALL
getMemberTypes() override
;
388 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
390 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
;
394 css::uno::Reference
< css::reflection::XTypeDescription
> >
395 SAL_CALL
getTypeArguments() override
{
396 return css::uno::Sequence
<
397 css::uno::Reference
< css::reflection::XTypeDescription
> >();
400 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
402 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
405 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
406 PolymorphicStructTypeTemplateDescription::getMemberTypes()
408 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
409 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
411 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
412 auto r
= asNonConstRange(s
);
413 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
414 r
[i
] = entity_
->getMembers()[i
].parameterized
415 ? new ParameterizedMemberTypeDescription(
416 entity_
->getMembers()[i
].type
)
417 : manager_
->resolve(entity_
->getMembers()[i
].type
);
422 css::uno::Sequence
< OUString
>
423 PolymorphicStructTypeTemplateDescription::getMemberNames()
425 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
426 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
427 css::uno::Sequence
< OUString
> s(n
);
428 auto r
= asNonConstRange(s
);
429 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
430 r
[i
] = entity_
->getMembers()[i
].name
;
435 css::uno::Sequence
< OUString
>
436 PolymorphicStructTypeTemplateDescription::getTypeParameters()
438 assert(entity_
->getTypeParameters().size() <= SAL_MAX_INT32
);
439 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getTypeParameters().size());
440 css::uno::Sequence
< OUString
> s(n
);
441 auto r
= asNonConstRange(s
);
442 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
443 r
[i
] = entity_
->getTypeParameters()[i
];
448 class InstantiatedPolymorphicStructTypeDescription
:
449 public cppu::WeakImplHelper
< css::reflection::XStructTypeDescription
>
452 InstantiatedPolymorphicStructTypeDescription(
453 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
455 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
457 std::vector
< OUString
>&& arguments
):
458 manager_(manager
), name_(std::move(name
)), entity_(entity
), arguments_(std::move(arguments
))
460 assert(manager
.is());
462 assert(arguments_
.size() == entity
->getTypeParameters().size());
466 virtual ~InstantiatedPolymorphicStructTypeDescription() override
{}
468 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
469 { return css::uno::TypeClass_STRUCT
; }
471 virtual OUString SAL_CALL
getName() override
474 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
475 getBaseType() override
476 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
480 css::uno::Reference
< css::reflection::XTypeDescription
> >
481 SAL_CALL
getMemberTypes() override
;
483 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
485 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
486 { return css::uno::Sequence
< OUString
>(); }
490 css::uno::Reference
< css::reflection::XTypeDescription
> >
491 SAL_CALL
getTypeArguments() override
;
493 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
495 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
496 std::vector
< OUString
> arguments_
;
499 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
500 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
502 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
503 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
505 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
506 auto r
= asNonConstRange(s
);
507 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
508 OUString
type(entity_
->getMembers()[i
].type
);
509 if (entity_
->getMembers()[i
].parameterized
) {
510 auto j
= std::find(entity_
->getTypeParameters().begin(), entity_
->getTypeParameters().end(), type
);
511 if (j
!= entity_
->getTypeParameters().end()) {
512 type
= arguments_
[j
- entity_
->getTypeParameters().begin()];
515 assert(false); // this cannot happen //TODO!
518 r
[i
] = manager_
->resolve(type
);
523 css::uno::Sequence
< OUString
>
524 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
526 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
527 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
528 css::uno::Sequence
< OUString
> s(n
);
529 auto r
= asNonConstRange(s
);
530 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
531 r
[i
] = entity_
->getMembers()[i
].name
;
535 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
536 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
538 assert(arguments_
.size() <= SAL_MAX_INT32
);
539 sal_Int32 n
= static_cast< sal_Int32
>(arguments_
.size());
541 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
542 auto r
= asNonConstRange(s
);
543 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
544 r
[i
] = manager_
->resolve(arguments_
[i
]);
549 typedef cppu::ImplInheritanceHelper
<
550 PublishableDescription
, css::reflection::XCompoundTypeDescription
>
551 ExceptionTypeDescription_Base
;
553 class ExceptionTypeDescription
: public ExceptionTypeDescription_Base
{
555 ExceptionTypeDescription(
556 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
558 rtl::Reference
< unoidl::ExceptionTypeEntity
> const & entity
):
559 ExceptionTypeDescription_Base(entity
->isPublished()), manager_(manager
),
560 name_(std::move(name
)), entity_(entity
)
561 { assert(manager
.is()); assert(entity
.is()); }
564 virtual ~ExceptionTypeDescription() override
{}
566 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
567 { return css::uno::TypeClass_EXCEPTION
; }
569 virtual OUString SAL_CALL
getName() override
572 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
573 getBaseType() override
{
574 return entity_
->getDirectBase().isEmpty()
575 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
576 : manager_
->resolve(entity_
->getDirectBase());
581 css::uno::Reference
< css::reflection::XTypeDescription
> >
582 SAL_CALL
getMemberTypes() override
;
584 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
586 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
588 rtl::Reference
< unoidl::ExceptionTypeEntity
> entity_
;
591 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
592 ExceptionTypeDescription::getMemberTypes() {
593 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
594 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
596 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
597 auto r
= asNonConstRange(s
);
598 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
599 r
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
604 css::uno::Sequence
< OUString
> ExceptionTypeDescription::getMemberNames()
606 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
607 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
608 css::uno::Sequence
< OUString
> s(n
);
609 auto r
= asNonConstRange(s
);
610 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
611 r
[i
] = entity_
->getDirectMembers()[i
].name
;
616 class AttributeDescription
:
617 public cppu::WeakImplHelper
<
618 css::reflection::XInterfaceAttributeTypeDescription2
>
621 AttributeDescription(
622 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
624 unoidl::InterfaceTypeEntity::Attribute attribute
,
626 manager_(manager
), name_(std::move(name
)), attribute_(std::move(attribute
)),
628 { assert(manager
.is()); }
631 virtual ~AttributeDescription() override
{}
633 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
634 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE
; }
636 virtual OUString SAL_CALL
getName() override
639 virtual OUString SAL_CALL
getMemberName() override
640 { return attribute_
.name
; }
642 virtual sal_Int32 SAL_CALL
getPosition() override
643 { return position_
; }
645 virtual sal_Bool SAL_CALL
isReadOnly() override
646 { return attribute_
.readOnly
; }
648 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
650 { return manager_
->resolve(attribute_
.type
); }
652 virtual sal_Bool SAL_CALL
isBound() override
653 { return attribute_
.bound
; }
657 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
658 SAL_CALL
getGetExceptions() override
;
662 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
663 SAL_CALL
getSetExceptions() override
;
665 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
667 unoidl::InterfaceTypeEntity::Attribute attribute_
;
672 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
673 AttributeDescription::getGetExceptions() {
674 assert(attribute_
.getExceptions
.size() <= SAL_MAX_INT32
);
675 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.getExceptions
.size());
677 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
678 auto r
= asNonConstRange(s
);
679 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
681 manager_
->resolve(attribute_
.getExceptions
[i
]),
682 css::uno::UNO_QUERY_THROW
);
688 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
689 AttributeDescription::getSetExceptions() {
690 assert(attribute_
.setExceptions
.size() <= SAL_MAX_INT32
);
691 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.setExceptions
.size());
693 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
694 auto r
= asNonConstRange(s
);
695 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
697 manager_
->resolve(attribute_
.setExceptions
[i
]),
698 css::uno::UNO_QUERY_THROW
);
703 class MethodParameter
:
704 public cppu::WeakImplHelper
< css::reflection::XMethodParameter
>
708 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
709 unoidl::InterfaceTypeEntity::Method::Parameter parameter
,
711 manager_(manager
), parameter_(std::move(parameter
)), position_(position
)
712 { assert(manager
.is()); }
715 virtual ~MethodParameter() override
{}
717 virtual OUString SAL_CALL
getName() override
718 { return parameter_
.name
; }
720 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
722 { return manager_
->resolve(parameter_
.type
); }
724 virtual sal_Bool SAL_CALL
isIn() override
{
726 (parameter_
.direction
727 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
728 || (parameter_
.direction
729 == unoidl::InterfaceTypeEntity::Method::Parameter::
733 virtual sal_Bool SAL_CALL
isOut() override
{
735 (parameter_
.direction
736 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
)
737 || (parameter_
.direction
738 == unoidl::InterfaceTypeEntity::Method::Parameter::
742 virtual sal_Int32 SAL_CALL
getPosition() override
743 { return position_
; }
745 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
746 unoidl::InterfaceTypeEntity::Method::Parameter parameter_
;
750 class MethodDescription
:
751 public cppu::WeakImplHelper
<
752 css::reflection::XInterfaceMethodTypeDescription
>
756 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
758 unoidl::InterfaceTypeEntity::Method method
, sal_Int32 position
):
759 manager_(manager
), name_(std::move(name
)), method_(std::move(method
)), position_(position
)
760 { assert(manager
.is()); }
763 virtual ~MethodDescription() override
{}
765 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
766 { return css::uno::TypeClass_INTERFACE_METHOD
; }
768 virtual OUString SAL_CALL
getName() override
771 virtual OUString SAL_CALL
getMemberName() override
772 { return method_
.name
; }
774 virtual sal_Int32 SAL_CALL
getPosition() override
775 { return position_
; }
777 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
778 getReturnType() override
779 { return manager_
->resolve(method_
.returnType
); }
781 virtual sal_Bool SAL_CALL
isOneway() override
786 css::uno::Reference
< css::reflection::XMethodParameter
> >
787 SAL_CALL
getParameters() override
;
791 css::uno::Reference
< css::reflection::XTypeDescription
> >
792 SAL_CALL
getExceptions() override
;
794 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
796 unoidl::InterfaceTypeEntity::Method method_
;
800 css::uno::Sequence
< css::uno::Reference
< css::reflection::XMethodParameter
> >
801 MethodDescription::getParameters() {
802 assert(method_
.parameters
.size() <= SAL_MAX_INT32
);
803 sal_Int32 n
= static_cast< sal_Int32
>(method_
.parameters
.size());
805 css::uno::Reference
< css::reflection::XMethodParameter
> > s(n
);
806 auto r
= asNonConstRange(s
);
807 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
808 r
[i
] = new MethodParameter(manager_
, method_
.parameters
[i
], i
);
813 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
814 MethodDescription::getExceptions() {
815 assert(method_
.exceptions
.size() <= SAL_MAX_INT32
);
816 sal_Int32 n
= static_cast< sal_Int32
>(method_
.exceptions
.size());
818 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
819 auto r
= asNonConstRange(s
);
820 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
821 r
[i
] = manager_
->resolve(method_
.exceptions
[i
]);
829 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
830 const & description
);
832 BaseOffset(const BaseOffset
&) = delete;
833 const BaseOffset
& operator=(const BaseOffset
&) = delete;
835 sal_Int32
get() const { return offset_
; }
839 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
840 const & description
);
843 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
844 const & description
);
846 std::set
< OUString
> set_
;
850 BaseOffset::BaseOffset(
851 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
855 calculateBases(description
);
858 void BaseOffset::calculateBases(
859 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
862 const css::uno::Sequence
<
863 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
864 description
->getBaseTypes());
865 for (const auto & i
: bases
) {
867 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
868 resolveTypedefs(css::uno::Any(i
)),
869 css::uno::UNO_QUERY_THROW
));
873 void BaseOffset::calculate(
874 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
877 if (set_
.insert(description
->getName()).second
) {
878 calculateBases(description
);
879 offset_
+= description
->getMembers().getLength();
883 typedef cppu::ImplInheritanceHelper
<
884 PublishableDescription
, css::reflection::XInterfaceTypeDescription2
>
885 InterfaceTypeDescription_Base
;
887 class InterfaceTypeDescription
: public InterfaceTypeDescription_Base
{
889 InterfaceTypeDescription(
890 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
892 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
893 InterfaceTypeDescription_Base(entity
->isPublished()), manager_(manager
),
894 name_(std::move(name
)), entity_(entity
)
895 { assert(manager
.is()); assert(entity
.is()); }
898 virtual ~InterfaceTypeDescription() override
{}
900 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
901 { return css::uno::TypeClass_INTERFACE
; }
903 virtual OUString SAL_CALL
getName() override
906 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
907 getBaseType() override
{
908 return entity_
->getDirectMandatoryBases().empty()
909 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
910 : manager_
->resolve(entity_
->getDirectMandatoryBases()[0].name
);
913 virtual css::uno::Uik SAL_CALL
getUik() override
914 { return css::uno::Uik(); }
919 css::reflection::XInterfaceMemberTypeDescription
> >
920 SAL_CALL
getMembers() override
;
924 css::uno::Reference
< css::reflection::XTypeDescription
> >
925 SAL_CALL
getBaseTypes() override
;
929 css::uno::Reference
< css::reflection::XTypeDescription
> >
930 SAL_CALL
getOptionalBaseTypes() override
;
932 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
934 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
938 css::uno::Reference
< css::reflection::XInterfaceMemberTypeDescription
> >
939 InterfaceTypeDescription::getMembers() {
941 entity_
->getDirectAttributes().size() <= SAL_MAX_INT32
942 && (entity_
->getDirectMethods().size()
943 <= SAL_MAX_INT32
- entity_
->getDirectAttributes().size()));
944 sal_Int32 n1
= static_cast< sal_Int32
>(
945 entity_
->getDirectAttributes().size());
946 sal_Int32 n2
= static_cast< sal_Int32
>(entity_
->getDirectMethods().size());
949 css::reflection::XInterfaceMemberTypeDescription
> > s(n1
+ n2
);
950 auto r
= asNonConstRange(s
);
951 sal_Int32 off
= BaseOffset(this).get();
952 for (sal_Int32 i
= 0; i
!= n1
; ++i
) {
953 r
[i
] = new AttributeDescription(
954 manager_
, name_
+ "::" + entity_
->getDirectAttributes()[i
].name
,
955 entity_
->getDirectAttributes()[i
], off
+ i
);
957 for (sal_Int32 i
= 0; i
!= n2
; ++i
) {
958 r
[n1
+ i
] = new MethodDescription(
959 manager_
, name_
+ "::" + entity_
->getDirectMethods()[i
].name
,
960 entity_
->getDirectMethods()[i
], off
+ n1
+ i
);
965 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
966 InterfaceTypeDescription::getBaseTypes() {
967 assert(entity_
->getDirectMandatoryBases().size() <= SAL_MAX_INT32
);
968 sal_Int32 n
= static_cast< sal_Int32
>(
969 entity_
->getDirectMandatoryBases().size());
971 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
972 auto r
= asNonConstRange(s
);
973 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
974 r
[i
] = manager_
->resolve(entity_
->getDirectMandatoryBases()[i
].name
);
979 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
980 InterfaceTypeDescription::getOptionalBaseTypes()
982 assert(entity_
->getDirectOptionalBases().size() <= SAL_MAX_INT32
);
983 sal_Int32 n
= static_cast< sal_Int32
>(
984 entity_
->getDirectOptionalBases().size());
986 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
987 auto r
= asNonConstRange(s
);
988 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
989 r
[i
] = manager_
->resolve(entity_
->getDirectOptionalBases()[i
].name
);
994 class ConstantDescription
:
995 public cppu::WeakImplHelper
< css::reflection::XConstantTypeDescription
>
999 OUString
const & constantGroupName
,
1000 unoidl::ConstantGroupEntity::Member
const & member
);
1003 virtual ~ConstantDescription() override
{}
1005 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1006 { return css::uno::TypeClass_CONSTANT
; }
1008 virtual OUString SAL_CALL
getName() override
1011 virtual css::uno::Any SAL_CALL
getConstantValue() override
1015 css::uno::Any value_
;
1018 ConstantDescription::ConstantDescription(
1019 OUString
const & constantGroupName
,
1020 unoidl::ConstantGroupEntity::Member
const & member
):
1021 name_(makePrefix(constantGroupName
) + member
.name
)
1023 switch (member
.value
.type
) {
1024 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1025 value_
<<= member
.value
.booleanValue
;
1027 case unoidl::ConstantValue::TYPE_BYTE
:
1028 value_
<<= member
.value
.byteValue
;
1030 case unoidl::ConstantValue::TYPE_SHORT
:
1031 value_
<<= member
.value
.shortValue
;
1033 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1034 value_
<<= member
.value
.unsignedShortValue
;
1036 case unoidl::ConstantValue::TYPE_LONG
:
1037 value_
<<= member
.value
.longValue
;
1039 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1040 value_
<<= member
.value
.unsignedLongValue
;
1042 case unoidl::ConstantValue::TYPE_HYPER
:
1043 value_
<<= member
.value
.hyperValue
;
1045 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1046 value_
<<= member
.value
.unsignedHyperValue
;
1048 case unoidl::ConstantValue::TYPE_FLOAT
:
1049 value_
<<= member
.value
.floatValue
;
1051 case unoidl::ConstantValue::TYPE_DOUBLE
:
1052 value_
<<= member
.value
.doubleValue
;
1055 for (;;) { std::abort(); } // this cannot happen
1059 typedef cppu::ImplInheritanceHelper
<
1060 PublishableDescription
, css::reflection::XConstantsTypeDescription
>
1061 ConstantGroupDescription_Base
;
1063 class ConstantGroupDescription
: public ConstantGroupDescription_Base
{
1065 ConstantGroupDescription(
1067 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
):
1068 ConstantGroupDescription_Base(entity
->isPublished()), name_(std::move(name
)),
1070 { assert(entity
.is()); }
1073 virtual ~ConstantGroupDescription() override
{}
1075 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1076 { return css::uno::TypeClass_CONSTANTS
; }
1078 virtual OUString SAL_CALL
getName() override
1083 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1084 SAL_CALL
getConstants() override
;
1087 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1091 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1092 ConstantGroupDescription::getConstants() {
1093 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
1094 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
1096 css::uno::Reference
< css::reflection::XConstantTypeDescription
> > s(n
);
1097 auto r
= asNonConstRange(s
);
1098 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1099 r
[i
] = new ConstantDescription(name_
, entity_
->getMembers()[i
]);
1104 typedef cppu::ImplInheritanceHelper
<
1105 PublishableDescription
, css::reflection::XIndirectTypeDescription
>
1106 TypedefDescription_Base
;
1108 class TypedefDescription
: public TypedefDescription_Base
{
1111 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1113 rtl::Reference
< unoidl::TypedefEntity
> const & entity
):
1114 TypedefDescription_Base(entity
->isPublished()), manager_(manager
),
1115 name_(std::move(name
)), entity_(entity
)
1116 { assert(manager
.is()); assert(entity
.is()); }
1119 virtual ~TypedefDescription() override
{}
1121 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1122 { return css::uno::TypeClass_TYPEDEF
; }
1124 virtual OUString SAL_CALL
getName() override
1127 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1128 getReferencedType() override
1129 { return manager_
->resolve(entity_
->getType()); }
1131 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1133 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
1136 class ConstructorParameter
:
1137 public cppu::WeakImplHelper
< css::reflection::XParameter
>
1140 ConstructorParameter(
1141 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1142 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter parameter
,
1143 sal_Int32 position
):
1144 manager_(manager
), parameter_(std::move(parameter
)), position_(position
)
1145 { assert(manager
.is()); }
1148 virtual ~ConstructorParameter() override
{}
1150 virtual OUString SAL_CALL
getName() override
1151 { return parameter_
.name
; }
1153 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1155 { return manager_
->resolve(parameter_
.type
); }
1157 virtual sal_Bool SAL_CALL
isIn() override
1160 virtual sal_Bool SAL_CALL
isOut() override
1163 virtual sal_Int32 SAL_CALL
getPosition() override
1164 { return position_
; }
1166 virtual sal_Bool SAL_CALL
isRestParameter() override
1167 { return parameter_
.rest
; }
1169 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1170 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1172 sal_Int32 position_
;
1175 class ConstructorDescription
:
1176 public cppu::WeakImplHelper
<
1177 css::reflection::XServiceConstructorDescription
>
1180 ConstructorDescription(
1181 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1182 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor
):
1183 manager_(manager
), constructor_(std::move(constructor
))
1184 { assert(manager
.is()); }
1187 virtual ~ConstructorDescription() override
{}
1189 virtual sal_Bool SAL_CALL
isDefaultConstructor() override
1190 { return constructor_
.defaultConstructor
; }
1192 virtual OUString SAL_CALL
getName() override
1193 { return constructor_
.name
; }
1197 css::uno::Reference
< css::reflection::XParameter
> >
1198 SAL_CALL
getParameters() override
;
1202 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1203 SAL_CALL
getExceptions() override
;
1205 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1206 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_
;
1209 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> >
1210 ConstructorDescription::getParameters() {
1211 assert(constructor_
.parameters
.size() <= SAL_MAX_INT32
);
1212 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.parameters
.size());
1213 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> > s(
1215 auto r
= asNonConstRange(s
);
1216 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1217 r
[i
] = new ConstructorParameter(
1218 manager_
, constructor_
.parameters
[i
], i
);
1224 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1225 ConstructorDescription::getExceptions() {
1226 assert(constructor_
.exceptions
.size() <= SAL_MAX_INT32
);
1227 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.exceptions
.size());
1229 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
1230 auto r
= asNonConstRange(s
);
1231 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1233 manager_
->resolve(constructor_
.exceptions
[i
]),
1234 css::uno::UNO_QUERY_THROW
);
1239 typedef cppu::ImplInheritanceHelper
<
1240 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1241 SingleInterfaceBasedServiceDescription_Base
;
1243 class SingleInterfaceBasedServiceDescription
:
1244 public SingleInterfaceBasedServiceDescription_Base
1247 SingleInterfaceBasedServiceDescription(
1248 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1250 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
1252 SingleInterfaceBasedServiceDescription_Base(entity
->isPublished()),
1253 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1254 { assert(manager
.is()); assert(entity
.is()); }
1257 virtual ~SingleInterfaceBasedServiceDescription() override
{}
1259 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1260 { return css::uno::TypeClass_SERVICE
; }
1262 virtual OUString SAL_CALL
getName() override
1267 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1268 SAL_CALL
getMandatoryServices() override
1270 return css::uno::Sequence
<
1271 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1276 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1277 SAL_CALL
getOptionalServices() override
1279 return css::uno::Sequence
<
1280 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1285 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1286 SAL_CALL
getMandatoryInterfaces() override
1288 return css::uno::Sequence
<
1289 css::uno::Reference
<
1290 css::reflection::XInterfaceTypeDescription
> >();
1295 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1296 SAL_CALL
getOptionalInterfaces() override
1298 return css::uno::Sequence
<
1299 css::uno::Reference
<
1300 css::reflection::XInterfaceTypeDescription
> >();
1305 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1306 SAL_CALL
getProperties() override
1308 return css::uno::Sequence
<
1309 css::uno::Reference
<
1310 css::reflection::XPropertyTypeDescription
> >();
1313 virtual sal_Bool SAL_CALL
isSingleInterfaceBased() override
1316 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1317 getInterface() override
1318 { return manager_
->resolve(entity_
->getBase()); }
1322 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1323 SAL_CALL
getConstructors() override
;
1325 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1327 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> entity_
;
1331 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1332 SingleInterfaceBasedServiceDescription::getConstructors()
1334 assert(entity_
->getConstructors().size() <= SAL_MAX_INT32
);
1335 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getConstructors().size());
1337 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1339 auto r
= asNonConstRange(s
);
1340 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1341 r
[i
] = new ConstructorDescription(
1342 manager_
, entity_
->getConstructors()[i
]);
1347 class PropertyDescription
:
1348 public cppu::WeakImplHelper
< css::reflection::XPropertyTypeDescription
>
1351 PropertyDescription(
1352 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1353 unoidl::AccumulationBasedServiceEntity::Property property
):
1354 manager_(manager
), property_(std::move(property
))
1355 { assert(manager
.is()); }
1358 virtual ~PropertyDescription() override
{}
1360 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1361 { return css::uno::TypeClass_PROPERTY
; }
1363 virtual OUString SAL_CALL
getName() override
1364 { return property_
.name
; }
1366 virtual sal_Int16 SAL_CALL
getPropertyFlags() override
1367 { return property_
.attributes
; }
1369 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1370 getPropertyTypeDescription() override
1371 { return manager_
->resolve(property_
.type
); }
1373 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1374 unoidl::AccumulationBasedServiceEntity::Property property_
;
1377 typedef cppu::ImplInheritanceHelper
<
1378 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1379 AccumulationBasedServiceDescription_Base
;
1381 class AccumulationBasedServiceDescription
:
1382 public AccumulationBasedServiceDescription_Base
1385 AccumulationBasedServiceDescription(
1386 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1388 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const &
1390 AccumulationBasedServiceDescription_Base(entity
->isPublished()),
1391 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1392 { assert(manager
.is()); assert(entity
.is()); }
1395 virtual ~AccumulationBasedServiceDescription() override
{}
1397 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1398 { return css::uno::TypeClass_SERVICE
; }
1400 virtual OUString SAL_CALL
getName() override
1405 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1406 SAL_CALL
getMandatoryServices() override
;
1410 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1411 SAL_CALL
getOptionalServices() override
;
1415 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1416 SAL_CALL
getMandatoryInterfaces() override
;
1420 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1421 SAL_CALL
getOptionalInterfaces() override
;
1425 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1426 SAL_CALL
getProperties() override
;
1428 virtual sal_Bool SAL_CALL
isSingleInterfaceBased() override
1431 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1432 getInterface() override
1433 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1437 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1438 SAL_CALL
getConstructors() override
1440 return css::uno::Sequence
<
1441 css::uno::Reference
<
1442 css::reflection::XServiceConstructorDescription
> >();
1445 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1447 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> entity_
;
1451 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1452 AccumulationBasedServiceDescription::getMandatoryServices()
1454 assert(entity_
->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32
);
1455 sal_Int32 n
= static_cast< sal_Int32
>(
1456 entity_
->getDirectMandatoryBaseServices().size());
1458 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1459 auto r
= asNonConstRange(s
);
1460 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1463 entity_
->getDirectMandatoryBaseServices()[i
].name
),
1464 css::uno::UNO_QUERY_THROW
);
1470 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1471 AccumulationBasedServiceDescription::getOptionalServices()
1473 assert(entity_
->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32
);
1474 sal_Int32 n
= static_cast< sal_Int32
>(
1475 entity_
->getDirectOptionalBaseServices().size());
1477 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1478 auto r
= asNonConstRange(s
);
1479 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1481 manager_
->resolve(entity_
->getDirectOptionalBaseServices()[i
].name
),
1482 css::uno::UNO_QUERY_THROW
);
1488 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1489 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1491 assert(entity_
->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32
);
1492 sal_Int32 n
= static_cast< sal_Int32
>(
1493 entity_
->getDirectMandatoryBaseInterfaces().size());
1495 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1497 auto r
= asNonConstRange(s
);
1498 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1502 entity_
->getDirectMandatoryBaseInterfaces()[i
].name
)),
1503 css::uno::UNO_QUERY_THROW
);
1509 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1510 AccumulationBasedServiceDescription::getOptionalInterfaces()
1512 assert(entity_
->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32
);
1513 sal_Int32 n
= static_cast< sal_Int32
>(
1514 entity_
->getDirectOptionalBaseInterfaces().size());
1516 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1518 auto r
= asNonConstRange(s
);
1519 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1523 entity_
->getDirectOptionalBaseInterfaces()[i
].name
)),
1524 css::uno::UNO_QUERY_THROW
);
1530 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1531 AccumulationBasedServiceDescription::getProperties()
1533 assert(entity_
->getDirectProperties().size() <= SAL_MAX_INT32
);
1534 sal_Int32 n
= static_cast< sal_Int32
>(
1535 entity_
->getDirectProperties().size());
1537 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> > s(n
);
1538 auto r
= asNonConstRange(s
);
1539 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1540 r
[i
] = new PropertyDescription(
1541 manager_
, entity_
->getDirectProperties()[i
]);
1546 typedef cppu::ImplInheritanceHelper
<
1547 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1548 InterfaceBasedSingletonDescription_Base
;
1550 class InterfaceBasedSingletonDescription
:
1551 public InterfaceBasedSingletonDescription_Base
1554 InterfaceBasedSingletonDescription(
1555 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1557 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
):
1558 InterfaceBasedSingletonDescription_Base(entity
->isPublished()),
1559 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1560 { assert(manager
.is()); assert(entity
.is()); }
1563 virtual ~InterfaceBasedSingletonDescription() override
{}
1565 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1566 { return css::uno::TypeClass_SINGLETON
; }
1568 virtual OUString SAL_CALL
getName() override
1571 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1572 SAL_CALL
getService() override
1575 css::uno::Reference
< css::reflection::XServiceTypeDescription
>();
1578 virtual sal_Bool SAL_CALL
isInterfaceBased() override
1581 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1582 SAL_CALL
getInterface() override
1583 { return manager_
->resolve(entity_
->getBase()); }
1585 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1587 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> entity_
;
1590 typedef cppu::ImplInheritanceHelper
<
1591 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1592 ServiceBasedSingletonDescription_Base
;
1594 class ServiceBasedSingletonDescription
:
1595 public ServiceBasedSingletonDescription_Base
1598 ServiceBasedSingletonDescription(
1599 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1601 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> const & entity
):
1602 ServiceBasedSingletonDescription_Base(entity
->isPublished()),
1603 manager_(manager
), name_(std::move(name
)), entity_(entity
)
1604 { assert(manager
.is()); assert(entity
.is()); }
1607 virtual ~ServiceBasedSingletonDescription() override
{}
1609 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1610 { return css::uno::TypeClass_SINGLETON
; }
1612 virtual OUString SAL_CALL
getName() override
1615 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1616 SAL_CALL
getService() override
1618 return css::uno::Reference
< css::reflection::XServiceTypeDescription
>(
1619 manager_
->resolve(entity_
->getBase()), css::uno::UNO_QUERY_THROW
);
1622 virtual sal_Bool SAL_CALL
isInterfaceBased() override
1625 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1626 SAL_CALL
getInterface() override
1627 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1629 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1631 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> entity_
;
1635 public cppu::WeakImplHelper
< css::reflection::XTypeDescriptionEnumeration
>
1639 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1640 OUString
const & prefix
,
1641 rtl::Reference
< unoidl::MapCursor
> const & cursor
,
1642 css::uno::Sequence
< css::uno::TypeClass
> const & types
, bool deep
):
1643 manager_(manager
), types_(types
), deep_(deep
)
1645 assert(manager
.is());
1646 positions_
.push(Position(prefix
, cursor
));
1651 virtual ~Enumeration() override
{}
1653 virtual sal_Bool SAL_CALL
hasMoreElements() override
1654 { return !positions_
.empty(); }
1656 virtual css::uno::Any SAL_CALL
nextElement() override
1657 { return css::uno::Any(nextTypeDescription()); }
1659 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1660 nextTypeDescription() override
;
1662 bool matches(css::uno::TypeClass tc
) const;
1664 void findNextMatch();
1669 rtl::Reference
< unoidl::MapCursor
> const & theCursor
):
1670 prefix(std::move(thePrefix
)), cursor(theCursor
)
1671 { assert(theCursor
.is()); }
1675 rtl::Reference
< unoidl::ConstantGroupEntity
> const &
1677 prefix(std::move(thePrefix
)), constantGroup(theConstantGroup
),
1678 constantGroupIndex(constantGroup
->getMembers().begin())
1679 { assert(theConstantGroup
.is()); }
1681 Position(Position
const & other
):
1682 prefix(other
.prefix
), cursor(other
.cursor
),
1683 constantGroup(other
.constantGroup
)
1685 if (constantGroup
.is()) {
1686 constantGroupIndex
= other
.constantGroupIndex
;
1691 rtl::Reference
< unoidl::MapCursor
> cursor
;
1692 rtl::Reference
< unoidl::ConstantGroupEntity
> constantGroup
;
1693 std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
1697 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1698 css::uno::Sequence
< css::uno::TypeClass
> types_
;
1702 std::stack
< Position
, std::vector
<Position
> > positions_
;
1706 css::uno::Reference
< css::reflection::XTypeDescription
>
1707 Enumeration::nextTypeDescription()
1711 std::scoped_lock
g(mutex_
);
1712 if (positions_
.empty()) {
1713 throw css::container::NoSuchElementException(
1714 "exhausted XTypeDescriptionEnumeration",
1715 static_cast< cppu::OWeakObject
* >(this));
1720 return manager_
->resolve(name
);
1723 bool Enumeration::matches(css::uno::TypeClass tc
) const {
1724 if (!types_
.hasElements()) {
1728 return std::any_of(types_
.begin(), types_
.end(), [&tc
](const auto& i
) { return i
== tc
; });
1731 void Enumeration::findNextMatch() {
1734 assert(!positions_
.empty());
1736 if (positions_
.top().cursor
.is()) { // root or module
1737 rtl::Reference
< unoidl::Entity
> ent(
1738 positions_
.top().cursor
->getNext(&name
));
1741 if (positions_
.empty()) {
1746 name
= positions_
.top().prefix
+ name
;
1747 css::uno::TypeClass tc
;
1748 switch (ent
->getSort()) {
1749 case unoidl::Entity::SORT_MODULE
:
1750 tc
= css::uno::TypeClass_MODULE
;
1755 static_cast< unoidl::ModuleEntity
* >(
1756 ent
.get())->createCursor()));
1759 case unoidl::Entity::SORT_ENUM_TYPE
:
1760 tc
= css::uno::TypeClass_ENUM
;
1762 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
1763 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
1764 tc
= css::uno::TypeClass_STRUCT
;
1766 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
1767 tc
= css::uno::TypeClass_EXCEPTION
;
1769 case unoidl::Entity::SORT_INTERFACE_TYPE
:
1770 tc
= css::uno::TypeClass_INTERFACE
;
1772 case unoidl::Entity::SORT_TYPEDEF
:
1773 tc
= css::uno::TypeClass_TYPEDEF
;
1775 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1776 tc
= css::uno::TypeClass_CONSTANTS
;
1777 if (deep_
&& matches(css::uno::TypeClass_CONSTANT
)) {
1781 static_cast< unoidl::ConstantGroupEntity
* >(
1785 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
1786 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
1787 tc
= css::uno::TypeClass_SERVICE
;
1789 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
1790 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
1791 tc
= css::uno::TypeClass_SINGLETON
;
1794 for (;;) { std::abort(); } // this cannot happen
1800 } else { // constant group
1801 if (positions_
.top().constantGroupIndex
1802 == positions_
.top().constantGroup
->getMembers().end())
1805 if (positions_
.empty()) {
1810 current_
= positions_
.top().prefix
1811 + positions_
.top().constantGroupIndex
++->name
;
1815 } catch (unoidl::FileFormatException
& e
) {
1816 throw css::uno::DeploymentException(
1817 e
.getUri() + ": " + e
.getDetail(),
1818 static_cast< cppu::OWeakObject
* >(this));
1824 cppuhelper::TypeManager::TypeManager():
1825 manager_(new unoidl::Manager
)
1828 css::uno::Any
cppuhelper::TypeManager::find(OUString
const & name
) {
1829 //TODO: caching? (here or in unoidl::Manager?)
1830 static constexpr std::pair
<std::u16string_view
, css::uno::TypeClass
> const simple
[] = {
1831 { u
"void", css::uno::TypeClass_VOID
},
1832 { u
"boolean", css::uno::TypeClass_BOOLEAN
},
1833 { u
"byte", css::uno::TypeClass_BYTE
},
1834 { u
"short", css::uno::TypeClass_SHORT
},
1835 { u
"unsigned short", css::uno::TypeClass_UNSIGNED_SHORT
},
1836 { u
"long", css::uno::TypeClass_LONG
},
1837 { u
"unsigned long", css::uno::TypeClass_UNSIGNED_LONG
},
1838 { u
"hyper", css::uno::TypeClass_HYPER
},
1839 { u
"unsigned hyper", css::uno::TypeClass_UNSIGNED_HYPER
},
1840 { u
"float", css::uno::TypeClass_FLOAT
},
1841 { u
"double", css::uno::TypeClass_DOUBLE
},
1842 { u
"char", css::uno::TypeClass_CHAR
},
1843 { u
"string", css::uno::TypeClass_STRING
},
1844 { u
"type", css::uno::TypeClass_TYPE
},
1845 { u
"any", css::uno::TypeClass_ANY
} };
1846 for (const auto& [ rName
, rTypeClass
] : simple
) {
1847 if (name
== rName
) {
1848 return css::uno::Any(
1849 css::uno::Reference
< css::reflection::XTypeDescription
>(
1850 new SimpleTypeDescription(rTypeClass
, name
)));
1853 if (name
.startsWith("[]")) {
1854 return getSequenceType(name
);
1856 sal_Int32 i
= name
.indexOf('<');
1858 return getInstantiatedStruct(name
, i
);
1860 i
= name
.indexOf("::");
1862 return getInterfaceMember(name
, i
);
1864 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
));
1866 return getNamed(name
, ent
);
1868 i
= name
.lastIndexOf('.');
1870 OUString
parent(name
.copy(0, i
));
1871 ent
= findEntity(parent
);
1873 switch (ent
->getSort()) {
1874 case unoidl::Entity::SORT_ENUM_TYPE
:
1875 return getEnumMember(
1876 static_cast< unoidl::EnumTypeEntity
* >(ent
.get()),
1877 name
.subView(i
+ 1));
1878 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1881 static_cast< unoidl::ConstantGroupEntity
* >(ent
.get()),
1882 name
.subView(i
+ 1));
1888 return css::uno::Any();
1891 css::uno::Reference
< css::reflection::XTypeDescription
>
1892 cppuhelper::TypeManager::resolve(OUString
const & name
) {
1893 css::uno::Reference
< css::reflection::XTypeDescription
> desc(
1894 find(name
), css::uno::UNO_QUERY
);
1896 throw css::uno::DeploymentException(
1897 "cannot resolve type \"" + name
+ "\"",
1898 static_cast< cppu::OWeakObject
* >(this));
1903 cppuhelper::TypeManager::~TypeManager() noexcept
{}
1905 OUString
cppuhelper::TypeManager::getImplementationName()
1908 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager";
1911 sal_Bool
cppuhelper::TypeManager::supportsService(
1912 OUString
const & ServiceName
)
1914 return cppu::supportsService(this, ServiceName
);
1917 css::uno::Sequence
< OUString
>
1918 cppuhelper::TypeManager::getSupportedServiceNames()
1920 return { "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1923 css::uno::Any
cppuhelper::TypeManager::getByHierarchicalName(
1924 OUString
const & aName
)
1926 css::uno::Any
desc(find(aName
));
1927 if (!desc
.hasValue()) {
1928 throw css::container::NoSuchElementException(
1929 aName
, static_cast< cppu::OWeakObject
* >(this));
1934 sal_Bool
cppuhelper::TypeManager::hasByHierarchicalName(
1935 OUString
const & aName
)
1937 return find(aName
).hasValue();
1940 css::uno::Type
cppuhelper::TypeManager::getElementType()
1942 return cppu::UnoType
< OUString
>::get();
1945 sal_Bool
cppuhelper::TypeManager::hasElements()
1947 throw css::uno::RuntimeException(
1948 "TypeManager hasElements: method not supported",
1949 static_cast< cppu::OWeakObject
* >(this));
1952 css::uno::Reference
< css::container::XEnumeration
>
1953 cppuhelper::TypeManager::createEnumeration()
1955 throw css::uno::RuntimeException(
1956 "TypeManager createEnumeration: method not supported",
1957 static_cast< cppu::OWeakObject
* >(this));
1960 sal_Bool
cppuhelper::TypeManager::has(css::uno::Any
const &)
1962 throw css::uno::RuntimeException(
1963 "TypeManager has: method not supported",
1964 static_cast< cppu::OWeakObject
* >(this));
1967 void cppuhelper::TypeManager::insert(css::uno::Any
const & aElement
)
1970 if (!(aElement
>>= uri
)) {
1971 throw css::lang::IllegalArgumentException(
1972 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
1974 static_cast< cppu::OWeakObject
* >(this), 0);
1976 //TODO: check for ElementExistException
1977 //TODO: check for consistency with existing data
1978 readRdbFile(uri
, false);
1981 void cppuhelper::TypeManager::remove(css::uno::Any
const & aElement
)
1984 if (!(aElement
>>= uri
)) {
1985 throw css::lang::IllegalArgumentException(
1986 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
1988 static_cast< cppu::OWeakObject
* >(this), 0);
1990 //TODO: remove requests are silently ignored for now
1993 css::uno::Reference
< css::reflection::XTypeDescriptionEnumeration
>
1994 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
1995 OUString
const & moduleName
,
1996 css::uno::Sequence
< css::uno::TypeClass
> const & types
,
1997 css::reflection::TypeDescriptionSearchDepth depth
)
1999 rtl::Reference
< unoidl::MapCursor
> cursor
;
2001 cursor
= manager_
->createCursor(moduleName
);
2002 } catch (unoidl::FileFormatException
& e
) {
2003 throw css::uno::DeploymentException(
2004 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2006 static_cast< cppu::OWeakObject
* >(this));
2009 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2011 throw css::reflection::NoSuchTypeNameException(
2012 moduleName
, static_cast< cppu::OWeakObject
* >(this));
2014 return new Enumeration(
2015 this, makePrefix(moduleName
), cursor
, types
,
2016 depth
== css::reflection::TypeDescriptionSearchDepth_INFINITE
);
2019 void cppuhelper::TypeManager::init(std::u16string_view rdbUris
) {
2020 for (sal_Int32 i
= 0; i
!= -1;) {
2021 std::u16string_view
uri(o3tl::getToken(rdbUris
, 0, ' ', i
));
2027 cppu::decodeRdbUri(&uri
, &optional
, &directory
);
2029 readRdbDirectory(uri
, optional
);
2031 readRdbFile(uri
, optional
);
2036 void cppuhelper::TypeManager::readRdbDirectory(
2037 std::u16string_view uri
, bool optional
)
2039 osl::Directory dir
= OUString(uri
);
2040 switch (dir
.open()) {
2041 case osl::FileBase::E_None
:
2043 case osl::FileBase::E_NOENT
:
2045 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri
));
2050 throw css::uno::DeploymentException(
2051 OUString::Concat("Cannot open directory ") + uri
,
2052 static_cast< cppu::OWeakObject
* >(this));
2056 if (!cppu::nextDirectoryItem(dir
, &url
)) {
2059 readRdbFile(url
, false);
2063 void cppuhelper::TypeManager::readRdbFile(
2064 std::u16string_view uri
, bool optional
)
2067 manager_
->addProvider(OUString(uri
));
2068 } catch (unoidl::NoSuchFileException
&) {
2070 throw css::uno::DeploymentException(
2071 OUString::Concat(uri
) + ": no such file",
2072 static_cast< cppu::OWeakObject
* >(this));
2074 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri
));
2075 } catch (unoidl::FileFormatException
& e
) {
2076 throw css::uno::DeploymentException(
2077 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2079 static_cast< cppu::OWeakObject
* >(this));
2083 css::uno::Any
cppuhelper::TypeManager::getSequenceType(
2084 OUString
const & name
)
2086 assert(name
.startsWith("[]"));
2087 return css::uno::Any(
2088 css::uno::Reference
< css::reflection::XTypeDescription
>(
2089 new SequenceTypeDescription(
2090 this, name
, name
.copy(std::strlen("[]")))));
2093 css::uno::Any
cppuhelper::TypeManager::getInstantiatedStruct(
2094 OUString
const & name
, sal_Int32 separator
)
2096 assert(name
.indexOf('<') == separator
&& separator
!= -1);
2097 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
.copy(0, separator
)));
2100 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
))
2102 return css::uno::Any();
2104 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
2105 static_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
2107 std::vector
< OUString
> args
;
2108 sal_Int32 i
= separator
;
2110 ++i
; // skip '<' or ','
2112 for (sal_Int32 level
= 0; j
!= name
.getLength(); ++j
) {
2113 sal_Unicode c
= name
[j
];
2118 } else if (c
== '<') {
2120 } else if (c
== '>') {
2127 if (j
!= name
.getLength()) {
2128 args
.push_back(name
.copy(i
, j
- i
));
2131 } while (i
!= name
.getLength() && name
[i
] != '>');
2132 if (i
!= name
.getLength() - 1 || name
[i
] != '>'
2133 || args
.size() != ent2
->getTypeParameters().size())
2135 return css::uno::Any();
2137 return css::uno::Any(
2138 css::uno::Reference
< css::reflection::XTypeDescription
>(
2139 new InstantiatedPolymorphicStructTypeDescription(
2140 this, name
, ent2
, std::move(args
))));
2143 css::uno::Any
cppuhelper::TypeManager::getInterfaceMember(
2144 std::u16string_view name
, std::size_t separator
)
2146 assert(name
.find(u
"::") == separator
&& separator
!= std::u16string_view::npos
);
2147 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> ifc(
2148 resolveTypedefs(find(OUString(name
.substr(0, separator
)))), css::uno::UNO_QUERY
);
2150 return css::uno::Any();
2152 std::u16string_view member
= name
.substr(separator
+ std::strlen("::"));
2153 const css::uno::Sequence
<
2154 css::uno::Reference
<
2155 css::reflection::XInterfaceMemberTypeDescription
> > mems(
2157 for (const auto & m
: mems
) {
2158 if (m
->getMemberName() == member
) {
2159 return css::uno::Any(
2160 css::uno::Reference
< css::reflection::XTypeDescription
>(m
));
2163 return css::uno::Any();
2166 css::uno::Any
cppuhelper::TypeManager::getNamed(
2167 OUString
const & name
, rtl::Reference
< unoidl::Entity
> const & entity
)
2169 assert(entity
.is());
2170 switch (entity
->getSort()) {
2171 case unoidl::Entity::SORT_MODULE
:
2172 return css::uno::Any(
2173 css::uno::Reference
< css::reflection::XTypeDescription
>(
2174 new ModuleDescription(
2176 static_cast< unoidl::ModuleEntity
* >(entity
.get()))));
2177 case unoidl::Entity::SORT_ENUM_TYPE
:
2178 return css::uno::Any(
2179 css::uno::Reference
< css::reflection::XTypeDescription
>(
2180 new EnumTypeDescription(
2182 static_cast< unoidl::EnumTypeEntity
* >(entity
.get()))));
2183 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
2184 return css::uno::Any(
2185 css::uno::Reference
< css::reflection::XTypeDescription
>(
2186 new PlainStructTypeDescription(
2188 static_cast< unoidl::PlainStructTypeEntity
* >(
2190 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
2191 return css::uno::Any(
2192 css::uno::Reference
< css::reflection::XTypeDescription
>(
2193 new PolymorphicStructTypeTemplateDescription(
2196 unoidl::PolymorphicStructTypeTemplateEntity
* >(
2198 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
2199 return css::uno::Any(
2200 css::uno::Reference
< css::reflection::XTypeDescription
>(
2201 new ExceptionTypeDescription(
2203 static_cast< unoidl::ExceptionTypeEntity
* >(
2205 case unoidl::Entity::SORT_INTERFACE_TYPE
:
2206 return css::uno::Any(
2207 css::uno::Reference
< css::reflection::XTypeDescription
>(
2208 new InterfaceTypeDescription(
2210 static_cast< unoidl::InterfaceTypeEntity
* >(
2212 case unoidl::Entity::SORT_TYPEDEF
:
2213 return css::uno::Any(
2214 css::uno::Reference
< css::reflection::XTypeDescription
>(
2215 new TypedefDescription(
2217 static_cast< unoidl::TypedefEntity
* >(entity
.get()))));
2218 case unoidl::Entity::SORT_CONSTANT_GROUP
:
2219 return css::uno::Any(
2220 css::uno::Reference
< css::reflection::XTypeDescription
>(
2221 new ConstantGroupDescription(
2223 static_cast< unoidl::ConstantGroupEntity
* >(
2225 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
2226 return css::uno::Any(
2227 css::uno::Reference
< css::reflection::XTypeDescription
>(
2228 new SingleInterfaceBasedServiceDescription(
2230 static_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
2232 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
2233 return css::uno::Any(
2234 css::uno::Reference
< css::reflection::XTypeDescription
>(
2235 new AccumulationBasedServiceDescription(
2237 static_cast< unoidl::AccumulationBasedServiceEntity
* >(
2239 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
2240 return css::uno::Any(
2241 css::uno::Reference
< css::reflection::XTypeDescription
>(
2242 new InterfaceBasedSingletonDescription(
2244 static_cast< unoidl::InterfaceBasedSingletonEntity
* >(
2246 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
2247 return css::uno::Any(
2248 css::uno::Reference
< css::reflection::XTypeDescription
>(
2249 new ServiceBasedSingletonDescription(
2251 static_cast< unoidl::ServiceBasedSingletonEntity
* >(
2254 for (;;) { std::abort(); } // this cannot happen
2258 css::uno::Any
cppuhelper::TypeManager::getEnumMember(
2259 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
2260 std::u16string_view member
)
2262 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2263 [&member
](const unoidl::EnumTypeEntity::Member
& rMember
) { return rMember
.name
== member
; });
2264 if (i
!= entity
->getMembers().end())
2265 return css::uno::Any(i
->value
);
2266 return css::uno::Any();
2269 css::uno::Any
cppuhelper::TypeManager::getConstant(
2270 std::u16string_view constantGroupName
,
2271 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
2272 std::u16string_view member
)
2274 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2275 [&member
](const unoidl::ConstantGroupEntity::Member
& rMember
) { return rMember
.name
== member
; });
2276 if (i
!= entity
->getMembers().end())
2277 return css::uno::Any(
2278 css::uno::Reference
< css::reflection::XTypeDescription
>(
2279 new ConstantDescription(OUString(constantGroupName
), *i
)));
2280 return css::uno::Any();
2283 rtl::Reference
< unoidl::Entity
> cppuhelper::TypeManager::findEntity(
2284 OUString
const & name
)
2287 return manager_
->findEntity(name
);
2288 } catch (unoidl::FileFormatException
& e
) {
2289 throw css::uno::DeploymentException(
2290 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2292 static_cast< cppu::OWeakObject
* >(this));
2296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */