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>
57 #include <unoidl/unoidl.hxx>
60 #include "typemanager.hxx"
64 OUString
makePrefix(OUString
const & name
) {
65 return name
.isEmpty() ? name
: name
+ ".";
68 css::uno::Any
resolveTypedefs(css::uno::Any
const & type
) {
69 for (css::uno::Any
t(type
);;) {
70 css::uno::Reference
< css::reflection::XIndirectTypeDescription
> ind(
71 type
, css::uno::UNO_QUERY
);
72 if (!ind
.is() || ind
->getTypeClass() != css::uno::TypeClass_TYPEDEF
) {
75 t
<<= ind
->getReferencedType();
79 class SimpleTypeDescription
:
80 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
83 SimpleTypeDescription(
84 css::uno::TypeClass typeClass
, OUString
const & name
):
85 typeClass_(typeClass
), name_(name
)
89 virtual ~SimpleTypeDescription() override
{}
91 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
92 { return typeClass_
; }
94 virtual OUString SAL_CALL
getName() override
97 css::uno::TypeClass typeClass_
;
101 class SequenceTypeDescription
:
102 public cppu::WeakImplHelper
< css::reflection::XIndirectTypeDescription
>
105 SequenceTypeDescription(
106 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
107 OUString
const & name
, OUString
const & componentType
):
108 manager_(manager
), name_(name
), componentType_(componentType
)
109 { assert(manager
.is()); }
112 virtual ~SequenceTypeDescription() override
{}
114 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
115 { return css::uno::TypeClass_SEQUENCE
; }
117 virtual OUString SAL_CALL
getName() override
120 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
121 getReferencedType() override
122 { return manager_
->resolve(componentType_
); }
124 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
126 OUString componentType_
;
129 class PublishableDescription
:
130 public cppu::WeakImplHelper
< css::reflection::XPublished
>
133 explicit PublishableDescription(bool published
): published_(published
) {}
135 virtual ~PublishableDescription() override
{}
138 virtual sal_Bool SAL_CALL
isPublished() override
139 { return published_
; }
144 class ModuleDescription
:
145 public cppu::WeakImplHelper
< css::reflection::XModuleTypeDescription
>
149 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
150 OUString
const & name
,
151 rtl::Reference
< unoidl::ModuleEntity
> const & entity
):
152 manager_(manager
), name_(name
), entity_(entity
)
153 { assert(manager
.is()); assert(entity
.is()); }
156 virtual ~ModuleDescription() override
{}
158 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
159 { return css::uno::TypeClass_MODULE
; }
161 virtual OUString SAL_CALL
getName() override
166 css::uno::Reference
< css::reflection::XTypeDescription
> >
167 SAL_CALL
getMembers() override
;
169 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
171 rtl::Reference
< unoidl::ModuleEntity
> entity_
;
174 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
175 ModuleDescription::getMembers() {
177 std::vector
< OUString
> names(entity_
->getMemberNames());
178 assert(names
.size() <= SAL_MAX_INT32
);
179 sal_Int32 n
= static_cast< sal_Int32
>(names
.size());
181 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
182 auto r
= asNonConstRange(s
);
183 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
184 r
[i
] = manager_
->resolve(makePrefix(name_
) + names
[i
]);
187 } catch (unoidl::FileFormatException
& e
) {
188 throw css::uno::DeploymentException(
189 e
.getUri() + ": " + e
.getDetail(),
190 static_cast< cppu::OWeakObject
* >(this));
194 typedef cppu::ImplInheritanceHelper
<
195 PublishableDescription
, css::reflection::XEnumTypeDescription
>
196 EnumTypeDescription_Base
;
198 class EnumTypeDescription
: public EnumTypeDescription_Base
{
201 OUString
const & name
,
202 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
):
203 EnumTypeDescription_Base(entity
->isPublished()), name_(name
),
205 { assert(entity
.is()); }
208 virtual ~EnumTypeDescription() override
{}
210 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
211 { return css::uno::TypeClass_ENUM
; }
213 virtual OUString SAL_CALL
getName() override
216 virtual sal_Int32 SAL_CALL
getDefaultEnumValue() override
217 { return entity_
->getMembers()[0].value
; }
219 virtual css::uno::Sequence
< OUString
> SAL_CALL
getEnumNames() override
;
221 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getEnumValues() override
;
224 rtl::Reference
< unoidl::EnumTypeEntity
> entity_
;
227 css::uno::Sequence
< OUString
> EnumTypeDescription::getEnumNames()
229 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
230 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
231 css::uno::Sequence
< OUString
> s(n
);
232 auto r
= asNonConstRange(s
);
233 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
234 r
[i
] = entity_
->getMembers()[i
].name
;
239 css::uno::Sequence
< sal_Int32
> EnumTypeDescription::getEnumValues()
241 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
242 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
243 css::uno::Sequence
< sal_Int32
> s(n
);
244 auto r
= asNonConstRange(s
);
245 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
246 r
[i
] = entity_
->getMembers()[i
].value
;
251 typedef cppu::ImplInheritanceHelper
<
252 PublishableDescription
, css::reflection::XStructTypeDescription
>
253 PlainStructTypeDescription_Base
;
255 class PlainStructTypeDescription
: public PlainStructTypeDescription_Base
{
257 PlainStructTypeDescription(
258 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
259 OUString
const & name
,
260 rtl::Reference
< unoidl::PlainStructTypeEntity
> const & entity
):
261 PlainStructTypeDescription_Base(entity
->isPublished()),
262 manager_(manager
), name_(name
), entity_(entity
)
263 { assert(manager
.is()); assert(entity
.is()); }
266 virtual ~PlainStructTypeDescription() override
{}
268 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
269 { return css::uno::TypeClass_STRUCT
; }
271 virtual OUString SAL_CALL
getName() override
274 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
275 getBaseType() override
{
276 return entity_
->getDirectBase().isEmpty()
277 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
278 : manager_
->resolve(entity_
->getDirectBase());
283 css::uno::Reference
< css::reflection::XTypeDescription
> >
284 SAL_CALL
getMemberTypes() override
;
286 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
288 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
289 { return css::uno::Sequence
< OUString
>(); }
293 css::uno::Reference
< css::reflection::XTypeDescription
> >
294 SAL_CALL
getTypeArguments() override
{
295 return css::uno::Sequence
<
296 css::uno::Reference
< css::reflection::XTypeDescription
> >();
299 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
301 rtl::Reference
< unoidl::PlainStructTypeEntity
> entity_
;
304 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
305 PlainStructTypeDescription::getMemberTypes()
307 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
308 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
310 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
311 auto r
= asNonConstRange(s
);
312 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
313 r
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
318 css::uno::Sequence
< OUString
> PlainStructTypeDescription::getMemberNames()
320 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
321 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
322 css::uno::Sequence
< OUString
> s(n
);
323 auto r
= asNonConstRange(s
);
324 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
325 r
[i
] = entity_
->getDirectMembers()[i
].name
;
330 class ParameterizedMemberTypeDescription
:
331 public cppu::WeakImplHelper
< css::reflection::XTypeDescription
>
334 explicit ParameterizedMemberTypeDescription(
335 OUString
const & typeParameterName
):
336 typeParameterName_(typeParameterName
)
340 virtual ~ParameterizedMemberTypeDescription() override
{}
342 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
343 { return css::uno::TypeClass_UNKNOWN
; }
345 virtual OUString SAL_CALL
getName() override
346 { return typeParameterName_
; }
348 OUString typeParameterName_
;
351 typedef cppu::ImplInheritanceHelper
<
352 PublishableDescription
, css::reflection::XStructTypeDescription
>
353 PolymorphicStructTypeTemplateDescription_Base
;
355 class PolymorphicStructTypeTemplateDescription
:
356 public PolymorphicStructTypeTemplateDescription_Base
359 PolymorphicStructTypeTemplateDescription(
360 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
361 OUString
const & name
,
362 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
364 PolymorphicStructTypeTemplateDescription_Base(entity
->isPublished()),
365 manager_(manager
), name_(name
), entity_(entity
)
366 { assert(manager
.is()); assert(entity
.is()); }
369 virtual ~PolymorphicStructTypeTemplateDescription() override
{}
371 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
372 { return css::uno::TypeClass_STRUCT
; }
374 virtual OUString SAL_CALL
getName() override
377 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
378 getBaseType() override
379 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
383 css::uno::Reference
< css::reflection::XTypeDescription
> >
384 SAL_CALL
getMemberTypes() override
;
386 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
388 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
;
392 css::uno::Reference
< css::reflection::XTypeDescription
> >
393 SAL_CALL
getTypeArguments() override
{
394 return css::uno::Sequence
<
395 css::uno::Reference
< css::reflection::XTypeDescription
> >();
398 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
400 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
403 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
404 PolymorphicStructTypeTemplateDescription::getMemberTypes()
406 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
407 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
409 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
410 auto r
= asNonConstRange(s
);
411 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
412 r
[i
] = entity_
->getMembers()[i
].parameterized
413 ? new ParameterizedMemberTypeDescription(
414 entity_
->getMembers()[i
].type
)
415 : manager_
->resolve(entity_
->getMembers()[i
].type
);
420 css::uno::Sequence
< OUString
>
421 PolymorphicStructTypeTemplateDescription::getMemberNames()
423 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
424 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
425 css::uno::Sequence
< OUString
> s(n
);
426 auto r
= asNonConstRange(s
);
427 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
428 r
[i
] = entity_
->getMembers()[i
].name
;
433 css::uno::Sequence
< OUString
>
434 PolymorphicStructTypeTemplateDescription::getTypeParameters()
436 assert(entity_
->getTypeParameters().size() <= SAL_MAX_INT32
);
437 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getTypeParameters().size());
438 css::uno::Sequence
< OUString
> s(n
);
439 auto r
= asNonConstRange(s
);
440 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
441 r
[i
] = entity_
->getTypeParameters()[i
];
446 class InstantiatedPolymorphicStructTypeDescription
:
447 public cppu::WeakImplHelper
< css::reflection::XStructTypeDescription
>
450 InstantiatedPolymorphicStructTypeDescription(
451 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
452 OUString
const & name
,
453 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
455 std::vector
< OUString
>&& arguments
):
456 manager_(manager
), name_(name
), entity_(entity
), arguments_(std::move(arguments
))
458 assert(manager
.is());
460 assert(arguments_
.size() == entity
->getTypeParameters().size());
464 virtual ~InstantiatedPolymorphicStructTypeDescription() override
{}
466 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
467 { return css::uno::TypeClass_STRUCT
; }
469 virtual OUString SAL_CALL
getName() override
472 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
473 getBaseType() override
474 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
478 css::uno::Reference
< css::reflection::XTypeDescription
> >
479 SAL_CALL
getMemberTypes() override
;
481 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
483 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTypeParameters() override
484 { return css::uno::Sequence
< OUString
>(); }
488 css::uno::Reference
< css::reflection::XTypeDescription
> >
489 SAL_CALL
getTypeArguments() override
;
491 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
493 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
494 std::vector
< OUString
> arguments_
;
497 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
498 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
500 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
501 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
503 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
504 auto r
= asNonConstRange(s
);
505 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
506 OUString
type(entity_
->getMembers()[i
].type
);
507 if (entity_
->getMembers()[i
].parameterized
) {
508 auto j
= std::find(entity_
->getTypeParameters().begin(), entity_
->getTypeParameters().end(), type
);
509 if (j
!= entity_
->getTypeParameters().end()) {
510 type
= arguments_
[j
- entity_
->getTypeParameters().begin()];
513 assert(false); // this cannot happen //TODO!
516 r
[i
] = manager_
->resolve(type
);
521 css::uno::Sequence
< OUString
>
522 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
524 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
525 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
526 css::uno::Sequence
< OUString
> s(n
);
527 auto r
= asNonConstRange(s
);
528 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
529 r
[i
] = entity_
->getMembers()[i
].name
;
533 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
534 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
536 assert(arguments_
.size() <= SAL_MAX_INT32
);
537 sal_Int32 n
= static_cast< sal_Int32
>(arguments_
.size());
539 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
540 auto r
= asNonConstRange(s
);
541 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
542 r
[i
] = manager_
->resolve(arguments_
[i
]);
547 typedef cppu::ImplInheritanceHelper
<
548 PublishableDescription
, css::reflection::XCompoundTypeDescription
>
549 ExceptionTypeDescription_Base
;
551 class ExceptionTypeDescription
: public ExceptionTypeDescription_Base
{
553 ExceptionTypeDescription(
554 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
555 OUString
const & name
,
556 rtl::Reference
< unoidl::ExceptionTypeEntity
> const & entity
):
557 ExceptionTypeDescription_Base(entity
->isPublished()), manager_(manager
),
558 name_(name
), entity_(entity
)
559 { assert(manager
.is()); assert(entity
.is()); }
562 virtual ~ExceptionTypeDescription() override
{}
564 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
565 { return css::uno::TypeClass_EXCEPTION
; }
567 virtual OUString SAL_CALL
getName() override
570 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
571 getBaseType() override
{
572 return entity_
->getDirectBase().isEmpty()
573 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
574 : manager_
->resolve(entity_
->getDirectBase());
579 css::uno::Reference
< css::reflection::XTypeDescription
> >
580 SAL_CALL
getMemberTypes() override
;
582 virtual css::uno::Sequence
< OUString
> SAL_CALL
getMemberNames() override
;
584 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
586 rtl::Reference
< unoidl::ExceptionTypeEntity
> entity_
;
589 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
590 ExceptionTypeDescription::getMemberTypes() {
591 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
592 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
594 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
595 auto r
= asNonConstRange(s
);
596 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
597 r
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
602 css::uno::Sequence
< OUString
> ExceptionTypeDescription::getMemberNames()
604 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
605 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
606 css::uno::Sequence
< OUString
> s(n
);
607 auto r
= asNonConstRange(s
);
608 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
609 r
[i
] = entity_
->getDirectMembers()[i
].name
;
614 class AttributeDescription
:
615 public cppu::WeakImplHelper
<
616 css::reflection::XInterfaceAttributeTypeDescription2
>
619 AttributeDescription(
620 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
621 OUString
const & name
,
622 unoidl::InterfaceTypeEntity::Attribute
const & attribute
,
624 manager_(manager
), name_(name
), attribute_(attribute
),
626 { assert(manager
.is()); }
629 virtual ~AttributeDescription() override
{}
631 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
632 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE
; }
634 virtual OUString SAL_CALL
getName() override
637 virtual OUString SAL_CALL
getMemberName() override
638 { return attribute_
.name
; }
640 virtual sal_Int32 SAL_CALL
getPosition() override
641 { return position_
; }
643 virtual sal_Bool SAL_CALL
isReadOnly() override
644 { return attribute_
.readOnly
; }
646 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
648 { return manager_
->resolve(attribute_
.type
); }
650 virtual sal_Bool SAL_CALL
isBound() override
651 { return attribute_
.bound
; }
655 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
656 SAL_CALL
getGetExceptions() override
;
660 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
661 SAL_CALL
getSetExceptions() override
;
663 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
665 unoidl::InterfaceTypeEntity::Attribute attribute_
;
670 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
671 AttributeDescription::getGetExceptions() {
672 assert(attribute_
.getExceptions
.size() <= SAL_MAX_INT32
);
673 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.getExceptions
.size());
675 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
676 auto r
= asNonConstRange(s
);
677 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
679 manager_
->resolve(attribute_
.getExceptions
[i
]),
680 css::uno::UNO_QUERY_THROW
);
686 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
687 AttributeDescription::getSetExceptions() {
688 assert(attribute_
.setExceptions
.size() <= SAL_MAX_INT32
);
689 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.setExceptions
.size());
691 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
692 auto r
= asNonConstRange(s
);
693 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
695 manager_
->resolve(attribute_
.setExceptions
[i
]),
696 css::uno::UNO_QUERY_THROW
);
701 class MethodParameter
:
702 public cppu::WeakImplHelper
< css::reflection::XMethodParameter
>
706 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
707 unoidl::InterfaceTypeEntity::Method::Parameter
const & parameter
,
709 manager_(manager
), parameter_(parameter
), position_(position
)
710 { assert(manager
.is()); }
713 virtual ~MethodParameter() override
{}
715 virtual OUString SAL_CALL
getName() override
716 { return parameter_
.name
; }
718 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
720 { return manager_
->resolve(parameter_
.type
); }
722 virtual sal_Bool SAL_CALL
isIn() override
{
724 (parameter_
.direction
725 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
726 || (parameter_
.direction
727 == unoidl::InterfaceTypeEntity::Method::Parameter::
731 virtual sal_Bool SAL_CALL
isOut() override
{
733 (parameter_
.direction
734 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
)
735 || (parameter_
.direction
736 == unoidl::InterfaceTypeEntity::Method::Parameter::
740 virtual sal_Int32 SAL_CALL
getPosition() override
741 { return position_
; }
743 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
744 unoidl::InterfaceTypeEntity::Method::Parameter parameter_
;
748 class MethodDescription
:
749 public cppu::WeakImplHelper
<
750 css::reflection::XInterfaceMethodTypeDescription
>
754 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
755 OUString
const & name
,
756 unoidl::InterfaceTypeEntity::Method
const & method
, sal_Int32 position
):
757 manager_(manager
), name_(name
), method_(method
), position_(position
)
758 { assert(manager
.is()); }
761 virtual ~MethodDescription() override
{}
763 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
764 { return css::uno::TypeClass_INTERFACE_METHOD
; }
766 virtual OUString SAL_CALL
getName() override
769 virtual OUString SAL_CALL
getMemberName() override
770 { return method_
.name
; }
772 virtual sal_Int32 SAL_CALL
getPosition() override
773 { return position_
; }
775 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
776 getReturnType() override
777 { return manager_
->resolve(method_
.returnType
); }
779 virtual sal_Bool SAL_CALL
isOneway() override
784 css::uno::Reference
< css::reflection::XMethodParameter
> >
785 SAL_CALL
getParameters() override
;
789 css::uno::Reference
< css::reflection::XTypeDescription
> >
790 SAL_CALL
getExceptions() override
;
792 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
794 unoidl::InterfaceTypeEntity::Method method_
;
798 css::uno::Sequence
< css::uno::Reference
< css::reflection::XMethodParameter
> >
799 MethodDescription::getParameters() {
800 assert(method_
.parameters
.size() <= SAL_MAX_INT32
);
801 sal_Int32 n
= static_cast< sal_Int32
>(method_
.parameters
.size());
803 css::uno::Reference
< css::reflection::XMethodParameter
> > s(n
);
804 auto r
= asNonConstRange(s
);
805 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
806 r
[i
] = new MethodParameter(manager_
, method_
.parameters
[i
], i
);
811 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
812 MethodDescription::getExceptions() {
813 assert(method_
.exceptions
.size() <= SAL_MAX_INT32
);
814 sal_Int32 n
= static_cast< sal_Int32
>(method_
.exceptions
.size());
816 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
817 auto r
= asNonConstRange(s
);
818 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
819 r
[i
] = manager_
->resolve(method_
.exceptions
[i
]);
827 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
828 const & description
);
830 BaseOffset(const BaseOffset
&) = delete;
831 const BaseOffset
& operator=(const BaseOffset
&) = delete;
833 sal_Int32
get() const { return offset_
; }
837 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
838 const & description
);
841 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
842 const & description
);
844 std::set
< OUString
> set_
;
848 BaseOffset::BaseOffset(
849 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
853 calculateBases(description
);
856 void BaseOffset::calculateBases(
857 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
860 const css::uno::Sequence
<
861 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
862 description
->getBaseTypes());
863 for (const auto & i
: bases
) {
865 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
866 resolveTypedefs(css::uno::makeAny(i
)),
867 css::uno::UNO_QUERY_THROW
));
871 void BaseOffset::calculate(
872 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
875 if (set_
.insert(description
->getName()).second
) {
876 calculateBases(description
);
877 offset_
+= description
->getMembers().getLength();
881 typedef cppu::ImplInheritanceHelper
<
882 PublishableDescription
, css::reflection::XInterfaceTypeDescription2
>
883 InterfaceTypeDescription_Base
;
885 class InterfaceTypeDescription
: public InterfaceTypeDescription_Base
{
887 InterfaceTypeDescription(
888 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
889 OUString
const & name
,
890 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
891 InterfaceTypeDescription_Base(entity
->isPublished()), manager_(manager
),
892 name_(name
), entity_(entity
)
893 { assert(manager
.is()); assert(entity
.is()); }
896 virtual ~InterfaceTypeDescription() override
{}
898 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
899 { return css::uno::TypeClass_INTERFACE
; }
901 virtual OUString SAL_CALL
getName() override
904 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
905 getBaseType() override
{
906 return entity_
->getDirectMandatoryBases().empty()
907 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
908 : manager_
->resolve(entity_
->getDirectMandatoryBases()[0].name
);
911 virtual css::uno::Uik SAL_CALL
getUik() override
912 { return css::uno::Uik(); }
917 css::reflection::XInterfaceMemberTypeDescription
> >
918 SAL_CALL
getMembers() override
;
922 css::uno::Reference
< css::reflection::XTypeDescription
> >
923 SAL_CALL
getBaseTypes() override
;
927 css::uno::Reference
< css::reflection::XTypeDescription
> >
928 SAL_CALL
getOptionalBaseTypes() override
;
930 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
932 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
936 css::uno::Reference
< css::reflection::XInterfaceMemberTypeDescription
> >
937 InterfaceTypeDescription::getMembers() {
939 entity_
->getDirectAttributes().size() <= SAL_MAX_INT32
940 && (entity_
->getDirectMethods().size()
941 <= SAL_MAX_INT32
- entity_
->getDirectAttributes().size()));
942 sal_Int32 n1
= static_cast< sal_Int32
>(
943 entity_
->getDirectAttributes().size());
944 sal_Int32 n2
= static_cast< sal_Int32
>(entity_
->getDirectMethods().size());
947 css::reflection::XInterfaceMemberTypeDescription
> > s(n1
+ n2
);
948 auto r
= asNonConstRange(s
);
949 sal_Int32 off
= BaseOffset(this).get();
950 for (sal_Int32 i
= 0; i
!= n1
; ++i
) {
951 r
[i
] = new AttributeDescription(
952 manager_
, name_
+ "::" + entity_
->getDirectAttributes()[i
].name
,
953 entity_
->getDirectAttributes()[i
], off
+ i
);
955 for (sal_Int32 i
= 0; i
!= n2
; ++i
) {
956 r
[n1
+ i
] = new MethodDescription(
957 manager_
, name_
+ "::" + entity_
->getDirectMethods()[i
].name
,
958 entity_
->getDirectMethods()[i
], off
+ n1
+ i
);
963 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
964 InterfaceTypeDescription::getBaseTypes() {
965 assert(entity_
->getDirectMandatoryBases().size() <= SAL_MAX_INT32
);
966 sal_Int32 n
= static_cast< sal_Int32
>(
967 entity_
->getDirectMandatoryBases().size());
969 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
970 auto r
= asNonConstRange(s
);
971 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
972 r
[i
] = manager_
->resolve(entity_
->getDirectMandatoryBases()[i
].name
);
977 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
978 InterfaceTypeDescription::getOptionalBaseTypes()
980 assert(entity_
->getDirectOptionalBases().size() <= SAL_MAX_INT32
);
981 sal_Int32 n
= static_cast< sal_Int32
>(
982 entity_
->getDirectOptionalBases().size());
984 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
985 auto r
= asNonConstRange(s
);
986 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
987 r
[i
] = manager_
->resolve(entity_
->getDirectOptionalBases()[i
].name
);
992 class ConstantDescription
:
993 public cppu::WeakImplHelper
< css::reflection::XConstantTypeDescription
>
997 OUString
const & constantGroupName
,
998 unoidl::ConstantGroupEntity::Member
const & member
);
1001 virtual ~ConstantDescription() override
{}
1003 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1004 { return css::uno::TypeClass_CONSTANT
; }
1006 virtual OUString SAL_CALL
getName() override
1009 virtual css::uno::Any SAL_CALL
getConstantValue() override
1013 css::uno::Any value_
;
1016 ConstantDescription::ConstantDescription(
1017 OUString
const & constantGroupName
,
1018 unoidl::ConstantGroupEntity::Member
const & member
):
1019 name_(makePrefix(constantGroupName
) + member
.name
)
1021 switch (member
.value
.type
) {
1022 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1023 value_
<<= member
.value
.booleanValue
;
1025 case unoidl::ConstantValue::TYPE_BYTE
:
1026 value_
<<= member
.value
.byteValue
;
1028 case unoidl::ConstantValue::TYPE_SHORT
:
1029 value_
<<= member
.value
.shortValue
;
1031 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1032 value_
<<= member
.value
.unsignedShortValue
;
1034 case unoidl::ConstantValue::TYPE_LONG
:
1035 value_
<<= member
.value
.longValue
;
1037 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1038 value_
<<= member
.value
.unsignedLongValue
;
1040 case unoidl::ConstantValue::TYPE_HYPER
:
1041 value_
<<= member
.value
.hyperValue
;
1043 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1044 value_
<<= member
.value
.unsignedHyperValue
;
1046 case unoidl::ConstantValue::TYPE_FLOAT
:
1047 value_
<<= member
.value
.floatValue
;
1049 case unoidl::ConstantValue::TYPE_DOUBLE
:
1050 value_
<<= member
.value
.doubleValue
;
1053 for (;;) { std::abort(); } // this cannot happen
1057 typedef cppu::ImplInheritanceHelper
<
1058 PublishableDescription
, css::reflection::XConstantsTypeDescription
>
1059 ConstantGroupDescription_Base
;
1061 class ConstantGroupDescription
: public ConstantGroupDescription_Base
{
1063 ConstantGroupDescription(
1064 OUString
const & name
,
1065 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
):
1066 ConstantGroupDescription_Base(entity
->isPublished()), name_(name
),
1068 { assert(entity
.is()); }
1071 virtual ~ConstantGroupDescription() override
{}
1073 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1074 { return css::uno::TypeClass_CONSTANTS
; }
1076 virtual OUString SAL_CALL
getName() override
1081 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1082 SAL_CALL
getConstants() override
;
1085 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1089 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1090 ConstantGroupDescription::getConstants() {
1091 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
1092 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
1094 css::uno::Reference
< css::reflection::XConstantTypeDescription
> > s(n
);
1095 auto r
= asNonConstRange(s
);
1096 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1097 r
[i
] = new ConstantDescription(name_
, entity_
->getMembers()[i
]);
1102 typedef cppu::ImplInheritanceHelper
<
1103 PublishableDescription
, css::reflection::XIndirectTypeDescription
>
1104 TypedefDescription_Base
;
1106 class TypedefDescription
: public TypedefDescription_Base
{
1109 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1110 OUString
const & name
,
1111 rtl::Reference
< unoidl::TypedefEntity
> const & entity
):
1112 TypedefDescription_Base(entity
->isPublished()), manager_(manager
),
1113 name_(name
), entity_(entity
)
1114 { assert(manager
.is()); assert(entity
.is()); }
1117 virtual ~TypedefDescription() override
{}
1119 virtual css::uno::TypeClass SAL_CALL
getTypeClass() override
1120 { return css::uno::TypeClass_TYPEDEF
; }
1122 virtual OUString SAL_CALL
getName() override
1125 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1126 getReferencedType() override
1127 { return manager_
->resolve(entity_
->getType()); }
1129 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1131 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
1134 class ConstructorParameter
:
1135 public cppu::WeakImplHelper
< css::reflection::XParameter
>
1138 ConstructorParameter(
1139 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1140 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1142 sal_Int32 position
):
1143 manager_(manager
), parameter_(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
const &
1183 manager_(manager
), constructor_(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
,
1249 OUString
const & name
,
1250 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
1252 SingleInterfaceBasedServiceDescription_Base(entity
->isPublished()),
1253 manager_(manager
), name_(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
const & property
):
1354 manager_(manager
), property_(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
,
1387 OUString
const & name
,
1388 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const &
1390 AccumulationBasedServiceDescription_Base(entity
->isPublished()),
1391 manager_(manager
), name_(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
,
1556 OUString
const & name
,
1557 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
):
1558 InterfaceBasedSingletonDescription_Base(entity
->isPublished()),
1559 manager_(manager
), name_(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
,
1600 OUString
const & name
,
1601 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> const & entity
):
1602 ServiceBasedSingletonDescription_Base(entity
->isPublished()),
1603 manager_(manager
), name_(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::makeAny(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();
1668 OUString
const & thePrefix
,
1669 rtl::Reference
< unoidl::MapCursor
> const & theCursor
):
1670 prefix(thePrefix
), cursor(theCursor
)
1671 { assert(theCursor
.is()); }
1674 OUString
const & thePrefix
,
1675 rtl::Reference
< unoidl::ConstantGroupEntity
> const &
1677 prefix(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()) {
1727 for (const auto & i
: types_
) {
1735 void Enumeration::findNextMatch() {
1738 assert(!positions_
.empty());
1740 if (positions_
.top().cursor
.is()) { // root or module
1741 rtl::Reference
< unoidl::Entity
> ent(
1742 positions_
.top().cursor
->getNext(&name
));
1745 if (positions_
.empty()) {
1750 name
= positions_
.top().prefix
+ name
;
1751 css::uno::TypeClass tc
;
1752 switch (ent
->getSort()) {
1753 case unoidl::Entity::SORT_MODULE
:
1754 tc
= css::uno::TypeClass_MODULE
;
1759 static_cast< unoidl::ModuleEntity
* >(
1760 ent
.get())->createCursor()));
1763 case unoidl::Entity::SORT_ENUM_TYPE
:
1764 tc
= css::uno::TypeClass_ENUM
;
1766 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
1767 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
1768 tc
= css::uno::TypeClass_STRUCT
;
1770 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
1771 tc
= css::uno::TypeClass_EXCEPTION
;
1773 case unoidl::Entity::SORT_INTERFACE_TYPE
:
1774 tc
= css::uno::TypeClass_INTERFACE
;
1776 case unoidl::Entity::SORT_TYPEDEF
:
1777 tc
= css::uno::TypeClass_TYPEDEF
;
1779 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1780 tc
= css::uno::TypeClass_CONSTANTS
;
1781 if (deep_
&& matches(css::uno::TypeClass_CONSTANT
)) {
1785 static_cast< unoidl::ConstantGroupEntity
* >(
1789 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
1790 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
1791 tc
= css::uno::TypeClass_SERVICE
;
1793 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
1794 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
1795 tc
= css::uno::TypeClass_SINGLETON
;
1798 for (;;) { std::abort(); } // this cannot happen
1804 } else { // constant group
1805 if (positions_
.top().constantGroupIndex
1806 == positions_
.top().constantGroup
->getMembers().end())
1809 if (positions_
.empty()) {
1814 current_
= positions_
.top().prefix
1815 + positions_
.top().constantGroupIndex
++->name
;
1819 } catch (unoidl::FileFormatException
& e
) {
1820 throw css::uno::DeploymentException(
1821 e
.getUri() + ": " + e
.getDetail(),
1822 static_cast< cppu::OWeakObject
* >(this));
1828 cppuhelper::TypeManager::TypeManager():
1829 TypeManager_Base(m_aMutex
),
1830 manager_(new unoidl::Manager
)
1833 css::uno::Any
cppuhelper::TypeManager::find(OUString
const & name
) {
1834 //TODO: caching? (here or in unoidl::Manager?)
1835 static constexpr std::pair
<std::u16string_view
, css::uno::TypeClass
> const simple
[] = {
1836 { u
"void", css::uno::TypeClass_VOID
},
1837 { u
"boolean", css::uno::TypeClass_BOOLEAN
},
1838 { u
"byte", css::uno::TypeClass_BYTE
},
1839 { u
"short", css::uno::TypeClass_SHORT
},
1840 { u
"unsigned short", css::uno::TypeClass_UNSIGNED_SHORT
},
1841 { u
"long", css::uno::TypeClass_LONG
},
1842 { u
"unsigned long", css::uno::TypeClass_UNSIGNED_LONG
},
1843 { u
"hyper", css::uno::TypeClass_HYPER
},
1844 { u
"unsigned hyper", css::uno::TypeClass_UNSIGNED_HYPER
},
1845 { u
"float", css::uno::TypeClass_FLOAT
},
1846 { u
"double", css::uno::TypeClass_DOUBLE
},
1847 { u
"char", css::uno::TypeClass_CHAR
},
1848 { u
"string", css::uno::TypeClass_STRING
},
1849 { u
"type", css::uno::TypeClass_TYPE
},
1850 { u
"any", css::uno::TypeClass_ANY
} };
1851 for (const auto& [ rName
, rTypeClass
] : simple
) {
1852 if (name
== rName
) {
1853 return css::uno::makeAny
<
1854 css::uno::Reference
< css::reflection::XTypeDescription
> >(
1855 new SimpleTypeDescription(rTypeClass
, name
));
1858 if (name
.startsWith("[]")) {
1859 return getSequenceType(name
);
1861 sal_Int32 i
= name
.indexOf('<');
1863 return getInstantiatedStruct(name
, i
);
1865 i
= name
.indexOf("::");
1867 return getInterfaceMember(name
, i
);
1869 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
));
1871 return getNamed(name
, ent
);
1873 i
= name
.lastIndexOf('.');
1875 OUString
parent(name
.copy(0, i
));
1876 ent
= findEntity(parent
);
1878 switch (ent
->getSort()) {
1879 case unoidl::Entity::SORT_ENUM_TYPE
:
1880 return getEnumMember(
1881 static_cast< unoidl::EnumTypeEntity
* >(ent
.get()),
1883 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1886 static_cast< unoidl::ConstantGroupEntity
* >(ent
.get()),
1893 return css::uno::Any();
1896 css::uno::Reference
< css::reflection::XTypeDescription
>
1897 cppuhelper::TypeManager::resolve(OUString
const & name
) {
1898 css::uno::Reference
< css::reflection::XTypeDescription
> desc(
1899 find(name
), css::uno::UNO_QUERY
);
1901 throw css::uno::DeploymentException(
1902 "cannot resolve type \"" + name
+ "\"",
1903 static_cast< cppu::OWeakObject
* >(this));
1908 cppuhelper::TypeManager::~TypeManager() noexcept
{}
1910 void cppuhelper::TypeManager::disposing() {} //TODO
1912 OUString
cppuhelper::TypeManager::getImplementationName()
1915 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager";
1918 sal_Bool
cppuhelper::TypeManager::supportsService(
1919 OUString
const & ServiceName
)
1921 return cppu::supportsService(this, ServiceName
);
1924 css::uno::Sequence
< OUString
>
1925 cppuhelper::TypeManager::getSupportedServiceNames()
1927 return { "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1930 css::uno::Any
cppuhelper::TypeManager::getByHierarchicalName(
1931 OUString
const & aName
)
1933 css::uno::Any
desc(find(aName
));
1934 if (!desc
.hasValue()) {
1935 throw css::container::NoSuchElementException(
1936 aName
, static_cast< cppu::OWeakObject
* >(this));
1941 sal_Bool
cppuhelper::TypeManager::hasByHierarchicalName(
1942 OUString
const & aName
)
1944 return find(aName
).hasValue();
1947 css::uno::Type
cppuhelper::TypeManager::getElementType()
1949 return cppu::UnoType
< OUString
>::get();
1952 sal_Bool
cppuhelper::TypeManager::hasElements()
1954 throw css::uno::RuntimeException(
1955 "TypeManager hasElements: method not supported",
1956 static_cast< cppu::OWeakObject
* >(this));
1959 css::uno::Reference
< css::container::XEnumeration
>
1960 cppuhelper::TypeManager::createEnumeration()
1962 throw css::uno::RuntimeException(
1963 "TypeManager createEnumeration: method not supported",
1964 static_cast< cppu::OWeakObject
* >(this));
1967 sal_Bool
cppuhelper::TypeManager::has(css::uno::Any
const &)
1969 throw css::uno::RuntimeException(
1970 "TypeManager has: method not supported",
1971 static_cast< cppu::OWeakObject
* >(this));
1974 void cppuhelper::TypeManager::insert(css::uno::Any
const & aElement
)
1977 if (!(aElement
>>= uri
)) {
1978 throw css::lang::IllegalArgumentException(
1979 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
1981 static_cast< cppu::OWeakObject
* >(this), 0);
1983 //TODO: check for ElementExistException
1984 //TODO: check for consistency with existing data
1985 readRdbFile(uri
, false);
1988 void cppuhelper::TypeManager::remove(css::uno::Any
const & aElement
)
1991 if (!(aElement
>>= uri
)) {
1992 throw css::lang::IllegalArgumentException(
1993 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
1995 static_cast< cppu::OWeakObject
* >(this), 0);
1997 //TODO: remove requests are silently ignored for now
2000 css::uno::Reference
< css::reflection::XTypeDescriptionEnumeration
>
2001 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
2002 OUString
const & moduleName
,
2003 css::uno::Sequence
< css::uno::TypeClass
> const & types
,
2004 css::reflection::TypeDescriptionSearchDepth depth
)
2006 rtl::Reference
< unoidl::MapCursor
> cursor
;
2008 cursor
= manager_
->createCursor(moduleName
);
2009 } catch (unoidl::FileFormatException
& e
) {
2010 throw css::uno::DeploymentException(
2011 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2013 static_cast< cppu::OWeakObject
* >(this));
2016 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2018 throw css::reflection::NoSuchTypeNameException(
2019 moduleName
, static_cast< cppu::OWeakObject
* >(this));
2021 return new Enumeration(
2022 this, makePrefix(moduleName
), cursor
, types
,
2023 depth
== css::reflection::TypeDescriptionSearchDepth_INFINITE
);
2026 void cppuhelper::TypeManager::init(OUString
const & rdbUris
) {
2027 for (sal_Int32 i
= 0; i
!= -1;) {
2028 OUString
uri(rdbUris
.getToken(0, ' ', i
));
2029 if (uri
.isEmpty()) {
2034 cppu::decodeRdbUri(&uri
, &optional
, &directory
);
2036 readRdbDirectory(uri
, optional
);
2038 readRdbFile(uri
, optional
);
2043 void cppuhelper::TypeManager::readRdbDirectory(
2044 OUString
const & uri
, bool optional
)
2046 osl::Directory
dir(uri
);
2047 switch (dir
.open()) {
2048 case osl::FileBase::E_None
:
2050 case osl::FileBase::E_NOENT
:
2052 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2057 throw css::uno::DeploymentException(
2058 "Cannot open directory " + uri
,
2059 static_cast< cppu::OWeakObject
* >(this));
2063 if (!cppu::nextDirectoryItem(dir
, &url
)) {
2066 readRdbFile(url
, false);
2070 void cppuhelper::TypeManager::readRdbFile(
2071 OUString
const & uri
, bool optional
)
2074 manager_
->addProvider(uri
);
2075 } catch (unoidl::NoSuchFileException
&) {
2077 throw css::uno::DeploymentException(
2078 uri
+ ": no such file",
2079 static_cast< cppu::OWeakObject
* >(this));
2081 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2082 } catch (unoidl::FileFormatException
& e
) {
2083 throw css::uno::DeploymentException(
2084 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2086 static_cast< cppu::OWeakObject
* >(this));
2090 css::uno::Any
cppuhelper::TypeManager::getSequenceType(
2091 OUString
const & name
)
2093 assert(name
.startsWith("[]"));
2094 return css::uno::makeAny
<
2095 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2096 new SequenceTypeDescription(
2097 this, name
, name
.copy(std::strlen("[]"))));
2100 css::uno::Any
cppuhelper::TypeManager::getInstantiatedStruct(
2101 OUString
const & name
, sal_Int32 separator
)
2103 assert(name
.indexOf('<') == separator
&& separator
!= -1);
2104 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
.copy(0, separator
)));
2107 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
))
2109 return css::uno::Any();
2111 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
2112 static_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
2114 std::vector
< OUString
> args
;
2115 sal_Int32 i
= separator
;
2117 ++i
; // skip '<' or ','
2119 for (sal_Int32 level
= 0; j
!= name
.getLength(); ++j
) {
2120 sal_Unicode c
= name
[j
];
2125 } else if (c
== '<') {
2127 } else if (c
== '>') {
2134 if (j
!= name
.getLength()) {
2135 args
.push_back(name
.copy(i
, j
- i
));
2138 } while (i
!= name
.getLength() && name
[i
] != '>');
2139 if (i
!= name
.getLength() - 1 || name
[i
] != '>'
2140 || args
.size() != ent2
->getTypeParameters().size())
2142 return css::uno::Any();
2144 return css::uno::makeAny
<
2145 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2146 new InstantiatedPolymorphicStructTypeDescription(
2147 this, name
, ent2
, std::move(args
)));
2150 css::uno::Any
cppuhelper::TypeManager::getInterfaceMember(
2151 OUString
const & name
, sal_Int32 separator
)
2153 assert(name
.indexOf("::") == separator
&& separator
!= -1);
2154 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> ifc(
2155 resolveTypedefs(find(name
.copy(0, separator
))), css::uno::UNO_QUERY
);
2157 return css::uno::Any();
2159 OUString
member(name
.copy(separator
+ std::strlen("::")));
2160 const css::uno::Sequence
<
2161 css::uno::Reference
<
2162 css::reflection::XInterfaceMemberTypeDescription
> > mems(
2164 for (const auto & m
: mems
) {
2165 if (m
->getMemberName() == member
) {
2166 return css::uno::makeAny
<
2167 css::uno::Reference
< css::reflection::XTypeDescription
> >(m
);
2170 return css::uno::Any();
2173 css::uno::Any
cppuhelper::TypeManager::getNamed(
2174 OUString
const & name
, rtl::Reference
< unoidl::Entity
> const & entity
)
2176 assert(entity
.is());
2177 switch (entity
->getSort()) {
2178 case unoidl::Entity::SORT_MODULE
:
2179 return css::uno::makeAny
<
2180 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2181 new ModuleDescription(
2183 static_cast< unoidl::ModuleEntity
* >(entity
.get())));
2184 case unoidl::Entity::SORT_ENUM_TYPE
:
2185 return css::uno::makeAny
<
2186 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2187 new EnumTypeDescription(
2189 static_cast< unoidl::EnumTypeEntity
* >(entity
.get())));
2190 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
2191 return css::uno::makeAny
<
2192 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2193 new PlainStructTypeDescription(
2195 static_cast< unoidl::PlainStructTypeEntity
* >(
2197 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
2198 return css::uno::makeAny
<
2199 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2200 new PolymorphicStructTypeTemplateDescription(
2203 unoidl::PolymorphicStructTypeTemplateEntity
* >(
2205 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
2206 return css::uno::makeAny
<
2207 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2208 new ExceptionTypeDescription(
2210 static_cast< unoidl::ExceptionTypeEntity
* >(
2212 case unoidl::Entity::SORT_INTERFACE_TYPE
:
2213 return css::uno::makeAny
<
2214 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2215 new InterfaceTypeDescription(
2217 static_cast< unoidl::InterfaceTypeEntity
* >(
2219 case unoidl::Entity::SORT_TYPEDEF
:
2220 return css::uno::makeAny
<
2221 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2222 new TypedefDescription(
2224 static_cast< unoidl::TypedefEntity
* >(entity
.get())));
2225 case unoidl::Entity::SORT_CONSTANT_GROUP
:
2226 return css::uno::makeAny
<
2227 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2228 new ConstantGroupDescription(
2230 static_cast< unoidl::ConstantGroupEntity
* >(
2232 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
2233 return css::uno::makeAny
<
2234 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2235 new SingleInterfaceBasedServiceDescription(
2237 static_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
2239 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
2240 return css::uno::makeAny
<
2241 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2242 new AccumulationBasedServiceDescription(
2244 static_cast< unoidl::AccumulationBasedServiceEntity
* >(
2246 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
2247 return css::uno::makeAny
<
2248 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2249 new InterfaceBasedSingletonDescription(
2251 static_cast< unoidl::InterfaceBasedSingletonEntity
* >(
2253 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
2254 return css::uno::makeAny
<
2255 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2256 new ServiceBasedSingletonDescription(
2258 static_cast< unoidl::ServiceBasedSingletonEntity
* >(
2261 for (;;) { std::abort(); } // this cannot happen
2265 css::uno::Any
cppuhelper::TypeManager::getEnumMember(
2266 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
2267 OUString
const & member
)
2269 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2270 [&member
](const unoidl::EnumTypeEntity::Member
& rMember
) { return rMember
.name
== member
; });
2271 if (i
!= entity
->getMembers().end())
2272 return css::uno::makeAny(i
->value
);
2273 return css::uno::Any();
2276 css::uno::Any
cppuhelper::TypeManager::getConstant(
2277 OUString
const & constantGroupName
,
2278 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
2279 OUString
const & member
)
2281 auto i
= std::find_if(entity
->getMembers().begin(), entity
->getMembers().end(),
2282 [&member
](const unoidl::ConstantGroupEntity::Member
& rMember
) { return rMember
.name
== member
; });
2283 if (i
!= entity
->getMembers().end())
2284 return css::uno::makeAny
<
2285 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2286 new ConstantDescription(constantGroupName
, *i
));
2287 return css::uno::Any();
2290 rtl::Reference
< unoidl::Entity
> cppuhelper::TypeManager::findEntity(
2291 OUString
const & name
)
2294 return manager_
->findEntity(name
);
2295 } catch (unoidl::FileFormatException
& e
) {
2296 throw css::uno::DeploymentException(
2297 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2299 static_cast< cppu::OWeakObject
* >(this));
2303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */