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
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>
50#include <osl/file.hxx>
51#include <rtl/ref.hxx>
52#include <rtl/ustring.hxx>
53#include <sal/log.hxx>
54#include <sal/macros.h>
55#include <sal/types.h>
56#include <o3tl/string_view.hxx>
57
58#include <unoidl/unoidl.hxx>
59
60#include "paths.hxx"
61#include "typemanager.hxx"
62
63namespace {
64
65OUString makePrefix(OUString const & name) {
66 return name.isEmpty() ? name : name + ".";
67}
68
69css::uno::Any resolveTypedefs(css::uno::Any const & type) {
70 for (css::uno::Any t(type);;) {
71 css::uno::Reference< css::reflection::XIndirectTypeDescription > ind(
72 type, css::uno::UNO_QUERY);
73 if (!ind.is() || ind->getTypeClass() != css::uno::TypeClass_TYPEDEF) {
74 return t;
75 }
76 t <<= ind->getReferencedType();
77 }
78}
79
80class SimpleTypeDescription:
81 public cppu::WeakImplHelper< css::reflection::XTypeDescription >
82{
83public:
84 SimpleTypeDescription(
85 css::uno::TypeClass typeClass, OUString name):
86 typeClass_(typeClass), name_(std::move(name))
87 {}
88
89private:
90 virtual ~SimpleTypeDescription() override {}
91
92 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
93 { return typeClass_; }
94
95 virtual OUString SAL_CALL getName() override
96 { return name_; }
97
98 css::uno::TypeClass typeClass_;
99 OUString name_;
100};
101
102class SequenceTypeDescription:
103 public cppu::WeakImplHelper< css::reflection::XIndirectTypeDescription >
104{
105public:
106 SequenceTypeDescription(
108 OUString name, OUString componentType):
109 manager_(manager), name_(std::move(name)), componentType_(std::move(componentType))
110 { assert(manager.is()); }
111
112private:
113 virtual ~SequenceTypeDescription() override {}
114
115 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
116 { return css::uno::TypeClass_SEQUENCE; }
117
118 virtual OUString SAL_CALL getName() override
119 { return name_; }
120
121 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
122 getReferencedType() override
123 { return manager_->resolve(componentType_); }
124
126 OUString name_;
127 OUString componentType_;
128};
129
130class PublishableDescription:
131 public cppu::WeakImplHelper< css::reflection::XPublished >
132{
133protected:
134 explicit PublishableDescription(bool published): published_(published) {}
135
136 virtual ~PublishableDescription() override {}
137
138private:
139 virtual sal_Bool SAL_CALL isPublished() override
140 { return published_; }
141
142 bool published_;
143};
144
145class ModuleDescription:
146 public cppu::WeakImplHelper< css::reflection::XModuleTypeDescription >
147{
148public:
149 ModuleDescription(
151 OUString name,
153 manager_(manager), name_(std::move(name)), entity_(entity)
154 { assert(manager.is()); assert(entity.is()); }
155
156private:
157 virtual ~ModuleDescription() override {}
158
159 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
160 { return css::uno::TypeClass_MODULE; }
161
162 virtual OUString SAL_CALL getName() override
163 { return name_; }
164
165 virtual
166 css::uno::Sequence<
167 css::uno::Reference< css::reflection::XTypeDescription > >
168 SAL_CALL getMembers() override;
169
171 OUString name_;
173};
174
175css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
176ModuleDescription::getMembers() {
177 try {
178 std::vector< OUString > names(entity_->getMemberNames());
179 assert(names.size() <= SAL_MAX_INT32);
180 sal_Int32 n = static_cast< sal_Int32 >(names.size());
181 css::uno::Sequence<
182 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
183 auto r = asNonConstRange(s);
184 for (sal_Int32 i = 0; i != n; ++i) {
185 r[i] = manager_->resolve(makePrefix(name_) + names[i]);
186 }
187 return s;
188 } catch (unoidl::FileFormatException & e) {
189 throw css::uno::DeploymentException(
190 e.getUri() + ": " + e.getDetail(),
191 static_cast< cppu::OWeakObject * >(this));
192 }
193}
194
195typedef cppu::ImplInheritanceHelper<
196 PublishableDescription, css::reflection::XEnumTypeDescription >
197EnumTypeDescription_Base;
198
199class EnumTypeDescription: public EnumTypeDescription_Base {
200public:
201 EnumTypeDescription(
202 OUString name,
204 EnumTypeDescription_Base(entity->isPublished()), name_(std::move(name)),
205 entity_(entity)
206 { assert(entity.is()); }
207
208private:
209 virtual ~EnumTypeDescription() override {}
210
211 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
212 { return css::uno::TypeClass_ENUM; }
213
214 virtual OUString SAL_CALL getName() override
215 { return name_; }
216
217 virtual sal_Int32 SAL_CALL getDefaultEnumValue() override
218 { return entity_->getMembers()[0].value; }
219
220 virtual css::uno::Sequence< OUString > SAL_CALL getEnumNames() override;
221
222 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getEnumValues() override;
223
224 OUString name_;
226};
227
228css::uno::Sequence< OUString > EnumTypeDescription::getEnumNames()
229{
230 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
231 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
232 css::uno::Sequence< OUString > s(n);
233 auto r = asNonConstRange(s);
234 for (sal_Int32 i = 0; i != n; ++i) {
235 r[i] = entity_->getMembers()[i].name;
236 }
237 return s;
238}
239
240css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
241{
242 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
243 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
244 css::uno::Sequence< sal_Int32 > s(n);
245 auto r = asNonConstRange(s);
246 for (sal_Int32 i = 0; i != n; ++i) {
247 r[i] = entity_->getMembers()[i].value;
248 }
249 return s;
250}
251
252typedef cppu::ImplInheritanceHelper<
253 PublishableDescription, css::reflection::XStructTypeDescription >
254PlainStructTypeDescription_Base;
255
256class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
257public:
258 PlainStructTypeDescription(
260 OUString name,
262 PlainStructTypeDescription_Base(entity->isPublished()),
263 manager_(manager), name_(std::move(name)), entity_(entity)
264 { assert(manager.is()); assert(entity.is()); }
265
266private:
267 virtual ~PlainStructTypeDescription() override {}
268
269 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
270 { return css::uno::TypeClass_STRUCT; }
271
272 virtual OUString SAL_CALL getName() override
273 { return name_; }
274
275 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
276 getBaseType() override {
277 return entity_->getDirectBase().isEmpty()
278 ? css::uno::Reference< css::reflection::XTypeDescription >()
279 : manager_->resolve(entity_->getDirectBase());
280 }
281
282 virtual
283 css::uno::Sequence<
284 css::uno::Reference< css::reflection::XTypeDescription > >
285 SAL_CALL getMemberTypes() override;
286
287 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
288
289 virtual css::uno::Sequence< OUString > SAL_CALL getTypeParameters() override
290 { return css::uno::Sequence< OUString >(); }
291
292 virtual
293 css::uno::Sequence<
294 css::uno::Reference< css::reflection::XTypeDescription > >
295 SAL_CALL getTypeArguments() override {
296 return css::uno::Sequence<
297 css::uno::Reference< css::reflection::XTypeDescription > >();
298 }
299
301 OUString name_;
303};
304
305css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
306PlainStructTypeDescription::getMemberTypes()
307{
308 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
309 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
310 css::uno::Sequence<
311 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
312 auto r = asNonConstRange(s);
313 for (sal_Int32 i = 0; i != n; ++i) {
314 r[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
315 }
316 return s;
317}
318
319css::uno::Sequence< OUString > PlainStructTypeDescription::getMemberNames()
320{
321 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
322 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
323 css::uno::Sequence< OUString > s(n);
324 auto r = asNonConstRange(s);
325 for (sal_Int32 i = 0; i != n; ++i) {
326 r[i] = entity_->getDirectMembers()[i].name;
327 }
328 return s;
329}
330
331class ParameterizedMemberTypeDescription:
332 public cppu::WeakImplHelper< css::reflection::XTypeDescription >
333{
334public:
335 explicit ParameterizedMemberTypeDescription(
336 OUString typeParameterName):
337 typeParameterName_(std::move(typeParameterName))
338 {}
339
340private:
341 virtual ~ParameterizedMemberTypeDescription() override {}
342
343 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
344 { return css::uno::TypeClass_UNKNOWN; }
345
346 virtual OUString SAL_CALL getName() override
347 { return typeParameterName_; }
348
349 OUString typeParameterName_;
350};
351
352typedef cppu::ImplInheritanceHelper<
353 PublishableDescription, css::reflection::XStructTypeDescription >
354PolymorphicStructTypeTemplateDescription_Base;
355
356class PolymorphicStructTypeTemplateDescription:
357 public PolymorphicStructTypeTemplateDescription_Base
358{
359public:
360 PolymorphicStructTypeTemplateDescription(
362 OUString name,
364 entity):
365 PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
366 manager_(manager), name_(std::move(name)), entity_(entity)
367 { assert(manager.is()); assert(entity.is()); }
368
369private:
370 virtual ~PolymorphicStructTypeTemplateDescription() override {}
371
372 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
373 { return css::uno::TypeClass_STRUCT; }
374
375 virtual OUString SAL_CALL getName() override
376 { return name_; }
377
378 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
379 getBaseType() override
380 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
381
382 virtual
383 css::uno::Sequence<
384 css::uno::Reference< css::reflection::XTypeDescription > >
385 SAL_CALL getMemberTypes() override;
386
387 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
388
389 virtual css::uno::Sequence< OUString > SAL_CALL getTypeParameters() override;
390
391 virtual
392 css::uno::Sequence<
393 css::uno::Reference< css::reflection::XTypeDescription > >
394 SAL_CALL getTypeArguments() override {
395 return css::uno::Sequence<
396 css::uno::Reference< css::reflection::XTypeDescription > >();
397 }
398
400 OUString name_;
402};
403
404css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
405PolymorphicStructTypeTemplateDescription::getMemberTypes()
406{
407 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
408 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
409 css::uno::Sequence<
410 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
411 auto r = asNonConstRange(s);
412 for (sal_Int32 i = 0; i != n; ++i) {
413 r[i] = entity_->getMembers()[i].parameterized
414 ? new ParameterizedMemberTypeDescription(
415 entity_->getMembers()[i].type)
416 : manager_->resolve(entity_->getMembers()[i].type);
417 }
418 return s;
419}
420
421css::uno::Sequence< OUString >
422PolymorphicStructTypeTemplateDescription::getMemberNames()
423{
424 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
425 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
426 css::uno::Sequence< OUString > s(n);
427 auto r = asNonConstRange(s);
428 for (sal_Int32 i = 0; i != n; ++i) {
429 r[i] = entity_->getMembers()[i].name;
430 }
431 return s;
432}
433
434css::uno::Sequence< OUString >
435PolymorphicStructTypeTemplateDescription::getTypeParameters()
436{
437 assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32);
438 sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size());
439 css::uno::Sequence< OUString > s(n);
440 auto r = asNonConstRange(s);
441 for (sal_Int32 i = 0; i != n; ++i) {
442 r[i] = entity_->getTypeParameters()[i];
443 }
444 return s;
445}
446
447class InstantiatedPolymorphicStructTypeDescription:
448 public cppu::WeakImplHelper< css::reflection::XStructTypeDescription >
449{
450public:
451 InstantiatedPolymorphicStructTypeDescription(
453 OUString name,
455 entity,
456 std::vector< OUString >&& arguments):
457 manager_(manager), name_(std::move(name)), entity_(entity), arguments_(std::move(arguments))
458 {
459 assert(manager.is());
460 assert(entity.is());
461 assert(arguments_.size() == entity->getTypeParameters().size());
462 }
463
464private:
465 virtual ~InstantiatedPolymorphicStructTypeDescription() override {}
466
467 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
468 { return css::uno::TypeClass_STRUCT; }
469
470 virtual OUString SAL_CALL getName() override
471 { return name_; }
472
473 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
474 getBaseType() override
475 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
476
477 virtual
478 css::uno::Sequence<
479 css::uno::Reference< css::reflection::XTypeDescription > >
480 SAL_CALL getMemberTypes() override;
481
482 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
483
484 virtual css::uno::Sequence< OUString > SAL_CALL getTypeParameters() override
485 { return css::uno::Sequence< OUString >(); }
486
487 virtual
488 css::uno::Sequence<
489 css::uno::Reference< css::reflection::XTypeDescription > >
490 SAL_CALL getTypeArguments() override;
491
493 OUString name_;
495 std::vector< OUString > arguments_;
496};
497
498css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
499InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
500{
501 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
502 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
503 css::uno::Sequence<
504 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
505 auto r = asNonConstRange(s);
506 for (sal_Int32 i = 0; i != n; ++i) {
507 OUString type(entity_->getMembers()[i].type);
508 if (entity_->getMembers()[i].parameterized) {
509 auto j = std::find(entity_->getTypeParameters().begin(), entity_->getTypeParameters().end(), type);
510 if (j != entity_->getTypeParameters().end()) {
511 type = arguments_[j - entity_->getTypeParameters().begin()];
512 goto found;
513 }
514 assert(false); // this cannot happen //TODO!
515 found:;
516 }
517 r[i] = manager_->resolve(type);
518 }
519 return s;
520}
521
522css::uno::Sequence< OUString >
523InstantiatedPolymorphicStructTypeDescription::getMemberNames()
524{
525 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
526 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
527 css::uno::Sequence< OUString > s(n);
528 auto r = asNonConstRange(s);
529 for (sal_Int32 i = 0; i != n; ++i) {
530 r[i] = entity_->getMembers()[i].name;
531 }
532 return s;
533}
534css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
535InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
536{
537 assert(arguments_.size() <= SAL_MAX_INT32);
538 sal_Int32 n = static_cast< sal_Int32 >(arguments_.size());
539 css::uno::Sequence<
540 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
541 auto r = asNonConstRange(s);
542 for (sal_Int32 i = 0; i != n; ++i) {
543 r[i] = manager_->resolve(arguments_[i]);
544 }
545 return s;
546}
547
548typedef cppu::ImplInheritanceHelper<
549 PublishableDescription, css::reflection::XCompoundTypeDescription >
550ExceptionTypeDescription_Base;
551
552class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
553public:
554 ExceptionTypeDescription(
556 OUString name,
558 ExceptionTypeDescription_Base(entity->isPublished()), manager_(manager),
559 name_(std::move(name)), entity_(entity)
560 { assert(manager.is()); assert(entity.is()); }
561
562private:
563 virtual ~ExceptionTypeDescription() override {}
564
565 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
566 { return css::uno::TypeClass_EXCEPTION; }
567
568 virtual OUString SAL_CALL getName() override
569 { return name_; }
570
571 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
572 getBaseType() override {
573 return entity_->getDirectBase().isEmpty()
574 ? css::uno::Reference< css::reflection::XTypeDescription >()
575 : manager_->resolve(entity_->getDirectBase());
576 }
577
578 virtual
579 css::uno::Sequence<
580 css::uno::Reference< css::reflection::XTypeDescription > >
581 SAL_CALL getMemberTypes() override;
582
583 virtual css::uno::Sequence< OUString > SAL_CALL getMemberNames() override;
584
586 OUString name_;
588};
589
590css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
591ExceptionTypeDescription::getMemberTypes() {
592 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
593 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
594 css::uno::Sequence<
595 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
596 auto r = asNonConstRange(s);
597 for (sal_Int32 i = 0; i != n; ++i) {
598 r[i] = manager_->resolve(entity_->getDirectMembers()[i].type);
599 }
600 return s;
601}
602
603css::uno::Sequence< OUString > ExceptionTypeDescription::getMemberNames()
604{
605 assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
606 sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
607 css::uno::Sequence< OUString > s(n);
608 auto r = asNonConstRange(s);
609 for (sal_Int32 i = 0; i != n; ++i) {
610 r[i] = entity_->getDirectMembers()[i].name;
611 }
612 return s;
613}
614
615class AttributeDescription:
616 public cppu::WeakImplHelper<
617 css::reflection::XInterfaceAttributeTypeDescription2 >
618{
619public:
620 AttributeDescription(
622 OUString name,
624 sal_Int32 position):
625 manager_(manager), name_(std::move(name)), attribute_(std::move(attribute)),
626 position_(position)
627 { assert(manager.is()); }
628
629private:
630 virtual ~AttributeDescription() override {}
631
632 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
633 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE; }
634
635 virtual OUString SAL_CALL getName() override
636 { return name_; }
637
638 virtual OUString SAL_CALL getMemberName() override
639 { return attribute_.name; }
640
641 virtual sal_Int32 SAL_CALL getPosition() override
642 { return position_; }
643
644 virtual sal_Bool SAL_CALL isReadOnly() override
645 { return attribute_.readOnly; }
646
647 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
648 getType() override
649 { return manager_->resolve(attribute_.type); }
650
651 virtual sal_Bool SAL_CALL isBound() override
652 { return attribute_.bound; }
653
654 virtual
655 css::uno::Sequence<
656 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
657 SAL_CALL getGetExceptions() override;
658
659 virtual
660 css::uno::Sequence<
661 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
662 SAL_CALL getSetExceptions() override;
663
665 OUString name_;
667 sal_Int32 position_;
668};
669
670css::uno::Sequence<
671 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
672AttributeDescription::getGetExceptions() {
673 assert(attribute_.getExceptions.size() <= SAL_MAX_INT32);
674 sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size());
675 css::uno::Sequence<
676 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
677 auto r = asNonConstRange(s);
678 for (sal_Int32 i = 0; i != n; ++i) {
679 r[i].set(
680 manager_->resolve(attribute_.getExceptions[i]),
681 css::uno::UNO_QUERY_THROW);
682 }
683 return s;
684}
685
686css::uno::Sequence<
687 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
688AttributeDescription::getSetExceptions() {
689 assert(attribute_.setExceptions.size() <= SAL_MAX_INT32);
690 sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size());
691 css::uno::Sequence<
692 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
693 auto r = asNonConstRange(s);
694 for (sal_Int32 i = 0; i != n; ++i) {
695 r[i].set(
696 manager_->resolve(attribute_.setExceptions[i]),
697 css::uno::UNO_QUERY_THROW);
698 }
699 return s;
700}
701
702class MethodParameter:
703 public cppu::WeakImplHelper< css::reflection::XMethodParameter >
704{
705public:
706 MethodParameter(
709 sal_Int32 position):
710 manager_(manager), parameter_(std::move(parameter)), position_(position)
711 { assert(manager.is()); }
712
713private:
714 virtual ~MethodParameter() override {}
715
716 virtual OUString SAL_CALL getName() override
717 { return parameter_.name; }
718
719 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
720 getType() override
721 { return manager_->resolve(parameter_.type); }
722
723 virtual sal_Bool SAL_CALL isIn() override {
724 return
725 (parameter_.direction
727 || (parameter_.direction
730 }
731
732 virtual sal_Bool SAL_CALL isOut() override {
733 return
734 (parameter_.direction
736 || (parameter_.direction
739 }
740
741 virtual sal_Int32 SAL_CALL getPosition() override
742 { return position_; }
743
746 sal_Int32 position_;
747};
748
749class MethodDescription:
750 public cppu::WeakImplHelper<
751 css::reflection::XInterfaceMethodTypeDescription >
752{
753public:
754 MethodDescription(
756 OUString name,
757 unoidl::InterfaceTypeEntity::Method method, sal_Int32 position):
758 manager_(manager), name_(std::move(name)), method_(std::move(method)), position_(position)
759 { assert(manager.is()); }
760
761private:
762 virtual ~MethodDescription() override {}
763
764 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
765 { return css::uno::TypeClass_INTERFACE_METHOD; }
766
767 virtual OUString SAL_CALL getName() override
768 { return name_; }
769
770 virtual OUString SAL_CALL getMemberName() override
771 { return method_.name; }
772
773 virtual sal_Int32 SAL_CALL getPosition() override
774 { return position_; }
775
776 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
777 getReturnType() override
778 { return manager_->resolve(method_.returnType); }
779
780 virtual sal_Bool SAL_CALL isOneway() override
781 { return false; }
782
783 virtual
784 css::uno::Sequence<
785 css::uno::Reference< css::reflection::XMethodParameter > >
786 SAL_CALL getParameters() override;
787
788 virtual
789 css::uno::Sequence<
790 css::uno::Reference< css::reflection::XTypeDescription > >
791 SAL_CALL getExceptions() override;
792
794 OUString name_;
796 sal_Int32 position_;
797};
798
799css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > >
800MethodDescription::getParameters() {
801 assert(method_.parameters.size() <= SAL_MAX_INT32);
802 sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size());
803 css::uno::Sequence<
804 css::uno::Reference< css::reflection::XMethodParameter > > s(n);
805 auto r = asNonConstRange(s);
806 for (sal_Int32 i = 0; i != n; ++i) {
807 r[i] = new MethodParameter(manager_, method_.parameters[i], i);
808 }
809 return s;
810}
811
812css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
813MethodDescription::getExceptions() {
814 assert(method_.exceptions.size() <= SAL_MAX_INT32);
815 sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size());
816 css::uno::Sequence<
817 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
818 auto r = asNonConstRange(s);
819 for (sal_Int32 i = 0; i != n; ++i) {
820 r[i] = manager_->resolve(method_.exceptions[i]);
821 }
822 return s;
823}
824
825class BaseOffset {
826public:
827 explicit BaseOffset(
828 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
829 const & description);
830
831 BaseOffset(const BaseOffset&) = delete;
832 const BaseOffset& operator=(const BaseOffset&) = delete;
833
834 sal_Int32 get() const { return offset_; }
835
836private:
837 void calculateBases(
838 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
839 const & description);
840
841 void calculate(
842 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
843 const & description);
844
845 std::set< OUString > set_;
846 sal_Int32 offset_;
847};
848
849BaseOffset::BaseOffset(
850 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
851 description):
852 offset_(0)
853{
854 calculateBases(description);
855}
856
857void BaseOffset::calculateBases(
858 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
859 description)
860{
861 const css::uno::Sequence<
862 css::uno::Reference < css::reflection::XTypeDescription > > bases(
863 description->getBaseTypes());
864 for (const auto & i : bases) {
865 calculate(
866 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
867 resolveTypedefs(css::uno::Any(i)),
868 css::uno::UNO_QUERY_THROW));
869 }
870}
871
872void BaseOffset::calculate(
873 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
874 description)
875{
876 if (set_.insert(description->getName()).second) {
877 calculateBases(description);
878 offset_ += description->getMembers().getLength();
879 }
880}
881
882typedef cppu::ImplInheritanceHelper<
883 PublishableDescription, css::reflection::XInterfaceTypeDescription2 >
884InterfaceTypeDescription_Base;
885
886class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
887public:
888 InterfaceTypeDescription(
890 OUString name,
892 InterfaceTypeDescription_Base(entity->isPublished()), manager_(manager),
893 name_(std::move(name)), entity_(entity)
894 { assert(manager.is()); assert(entity.is()); }
895
896private:
897 virtual ~InterfaceTypeDescription() override {}
898
899 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
900 { return css::uno::TypeClass_INTERFACE; }
901
902 virtual OUString SAL_CALL getName() override
903 { return name_; }
904
905 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
906 getBaseType() override {
907 return entity_->getDirectMandatoryBases().empty()
908 ? css::uno::Reference< css::reflection::XTypeDescription >()
909 : manager_->resolve(entity_->getDirectMandatoryBases()[0].name);
910 }
911
912 virtual css::uno::Uik SAL_CALL getUik() override
913 { return css::uno::Uik(); }
914
915 virtual
916 css::uno::Sequence<
917 css::uno::Reference<
918 css::reflection::XInterfaceMemberTypeDescription > >
919 SAL_CALL getMembers() override;
920
921 virtual
922 css::uno::Sequence<
923 css::uno::Reference< css::reflection::XTypeDescription > >
924 SAL_CALL getBaseTypes() override;
925
926 virtual
927 css::uno::Sequence<
928 css::uno::Reference< css::reflection::XTypeDescription > >
929 SAL_CALL getOptionalBaseTypes() override;
930
932 OUString name_;
934};
935
936css::uno::Sequence<
937 css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
938InterfaceTypeDescription::getMembers() {
939 assert(
940 entity_->getDirectAttributes().size() <= SAL_MAX_INT32
941 && (entity_->getDirectMethods().size()
942 <= SAL_MAX_INT32 - entity_->getDirectAttributes().size()));
943 sal_Int32 n1 = static_cast< sal_Int32 >(
944 entity_->getDirectAttributes().size());
945 sal_Int32 n2 = static_cast< sal_Int32 >(entity_->getDirectMethods().size());
946 css::uno::Sequence<
947 css::uno::Reference<
948 css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2);
949 auto r = asNonConstRange(s);
950 sal_Int32 off = BaseOffset(this).get();
951 for (sal_Int32 i = 0; i != n1; ++i) {
952 r[i] = new AttributeDescription(
953 manager_, name_ + "::" + entity_->getDirectAttributes()[i].name,
954 entity_->getDirectAttributes()[i], off + i);
955 }
956 for (sal_Int32 i = 0; i != n2; ++i) {
957 r[n1 + i] = new MethodDescription(
958 manager_, name_ + "::" + entity_->getDirectMethods()[i].name,
959 entity_->getDirectMethods()[i], off + n1 + i);
960 }
961 return s;
962}
963
964css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
965InterfaceTypeDescription::getBaseTypes() {
966 assert(entity_->getDirectMandatoryBases().size() <= SAL_MAX_INT32);
967 sal_Int32 n = static_cast< sal_Int32 >(
968 entity_->getDirectMandatoryBases().size());
969 css::uno::Sequence<
970 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
971 auto r = asNonConstRange(s);
972 for (sal_Int32 i = 0; i != n; ++i) {
973 r[i] = manager_->resolve(entity_->getDirectMandatoryBases()[i].name);
974 }
975 return s;
976}
977
978css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
979InterfaceTypeDescription::getOptionalBaseTypes()
980{
981 assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
982 sal_Int32 n = static_cast< sal_Int32 >(
983 entity_->getDirectOptionalBases().size());
984 css::uno::Sequence<
985 css::uno::Reference< css::reflection::XTypeDescription > > s(n);
986 auto r = asNonConstRange(s);
987 for (sal_Int32 i = 0; i != n; ++i) {
988 r[i] = manager_->resolve(entity_->getDirectOptionalBases()[i].name);
989 }
990 return s;
991}
992
993class ConstantDescription:
994 public cppu::WeakImplHelper< css::reflection::XConstantTypeDescription >
995{
996public:
997 ConstantDescription(
998 OUString const & constantGroupName,
1000
1001private:
1002 virtual ~ConstantDescription() override {}
1003
1004 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1005 { return css::uno::TypeClass_CONSTANT; }
1006
1007 virtual OUString SAL_CALL getName() override
1008 { return name_; }
1009
1010 virtual css::uno::Any SAL_CALL getConstantValue() override
1011 { return value_; }
1012
1013 OUString name_;
1014 css::uno::Any value_;
1015};
1016
1017ConstantDescription::ConstantDescription(
1018 OUString const & constantGroupName,
1020 name_(makePrefix(constantGroupName) + member.name)
1021{
1022 switch (member.value.type) {
1024 value_ <<= member.value.booleanValue;
1025 break;
1027 value_ <<= member.value.byteValue;
1028 break;
1030 value_ <<= member.value.shortValue;
1031 break;
1033 value_ <<= member.value.unsignedShortValue;
1034 break;
1036 value_ <<= member.value.longValue;
1037 break;
1039 value_ <<= member.value.unsignedLongValue;
1040 break;
1042 value_ <<= member.value.hyperValue;
1043 break;
1045 value_ <<= member.value.unsignedHyperValue;
1046 break;
1048 value_ <<= member.value.floatValue;
1049 break;
1051 value_ <<= member.value.doubleValue;
1052 break;
1053 default:
1054 for (;;) { std::abort(); } // this cannot happen
1055 }
1056}
1057
1058typedef cppu::ImplInheritanceHelper<
1059 PublishableDescription, css::reflection::XConstantsTypeDescription >
1060ConstantGroupDescription_Base;
1061
1062class ConstantGroupDescription: public ConstantGroupDescription_Base {
1063public:
1064 ConstantGroupDescription(
1065 OUString name,
1067 ConstantGroupDescription_Base(entity->isPublished()), name_(std::move(name)),
1068 entity_(entity)
1069 { assert(entity.is()); }
1070
1071private:
1072 virtual ~ConstantGroupDescription() override {}
1073
1074 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1075 { return css::uno::TypeClass_CONSTANTS; }
1076
1077 virtual OUString SAL_CALL getName() override
1078 { return name_; }
1079
1080 virtual
1081 css::uno::Sequence<
1082 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1083 SAL_CALL getConstants() override;
1084
1085 OUString name_;
1087};
1088
1089css::uno::Sequence<
1090 css::uno::Reference< css::reflection::XConstantTypeDescription > >
1091ConstantGroupDescription::getConstants() {
1092 assert(entity_->getMembers().size() <= SAL_MAX_INT32);
1093 sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
1094 css::uno::Sequence<
1095 css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n);
1096 auto r = asNonConstRange(s);
1097 for (sal_Int32 i = 0; i != n; ++i) {
1098 r[i] = new ConstantDescription(name_, entity_->getMembers()[i]);
1099 }
1100 return s;
1101}
1102
1103typedef cppu::ImplInheritanceHelper<
1104 PublishableDescription, css::reflection::XIndirectTypeDescription >
1105TypedefDescription_Base;
1106
1107class TypedefDescription: public TypedefDescription_Base {
1108public:
1109 TypedefDescription(
1111 OUString name,
1113 TypedefDescription_Base(entity->isPublished()), manager_(manager),
1114 name_(std::move(name)), entity_(entity)
1115 { assert(manager.is()); assert(entity.is()); }
1116
1117private:
1118 virtual ~TypedefDescription() override {}
1119
1120 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1121 { return css::uno::TypeClass_TYPEDEF; }
1122
1123 virtual OUString SAL_CALL getName() override
1124 { return name_; }
1125
1126 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1127 getReferencedType() override
1128 { return manager_->resolve(entity_->getType()); }
1129
1131 OUString name_;
1133};
1134
1135class ConstructorParameter:
1136 public cppu::WeakImplHelper< css::reflection::XParameter >
1137{
1138public:
1139 ConstructorParameter(
1142 sal_Int32 position):
1143 manager_(manager), parameter_(std::move(parameter)), position_(position)
1144 { assert(manager.is()); }
1145
1146private:
1147 virtual ~ConstructorParameter() override {}
1148
1149 virtual OUString SAL_CALL getName() override
1150 { return parameter_.name; }
1151
1152 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1153 getType() override
1154 { return manager_->resolve(parameter_.type); }
1155
1156 virtual sal_Bool SAL_CALL isIn() override
1157 { return true; }
1158
1159 virtual sal_Bool SAL_CALL isOut() override
1160 { return false; }
1161
1162 virtual sal_Int32 SAL_CALL getPosition() override
1163 { return position_; }
1164
1165 virtual sal_Bool SAL_CALL isRestParameter() override
1166 { return parameter_.rest; }
1167
1170 parameter_;
1171 sal_Int32 position_;
1172};
1173
1174class ConstructorDescription:
1175 public cppu::WeakImplHelper<
1176 css::reflection::XServiceConstructorDescription >
1177{
1178public:
1179 ConstructorDescription(
1182 manager_(manager), constructor_(std::move(constructor))
1183 { assert(manager.is()); }
1184
1185private:
1186 virtual ~ConstructorDescription() override {}
1187
1188 virtual sal_Bool SAL_CALL isDefaultConstructor() override
1189 { return constructor_.defaultConstructor; }
1190
1191 virtual OUString SAL_CALL getName() override
1192 { return constructor_.name; }
1193
1194 virtual
1195 css::uno::Sequence<
1196 css::uno::Reference< css::reflection::XParameter > >
1197 SAL_CALL getParameters() override;
1198
1199 virtual
1200 css::uno::Sequence<
1201 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1202 SAL_CALL getExceptions() override;
1203
1206};
1207
1208css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
1209ConstructorDescription::getParameters() {
1210 assert(constructor_.parameters.size() <= SAL_MAX_INT32);
1211 sal_Int32 n = static_cast< sal_Int32 >(constructor_.parameters.size());
1212 css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > > s(
1213 n);
1214 auto r = asNonConstRange(s);
1215 for (sal_Int32 i = 0; i != n; ++i) {
1216 r[i] = new ConstructorParameter(
1217 manager_, constructor_.parameters[i], i);
1218 }
1219 return s;
1220}
1221
1222css::uno::Sequence<
1223 css::uno::Reference< css::reflection::XCompoundTypeDescription > >
1224ConstructorDescription::getExceptions() {
1225 assert(constructor_.exceptions.size() <= SAL_MAX_INT32);
1226 sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size());
1227 css::uno::Sequence<
1228 css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
1229 auto r = asNonConstRange(s);
1230 for (sal_Int32 i = 0; i != n; ++i) {
1231 r[i].set(
1232 manager_->resolve(constructor_.exceptions[i]),
1233 css::uno::UNO_QUERY_THROW);
1234 }
1235 return s;
1236}
1237
1238typedef cppu::ImplInheritanceHelper<
1239 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1240SingleInterfaceBasedServiceDescription_Base;
1241
1242class SingleInterfaceBasedServiceDescription:
1243 public SingleInterfaceBasedServiceDescription_Base
1244{
1245public:
1246 SingleInterfaceBasedServiceDescription(
1248 OUString name,
1250 entity):
1251 SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
1252 manager_(manager), name_(std::move(name)), entity_(entity)
1253 { assert(manager.is()); assert(entity.is()); }
1254
1255private:
1256 virtual ~SingleInterfaceBasedServiceDescription() override {}
1257
1258 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1259 { return css::uno::TypeClass_SERVICE; }
1260
1261 virtual OUString SAL_CALL getName() override
1262 { return name_; }
1263
1264 virtual
1265 css::uno::Sequence<
1266 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1267 SAL_CALL getMandatoryServices() override
1268 {
1269 return css::uno::Sequence<
1270 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1271 }
1272
1273 virtual
1274 css::uno::Sequence<
1275 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1276 SAL_CALL getOptionalServices() override
1277 {
1278 return css::uno::Sequence<
1279 css::uno::Reference< css::reflection::XServiceTypeDescription > >();
1280 }
1281
1282 virtual
1283 css::uno::Sequence<
1284 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1285 SAL_CALL getMandatoryInterfaces() override
1286 {
1287 return css::uno::Sequence<
1288 css::uno::Reference<
1289 css::reflection::XInterfaceTypeDescription > >();
1290 }
1291
1292 virtual
1293 css::uno::Sequence<
1294 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1295 SAL_CALL getOptionalInterfaces() override
1296 {
1297 return css::uno::Sequence<
1298 css::uno::Reference<
1299 css::reflection::XInterfaceTypeDescription > >();
1300 }
1301
1302 virtual
1303 css::uno::Sequence<
1304 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1305 SAL_CALL getProperties() override
1306 {
1307 return css::uno::Sequence<
1308 css::uno::Reference<
1309 css::reflection::XPropertyTypeDescription > >();
1310 }
1311
1312 virtual sal_Bool SAL_CALL isSingleInterfaceBased() override
1313 { return true; }
1314
1315 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1316 getInterface() override
1317 { return manager_->resolve(entity_->getBase()); }
1318
1319 virtual
1320 css::uno::Sequence<
1321 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1322 SAL_CALL getConstructors() override;
1323
1325 OUString name_;
1327};
1328
1329css::uno::Sequence<
1330 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1331SingleInterfaceBasedServiceDescription::getConstructors()
1332{
1333 assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
1334 sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
1335 css::uno::Sequence<
1336 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1337 s(n);
1338 auto r = asNonConstRange(s);
1339 for (sal_Int32 i = 0; i != n; ++i) {
1340 r[i] = new ConstructorDescription(
1341 manager_, entity_->getConstructors()[i]);
1342 }
1343 return s;
1344}
1345
1346class PropertyDescription:
1347 public cppu::WeakImplHelper< css::reflection::XPropertyTypeDescription >
1348{
1349public:
1350 PropertyDescription(
1353 manager_(manager), property_(std::move(property))
1354 { assert(manager.is()); }
1355
1356private:
1357 virtual ~PropertyDescription() override {}
1358
1359 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1360 { return css::uno::TypeClass_PROPERTY; }
1361
1362 virtual OUString SAL_CALL getName() override
1363 { return property_.name; }
1364
1365 virtual sal_Int16 SAL_CALL getPropertyFlags() override
1366 { return property_.attributes; }
1367
1368 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1369 getPropertyTypeDescription() override
1370 { return manager_->resolve(property_.type); }
1371
1374};
1375
1376typedef cppu::ImplInheritanceHelper<
1377 PublishableDescription, css::reflection::XServiceTypeDescription2 >
1378AccumulationBasedServiceDescription_Base;
1379
1380class AccumulationBasedServiceDescription:
1381 public AccumulationBasedServiceDescription_Base
1382{
1383public:
1384 AccumulationBasedServiceDescription(
1386 OUString name,
1388 entity):
1389 AccumulationBasedServiceDescription_Base(entity->isPublished()),
1390 manager_(manager), name_(std::move(name)), entity_(entity)
1391 { assert(manager.is()); assert(entity.is()); }
1392
1393private:
1394 virtual ~AccumulationBasedServiceDescription() override {}
1395
1396 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1397 { return css::uno::TypeClass_SERVICE; }
1398
1399 virtual OUString SAL_CALL getName() override
1400 { return name_; }
1401
1402 virtual
1403 css::uno::Sequence<
1404 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1405 SAL_CALL getMandatoryServices() override;
1406
1407 virtual
1408 css::uno::Sequence<
1409 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1410 SAL_CALL getOptionalServices() override;
1411
1412 virtual
1413 css::uno::Sequence<
1414 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1415 SAL_CALL getMandatoryInterfaces() override;
1416
1417 virtual
1418 css::uno::Sequence<
1419 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1420 SAL_CALL getOptionalInterfaces() override;
1421
1422 virtual
1423 css::uno::Sequence<
1424 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1425 SAL_CALL getProperties() override;
1426
1427 virtual sal_Bool SAL_CALL isSingleInterfaceBased() override
1428 { return false; }
1429
1430 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1431 getInterface() override
1432 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1433
1434 virtual
1435 css::uno::Sequence<
1436 css::uno::Reference< css::reflection::XServiceConstructorDescription > >
1437 SAL_CALL getConstructors() override
1438 {
1439 return css::uno::Sequence<
1440 css::uno::Reference<
1441 css::reflection::XServiceConstructorDescription > >();
1442 }
1443
1445 OUString name_;
1447};
1448
1449css::uno::Sequence<
1450 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1451AccumulationBasedServiceDescription::getMandatoryServices()
1452{
1453 assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
1454 sal_Int32 n = static_cast< sal_Int32 >(
1455 entity_->getDirectMandatoryBaseServices().size());
1456 css::uno::Sequence<
1457 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1458 auto r = asNonConstRange(s);
1459 for (sal_Int32 i = 0; i != n; ++i) {
1460 r[i].set(
1461 manager_->resolve(
1462 entity_->getDirectMandatoryBaseServices()[i].name),
1463 css::uno::UNO_QUERY_THROW);
1464 }
1465 return s;
1466}
1467
1468css::uno::Sequence<
1469 css::uno::Reference< css::reflection::XServiceTypeDescription > >
1470AccumulationBasedServiceDescription::getOptionalServices()
1471{
1472 assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
1473 sal_Int32 n = static_cast< sal_Int32 >(
1474 entity_->getDirectOptionalBaseServices().size());
1475 css::uno::Sequence<
1476 css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
1477 auto r = asNonConstRange(s);
1478 for (sal_Int32 i = 0; i != n; ++i) {
1479 r[i].set(
1480 manager_->resolve(entity_->getDirectOptionalBaseServices()[i].name),
1481 css::uno::UNO_QUERY_THROW);
1482 }
1483 return s;
1484}
1485
1486css::uno::Sequence<
1487 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1488AccumulationBasedServiceDescription::getMandatoryInterfaces()
1489{
1490 assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
1491 sal_Int32 n = static_cast< sal_Int32 >(
1492 entity_->getDirectMandatoryBaseInterfaces().size());
1493 css::uno::Sequence<
1494 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1495 n);
1496 auto r = asNonConstRange(s);
1497 for (sal_Int32 i = 0; i != n; ++i) {
1498 r[i].set(
1499 resolveTypedefs(
1500 manager_->find(
1501 entity_->getDirectMandatoryBaseInterfaces()[i].name)),
1502 css::uno::UNO_QUERY_THROW);
1503 }
1504 return s;
1505}
1506
1507css::uno::Sequence<
1508 css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
1509AccumulationBasedServiceDescription::getOptionalInterfaces()
1510{
1511 assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
1512 sal_Int32 n = static_cast< sal_Int32 >(
1513 entity_->getDirectOptionalBaseInterfaces().size());
1514 css::uno::Sequence<
1515 css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
1516 n);
1517 auto r = asNonConstRange(s);
1518 for (sal_Int32 i = 0; i != n; ++i) {
1519 r[i].set(
1520 resolveTypedefs(
1521 manager_->find(
1522 entity_->getDirectOptionalBaseInterfaces()[i].name)),
1523 css::uno::UNO_QUERY_THROW);
1524 }
1525 return s;
1526}
1527
1528css::uno::Sequence<
1529 css::uno::Reference< css::reflection::XPropertyTypeDescription > >
1530AccumulationBasedServiceDescription::getProperties()
1531{
1532 assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
1533 sal_Int32 n = static_cast< sal_Int32 >(
1534 entity_->getDirectProperties().size());
1535 css::uno::Sequence<
1536 css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n);
1537 auto r = asNonConstRange(s);
1538 for (sal_Int32 i = 0; i != n; ++i) {
1539 r[i] = new PropertyDescription(
1540 manager_, entity_->getDirectProperties()[i]);
1541 }
1542 return s;
1543}
1544
1545typedef cppu::ImplInheritanceHelper<
1546 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1547InterfaceBasedSingletonDescription_Base;
1548
1549class InterfaceBasedSingletonDescription:
1550 public InterfaceBasedSingletonDescription_Base
1551{
1552public:
1553 InterfaceBasedSingletonDescription(
1555 OUString name,
1557 InterfaceBasedSingletonDescription_Base(entity->isPublished()),
1558 manager_(manager), name_(std::move(name)), entity_(entity)
1559 { assert(manager.is()); assert(entity.is()); }
1560
1561private:
1562 virtual ~InterfaceBasedSingletonDescription() override {}
1563
1564 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1565 { return css::uno::TypeClass_SINGLETON; }
1566
1567 virtual OUString SAL_CALL getName() override
1568 { return name_; }
1569
1570 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1571 SAL_CALL getService() override
1572 {
1573 return
1574 css::uno::Reference< css::reflection::XServiceTypeDescription >();
1575 }
1576
1577 virtual sal_Bool SAL_CALL isInterfaceBased() override
1578 { return true; }
1579
1580 virtual css::uno::Reference< css::reflection::XTypeDescription >
1581 SAL_CALL getInterface() override
1582 { return manager_->resolve(entity_->getBase()); }
1583
1585 OUString name_;
1587};
1588
1589typedef cppu::ImplInheritanceHelper<
1590 PublishableDescription, css::reflection::XSingletonTypeDescription2 >
1591ServiceBasedSingletonDescription_Base;
1592
1593class ServiceBasedSingletonDescription:
1594 public ServiceBasedSingletonDescription_Base
1595{
1596public:
1597 ServiceBasedSingletonDescription(
1599 OUString name,
1601 ServiceBasedSingletonDescription_Base(entity->isPublished()),
1602 manager_(manager), name_(std::move(name)), entity_(entity)
1603 { assert(manager.is()); assert(entity.is()); }
1604
1605private:
1606 virtual ~ServiceBasedSingletonDescription() override {}
1607
1608 virtual css::uno::TypeClass SAL_CALL getTypeClass() override
1609 { return css::uno::TypeClass_SINGLETON; }
1610
1611 virtual OUString SAL_CALL getName() override
1612 { return name_; }
1613
1614 virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
1615 SAL_CALL getService() override
1616 {
1617 return css::uno::Reference< css::reflection::XServiceTypeDescription >(
1618 manager_->resolve(entity_->getBase()), css::uno::UNO_QUERY_THROW);
1619 }
1620
1621 virtual sal_Bool SAL_CALL isInterfaceBased() override
1622 { return false; }
1623
1624 virtual css::uno::Reference< css::reflection::XTypeDescription >
1625 SAL_CALL getInterface() override
1626 { return css::uno::Reference< css::reflection::XTypeDescription >(); }
1627
1629 OUString name_;
1631};
1632
1633class Enumeration:
1634 public cppu::WeakImplHelper< css::reflection::XTypeDescriptionEnumeration >
1635{
1636public:
1639 OUString const & prefix,
1641 css::uno::Sequence< css::uno::TypeClass > const & types, bool deep):
1642 manager_(manager), types_(types), deep_(deep)
1643 {
1644 assert(manager.is());
1645 positions_.push(Position(prefix, cursor));
1646 findNextMatch();
1647 }
1648
1649private:
1650 virtual ~Enumeration() override {}
1651
1652 virtual sal_Bool SAL_CALL hasMoreElements() override
1653 { return !positions_.empty(); }
1654
1655 virtual css::uno::Any SAL_CALL nextElement() override
1656 { return css::uno::Any(nextTypeDescription()); }
1657
1658 virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
1659 nextTypeDescription() override;
1660
1661 bool matches(css::uno::TypeClass tc) const;
1662
1663 void findNextMatch();
1664
1665 struct Position {
1666 Position(
1667 OUString thePrefix,
1668 rtl::Reference< unoidl::MapCursor > const & theCursor):
1669 prefix(std::move(thePrefix)), cursor(theCursor)
1670 { assert(theCursor.is()); }
1671
1672 Position(
1673 OUString thePrefix,
1675 theConstantGroup):
1676 prefix(std::move(thePrefix)), constantGroup(theConstantGroup),
1677 constantGroupIndex(constantGroup->getMembers().begin())
1678 { assert(theConstantGroup.is()); }
1679
1680 Position(Position const & other):
1681 prefix(other.prefix), cursor(other.cursor),
1682 constantGroup(other.constantGroup)
1683 {
1684 if (constantGroup.is()) {
1685 constantGroupIndex = other.constantGroupIndex;
1686 }
1687 }
1688
1689 OUString prefix;
1692 std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator
1693 constantGroupIndex;
1694 };
1695
1697 css::uno::Sequence< css::uno::TypeClass > types_;
1698 bool deep_;
1699
1700 std::mutex mutex_;
1701 std::stack< Position, std::vector<Position> > positions_;
1702 OUString current_;
1703};
1704
1705css::uno::Reference< css::reflection::XTypeDescription >
1706Enumeration::nextTypeDescription()
1707{
1708 OUString name;
1709 {
1710 std::scoped_lock g(mutex_);
1711 if (positions_.empty()) {
1712 throw css::container::NoSuchElementException(
1713 "exhausted XTypeDescriptionEnumeration",
1714 static_cast< cppu::OWeakObject * >(this));
1715 }
1716 name = current_;
1717 findNextMatch();
1718 }
1719 return manager_->resolve(name);
1720}
1721
1722bool Enumeration::matches(css::uno::TypeClass tc) const {
1723 if (!types_.hasElements()) {
1724 return true;
1725 }
1726 for (const auto & i : types_) {
1727 if (i == tc) {
1728 return true;
1729 }
1730 }
1731 return false;
1732}
1733
1734void Enumeration::findNextMatch() {
1735 try {
1736 for (;;) {
1737 assert(!positions_.empty());
1738 OUString name;
1739 if (positions_.top().cursor.is()) { // root or module
1741 positions_.top().cursor->getNext(&name));
1742 if (!ent.is()) {
1743 positions_.pop();
1744 if (positions_.empty()) {
1745 break;
1746 }
1747 continue;
1748 }
1749 name = positions_.top().prefix + name;
1750 css::uno::TypeClass tc;
1751 switch (ent->getSort()) {
1753 tc = css::uno::TypeClass_MODULE;
1754 if (deep_) {
1755 positions_.push(
1756 Position(
1757 makePrefix(name),
1758 static_cast< unoidl::ModuleEntity * >(
1759 ent.get())->createCursor()));
1760 }
1761 break;
1763 tc = css::uno::TypeClass_ENUM;
1764 break;
1767 tc = css::uno::TypeClass_STRUCT;
1768 break;
1770 tc = css::uno::TypeClass_EXCEPTION;
1771 break;
1773 tc = css::uno::TypeClass_INTERFACE;
1774 break;
1776 tc = css::uno::TypeClass_TYPEDEF;
1777 break;
1779 tc = css::uno::TypeClass_CONSTANTS;
1780 if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
1781 positions_.push(
1782 Position(
1783 makePrefix(name),
1784 static_cast< unoidl::ConstantGroupEntity * >(
1785 ent.get())));
1786 }
1787 break;
1790 tc = css::uno::TypeClass_SERVICE;
1791 break;
1794 tc = css::uno::TypeClass_SINGLETON;
1795 break;
1796 default:
1797 for (;;) { std::abort(); } // this cannot happen
1798 }
1799 if (matches(tc)) {
1800 current_ = name;
1801 break;
1802 }
1803 } else { // constant group
1804 if (positions_.top().constantGroupIndex
1805 == positions_.top().constantGroup->getMembers().end())
1806 {
1807 positions_.pop();
1808 if (positions_.empty()) {
1809 break;
1810 }
1811 continue;
1812 }
1813 current_ = positions_.top().prefix
1814 + positions_.top().constantGroupIndex++->name;
1815 break;
1816 }
1817 }
1818 } catch (unoidl::FileFormatException & e) {
1819 throw css::uno::DeploymentException(
1820 e.getUri() + ": " + e.getDetail(),
1821 static_cast< cppu::OWeakObject * >(this));
1822 }
1823}
1824
1825}
1826
1829 manager_(new unoidl::Manager)
1830{}
1831
1832css::uno::Any cppuhelper::TypeManager::find(OUString const & name) {
1833 //TODO: caching? (here or in unoidl::Manager?)
1834 static constexpr std::pair<std::u16string_view, css::uno::TypeClass> const simple[] = {
1835 { u"void", css::uno::TypeClass_VOID },
1836 { u"boolean", css::uno::TypeClass_BOOLEAN },
1837 { u"byte", css::uno::TypeClass_BYTE },
1838 { u"short", css::uno::TypeClass_SHORT },
1839 { u"unsigned short", css::uno::TypeClass_UNSIGNED_SHORT },
1840 { u"long", css::uno::TypeClass_LONG },
1841 { u"unsigned long", css::uno::TypeClass_UNSIGNED_LONG },
1842 { u"hyper", css::uno::TypeClass_HYPER },
1843 { u"unsigned hyper", css::uno::TypeClass_UNSIGNED_HYPER },
1844 { u"float", css::uno::TypeClass_FLOAT },
1845 { u"double", css::uno::TypeClass_DOUBLE },
1846 { u"char", css::uno::TypeClass_CHAR },
1847 { u"string", css::uno::TypeClass_STRING },
1848 { u"type", css::uno::TypeClass_TYPE },
1849 { u"any", css::uno::TypeClass_ANY } };
1850 for (const auto& [ rName, rTypeClass ] : simple) {
1851 if (name == rName) {
1852 return css::uno::Any(
1853 css::uno::Reference< css::reflection::XTypeDescription >(
1854 new SimpleTypeDescription(rTypeClass, name)));
1855 }
1856 }
1857 if (name.startsWith("[]")) {
1858 return getSequenceType(name);
1859 }
1860 sal_Int32 i = name.indexOf('<');
1861 if (i != -1) {
1862 return getInstantiatedStruct(name, i);
1863 }
1864 i = name.indexOf("::");
1865 if (i != -1) {
1866 return getInterfaceMember(name, i);
1867 }
1868 rtl::Reference< unoidl::Entity > ent(findEntity(name));
1869 if (ent.is()) {
1870 return getNamed(name, ent);
1871 }
1872 i = name.lastIndexOf('.');
1873 if (i != -1) {
1874 OUString parent(name.copy(0, i));
1875 ent = findEntity(parent);
1876 if (ent.is()) {
1877 switch (ent->getSort()) {
1879 return getEnumMember(
1880 static_cast< unoidl::EnumTypeEntity * >(ent.get()),
1881 name.subView(i + 1));
1883 return getConstant(
1884 parent,
1885 static_cast< unoidl::ConstantGroupEntity * >(ent.get()),
1886 name.subView(i + 1));
1887 default:
1888 break;
1889 }
1890 }
1891 }
1892 return css::uno::Any();
1893}
1894
1895css::uno::Reference< css::reflection::XTypeDescription >
1896cppuhelper::TypeManager::resolve(OUString const & name) {
1897 css::uno::Reference< css::reflection::XTypeDescription > desc(
1898 find(name), css::uno::UNO_QUERY);
1899 if (!desc.is()) {
1900 throw css::uno::DeploymentException(
1901 "cannot resolve type \"" + name + "\"",
1902 static_cast< cppu::OWeakObject * >(this));
1903 }
1904 return desc;
1905}
1906
1908
1910
1912{
1913 return
1914 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager";
1915}
1916
1918 OUString const & ServiceName)
1919{
1920 return cppu::supportsService(this, ServiceName);
1921}
1922
1923css::uno::Sequence< OUString >
1925{
1926 return { "com.sun.star.reflection.TypeDescriptionManager" }; //TODO
1927}
1928
1930 OUString const & aName)
1931{
1932 css::uno::Any desc(find(aName));
1933 if (!desc.hasValue()) {
1934 throw css::container::NoSuchElementException(
1935 aName, static_cast< cppu::OWeakObject * >(this));
1936 }
1937 return desc;
1938}
1939
1941 OUString const & aName)
1942{
1943 return find(aName).hasValue();
1944}
1945
1947{
1949}
1950
1952{
1953 throw css::uno::RuntimeException(
1954 "TypeManager hasElements: method not supported",
1955 static_cast< cppu::OWeakObject * >(this));
1956}
1957
1958css::uno::Reference< css::container::XEnumeration >
1960{
1961 throw css::uno::RuntimeException(
1962 "TypeManager createEnumeration: method not supported",
1963 static_cast< cppu::OWeakObject * >(this));
1964}
1965
1967{
1968 throw css::uno::RuntimeException(
1969 "TypeManager has: method not supported",
1970 static_cast< cppu::OWeakObject * >(this));
1971}
1972
1973void cppuhelper::TypeManager::insert(css::uno::Any const & aElement)
1974{
1975 OUString uri;
1976 if (!(aElement >>= uri)) {
1977 throw css::lang::IllegalArgumentException(
1978 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
1979 " argument"),
1980 static_cast< cppu::OWeakObject * >(this), 0);
1981 }
1982 //TODO: check for ElementExistException
1983 //TODO: check for consistency with existing data
1984 readRdbFile(uri, false);
1985}
1986
1987void cppuhelper::TypeManager::remove(css::uno::Any const & aElement)
1988{
1989 OUString uri;
1990 if (!(aElement >>= uri)) {
1991 throw css::lang::IllegalArgumentException(
1992 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
1993 " argument"),
1994 static_cast< cppu::OWeakObject * >(this), 0);
1995 }
1996 //TODO: remove requests are silently ignored for now
1997}
1998
1999css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
2001 OUString const & moduleName,
2002 css::uno::Sequence< css::uno::TypeClass > const & types,
2003 css::reflection::TypeDescriptionSearchDepth depth)
2004{
2006 try {
2007 cursor = manager_->createCursor(moduleName);
2008 } catch (unoidl::FileFormatException & e) {
2009 throw css::uno::DeploymentException(
2010 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2011 + e.getDetail()),
2012 static_cast< cppu::OWeakObject * >(this));
2013 }
2014 if (!cursor.is()) {
2015 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2016 // non-module
2017 throw css::reflection::NoSuchTypeNameException(
2018 moduleName, static_cast< cppu::OWeakObject * >(this));
2019 }
2020 return new Enumeration(
2021 this, makePrefix(moduleName), cursor, types,
2022 depth == css::reflection::TypeDescriptionSearchDepth_INFINITE);
2023}
2024
2025void cppuhelper::TypeManager::init(std::u16string_view rdbUris) {
2026 for (sal_Int32 i = 0; i != -1;) {
2027 std::u16string_view uri(o3tl::getToken(rdbUris, 0, ' ', i));
2028 if (uri.empty()) {
2029 continue;
2030 }
2031 bool optional;
2032 bool directory;
2033 cppu::decodeRdbUri(&uri, &optional, &directory);
2034 if (directory) {
2035 readRdbDirectory(uri, optional);
2036 } else {
2037 readRdbFile(uri, optional);
2038 }
2039 }
2040}
2041
2043 std::u16string_view uri, bool optional)
2044{
2045 osl::Directory dir = OUString(uri);
2046 switch (dir.open()) {
2047 case osl::FileBase::E_None:
2048 break;
2049 case osl::FileBase::E_NOENT:
2050 if (optional) {
2051 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
2052 return;
2053 }
2054 [[fallthrough]];
2055 default:
2056 throw css::uno::DeploymentException(
2057 OUString::Concat("Cannot open directory ") + uri,
2058 static_cast< cppu::OWeakObject * >(this));
2059 }
2060 for (;;) {
2061 OUString url;
2062 if (!cppu::nextDirectoryItem(dir, &url)) {
2063 break;
2064 }
2065 readRdbFile(url, false);
2066 }
2067}
2068
2070 std::u16string_view uri, bool optional)
2071{
2072 try {
2073 manager_->addProvider(OUString(uri));
2074 } catch (unoidl::NoSuchFileException &) {
2075 if (!optional) {
2076 throw css::uno::DeploymentException(
2077 OUString::Concat(uri) + ": no such file",
2078 static_cast< cppu::OWeakObject * >(this));
2079 }
2080 SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
2081 } catch (unoidl::FileFormatException & e) {
2082 throw css::uno::DeploymentException(
2083 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2084 + e.getDetail()),
2085 static_cast< cppu::OWeakObject * >(this));
2086 }
2087}
2088
2090 OUString const & name)
2091{
2092 assert(name.startsWith("[]"));
2093 return css::uno::Any(
2094 css::uno::Reference< css::reflection::XTypeDescription >(
2095 new SequenceTypeDescription(
2096 this, name, name.copy(std::strlen("[]")))));
2097}
2098
2100 OUString const & name, sal_Int32 separator)
2101{
2102 assert(name.indexOf('<') == separator && separator != -1);
2103 rtl::Reference< unoidl::Entity > ent(findEntity(name.copy(0, separator)));
2104 if (!ent.is()
2105 || (ent->getSort()
2107 {
2108 return css::uno::Any();
2109 }
2112 ent.get()));
2113 std::vector< OUString > args;
2114 sal_Int32 i = separator;
2115 do {
2116 ++i; // skip '<' or ','
2117 sal_Int32 j = i;
2118 for (sal_Int32 level = 0; j != name.getLength(); ++j) {
2119 sal_Unicode c = name[j];
2120 if (c == ',') {
2121 if (level == 0) {
2122 break;
2123 }
2124 } else if (c == '<') {
2125 ++level;
2126 } else if (c == '>') {
2127 if (level == 0) {
2128 break;
2129 }
2130 --level;
2131 }
2132 }
2133 if (j != name.getLength()) {
2134 args.push_back(name.copy(i, j - i));
2135 }
2136 i = j;
2137 } while (i != name.getLength() && name[i] != '>');
2138 if (i != name.getLength() - 1 || name[i] != '>'
2139 || args.size() != ent2->getTypeParameters().size())
2140 {
2141 return css::uno::Any();
2142 }
2143 return css::uno::Any(
2144 css::uno::Reference< css::reflection::XTypeDescription >(
2145 new InstantiatedPolymorphicStructTypeDescription(
2146 this, name, ent2, std::move(args))));
2147}
2148
2150 std::u16string_view name, std::size_t separator)
2151{
2152 assert(name.find(u"::") == separator && separator != std::u16string_view::npos);
2153 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
2154 resolveTypedefs(find(OUString(name.substr(0, separator)))), css::uno::UNO_QUERY);
2155 if (!ifc.is()) {
2156 return css::uno::Any();
2157 }
2158 std::u16string_view member = name.substr(separator + std::strlen("::"));
2159 const css::uno::Sequence<
2160 css::uno::Reference<
2161 css::reflection::XInterfaceMemberTypeDescription > > mems(
2162 ifc->getMembers());
2163 for (const auto & m : mems) {
2164 if (m->getMemberName() == member) {
2165 return css::uno::Any(
2166 css::uno::Reference< css::reflection::XTypeDescription >(m));
2167 }
2168 }
2169 return css::uno::Any();
2170}
2171
2173 OUString const & name, rtl::Reference< unoidl::Entity > const & entity)
2174{
2175 assert(entity.is());
2176 switch (entity->getSort()) {
2178 return css::uno::Any(
2179 css::uno::Reference< css::reflection::XTypeDescription >(
2180 new ModuleDescription(
2181 this, name,
2182 static_cast< unoidl::ModuleEntity * >(entity.get()))));
2184 return css::uno::Any(
2185 css::uno::Reference< css::reflection::XTypeDescription >(
2186 new EnumTypeDescription(
2187 name,
2188 static_cast< unoidl::EnumTypeEntity * >(entity.get()))));
2190 return css::uno::Any(
2191 css::uno::Reference< css::reflection::XTypeDescription >(
2192 new PlainStructTypeDescription(
2193 this, name,
2194 static_cast< unoidl::PlainStructTypeEntity * >(
2195 entity.get()))));
2197 return css::uno::Any(
2198 css::uno::Reference< css::reflection::XTypeDescription >(
2199 new PolymorphicStructTypeTemplateDescription(
2200 this, name,
2201 static_cast<
2203 entity.get()))));
2205 return css::uno::Any(
2206 css::uno::Reference< css::reflection::XTypeDescription >(
2207 new ExceptionTypeDescription(
2208 this, name,
2209 static_cast< unoidl::ExceptionTypeEntity * >(
2210 entity.get()))));
2212 return css::uno::Any(
2213 css::uno::Reference< css::reflection::XTypeDescription >(
2214 new InterfaceTypeDescription(
2215 this, name,
2216 static_cast< unoidl::InterfaceTypeEntity * >(
2217 entity.get()))));
2219 return css::uno::Any(
2220 css::uno::Reference< css::reflection::XTypeDescription >(
2221 new TypedefDescription(
2222 this, name,
2223 static_cast< unoidl::TypedefEntity * >(entity.get()))));
2225 return css::uno::Any(
2226 css::uno::Reference< css::reflection::XTypeDescription >(
2227 new ConstantGroupDescription(
2228 name,
2229 static_cast< unoidl::ConstantGroupEntity * >(
2230 entity.get()))));
2232 return css::uno::Any(
2233 css::uno::Reference< css::reflection::XTypeDescription >(
2234 new SingleInterfaceBasedServiceDescription(
2235 this, name,
2237 entity.get()))));
2239 return css::uno::Any(
2240 css::uno::Reference< css::reflection::XTypeDescription >(
2241 new AccumulationBasedServiceDescription(
2242 this, name,
2244 entity.get()))));
2246 return css::uno::Any(
2247 css::uno::Reference< css::reflection::XTypeDescription >(
2248 new InterfaceBasedSingletonDescription(
2249 this, name,
2251 entity.get()))));
2253 return css::uno::Any(
2254 css::uno::Reference< css::reflection::XTypeDescription >(
2255 new ServiceBasedSingletonDescription(
2256 this, name,
2257 static_cast< unoidl::ServiceBasedSingletonEntity * >(
2258 entity.get()))));
2259 default:
2260 for (;;) { std::abort(); } // this cannot happen
2261 }
2262}
2263
2266 std::u16string_view member)
2267{
2268 auto i = std::find_if(entity->getMembers().begin(), entity->getMembers().end(),
2269 [&member](const unoidl::EnumTypeEntity::Member& rMember) { return rMember.name == member; });
2270 if (i != entity->getMembers().end())
2271 return css::uno::Any(i->value);
2272 return css::uno::Any();
2273}
2274
2276 std::u16string_view constantGroupName,
2278 std::u16string_view member)
2279{
2280 auto i = std::find_if(entity->getMembers().begin(), entity->getMembers().end(),
2281 [&member](const unoidl::ConstantGroupEntity::Member& rMember) { return rMember.name == member; });
2282 if (i != entity->getMembers().end())
2283 return css::uno::Any(
2284 css::uno::Reference< css::reflection::XTypeDescription >(
2285 new ConstantDescription(OUString(constantGroupName), *i)));
2286 return css::uno::Any();
2287}
2288
2290 OUString const & name)
2291{
2292 try {
2293 return manager_->findEntity(name);
2294 } catch (unoidl::FileFormatException & e) {
2295 throw css::uno::DeploymentException(
2296 ("unoidl::FileFormatException for <" + e.getUri() + ">: "
2297 + e.getDetail()),
2298 static_cast< cppu::OWeakObject * >(this));
2299 }
2300}
2301
2302/* 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)
virtual void SAL_CALL disposing() override
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
std::mutex m_aMutex
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:112
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
cppu::WeakComponentImplHelper< css::lang::XServiceInfo, css::container::XHierarchicalNameAccess, css::container::XSet, css::reflection::XTypeDescriptionEnumerationAccess > TypeManager_Base
Definition: typemanager.hxx:43
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_