LibreOffice Module cppuhelper (master) 1
typemanager.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
10#include <sal/config.h>
11
12#include <cassert>
13#include <cstddef>
14#include <cstdlib>
15#include <cstring>
16#include <mutex>
17#include <set>
18#include <stack>
19#include <string_view>
20#include <utility>
21#include <vector>
22#include <algorithm>
23
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>
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>
58
59#include <unoidl/unoidl.hxx>
60
61#include "paths.hxx"
62#include "typemanager.hxx"
63
64namespace {
65
66OUString makePrefix(OUString const & name) {
67 return name.isEmpty() ? name : name + ".";
68}
69
70css::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) {
75 return t;
76 }
77 t <<= ind->getReferencedType();
78 }
79}
80
81class SimpleTypeDescription:
82 public cppu::WeakImplHelper< css::reflection::XTypeDescription >
83{
84public:
85 SimpleTypeDescription(
86 css::uno::TypeClass typeClass, OUString name):
87 typeClass_(typeClass), name_(std::move(name))
88 {}
89
90private:
91 virtual ~SimpleTypeDescription() override {}
92
93 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
94 { return typeClass_; }
95
96 virtual OUString SAL_CALL getName() override
97 { return name_; }
98
99 css::uno::TypeClass typeClass_;
100 OUString name_;
101};
102
103class SequenceTypeDescription:
104 public cppu::WeakImplHelper< css::reflection::XIndirectTypeDescription >
105{
106public:
107 SequenceTypeDescription(
109 OUString name, OUString componentType):
110 manager_(manager), name_(std::move(name)), componentType_(std::move(componentType))
111 { assert(manager.is()); }
112
113private:
114 virtual ~SequenceTypeDescription() override {}
115
116 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
117 { return css::uno::TypeClass_SEQUENCE; }
118
119 virtual OUString SAL_CALL getName() override
120 { return name_; }
121
122 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
123 getReferencedType() override
124 { return manager_->resolve(componentType_); }
125
127 OUString name_;
128 OUString componentType_;
129};
130
131class PublishableDescription:
132 public cppu::WeakImplHelper< css::reflection::XPublished >
133{
134protected:
135 explicit PublishableDescription(bool published): published_(published) {}
136
137 virtual ~PublishableDescription() override {}
138
139private:
140 virtual sal_Bool SAL_CALL isPublished() override
141 { return published_; }
142
143 bool published_;
144};
145
146class ModuleDescription:
147 public cppu::WeakImplHelper< css::reflection::XModuleTypeDescription >
148{
149public:
150 ModuleDescription(
152 OUString name,
154 manager_(manager), name_(std::move(name)), entity_(entity)
155 { assert(manager.is()); assert(entity.is()); }
156
157private:
158 virtual ~ModuleDescription() override {}
159
160 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
161 { return css::uno::TypeClass_MODULE; }
162
163 virtual OUString SAL_CALL getName() override
164 { return name_; }
165
166 virtual
167 css::uno::Sequence<
168 css::uno::Reference< css::reflection::XTypeDescription > >
169 SAL_CALL getMembers() override;
170
172 OUString name_;
174};
175
176css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
177ModuleDescription::getMembers() {
178 try {
179 std::vector< OUString > names(entity_->getMemberNames());
180 assert(names.size() <= SAL_MAX_INT32);
181 sal_Int32 n = static_cast< sal_Int32 >(names.size());
182 css::uno::Sequence<
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]);
187 }
188 return s;
189 } catch (unoidl::FileFormatException & e) {
190 throw css::uno::DeploymentException(
191 e.getUri() + ": " + e.getDetail(),
192 static_cast< cppu::OWeakObject * >(this));
193 }
194}
195
196typedef cppu::ImplInheritanceHelper<
197 PublishableDescription, css::reflection::XEnumTypeDescription >
198EnumTypeDescription_Base;
199
200class EnumTypeDescription: public EnumTypeDescription_Base {
201public:
202 EnumTypeDescription(
203 OUString name,
205 EnumTypeDescription_Base(entity->isPublished()), name_(std::move(name)),
206 entity_(entity)
207 { assert(entity.is()); }
208
209private:
210 virtual ~EnumTypeDescription() override {}
211
212 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
213 { return css::uno::TypeClass_ENUM; }
214
215 virtual OUString SAL_CALL getName() override
216 { return name_; }
217
218 virtual sal_Int32 SAL_CALL getDefaultEnumValue() override
219 { return entity_->getMembers()[0].value; }
220
221 virtual css::uno::Sequence< OUString > SAL_CALL getEnumNames() override;
222
223 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getEnumValues() override;
224
225 OUString name_;
227};
228
229css::uno::Sequence< OUString > EnumTypeDescription::getEnumNames()
230{
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;
237 }
238 return s;
239}
240
241css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
242{
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;
249 }
250 return s;
251}
252
253typedef cppu::ImplInheritanceHelper<
254 PublishableDescription, css::reflection::XStructTypeDescription >
255PlainStructTypeDescription_Base;
256
257class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
258public:
259 PlainStructTypeDescription(
261 OUString name,
263 PlainStructTypeDescription_Base(entity->isPublished()),
264 manager_(manager), name_(std::move(name)), entity_(entity)
265 { assert(manager.is()); assert(entity.is()); }
266
267private:
268 virtual ~PlainStructTypeDescription() override {}
269
270 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
271 { return css::uno::TypeClass_STRUCT; }
272
273 virtual OUString SAL_CALL getName() override
274 { return name_; }
275
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());
281 }
282
283 virtual
284 css::uno::Sequence<
285 css::uno::Reference< css::reflection::XTypeDescription > >
286 SAL_CALL getMemberTypes() override;
287
288 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
289
290 virtual css::uno::Sequence< OUString > SAL_CALL getTypeParameters() override
291 { return css::uno::Sequence< OUString >(); }
292
293 virtual
294 css::uno::Sequence<
295 css::uno::Reference< css::reflection::XTypeDescription > >
296 SAL_CALL getTypeArguments() override {
297 return css::uno::Sequence<
298 css::uno::Reference< css::reflection::XTypeDescription > >();
299 }
300
302 OUString name_;
304};
305
306css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
307PlainStructTypeDescription::getMemberTypes()
308{
309 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
310 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
311 css::uno::Sequence<
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);
316 }
317 return s;
318}
319
320css::uno::Sequence< OUString > PlainStructTypeDescription::getMemberNames()
321{
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;
328 }
329 return s;
330}
331
332class ParameterizedMemberTypeDescription:
333 public cppu::WeakImplHelper< css::reflection::XTypeDescription >
334{
335public:
336 explicit ParameterizedMemberTypeDescription(
337 OUString typeParameterName):
338 typeParameterName_(std::move(typeParameterName))
339 {}
340
341private:
342 virtual ~ParameterizedMemberTypeDescription() override {}
343
344 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
345 { return css::uno::TypeClass_UNKNOWN; }
346
347 virtual OUString SAL_CALL getName() override
348 { return typeParameterName_; }
349
350 OUString typeParameterName_;
351};
352
353typedef cppu::ImplInheritanceHelper<
354 PublishableDescription, css::reflection::XStructTypeDescription >
355PolymorphicStructTypeTemplateDescription_Base;
356
357class PolymorphicStructTypeTemplateDescription:
358 public PolymorphicStructTypeTemplateDescription_Base
359{
360public:
361 PolymorphicStructTypeTemplateDescription(
363 OUString name,
365 entity):
366 PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
367 manager_(manager), name_(std::move(name)), entity_(entity)
368 { assert(manager.is()); assert(entity.is()); }
369
370private:
371 virtual ~PolymorphicStructTypeTemplateDescription() override {}
372
373 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
374 { return css::uno::TypeClass_STRUCT; }
375
376 virtual OUString SAL_CALL getName() override
377 { return name_; }
378
379 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
380 getBaseType() override
381 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
382
383 virtual
384 css::uno::Sequence<
385 css::uno::Reference< css::reflection::XTypeDescription > >
386 SAL_CALL getMemberTypes() override;
387
388 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
389
390 virtual css::uno::Sequence< OUString > SAL_CALL getTypeParameters() override;
391
392 virtual
393 css::uno::Sequence<
394 css::uno::Reference< css::reflection::XTypeDescription > >
395 SAL_CALL getTypeArguments() override {
396 return css::uno::Sequence<
397 css::uno::Reference< css::reflection::XTypeDescription > >();
398 }
399
401 OUString name_;
403};
404
405css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
406PolymorphicStructTypeTemplateDescription::getMemberTypes()
407{
408 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
409 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
410 css::uno::Sequence<
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);
418 }
419 return s;
420}
421
422css::uno::Sequence< OUString >
423PolymorphicStructTypeTemplateDescription::getMemberNames()
424{
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;
431 }
432 return s;
433}
434
435css::uno::Sequence< OUString >
436PolymorphicStructTypeTemplateDescription::getTypeParameters()
437{
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];
444 }
445 return s;
446}
447
448class InstantiatedPolymorphicStructTypeDescription:
449 public cppu::WeakImplHelper< css::reflection::XStructTypeDescription >
450{
451public:
452 InstantiatedPolymorphicStructTypeDescription(
454 OUString name,
456 entity,
457 std::vector< OUString >&& arguments):
458 manager_(manager), name_(std::move(name)), entity_(entity), arguments_(std::move(arguments))
459 {
460 assert(manager.is());
461 assert(entity.is());
462 assert(arguments_.size() == entity->getTypeParameters().size());
463 }
464
465private:
466 virtual ~InstantiatedPolymorphicStructTypeDescription() override {}
467
468 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
469 { return css::uno::TypeClass_STRUCT; }
470
471 virtual OUString SAL_CALL getName() override
472 { return name_; }
473
474 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
475 getBaseType() override
476 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
477
478 virtual
479 css::uno::Sequence<
480 css::uno::Reference< css::reflection::XTypeDescription > >
481 SAL_CALL getMemberTypes() override;
482
483 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
484
485 virtual css::uno::Sequence< OUString > SAL_CALL getTypeParameters() override
486 { return css::uno::Sequence< OUString >(); }
487
488 virtual
489 css::uno::Sequence<
490 css::uno::Reference< css::reflection::XTypeDescription > >
491 SAL_CALL getTypeArguments() override;
492
494 OUString name_;
496 std::vector< OUString > arguments_;
497};
498
499css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
500InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
501{
502 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
503 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
504 css::uno::Sequence<
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()];
513 goto found;
514 }
515 assert(false); // this cannot happen //TODO!
516 found:;
517 }
518 r[i] = manager_->resolve(type);
519 }
520 return s;
521}
522
523css::uno::Sequence< OUString >
524InstantiatedPolymorphicStructTypeDescription::getMemberNames()
525{
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;
532 }
533 return s;
534}
535css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
536InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
537{
538 assert(arguments_.size() <= SAL_MAX_INT32);
539 sal_Int32 n = static_cast< sal_Int32 >(arguments_.size());
540 css::uno::Sequence<
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]);
545 }
546 return s;
547}
548
549typedef cppu::ImplInheritanceHelper<
550 PublishableDescription, css::reflection::XCompoundTypeDescription >
551ExceptionTypeDescription_Base;
552
553class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
554public:
555 ExceptionTypeDescription(
557 OUString name,
559 ExceptionTypeDescription_Base(entity->isPublished()), manager_(manager),
560 name_(std::move(name)), entity_(entity)
561 { assert(manager.is()); assert(entity.is()); }
562
563private:
564 virtual ~ExceptionTypeDescription() override {}
565
566 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
567 { return css::uno::TypeClass_EXCEPTION; }
568
569 virtual OUString SAL_CALL getName() override
570 { return name_; }
571
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());
577 }
578
579 virtual
580 css::uno::Sequence<
581 css::uno::Reference< css::reflection::XTypeDescription > >
582 SAL_CALL getMemberTypes() override;
583
584 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
585
587 OUString name_;
589};
590
591css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
592ExceptionTypeDescription::getMemberTypes() {
593 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
594 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
595 css::uno::Sequence<
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);
600 }
601 return s;
602}
603
604css::uno::Sequence< OUString > ExceptionTypeDescription::getMemberNames()
605{
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;
612 }
613 return s;
614}
615
616class AttributeDescription:
617 public cppu::WeakImplHelper<
618 css::reflection::XInterfaceAttributeTypeDescription2 >
619{
620public:
621 AttributeDescription(
623 OUString name,
625 sal_Int32 position):
626 manager_(manager), name_(std::move(name)), attribute_(std::move(attribute)),
627 position_(position)
628 { assert(manager.is()); }
629
630private:
631 virtual ~AttributeDescription() override {}
632
633 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
634 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE; }
635
636 virtual OUString SAL_CALL getName() override
637 { return name_; }
638
639 virtual OUString SAL_CALL getMemberName() override
640 { return attribute_.name; }
641
642 virtual sal_Int32 SAL_CALL getPosition() override
643 { return position_; }
644
645 virtual sal_Bool SAL_CALL isReadOnly() override
646 { return attribute_.readOnly; }
647
648 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
649 getType() override
650 { return manager_->resolve(attribute_.type); }
651
652 virtual sal_Bool SAL_CALL isBound() override
653 { return attribute_.bound; }
654
655 virtual
656 css::uno::Sequence<
657 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
658 SAL_CALL getGetExceptions() override;
659
660 virtual
661 css::uno::Sequence<
662 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
663 SAL_CALL getSetExceptions() override;
664
666 OUString name_;
668 sal_Int32 position_;
669};
670
671css::uno::Sequence<
672 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
673AttributeDescription::getGetExceptions() {
674 assert(attribute_.getExceptions.size() <= SAL_MAX_INT32);
675 sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size());
676 css::uno::Sequence<
677 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
678 auto r = asNonConstRange(s);
679 for (sal_Int32 i = 0; i != n; ++i) {
680 r[i].set(
681 manager_->resolve(attribute_.getExceptions[i]),
682 css::uno::UNO_QUERY_THROW);
683 }
684 return s;
685}
686
687css::uno::Sequence<
688 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
689AttributeDescription::getSetExceptions() {
690 assert(attribute_.setExceptions.size() <= SAL_MAX_INT32);
691 sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size());
692 css::uno::Sequence<
693 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
694 auto r = asNonConstRange(s);
695 for (sal_Int32 i = 0; i != n; ++i) {
696 r[i].set(
697 manager_->resolve(attribute_.setExceptions[i]),
698 css::uno::UNO_QUERY_THROW);
699 }
700 return s;
701}
702
703class MethodParameter:
704 public cppu::WeakImplHelper< css::reflection::XMethodParameter >
705{
706public:
707 MethodParameter(
710 sal_Int32 position):
711 manager_(manager), parameter_(std::move(parameter)), position_(position)
712 { assert(manager.is()); }
713
714private:
715 virtual ~MethodParameter() override {}
716
717 virtual OUString SAL_CALL getName() override
718 { return parameter_.name; }
719
720 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
721 getType() override
722 { return manager_->resolve(parameter_.type); }
723
724 virtual sal_Bool SAL_CALL isIn() override {
725 return
726 (parameter_.direction
728 || (parameter_.direction
731 }
732
733 virtual sal_Bool SAL_CALL isOut() override {
734 return
735 (parameter_.direction
737 || (parameter_.direction
740 }
741
742 virtual sal_Int32 SAL_CALL getPosition() override
743 { return position_; }
744
747 sal_Int32 position_;
748};
749
750class MethodDescription:
751 public cppu::WeakImplHelper<
752 css::reflection::XInterfaceMethodTypeDescription >
753{
754public:
755 MethodDescription(
757 OUString name,
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()); }
761
762private:
763 virtual ~MethodDescription() override {}
764
765 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
766 { return css::uno::TypeClass_INTERFACE_METHOD; }
767
768 virtual OUString SAL_CALL getName() override
769 { return name_; }
770
771 virtual OUString SAL_CALL getMemberName() override
772 { return method_.name; }
773
774 virtual sal_Int32 SAL_CALL getPosition() override
775 { return position_; }
776
777 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
778 getReturnType() override
779 { return manager_->resolve(method_.returnType); }
780
781 virtual sal_Bool SAL_CALL isOneway() override
782 { return false; }
783
784 virtual
785 css::uno::Sequence<
786 css::uno::Reference< css::reflection::XMethodParameter > >
787 SAL_CALL getParameters() override;
788
789 virtual
790 css::uno::Sequence<
791 css::uno::Reference< css::reflection::XTypeDescription > >
792 SAL_CALL getExceptions() override;
793
795 OUString name_;
797 sal_Int32 position_;
798};
799
800css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > >
801MethodDescription::getParameters() {
802 assert(method_.parameters.size() <= SAL_MAX_INT32);
803 sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size());
804 css::uno::Sequence<
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);
809 }
810 return s;
811}
812
813css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
814MethodDescription::getExceptions() {
815 assert(method_.exceptions.size() <= SAL_MAX_INT32);
816 sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size());
817 css::uno::Sequence<
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]);
822 }
823 return s;
824}
825
826class BaseOffset {
827public:
828 explicit BaseOffset(
829 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
830 const & description);
831
832 BaseOffset(const BaseOffset&) = delete;
833 const BaseOffset& operator=(const BaseOffset&) = delete;
834
835 sal_Int32 get() const { return offset_; }
836
837private:
838 void calculateBases(
839 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
840 const & description);
841
842 void calculate(
843 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
844 const & description);
845
846 std::set< OUString > set_;
847 sal_Int32 offset_;
848};
849
850BaseOffset::BaseOffset(
851 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
852 description):
853 offset_(0)
854{
855 calculateBases(description);
856}
857
858void BaseOffset::calculateBases(
859 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
860 description)
861{
862 const css::uno::Sequence<
863 css::uno::Reference < css::reflection::XTypeDescription > > bases(
864 description->getBaseTypes());
865 for (const auto & i : bases) {
866 calculate(
867 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
868 resolveTypedefs(css::uno::Any(i)),
869 css::uno::UNO_QUERY_THROW));
870 }
871}
872
873void BaseOffset::calculate(
874 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
875 description)
876{
877 if (set_.insert(description->getName()).second) {
878 calculateBases(description);
879 offset_ += description->getMembers().getLength();
880 }
881}
882
883typedef cppu::ImplInheritanceHelper<
884 PublishableDescription, css::reflection::XInterfaceTypeDescription2 >
885InterfaceTypeDescription_Base;
886
887class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
888public:
889 InterfaceTypeDescription(
891 OUString name,
893 InterfaceTypeDescription_Base(entity->isPublished()), manager_(manager),
894 name_(std::move(name)), entity_(entity)
895 { assert(manager.is()); assert(entity.is()); }
896
897private:
898 virtual ~InterfaceTypeDescription() override {}
899
900 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
901 { return css::uno::TypeClass_INTERFACE; }
902
903 virtual OUString SAL_CALL getName() override
904 { return name_; }
905
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);
911 }
912
913 virtual css::uno::Uik SAL_CALL getUik() override
914 { return css::uno::Uik(); }
915
916 virtual
917 css::uno::Sequence<
918 css::uno::Reference<
919 css::reflection::XInterfaceMemberTypeDescription > >
920 SAL_CALL getMembers() override;
921
922 virtual
923 css::uno::Sequence<
924 css::uno::Reference< css::reflection::XTypeDescription > >
925 SAL_CALL getBaseTypes() override;
926
927 virtual
928 css::uno::Sequence<
929 css::uno::Reference< css::reflection::XTypeDescription > >
930 SAL_CALL getOptionalBaseTypes() override;
931
933 OUString name_;
935};
936
937css::uno::Sequence<
938 css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
939InterfaceTypeDescription::getMembers() {
940 assert(
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());
947 css::uno::Sequence<
948 css::uno::Reference<
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);
956 }
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);
961 }
962 return s;
963}
964
965css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
966InterfaceTypeDescription::getBaseTypes() {
967 assert(entity_->getDirectMandatoryBases().size() <= SAL_MAX_INT32);
968 sal_Int32 n = static_cast< sal_Int32 >(
969 entity_->getDirectMandatoryBases().size());
970 css::uno::Sequence<
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);
975 }
976 return s;
977}
978
979css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
980InterfaceTypeDescription::getOptionalBaseTypes()
981{
982 assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
983 sal_Int32 n = static_cast< sal_Int32 >(
984 entity_->getDirectOptionalBases().size());
985 css::uno::Sequence<
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);
990 }
991 return s;
992}
993
994class ConstantDescription:
995 public cppu::WeakImplHelper< css::reflection::XConstantTypeDescription >
996{
997public:
998 ConstantDescription(
999 OUString const & constantGroupName,
1001
1002private:
1003 virtual ~ConstantDescription() override {}
1004
1005 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1006 { return css::uno::TypeClass_CONSTANT; }
1007
1008 virtual OUString SAL_CALL getName() override
1009 { return name_; }
1010
1011 virtual css::uno::Any SAL_CALL getConstantValue() override
1012 { return value_; }
1013
1014 OUString name_;
1015 css::uno::Any value_;
1016};
1017
1018ConstantDescription::ConstantDescription(
1019 OUString const & constantGroupName,
1021 name_(makePrefix(constantGroupName) + member.name)
1022{
1023 switch (member.value.type) {
1025 value_ <<= member.value.booleanValue;
1026 break;
1028 value_ <<= member.value.byteValue;
1029 break;
1031 value_ <<= member.value.shortValue;
1032 break;
1034 value_ <<= member.value.unsignedShortValue;
1035 break;
1037 value_ <<= member.value.longValue;
1038 break;
1040 value_ <<= member.value.unsignedLongValue;
1041 break;
1043 value_ <<= member.value.hyperValue;
1044 break;
1046 value_ <<= member.value.unsignedHyperValue;
1047 break;
1049 value_ <<= member.value.floatValue;
1050 break;
1052 value_ <<= member.value.doubleValue;
1053 break;
1054 default:
1055 for (;;) { std::abort(); } // this cannot happen
1056 }
1057}
1058
1059typedef cppu::ImplInheritanceHelper<
1060 PublishableDescription, css::reflection::XConstantsTypeDescription >
1061ConstantGroupDescription_Base;
1062
1063class ConstantGroupDescription: public ConstantGroupDescription_Base {
1064public:
1065 ConstantGroupDescription(
1066 OUString name,
1068 ConstantGroupDescription_Base(entity->isPublished()), name_(std::move(name)),
1069 entity_(entity)
1070 { assert(entity.is()); }
1071
1072private:
1073 virtual ~ConstantGroupDescription() override {}
1074
1075 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1076 { return css::uno::TypeClass_CONSTANTS; }
1077
1078 virtual OUString SAL_CALL getName() override
1079 { return name_; }
1080
1081 virtual
1082 css::uno::Sequence<
1083 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1084 SAL_CALL getConstants() override;
1085
1086 OUString name_;
1088};
1089
1090css::uno::Sequence<
1091 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1092ConstantGroupDescription::getConstants() {
1093 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
1094 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
1095 css::uno::Sequence<
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]);
1100 }
1101 return s;
1102}
1103
1104typedef cppu::ImplInheritanceHelper<
1105 PublishableDescription, css::reflection::XIndirectTypeDescription >
1106TypedefDescription_Base;
1107
1108class TypedefDescription: public TypedefDescription_Base {
1109public:
1110 TypedefDescription(
1112 OUString name,
1114 TypedefDescription_Base(entity->isPublished()), manager_(manager),
1115 name_(std::move(name)), entity_(entity)
1116 { assert(manager.is()); assert(entity.is()); }
1117
1118private:
1119 virtual ~TypedefDescription() override {}
1120
1121 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1122 { return css::uno::TypeClass_TYPEDEF; }
1123
1124 virtual OUString SAL_CALL getName() override
1125 { return name_; }
1126
1127 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1128 getReferencedType() override
1129 { return manager_->resolve(entity_->getType()); }
1130
1132 OUString name_;
1134};
1135
1136class ConstructorParameter:
1137 public cppu::WeakImplHelper< css::reflection::XParameter >
1138{
1139public:
1140 ConstructorParameter(
1143 sal_Int32 position):
1144 manager_(manager), parameter_(std::move(parameter)), position_(position)
1145 { assert(manager.is()); }
1146
1147private:
1148 virtual ~ConstructorParameter() override {}
1149
1150 virtual OUString SAL_CALL getName() override
1151 { return parameter_.name; }
1152
1153 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1154 getType() override
1155 { return manager_->resolve(parameter_.type); }
1156
1157 virtual sal_Bool SAL_CALL isIn() override
1158 { return true; }
1159
1160 virtual sal_Bool SAL_CALL isOut() override
1161 { return false; }
1162
1163 virtual sal_Int32 SAL_CALL getPosition() override
1164 { return position_; }
1165
1166 virtual sal_Bool SAL_CALL isRestParameter() override
1167 { return parameter_.rest; }
1168
1171 parameter_;
1172 sal_Int32 position_;
1173};
1174
1175class ConstructorDescription:
1176 public cppu::WeakImplHelper<
1177 css::reflection::XServiceConstructorDescription >
1178{
1179public:
1180 ConstructorDescription(
1183 manager_(manager), constructor_(std::move(constructor))
1184 { assert(manager.is()); }
1185
1186private:
1187 virtual ~ConstructorDescription() override {}
1188
1189 virtual sal_Bool SAL_CALL isDefaultConstructor() override
1190 { return constructor_.defaultConstructor; }
1191
1192 virtual OUString SAL_CALL getName() override
1193 { return constructor_.name; }
1194
1195 virtual
1196 css::uno::Sequence<
1197 css::uno::Reference< css::reflection::XParameter > >
1198 SAL_CALL getParameters() override;
1199
1200 virtual
1201 css::uno::Sequence<
1202 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1203 SAL_CALL getExceptions() override;
1204
1207};
1208
1209css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
1210ConstructorDescription::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(
1214 n);
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);
1219 }
1220 return s;
1221}
1222
1223css::uno::Sequence<
1224 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1225ConstructorDescription::getExceptions() {
1226 assert(constructor_.exceptions.size() <= SAL_MAX_INT32);
1227 sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size());
1228 css::uno::Sequence<
1229 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
1230 auto r = asNonConstRange(s);
1231 for (sal_Int32 i = 0; i != n; ++i) {
1232 r[i].set(
1233 manager_->resolve(constructor_.exceptions[i]),
1234 css::uno::UNO_QUERY_THROW);
1235 }
1236 return s;
1237}
1238
1239typedef cppu::ImplInheritanceHelper<
1240 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1241SingleInterfaceBasedServiceDescription_Base;
1242
1243class SingleInterfaceBasedServiceDescription:
1244 public SingleInterfaceBasedServiceDescription_Base
1245{
1246public:
1247 SingleInterfaceBasedServiceDescription(
1249 OUString name,
1251 entity):
1252 SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
1253 manager_(manager), name_(std::move(name)), entity_(entity)
1254 { assert(manager.is()); assert(entity.is()); }
1255
1256private:
1257 virtual ~SingleInterfaceBasedServiceDescription() override {}
1258
1259 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1260 { return css::uno::TypeClass_SERVICE; }
1261
1262 virtual OUString SAL_CALL getName() override
1263 { return name_; }
1264
1265 virtual
1266 css::uno::Sequence<
1267 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1268 SAL_CALL getMandatoryServices() override
1269 {
1270 return css::uno::Sequence<
1271 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1272 }
1273
1274 virtual
1275 css::uno::Sequence<
1276 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1277 SAL_CALL getOptionalServices() override
1278 {
1279 return css::uno::Sequence<
1280 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1281 }
1282
1283 virtual
1284 css::uno::Sequence<
1285 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1286 SAL_CALL getMandatoryInterfaces() override
1287 {
1288 return css::uno::Sequence<
1289 css::uno::Reference<
1290 css::reflection::XInterfaceTypeDescription > >();
1291 }
1292
1293 virtual
1294 css::uno::Sequence<
1295 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1296 SAL_CALL getOptionalInterfaces() override
1297 {
1298 return css::uno::Sequence<
1299 css::uno::Reference<
1300 css::reflection::XInterfaceTypeDescription > >();
1301 }
1302
1303 virtual
1304 css::uno::Sequence<
1305 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1306 SAL_CALL getProperties() override
1307 {
1308 return css::uno::Sequence<
1309 css::uno::Reference<
1310 css::reflection::XPropertyTypeDescription > >();
1311 }
1312
1313 virtual sal_Bool SAL_CALL isSingleInterfaceBased() override
1314 { return true; }
1315
1316 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1317 getInterface() override
1318 { return manager_->resolve(entity_->getBase()); }
1319
1320 virtual
1321 css::uno::Sequence<
1322 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1323 SAL_CALL getConstructors() override;
1324
1326 OUString name_;
1328};
1329
1330css::uno::Sequence<
1331 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1332SingleInterfaceBasedServiceDescription::getConstructors()
1333{
1334 assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
1335 sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
1336 css::uno::Sequence<
1337 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1338 s(n);
1339 auto r = asNonConstRange(s);
1340 for (sal_Int32 i = 0; i != n; ++i) {
1341 r[i] = new ConstructorDescription(
1342 manager_, entity_->getConstructors()[i]);
1343 }
1344 return s;
1345}
1346
1347class PropertyDescription:
1348 public cppu::WeakImplHelper< css::reflection::XPropertyTypeDescription >
1349{
1350public:
1351 PropertyDescription(
1354 manager_(manager), property_(std::move(property))
1355 { assert(manager.is()); }
1356
1357private:
1358 virtual ~PropertyDescription() override {}
1359
1360 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1361 { return css::uno::TypeClass_PROPERTY; }
1362
1363 virtual OUString SAL_CALL getName() override
1364 { return property_.name; }
1365
1366 virtual sal_Int16 SAL_CALL getPropertyFlags() override
1367 { return property_.attributes; }
1368
1369 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1370 getPropertyTypeDescription() override
1371 { return manager_->resolve(property_.type); }
1372
1375};
1376
1377typedef cppu::ImplInheritanceHelper<
1378 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1379AccumulationBasedServiceDescription_Base;
1380
1381class AccumulationBasedServiceDescription:
1382 public AccumulationBasedServiceDescription_Base
1383{
1384public:
1385 AccumulationBasedServiceDescription(
1387 OUString name,
1389 entity):
1390 AccumulationBasedServiceDescription_Base(entity->isPublished()),
1391 manager_(manager), name_(std::move(name)), entity_(entity)
1392 { assert(manager.is()); assert(entity.is()); }
1393
1394private:
1395 virtual ~AccumulationBasedServiceDescription() override {}
1396
1397 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1398 { return css::uno::TypeClass_SERVICE; }
1399
1400 virtual OUString SAL_CALL getName() override
1401 { return name_; }
1402
1403 virtual
1404 css::uno::Sequence<
1405 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1406 SAL_CALL getMandatoryServices() override;
1407
1408 virtual
1409 css::uno::Sequence<
1410 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1411 SAL_CALL getOptionalServices() override;
1412
1413 virtual
1414 css::uno::Sequence<
1415 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1416 SAL_CALL getMandatoryInterfaces() override;
1417
1418 virtual
1419 css::uno::Sequence<
1420 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1421 SAL_CALL getOptionalInterfaces() override;
1422
1423 virtual
1424 css::uno::Sequence<
1425 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1426 SAL_CALL getProperties() override;
1427
1428 virtual sal_Bool SAL_CALL isSingleInterfaceBased() override
1429 { return false; }
1430
1431 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1432 getInterface() override
1433 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1434
1435 virtual
1436 css::uno::Sequence<
1437 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1438 SAL_CALL getConstructors() override
1439 {
1440 return css::uno::Sequence<
1441 css::uno::Reference<
1442 css::reflection::XServiceConstructorDescription > >();
1443 }
1444
1446 OUString name_;
1448};
1449
1450css::uno::Sequence<
1451 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1452AccumulationBasedServiceDescription::getMandatoryServices()
1453{
1454 assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
1455 sal_Int32 n = static_cast< sal_Int32 >(
1456 entity_->getDirectMandatoryBaseServices().size());
1457 css::uno::Sequence<
1458 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1459 auto r = asNonConstRange(s);
1460 for (sal_Int32 i = 0; i != n; ++i) {
1461 r[i].set(
1462 manager_->resolve(
1463 entity_->getDirectMandatoryBaseServices()[i].name),
1464 css::uno::UNO_QUERY_THROW);
1465 }
1466 return s;
1467}
1468
1469css::uno::Sequence<
1470 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1471AccumulationBasedServiceDescription::getOptionalServices()
1472{
1473 assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
1474 sal_Int32 n = static_cast< sal_Int32 >(
1475 entity_->getDirectOptionalBaseServices().size());
1476 css::uno::Sequence<
1477 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1478 auto r = asNonConstRange(s);
1479 for (sal_Int32 i = 0; i != n; ++i) {
1480 r[i].set(
1481 manager_->resolve(entity_->getDirectOptionalBaseServices()[i].name),
1482 css::uno::UNO_QUERY_THROW);
1483 }
1484 return s;
1485}
1486
1487css::uno::Sequence<
1488 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1489AccumulationBasedServiceDescription::getMandatoryInterfaces()
1490{
1491 assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
1492 sal_Int32 n = static_cast< sal_Int32 >(
1493 entity_->getDirectMandatoryBaseInterfaces().size());
1494 css::uno::Sequence<
1495 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1496 n);
1497 auto r = asNonConstRange(s);
1498 for (sal_Int32 i = 0; i != n; ++i) {
1499 r[i].set(
1500 resolveTypedefs(
1501 manager_->find(
1502 entity_->getDirectMandatoryBaseInterfaces()[i].name)),
1503 css::uno::UNO_QUERY_THROW);
1504 }
1505 return s;
1506}
1507
1508css::uno::Sequence<
1509 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1510AccumulationBasedServiceDescription::getOptionalInterfaces()
1511{
1512 assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
1513 sal_Int32 n = static_cast< sal_Int32 >(
1514 entity_->getDirectOptionalBaseInterfaces().size());
1515 css::uno::Sequence<
1516 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1517 n);
1518 auto r = asNonConstRange(s);
1519 for (sal_Int32 i = 0; i != n; ++i) {
1520 r[i].set(
1521 resolveTypedefs(
1522 manager_->find(
1523 entity_->getDirectOptionalBaseInterfaces()[i].name)),
1524 css::uno::UNO_QUERY_THROW);
1525 }
1526 return s;
1527}
1528
1529css::uno::Sequence<
1530 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1531AccumulationBasedServiceDescription::getProperties()
1532{
1533 assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
1534 sal_Int32 n = static_cast< sal_Int32 >(
1535 entity_->getDirectProperties().size());
1536 css::uno::Sequence<
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]);
1542 }
1543 return s;
1544}
1545
1546typedef cppu::ImplInheritanceHelper<
1547 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1548InterfaceBasedSingletonDescription_Base;
1549
1550class InterfaceBasedSingletonDescription:
1551 public InterfaceBasedSingletonDescription_Base
1552{
1553public:
1554 InterfaceBasedSingletonDescription(
1556 OUString name,
1558 InterfaceBasedSingletonDescription_Base(entity->isPublished()),
1559 manager_(manager), name_(std::move(name)), entity_(entity)
1560 { assert(manager.is()); assert(entity.is()); }
1561
1562private:
1563 virtual ~InterfaceBasedSingletonDescription() override {}
1564
1565 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1566 { return css::uno::TypeClass_SINGLETON; }
1567
1568 virtual OUString SAL_CALL getName() override
1569 { return name_; }
1570
1571 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1572 SAL_CALL getService() override
1573 {
1574 return
1575 css::uno::Reference< css::reflection::XServiceTypeDescription >();
1576 }
1577
1578 virtual sal_Bool SAL_CALL isInterfaceBased() override
1579 { return true; }
1580
1581 virtual css::uno::Reference< css::reflection::XTypeDescription >
1582 SAL_CALL getInterface() override
1583 { return manager_->resolve(entity_->getBase()); }
1584
1586 OUString name_;
1588};
1589
1590typedef cppu::ImplInheritanceHelper<
1591 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1592ServiceBasedSingletonDescription_Base;
1593
1594class ServiceBasedSingletonDescription:
1595 public ServiceBasedSingletonDescription_Base
1596{
1597public:
1598 ServiceBasedSingletonDescription(
1600 OUString name,
1602 ServiceBasedSingletonDescription_Base(entity->isPublished()),
1603 manager_(manager), name_(std::move(name)), entity_(entity)
1604 { assert(manager.is()); assert(entity.is()); }
1605
1606private:
1607 virtual ~ServiceBasedSingletonDescription() override {}
1608
1609 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1610 { return css::uno::TypeClass_SINGLETON; }
1611
1612 virtual OUString SAL_CALL getName() override
1613 { return name_; }
1614
1615 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1616 SAL_CALL getService() override
1617 {
1618 return css::uno::Reference< css::reflection::XServiceTypeDescription >(
1619 manager_->resolve(entity_->getBase()), css::uno::UNO_QUERY_THROW);
1620 }
1621
1622 virtual sal_Bool SAL_CALL isInterfaceBased() override
1623 { return false; }
1624
1625 virtual css::uno::Reference< css::reflection::XTypeDescription >
1626 SAL_CALL getInterface() override
1627 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1628
1630 OUString name_;
1632};
1633
1634class Enumeration:
1635 public cppu::WeakImplHelper< css::reflection::XTypeDescriptionEnumeration >
1636{
1637public:
1640 OUString const & prefix,
1642 css::uno::Sequence< css::uno::TypeClass > const & types, bool deep):
1643 manager_(manager), types_(types), deep_(deep)
1644 {
1645 assert(manager.is());
1646 positions_.push(Position(prefix, cursor));
1647 findNextMatch();
1648 }
1649
1650private:
1651 virtual ~Enumeration() override {}
1652
1653 virtual sal_Bool SAL_CALL hasMoreElements() override
1654 { return !positions_.empty(); }
1655
1656 virtual css::uno::Any SAL_CALL nextElement() override
1657 { return css::uno::Any(nextTypeDescription()); }
1658
1659 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1660 nextTypeDescription() override;
1661
1662 bool matches(css::uno::TypeClass tc) const;
1663
1664 void findNextMatch();
1665
1666 struct Position {
1667 Position(
1668 OUString thePrefix,
1669 rtl::Reference< unoidl::MapCursor > const & theCursor):
1670 prefix(std::move(thePrefix)), cursor(theCursor)
1671 { assert(theCursor.is()); }
1672
1673 Position(
1674 OUString thePrefix,
1676 theConstantGroup):
1677 prefix(std::move(thePrefix)), constantGroup(theConstantGroup),
1678 constantGroupIndex(constantGroup->getMembers().begin())
1679 { assert(theConstantGroup.is()); }
1680
1681 Position(Position const & other):
1682 prefix(other.prefix), cursor(other.cursor),
1683 constantGroup(other.constantGroup)
1684 {
1685 if (constantGroup.is()) {
1686 constantGroupIndex = other.constantGroupIndex;
1687 }
1688 }
1689
1690 OUString prefix;
1693 std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator
1694 constantGroupIndex;
1695 };
1696
1698 css::uno::Sequence< css::uno::TypeClass > types_;
1699 bool deep_;
1700
1701 std::mutex mutex_;
1702 std::stack< Position, std::vector<Position> > positions_;
1703 OUString current_;
1704};
1705
1706css::uno::Reference< css::reflection::XTypeDescription >
1707Enumeration::nextTypeDescription()
1708{
1709 OUString name;
1710 {
1711 std::scoped_lock g(mutex_);
1712 if (positions_.empty()) {
1713 throw css::container::NoSuchElementException(
1714 "exhausted XTypeDescriptionEnumeration",
1715 static_cast< cppu::OWeakObject * >(this));
1716 }
1717 name = current_;
1718 findNextMatch();
1719 }
1720 return manager_->resolve(name);
1721}
1722
1723bool Enumeration::matches(css::uno::TypeClass tc) const {
1724 if (!types_.hasElements()) {
1725 return true;
1726 }
1727
1728 return std::any_of(types_.begin(), types_.end(), [&tc](const auto& i) { return i == tc; });
1729}
1730
1731void Enumeration::findNextMatch() {
1732 try {
1733 for (;;) {
1734 assert(!positions_.empty());
1735 OUString name;
1736 if (positions_.top().cursor.is()) { // root or module
1738 positions_.top().cursor->getNext(&name));
1739 if (!ent.is()) {
1740 positions_.pop();
1741 if (positions_.empty()) {
1742 break;
1743 }
1744 continue;
1745 }
1746 name = positions_.top().prefix + name;
1747 css::uno::TypeClass tc;
1748 switch (ent->getSort()) {
1750 tc = css::uno::TypeClass_MODULE;
1751 if (deep_) {
1752 positions_.push(
1753 Position(
1754 makePrefix(name),
1755 static_cast< unoidl::ModuleEntity * >(
1756 ent.get())->createCursor()));
1757 }
1758 break;
1760 tc = css::uno::TypeClass_ENUM;
1761 break;
1764 tc = css::uno::TypeClass_STRUCT;
1765 break;
1767 tc = css::uno::TypeClass_EXCEPTION;
1768 break;
1770 tc = css::uno::TypeClass_INTERFACE;
1771 break;
1773 tc = css::uno::TypeClass_TYPEDEF;
1774 break;
1776 tc = css::uno::TypeClass_CONSTANTS;
1777 if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
1778 positions_.push(
1779 Position(
1780 makePrefix(name),
1781 static_cast< unoidl::ConstantGroupEntity * >(
1782 ent.get())));
1783 }
1784 break;
1787 tc = css::uno::TypeClass_SERVICE;
1788 break;
1791 tc = css::uno::TypeClass_SINGLETON;
1792 break;
1793 default:
1794 for (;;) { std::abort(); } // this cannot happen
1795 }
1796 if (matches(tc)) {
1797 current_ = name;
1798 break;
1799 }
1800 } else { // constant group
1801 if (positions_.top().constantGroupIndex
1802 == positions_.top().constantGroup->getMembers().end())
1803 {
1804 positions_.pop();
1805 if (positions_.empty()) {
1806 break;
1807 }
1808 continue;
1809 }
1810 current_ = positions_.top().prefix
1811 + positions_.top().constantGroupIndex++->name;
1812 break;
1813 }
1814 }
1815 } catch (unoidl::FileFormatException & e) {
1816 throw css::uno::DeploymentException(
1817 e.getUri() + ": " + e.getDetail(),
1818 static_cast< cppu::OWeakObject * >(this));
1819 }
1820}
1821
1822}
1823
1825 manager_(new unoidl::Manager)
1826{}
1827
1828css::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)));
1851 }
1852 }
1853 if (name.startsWith("[]")) {
1854 return getSequenceType(name);
1855 }
1856 sal_Int32 i = name.indexOf('<');
1857 if (i != -1) {
1858 return getInstantiatedStruct(name, i);
1859 }
1860 i = name.indexOf("::");
1861 if (i != -1) {
1862 return getInterfaceMember(name, i);
1863 }
1864 rtl::Reference< unoidl::Entity > ent(findEntity(name));
1865 if (ent.is()) {
1866 return getNamed(name, ent);
1867 }
1868 i = name.lastIndexOf('.');
1869 if (i != -1) {
1870 OUString parent(name.copy(0, i));
1871 ent = findEntity(parent);
1872 if (ent.is()) {
1873 switch (ent->getSort()) {
1875 return getEnumMember(
1876 static_cast< unoidl::EnumTypeEntity * >(ent.get()),
1877 name.subView(i + 1));
1879 return getConstant(
1880 parent,
1881 static_cast< unoidl::ConstantGroupEntity * >(ent.get()),
1882 name.subView(i + 1));
1883 default:
1884 break;
1885 }
1886 }
1887 }
1888 return css::uno::Any();
1889}
1890
1891css::uno::Reference< css::reflection::XTypeDescription >
1892cppuhelper::TypeManager::resolve(OUString const & name) {
1893 css::uno::Reference< css::reflection::XTypeDescription > desc(
1894 find(name), css::uno::UNO_QUERY);
1895 if (!desc.is()) {
1896 throw css::uno::DeploymentException(
1897 "cannot resolve type \"" + name + "\"",
1898 static_cast< cppu::OWeakObject * >(this));
1899 }
1900 return desc;
1901}
1902
1904
1906{
1907 return
1908 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager";
1909}
1910
1912 OUString const & ServiceName)
1913{
1914 return cppu::supportsService(this, ServiceName);
1915}
1916
1917css::uno::Sequence< OUString >
1919{
1920 return { "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1921}
1922
1924 OUString const & aName)
1925{
1926 css::uno::Any desc(find(aName));
1927 if (!desc.hasValue()) {
1928 throw css::container::NoSuchElementException(
1929 aName, static_cast< cppu::OWeakObject * >(this));
1930 }
1931 return desc;
1932}
1933
1935 OUString const & aName)
1936{
1937 return find(aName).hasValue();
1938}
1939
1941{
1943}
1944
1946{
1947 throw css::uno::RuntimeException(
1948 "TypeManager hasElements: method not supported",
1949 static_cast< cppu::OWeakObject * >(this));
1950}
1951
1952css::uno::Reference< css::container::XEnumeration >
1954{
1955 throw css::uno::RuntimeException(
1956 "TypeManager createEnumeration: method not supported",
1957 static_cast< cppu::OWeakObject * >(this));
1958}
1959
1961{
1962 throw css::uno::RuntimeException(
1963 "TypeManager has: method not supported",
1964 static_cast< cppu::OWeakObject * >(this));
1965}
1966
1967void cppuhelper::TypeManager::insert(css::uno::Any const & aElement)
1968{
1969 OUString uri;
1970 if (!(aElement >>= uri)) {
1971 throw css::lang::IllegalArgumentException(
1972 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
1973 " argument"),
1974 static_cast< cppu::OWeakObject * >(this), 0);
1975 }
1976 //TODO: check for ElementExistException
1977 //TODO: check for consistency with existing data
1978 readRdbFile(uri, false);
1979}
1980
1981void cppuhelper::TypeManager::remove(css::uno::Any const & aElement)
1982{
1983 OUString uri;
1984 if (!(aElement >>= uri)) {
1985 throw css::lang::IllegalArgumentException(
1986 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
1987 " argument"),
1988 static_cast< cppu::OWeakObject * >(this), 0);
1989 }
1990 //TODO: remove requests are silently ignored for now
1991}
1992
1993css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
1995 OUString const & moduleName,
1996 css::uno::Sequence< css::uno::TypeClass > const & types,
1997 css::reflection::TypeDescriptionSearchDepth depth)
1998{
2000 try {
2001 cursor = manager_->createCursor(moduleName);
2002 } catch (unoidl::FileFormatException & e) {
2003 throw css::uno::DeploymentException(
2004 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2005 + e.getDetail()),
2006 static_cast< cppu::OWeakObject * >(this));
2007 }
2008 if (!cursor.is()) {
2009 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2010 // non-module
2011 throw css::reflection::NoSuchTypeNameException(
2012 moduleName, static_cast< cppu::OWeakObject * >(this));
2013 }
2014 return new Enumeration(
2015 this, makePrefix(moduleName), cursor, types,
2016 depth == css::reflection::TypeDescriptionSearchDepth_INFINITE);
2017}
2018
2019void 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));
2022 if (uri.empty()) {
2023 continue;
2024 }
2025 bool optional;
2026 bool directory;
2027 cppu::decodeRdbUri(&uri, &optional, &directory);
2028 if (directory) {
2029 readRdbDirectory(uri, optional);
2030 } else {
2031 readRdbFile(uri, optional);
2032 }
2033 }
2034}
2035
2037 std::u16string_view uri, bool optional)
2038{
2039 osl::Directory dir = OUString(uri);
2040 switch (dir.open()) {
2041 case osl::FileBase::E_None:
2042 break;
2043 case osl::FileBase::E_NOENT:
2044 if (optional) {
2045 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
2046 return;
2047 }
2048 [[fallthrough]];
2049 default:
2050 throw css::uno::DeploymentException(
2051 OUString::Concat("Cannot open directory ") + uri,
2052 static_cast< cppu::OWeakObject * >(this));
2053 }
2054 for (;;) {
2055 OUString url;
2056 if (!cppu::nextDirectoryItem(dir, &url)) {
2057 break;
2058 }
2059 readRdbFile(url, false);
2060 }
2061}
2062
2064 std::u16string_view uri, bool optional)
2065{
2066 try {
2067 manager_->addProvider(OUString(uri));
2068 } catch (unoidl::NoSuchFileException &) {
2069 if (!optional) {
2070 throw css::uno::DeploymentException(
2071 OUString::Concat(uri) + ": no such file",
2072 static_cast< cppu::OWeakObject * >(this));
2073 }
2074 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
2075 } catch (unoidl::FileFormatException & e) {
2076 throw css::uno::DeploymentException(
2077 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2078 + e.getDetail()),
2079 static_cast< cppu::OWeakObject * >(this));
2080 }
2081}
2082
2084 OUString const & name)
2085{
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("[]")))));
2091}
2092
2094 OUString const & name, sal_Int32 separator)
2095{
2096 assert(name.indexOf('<') == separator && separator != -1);
2097 rtl::Reference< unoidl::Entity > ent(findEntity(name.copy(0, separator)));
2098 if (!ent.is()
2099 || (ent->getSort()
2101 {
2102 return css::uno::Any();
2103 }
2106 ent.get()));
2107 std::vector< OUString > args;
2108 sal_Int32 i = separator;
2109 do {
2110 ++i; // skip '<' or ','
2111 sal_Int32 j = i;
2112 for (sal_Int32 level = 0; j != name.getLength(); ++j) {
2113 sal_Unicode c = name[j];
2114 if (c == ',') {
2115 if (level == 0) {
2116 break;
2117 }
2118 } else if (c == '<') {
2119 ++level;
2120 } else if (c == '>') {
2121 if (level == 0) {
2122 break;
2123 }
2124 --level;
2125 }
2126 }
2127 if (j != name.getLength()) {
2128 args.push_back(name.copy(i, j - i));
2129 }
2130 i = j;
2131 } while (i != name.getLength() && name[i] != '>');
2132 if (i != name.getLength() - 1 || name[i] != '>'
2133 || args.size() != ent2->getTypeParameters().size())
2134 {
2135 return css::uno::Any();
2136 }
2137 return css::uno::Any(
2138 css::uno::Reference< css::reflection::XTypeDescription >(
2139 new InstantiatedPolymorphicStructTypeDescription(
2140 this, name, ent2, std::move(args))));
2141}
2142
2144 std::u16string_view name, std::size_t separator)
2145{
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);
2149 if (!ifc.is()) {
2150 return css::uno::Any();
2151 }
2152 std::u16string_view member = name.substr(separator + std::strlen("::"));
2153 const css::uno::Sequence<
2154 css::uno::Reference<
2155 css::reflection::XInterfaceMemberTypeDescription > > mems(
2156 ifc->getMembers());
2157 for (const auto & m : mems) {
2158 if (m->getMemberName() == member) {
2159 return css::uno::Any(
2160 css::uno::Reference< css::reflection::XTypeDescription >(m));
2161 }
2162 }
2163 return css::uno::Any();
2164}
2165
2167 OUString const & name, rtl::Reference< unoidl::Entity > const & entity)
2168{
2169 assert(entity.is());
2170 switch (entity->getSort()) {
2172 return css::uno::Any(
2173 css::uno::Reference< css::reflection::XTypeDescription >(
2174 new ModuleDescription(
2175 this, name,
2176 static_cast< unoidl::ModuleEntity * >(entity.get()))));
2178 return css::uno::Any(
2179 css::uno::Reference< css::reflection::XTypeDescription >(
2180 new EnumTypeDescription(
2181 name,
2182 static_cast< unoidl::EnumTypeEntity * >(entity.get()))));
2184 return css::uno::Any(
2185 css::uno::Reference< css::reflection::XTypeDescription >(
2186 new PlainStructTypeDescription(
2187 this, name,
2188 static_cast< unoidl::PlainStructTypeEntity * >(
2189 entity.get()))));
2191 return css::uno::Any(
2192 css::uno::Reference< css::reflection::XTypeDescription >(
2193 new PolymorphicStructTypeTemplateDescription(
2194 this, name,
2195 static_cast<
2197 entity.get()))));
2199 return css::uno::Any(
2200 css::uno::Reference< css::reflection::XTypeDescription >(
2201 new ExceptionTypeDescription(
2202 this, name,
2203 static_cast< unoidl::ExceptionTypeEntity * >(
2204 entity.get()))));
2206 return css::uno::Any(
2207 css::uno::Reference< css::reflection::XTypeDescription >(
2208 new InterfaceTypeDescription(
2209 this, name,
2210 static_cast< unoidl::InterfaceTypeEntity * >(
2211 entity.get()))));
2213 return css::uno::Any(
2214 css::uno::Reference< css::reflection::XTypeDescription >(
2215 new TypedefDescription(
2216 this, name,
2217 static_cast< unoidl::TypedefEntity * >(entity.get()))));
2219 return css::uno::Any(
2220 css::uno::Reference< css::reflection::XTypeDescription >(
2221 new ConstantGroupDescription(
2222 name,
2223 static_cast< unoidl::ConstantGroupEntity * >(
2224 entity.get()))));
2226 return css::uno::Any(
2227 css::uno::Reference< css::reflection::XTypeDescription >(
2228 new SingleInterfaceBasedServiceDescription(
2229 this, name,
2231 entity.get()))));
2233 return css::uno::Any(
2234 css::uno::Reference< css::reflection::XTypeDescription >(
2235 new AccumulationBasedServiceDescription(
2236 this, name,
2238 entity.get()))));
2240 return css::uno::Any(
2241 css::uno::Reference< css::reflection::XTypeDescription >(
2242 new InterfaceBasedSingletonDescription(
2243 this, name,
2245 entity.get()))));
2247 return css::uno::Any(
2248 css::uno::Reference< css::reflection::XTypeDescription >(
2249 new ServiceBasedSingletonDescription(
2250 this, name,
2251 static_cast< unoidl::ServiceBasedSingletonEntity * >(
2252 entity.get()))));
2253 default:
2254 for (;;) { std::abort(); } // this cannot happen
2255 }
2256}
2257
2260 std::u16string_view member)
2261{
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();
2267}
2268
2270 std::u16string_view constantGroupName,
2272 std::u16string_view member)
2273{
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();
2281}
2282
2284 OUString const & name)
2285{
2286 try {
2287 return manager_->findEntity(name);
2288 } catch (unoidl::FileFormatException & e) {
2289 throw css::uno::DeploymentException(
2290 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2291 + e.getDetail()),
2292 static_cast< cppu::OWeakObject * >(this));
2293 }
2294}
2295
2296/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
virtual css::uno::Any SAL_CALL nextElement() override
Enumeration(css::container::XIndexAccess *)
virtual sal_Bool SAL_CALL hasMoreElements() override
Base class to implement a UNO object supporting weak references, i.e.
Definition: weak.hxx:48
css::uno::Type const & get()
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL hasElements() override
static css::uno::Any getEnumMember(rtl::Reference< unoidl::EnumTypeEntity > const &entity, std::u16string_view member)
virtual void SAL_CALL remove(css::uno::Any const &aElement) override
virtual css::uno::Reference< css::reflection::XTypeDescriptionEnumeration > SAL_CALL createTypeDescriptionEnumeration(OUString const &moduleName, css::uno::Sequence< css::uno::TypeClass > const &types, css::reflection::TypeDescriptionSearchDepth depth) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Any SAL_CALL getByHierarchicalName(OUString const &aName) override
css::uno::Reference< css::reflection::XTypeDescription > resolve(OUString const &name)
virtual sal_Bool SAL_CALL has(css::uno::Any const &aElement) override
css::uno::Any find(OUString const &name)
virtual ~TypeManager() noexcept override
rtl::Reference< unoidl::Entity > findEntity(OUString const &name)
virtual void SAL_CALL insert(css::uno::Any const &aElement) override
void readRdbDirectory(std::u16string_view uri, bool optional)
css::uno::Any getNamed(OUString const &name, rtl::Reference< unoidl::Entity > const &entity)
css::uno::Any getInterfaceMember(std::u16string_view name, std::size_t separator)
css::uno::Any getInstantiatedStruct(OUString const &name, sal_Int32 separator)
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual css::uno::Type SAL_CALL getElementType() override
css::uno::Any getSequenceType(OUString const &name)
void init(std::u16string_view rdbUris)
void readRdbFile(std::u16string_view uri, bool optional)
virtual sal_Bool SAL_CALL hasByHierarchicalName(OUString const &aName) override
static css::uno::Any getConstant(std::u16string_view constantGroupName, rtl::Reference< unoidl::ConstantGroupEntity > const &entity, std::u16string_view member)
SORT_SINGLE_INTERFACE_BASED_SERVICE
SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
const OUString & getDetail() const
const OUString & getUri() const
virtual rtl::Reference< MapCursor > createCursor() const=0
rtl::Reference< ParseManager > manager
css::uno::Any value_
std::mutex mutex_
float u
const char * name
OUString aName
sal_Int64 n
rtl::Reference< Manager > manager_
#define SAL_INFO(area, stream)
int n2
int n1
def position(n=-1)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
void decodeRdbUri(std::u16string_view *uri, bool *optional, bool *directory)
Definition: paths.cxx:114
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
A helper for implementations of com.sun.star.lang.XServiceInfo.
bool nextDirectoryItem(osl::Directory &directory, OUString *url)
Definition: paths.cxx:81
int i
m
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
enumrange< T >::Iterator begin(enumrange< T >)
args
PyRef getTypeClass(const Runtime &)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool getType(BSTR name, Type &type)
sal_Int32 attribute
sal_uInt16 unsignedShortValue
sal_uInt64 unsignedHyperValue
sal_uInt32 unsignedLongValue
unsigned char sal_Bool
sal_uInt16 sal_Unicode
ResultType type
OUString name_