1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
20 #include <boost/noncopyable.hpp>
21 #include <com/sun/star/container/ElementExistException.hpp>
22 #include <com/sun/star/container/NoSuchElementException.hpp>
23 #include <com/sun/star/lang/IllegalArgumentException.hpp>
24 #include <com/sun/star/reflection/InvalidTypeNameException.hpp>
25 #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
26 #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
27 #include <com/sun/star/reflection/XConstantTypeDescription.hpp>
28 #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
29 #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
30 #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
31 #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
32 #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
33 #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
34 #include <com/sun/star/reflection/XModuleTypeDescription.hpp>
35 #include <com/sun/star/reflection/XPublished.hpp>
36 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
37 #include <com/sun/star/reflection/XSingletonTypeDescription2.hpp>
38 #include <com/sun/star/reflection/XStructTypeDescription.hpp>
39 #include <com/sun/star/reflection/XTypeDescription.hpp>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/DeploymentException.hpp>
42 #include <com/sun/star/uno/Reference.hxx>
43 #include <com/sun/star/uno/RuntimeException.hpp>
44 #include <com/sun/star/uno/Sequence.hxx>
45 #include <com/sun/star/uno/Type.hxx>
46 #include <com/sun/star/uno/TypeClass.hpp>
47 #include <cppu/unotype.hxx>
48 #include <cppuhelper/implbase1.hxx>
49 #include <cppuhelper/supportsservice.hxx>
50 #include <osl/file.hxx>
51 #include <osl/mutex.hxx>
52 #include <rtl/ref.hxx>
53 #include <rtl/string.h>
54 #include <rtl/ustring.hxx>
55 #include <sal/log.hxx>
56 #include <sal/macros.h>
57 #include <sal/types.h>
61 #include <unoidl/unoidl.hxx>
64 #include "typemanager.hxx"
68 rtl::OUString
makePrefix(rtl::OUString
const & name
) {
69 return name
.isEmpty() ? name
: name
+ ".";
72 css::uno::Any
resolveTypedefs(css::uno::Any
const & type
) {
73 for (css::uno::Any
t(type
);;) {
74 css::uno::Reference
< css::reflection::XIndirectTypeDescription
> ind(
75 type
, css::uno::UNO_QUERY
);
76 if (!ind
.is() || ind
->getTypeClass() != css::uno::TypeClass_TYPEDEF
) {
79 t
= css::uno::makeAny(ind
->getReferencedType());
83 class SimpleTypeDescription
:
84 public cppu::WeakImplHelper1
< css::reflection::XTypeDescription
>
87 SimpleTypeDescription(
88 css::uno::TypeClass typeClass
, rtl::OUString
const & name
):
89 typeClass_(typeClass
), name_(name
)
93 virtual ~SimpleTypeDescription() {}
95 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
96 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
97 { return typeClass_
; }
99 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
102 css::uno::TypeClass typeClass_
;
106 class SequenceTypeDescription
:
107 public cppu::WeakImplHelper1
< css::reflection::XIndirectTypeDescription
>
110 SequenceTypeDescription(
111 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
112 rtl::OUString
const & name
, rtl::OUString
const & componentType
):
113 manager_(manager
), name_(name
), componentType_(componentType
)
114 { assert(manager
.is()); }
117 virtual ~SequenceTypeDescription() {}
119 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
120 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
121 { return css::uno::TypeClass_SEQUENCE
; }
123 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
126 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
127 getReferencedType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
128 { return manager_
->resolve(componentType_
); }
130 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
132 rtl::OUString componentType_
;
135 class PublishableDescription
:
136 public cppu::WeakImplHelper1
< css::reflection::XPublished
>
139 PublishableDescription(bool published
): published_(published
) {}
141 virtual ~PublishableDescription() {}
144 virtual sal_Bool SAL_CALL
isPublished() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
145 { return published_
; }
150 class ModuleDescription
:
151 public cppu::WeakImplHelper1
< css::reflection::XModuleTypeDescription
>
155 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
156 rtl::OUString
const & name
,
157 rtl::Reference
< unoidl::ModuleEntity
> const & entity
):
158 manager_(manager
), name_(name
), entity_(entity
)
159 { assert(manager
.is()); assert(entity
.is()); }
162 virtual ~ModuleDescription() {}
164 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
165 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
166 { return css::uno::TypeClass_MODULE
; }
168 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
173 css::uno::Reference
< css::reflection::XTypeDescription
> >
174 SAL_CALL
getMembers() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
176 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
178 rtl::Reference
< unoidl::ModuleEntity
> entity_
;
181 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
182 ModuleDescription::getMembers() throw (css::uno::RuntimeException
, std::exception
) {
184 std::vector
< rtl::OUString
> names(entity_
->getMemberNames());
185 assert(names
.size() <= SAL_MAX_INT32
);
186 sal_Int32 n
= static_cast< sal_Int32
>(names
.size());
188 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
189 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
190 s
[i
] = manager_
->resolve(makePrefix(name_
) + names
[i
]);
193 } catch (unoidl::FileFormatException
& e
) {
194 throw css::uno::DeploymentException(
195 e
.getUri() + ": " + e
.getDetail(),
196 static_cast< cppu::OWeakObject
* >(this));
200 typedef cppu::ImplInheritanceHelper1
<
201 PublishableDescription
, css::reflection::XEnumTypeDescription
>
202 EnumTypeDescription_Base
;
204 class EnumTypeDescription
: public EnumTypeDescription_Base
{
207 rtl::OUString
const & name
,
208 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
):
209 EnumTypeDescription_Base(entity
->isPublished()), name_(name
),
211 { assert(entity
.is()); }
214 virtual ~EnumTypeDescription() {}
216 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
217 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
218 { return css::uno::TypeClass_ENUM
; }
220 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
223 virtual sal_Int32 SAL_CALL
getDefaultEnumValue()
224 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
225 { return entity_
->getMembers()[0].value
; }
227 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getEnumNames()
228 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
230 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getEnumValues()
231 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
234 rtl::Reference
< unoidl::EnumTypeEntity
> entity_
;
237 css::uno::Sequence
< rtl::OUString
> EnumTypeDescription::getEnumNames()
238 throw (css::uno::RuntimeException
, std::exception
)
240 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
241 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
242 css::uno::Sequence
< rtl::OUString
> s(n
);
243 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
244 s
[i
] = entity_
->getMembers()[i
].name
;
249 css::uno::Sequence
< sal_Int32
> EnumTypeDescription::getEnumValues()
250 throw (css::uno::RuntimeException
, std::exception
)
252 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
253 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
254 css::uno::Sequence
< sal_Int32
> s(n
);
255 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
256 s
[i
] = entity_
->getMembers()[i
].value
;
261 typedef cppu::ImplInheritanceHelper1
<
262 PublishableDescription
, css::reflection::XStructTypeDescription
>
263 PlainStructTypeDescription_Base
;
265 class PlainStructTypeDescription
: public PlainStructTypeDescription_Base
{
267 PlainStructTypeDescription(
268 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
269 rtl::OUString
const & name
,
270 rtl::Reference
< unoidl::PlainStructTypeEntity
> const & entity
):
271 PlainStructTypeDescription_Base(entity
->isPublished()),
272 manager_(manager
), name_(name
), entity_(entity
)
273 { assert(manager
.is()); assert(entity
.is()); }
276 virtual ~PlainStructTypeDescription() {}
278 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
279 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
280 { return css::uno::TypeClass_STRUCT
; }
282 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
285 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
286 getBaseType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
287 return entity_
->getDirectBase().isEmpty()
288 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
289 : manager_
->resolve(entity_
->getDirectBase());
294 css::uno::Reference
< css::reflection::XTypeDescription
> >
295 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
297 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
298 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
300 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getTypeParameters()
301 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
302 { return css::uno::Sequence
< rtl::OUString
>(); }
306 css::uno::Reference
< css::reflection::XTypeDescription
> >
307 SAL_CALL
getTypeArguments() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
308 return css::uno::Sequence
<
309 css::uno::Reference
< css::reflection::XTypeDescription
> >();
312 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
314 rtl::Reference
< unoidl::PlainStructTypeEntity
> entity_
;
317 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
318 PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException
, std::exception
)
320 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
321 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
323 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
324 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
325 s
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
330 css::uno::Sequence
< rtl::OUString
> PlainStructTypeDescription::getMemberNames()
331 throw (css::uno::RuntimeException
, std::exception
)
333 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
334 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
335 css::uno::Sequence
< rtl::OUString
> s(n
);
336 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
337 s
[i
] = entity_
->getDirectMembers()[i
].name
;
342 class ParameterizedMemberTypeDescription
:
343 public cppu::WeakImplHelper1
< css::reflection::XTypeDescription
>
346 explicit ParameterizedMemberTypeDescription(
347 rtl::OUString
const & typeParameterName
):
348 typeParameterName_(typeParameterName
)
352 virtual ~ParameterizedMemberTypeDescription() {}
354 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
355 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
356 { return css::uno::TypeClass_UNKNOWN
; }
358 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
359 { return typeParameterName_
; }
361 rtl::OUString typeParameterName_
;
364 typedef cppu::ImplInheritanceHelper1
<
365 PublishableDescription
, css::reflection::XStructTypeDescription
>
366 PolymorphicStructTypeTemplateDescription_Base
;
368 class PolymorphicStructTypeTemplateDescription
:
369 public PolymorphicStructTypeTemplateDescription_Base
372 PolymorphicStructTypeTemplateDescription(
373 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
374 rtl::OUString
const & name
,
375 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
377 PolymorphicStructTypeTemplateDescription_Base(entity
->isPublished()),
378 manager_(manager
), name_(name
), entity_(entity
)
379 { assert(manager
.is()); assert(entity
.is()); }
382 virtual ~PolymorphicStructTypeTemplateDescription() {}
384 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
385 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
386 { return css::uno::TypeClass_STRUCT
; }
388 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
391 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
392 getBaseType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
393 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
397 css::uno::Reference
< css::reflection::XTypeDescription
> >
398 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
400 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
401 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
403 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getTypeParameters()
404 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
408 css::uno::Reference
< css::reflection::XTypeDescription
> >
409 SAL_CALL
getTypeArguments() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
410 return css::uno::Sequence
<
411 css::uno::Reference
< css::reflection::XTypeDescription
> >();
414 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
416 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
419 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
420 PolymorphicStructTypeTemplateDescription::getMemberTypes()
421 throw (css::uno::RuntimeException
, std::exception
)
423 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
424 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
426 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
427 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
428 s
[i
] = entity_
->getMembers()[i
].parameterized
429 ? new ParameterizedMemberTypeDescription(
430 entity_
->getMembers()[i
].type
)
431 : manager_
->resolve(entity_
->getMembers()[i
].type
);
436 css::uno::Sequence
< rtl::OUString
>
437 PolymorphicStructTypeTemplateDescription::getMemberNames()
438 throw (css::uno::RuntimeException
, std::exception
)
440 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
441 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
442 css::uno::Sequence
< rtl::OUString
> s(n
);
443 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
444 s
[i
] = entity_
->getMembers()[i
].name
;
449 css::uno::Sequence
< rtl::OUString
>
450 PolymorphicStructTypeTemplateDescription::getTypeParameters()
451 throw (css::uno::RuntimeException
, std::exception
)
453 assert(entity_
->getTypeParameters().size() <= SAL_MAX_INT32
);
454 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getTypeParameters().size());
455 css::uno::Sequence
< rtl::OUString
> s(n
);
456 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
457 s
[i
] = entity_
->getTypeParameters()[i
];
462 class InstantiatedPolymorphicStructTypeDescription
:
463 public cppu::WeakImplHelper1
< css::reflection::XStructTypeDescription
>
466 InstantiatedPolymorphicStructTypeDescription(
467 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
468 rtl::OUString
const & name
,
469 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
471 std::vector
< rtl::OUString
> const & arguments
):
472 manager_(manager
), name_(name
), entity_(entity
), arguments_(arguments
)
474 assert(manager
.is());
476 assert(arguments
.size() == entity
->getTypeParameters().size());
480 virtual ~InstantiatedPolymorphicStructTypeDescription() {}
482 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
483 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
484 { return css::uno::TypeClass_STRUCT
; }
486 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
489 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
490 getBaseType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
491 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
495 css::uno::Reference
< css::reflection::XTypeDescription
> >
496 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
498 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
499 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
501 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getTypeParameters()
502 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
503 { return css::uno::Sequence
< rtl::OUString
>(); }
507 css::uno::Reference
< css::reflection::XTypeDescription
> >
508 SAL_CALL
getTypeArguments() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
510 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
512 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
513 std::vector
< rtl::OUString
> arguments_
;
516 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
517 InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
518 throw (css::uno::RuntimeException
, std::exception
)
520 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
521 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
523 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
524 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
525 rtl::OUString
type(entity_
->getMembers()[i
].type
);
526 if (entity_
->getMembers()[i
].parameterized
) {
527 for (std::vector
< rtl::OUString
>::const_iterator
j(
528 entity_
->getTypeParameters().begin());
529 j
!= entity_
->getTypeParameters().end(); ++j
)
532 type
= arguments_
[j
- entity_
->getTypeParameters().begin()];
536 assert(false); // this cannot happen //TODO!
539 s
[i
] = manager_
->resolve(type
);
544 css::uno::Sequence
< rtl::OUString
>
545 InstantiatedPolymorphicStructTypeDescription::getMemberNames()
546 throw (css::uno::RuntimeException
, std::exception
)
548 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
549 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
550 css::uno::Sequence
< rtl::OUString
> s(n
);
551 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
552 s
[i
] = entity_
->getMembers()[i
].name
;
556 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
557 InstantiatedPolymorphicStructTypeDescription::getTypeArguments()
558 throw (css::uno::RuntimeException
, std::exception
)
560 assert(arguments_
.size() <= SAL_MAX_INT32
);
561 sal_Int32 n
= static_cast< sal_Int32
>(arguments_
.size());
563 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
564 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
565 s
[i
] = manager_
->resolve(arguments_
[i
]);
570 typedef cppu::ImplInheritanceHelper1
<
571 PublishableDescription
, css::reflection::XCompoundTypeDescription
>
572 ExceptionTypeDescription_Base
;
574 class ExceptionTypeDescription
: public ExceptionTypeDescription_Base
{
576 ExceptionTypeDescription(
577 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
578 rtl::OUString
const & name
,
579 rtl::Reference
< unoidl::ExceptionTypeEntity
> const & entity
):
580 ExceptionTypeDescription_Base(entity
->isPublished()), manager_(manager
),
581 name_(name
), entity_(entity
)
582 { assert(manager
.is()); assert(entity
.is()); }
585 virtual ~ExceptionTypeDescription() {}
587 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
588 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
589 { return css::uno::TypeClass_EXCEPTION
; }
591 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
594 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
595 getBaseType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
596 return entity_
->getDirectBase().isEmpty()
597 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
598 : manager_
->resolve(entity_
->getDirectBase());
603 css::uno::Reference
< css::reflection::XTypeDescription
> >
604 SAL_CALL
getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
606 virtual css::uno::Sequence
< rtl::OUString
> SAL_CALL
getMemberNames()
607 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
609 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
611 rtl::Reference
< unoidl::ExceptionTypeEntity
> entity_
;
614 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
615 ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException
, std::exception
) {
616 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
617 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
619 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
620 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
621 s
[i
] = manager_
->resolve(entity_
->getDirectMembers()[i
].type
);
626 css::uno::Sequence
< rtl::OUString
> ExceptionTypeDescription::getMemberNames()
627 throw (css::uno::RuntimeException
, std::exception
)
629 assert(entity_
->getDirectMembers().size() <= SAL_MAX_INT32
);
630 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getDirectMembers().size());
631 css::uno::Sequence
< rtl::OUString
> s(n
);
632 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
633 s
[i
] = entity_
->getDirectMembers()[i
].name
;
638 class AttributeDescription
:
639 public cppu::WeakImplHelper1
<
640 css::reflection::XInterfaceAttributeTypeDescription2
>
643 AttributeDescription(
644 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
645 rtl::OUString
const & name
,
646 unoidl::InterfaceTypeEntity::Attribute
const & attribute
,
648 manager_(manager
), name_(name
), attribute_(attribute
),
650 { assert(manager
.is()); }
653 virtual ~AttributeDescription() {}
655 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
656 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
657 { return css::uno::TypeClass_INTERFACE_ATTRIBUTE
; }
659 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
662 virtual rtl::OUString SAL_CALL
getMemberName()
663 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
664 { return attribute_
.name
; }
666 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
667 { return position_
; }
669 virtual sal_Bool SAL_CALL
isReadOnly() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
670 { return attribute_
.readOnly
; }
672 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
673 getType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
674 { return manager_
->resolve(attribute_
.type
); }
676 virtual sal_Bool SAL_CALL
isBound() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
677 { return attribute_
.bound
; }
681 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
682 SAL_CALL
getGetExceptions() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
686 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
687 SAL_CALL
getSetExceptions() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
689 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
691 unoidl::InterfaceTypeEntity::Attribute attribute_
;
696 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
697 AttributeDescription::getGetExceptions() throw (css::uno::RuntimeException
, std::exception
) {
698 assert(attribute_
.getExceptions
.size() <= SAL_MAX_INT32
);
699 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.getExceptions
.size());
701 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
702 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
704 manager_
->resolve(attribute_
.getExceptions
[i
]),
705 css::uno::UNO_QUERY_THROW
);
711 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
712 AttributeDescription::getSetExceptions() throw (css::uno::RuntimeException
, std::exception
) {
713 assert(attribute_
.setExceptions
.size() <= SAL_MAX_INT32
);
714 sal_Int32 n
= static_cast< sal_Int32
>(attribute_
.setExceptions
.size());
716 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
717 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
719 manager_
->resolve(attribute_
.setExceptions
[i
]),
720 css::uno::UNO_QUERY_THROW
);
725 class MethodParameter
:
726 public cppu::WeakImplHelper1
< css::reflection::XMethodParameter
>
730 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
731 unoidl::InterfaceTypeEntity::Method::Parameter
const & parameter
,
733 manager_(manager
), parameter_(parameter
), position_(position
)
734 { assert(manager
.is()); }
737 virtual ~MethodParameter() {}
739 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
740 { return parameter_
.name
; }
742 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
743 getType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
744 { return manager_
->resolve(parameter_
.type
); }
746 virtual sal_Bool SAL_CALL
isIn() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
748 (parameter_
.direction
749 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
750 || (parameter_
.direction
751 == unoidl::InterfaceTypeEntity::Method::Parameter::
755 virtual sal_Bool SAL_CALL
isOut() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
757 (parameter_
.direction
758 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
)
759 || (parameter_
.direction
760 == unoidl::InterfaceTypeEntity::Method::Parameter::
764 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
765 { return position_
; }
767 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
768 unoidl::InterfaceTypeEntity::Method::Parameter parameter_
;
772 class MethodDescription
:
773 public cppu::WeakImplHelper1
<
774 css::reflection::XInterfaceMethodTypeDescription
>
778 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
779 rtl::OUString
const & name
,
780 unoidl::InterfaceTypeEntity::Method
const & method
, sal_Int32 position
):
781 manager_(manager
), name_(name
), method_(method
), position_(position
)
782 { assert(manager
.is()); }
785 virtual ~MethodDescription() {}
787 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
788 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
789 { return css::uno::TypeClass_INTERFACE_METHOD
; }
791 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
794 virtual rtl::OUString SAL_CALL
getMemberName()
795 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
796 { return method_
.name
; }
798 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
799 { return position_
; }
801 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
802 getReturnType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
803 { return manager_
->resolve(method_
.returnType
); }
805 virtual sal_Bool SAL_CALL
isOneway() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
810 css::uno::Reference
< css::reflection::XMethodParameter
> >
811 SAL_CALL
getParameters() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
815 css::uno::Reference
< css::reflection::XTypeDescription
> >
816 SAL_CALL
getExceptions() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
818 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
820 unoidl::InterfaceTypeEntity::Method method_
;
824 css::uno::Sequence
< css::uno::Reference
< css::reflection::XMethodParameter
> >
825 MethodDescription::getParameters() throw (css::uno::RuntimeException
, std::exception
) {
826 assert(method_
.parameters
.size() <= SAL_MAX_INT32
);
827 sal_Int32 n
= static_cast< sal_Int32
>(method_
.parameters
.size());
829 css::uno::Reference
< css::reflection::XMethodParameter
> > s(n
);
830 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
831 s
[i
] = new MethodParameter(manager_
, method_
.parameters
[i
], i
);
836 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
837 MethodDescription::getExceptions() throw (css::uno::RuntimeException
, std::exception
) {
838 assert(method_
.exceptions
.size() <= SAL_MAX_INT32
);
839 sal_Int32 n
= static_cast< sal_Int32
>(method_
.exceptions
.size());
841 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
842 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
843 s
[i
] = manager_
->resolve(method_
.exceptions
[i
]);
848 class BaseOffset
: private boost::noncopyable
{
851 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
852 const & description
);
854 sal_Int32
get() const { return offset_
; }
858 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
859 const & description
);
862 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
863 const & description
);
865 std::set
< rtl::OUString
> set_
;
869 BaseOffset::BaseOffset(
870 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
874 calculateBases(description
);
877 void BaseOffset::calculateBases(
878 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
882 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
883 description
->getBaseTypes());
884 for (sal_Int32 i
= 0; i
!= bases
.getLength(); ++i
) {
886 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
887 resolveTypedefs(css::uno::makeAny(bases
[i
])),
888 css::uno::UNO_QUERY_THROW
));
892 void BaseOffset::calculate(
893 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> const &
896 if (set_
.insert(description
->getName()).second
) {
897 calculateBases(description
);
898 offset_
+= description
->getMembers().getLength();
902 typedef cppu::ImplInheritanceHelper1
<
903 PublishableDescription
, css::reflection::XInterfaceTypeDescription2
>
904 InterfaceTypeDescription_Base
;
906 class InterfaceTypeDescription
: public InterfaceTypeDescription_Base
{
908 InterfaceTypeDescription(
909 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
910 rtl::OUString
const & name
,
911 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
912 InterfaceTypeDescription_Base(entity
->isPublished()), manager_(manager
),
913 name_(name
), entity_(entity
)
914 { assert(manager
.is()); assert(entity
.is()); }
917 virtual ~InterfaceTypeDescription() {}
919 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
920 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
921 { return css::uno::TypeClass_INTERFACE
; }
923 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
926 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
927 getBaseType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{
928 return entity_
->getDirectMandatoryBases().empty()
929 ? css::uno::Reference
< css::reflection::XTypeDescription
>()
930 : manager_
->resolve(entity_
->getDirectMandatoryBases()[0].name
);
933 virtual css::uno::Uik SAL_CALL
getUik() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
934 { return css::uno::Uik(); }
939 css::reflection::XInterfaceMemberTypeDescription
> >
940 SAL_CALL
getMembers() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
944 css::uno::Reference
< css::reflection::XTypeDescription
> >
945 SAL_CALL
getBaseTypes() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
949 css::uno::Reference
< css::reflection::XTypeDescription
> >
950 SAL_CALL
getOptionalBaseTypes() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
952 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
954 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
958 css::uno::Reference
< css::reflection::XInterfaceMemberTypeDescription
> >
959 InterfaceTypeDescription::getMembers() throw (css::uno::RuntimeException
, std::exception
) {
961 entity_
->getDirectAttributes().size() <= SAL_MAX_INT32
962 && (entity_
->getDirectMethods().size()
963 <= SAL_MAX_INT32
- entity_
->getDirectAttributes().size()));
964 sal_Int32 n1
= static_cast< sal_Int32
>(
965 entity_
->getDirectAttributes().size());
966 sal_Int32 n2
= static_cast< sal_Int32
>(entity_
->getDirectMethods().size());
969 css::reflection::XInterfaceMemberTypeDescription
> > s(n1
+ n2
);
970 sal_Int32 off
= BaseOffset(this).get();
971 for (sal_Int32 i
= 0; i
!= n1
; ++i
) {
972 s
[i
] = new AttributeDescription(
973 manager_
, name_
+ "::" + entity_
->getDirectAttributes()[i
].name
,
974 entity_
->getDirectAttributes()[i
], off
+ i
);
976 for (sal_Int32 i
= 0; i
!= n2
; ++i
) {
977 s
[n1
+ i
] = new MethodDescription(
978 manager_
, name_
+ "::" + entity_
->getDirectMethods()[i
].name
,
979 entity_
->getDirectMethods()[i
], off
+ n1
+ i
);
984 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
985 InterfaceTypeDescription::getBaseTypes() throw (css::uno::RuntimeException
, std::exception
) {
986 assert(entity_
->getDirectMandatoryBases().size() <= SAL_MAX_INT32
);
987 sal_Int32 n
= static_cast< sal_Int32
>(
988 entity_
->getDirectMandatoryBases().size());
990 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
991 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
992 s
[i
] = manager_
->resolve(entity_
->getDirectMandatoryBases()[i
].name
);
997 css::uno::Sequence
< css::uno::Reference
< css::reflection::XTypeDescription
> >
998 InterfaceTypeDescription::getOptionalBaseTypes()
999 throw (css::uno::RuntimeException
, std::exception
)
1001 assert(entity_
->getDirectOptionalBases().size() <= SAL_MAX_INT32
);
1002 sal_Int32 n
= static_cast< sal_Int32
>(
1003 entity_
->getDirectOptionalBases().size());
1005 css::uno::Reference
< css::reflection::XTypeDescription
> > s(n
);
1006 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1007 s
[i
] = manager_
->resolve(entity_
->getDirectOptionalBases()[i
].name
);
1012 class ConstantDescription
:
1013 public cppu::WeakImplHelper1
< css::reflection::XConstantTypeDescription
>
1016 ConstantDescription(
1017 rtl::OUString
const & constantGroupName
,
1018 unoidl::ConstantGroupEntity::Member
const & member
);
1021 virtual ~ConstantDescription() {}
1023 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1024 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1025 { return css::uno::TypeClass_CONSTANT
; }
1027 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1030 virtual css::uno::Any SAL_CALL
getConstantValue()
1031 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1034 rtl::OUString name_
;
1035 css::uno::Any value_
;
1038 ConstantDescription::ConstantDescription(
1039 rtl::OUString
const & constantGroupName
,
1040 unoidl::ConstantGroupEntity::Member
const & member
):
1041 name_(makePrefix(constantGroupName
) + member
.name
)
1043 switch (member
.value
.type
) {
1044 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1045 value_
<<= member
.value
.booleanValue
;
1047 case unoidl::ConstantValue::TYPE_BYTE
:
1048 value_
<<= member
.value
.byteValue
;
1050 case unoidl::ConstantValue::TYPE_SHORT
:
1051 value_
<<= member
.value
.shortValue
;
1053 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1054 value_
<<= member
.value
.unsignedShortValue
;
1056 case unoidl::ConstantValue::TYPE_LONG
:
1057 value_
<<= member
.value
.longValue
;
1059 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1060 value_
<<= member
.value
.unsignedLongValue
;
1062 case unoidl::ConstantValue::TYPE_HYPER
:
1063 value_
<<= member
.value
.hyperValue
;
1065 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1066 value_
<<= member
.value
.unsignedHyperValue
;
1068 case unoidl::ConstantValue::TYPE_FLOAT
:
1069 value_
<<= member
.value
.floatValue
;
1071 case unoidl::ConstantValue::TYPE_DOUBLE
:
1072 value_
<<= member
.value
.doubleValue
;
1075 for (;;) { std::abort(); } // this cannot happen
1079 typedef cppu::ImplInheritanceHelper1
<
1080 PublishableDescription
, css::reflection::XConstantsTypeDescription
>
1081 ConstantGroupDescription_Base
;
1083 class ConstantGroupDescription
: public ConstantGroupDescription_Base
{
1085 ConstantGroupDescription(
1086 rtl::OUString
const & name
,
1087 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
):
1088 ConstantGroupDescription_Base(entity
->isPublished()), name_(name
),
1090 { assert(entity
.is()); }
1093 virtual ~ConstantGroupDescription() {}
1095 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1096 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1097 { return css::uno::TypeClass_CONSTANTS
; }
1099 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1104 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1105 SAL_CALL
getConstants() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1107 rtl::OUString name_
;
1108 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1112 css::uno::Reference
< css::reflection::XConstantTypeDescription
> >
1113 ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException
, std::exception
) {
1114 assert(entity_
->getMembers().size() <= SAL_MAX_INT32
);
1115 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getMembers().size());
1117 css::uno::Reference
< css::reflection::XConstantTypeDescription
> > s(n
);
1118 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1119 s
[i
] = new ConstantDescription(name_
, entity_
->getMembers()[i
]);
1124 typedef cppu::ImplInheritanceHelper1
<
1125 PublishableDescription
, css::reflection::XIndirectTypeDescription
>
1126 TypedefDescription_Base
;
1128 class TypedefDescription
: public TypedefDescription_Base
{
1131 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1132 rtl::OUString
const & name
,
1133 rtl::Reference
< unoidl::TypedefEntity
> const & entity
):
1134 TypedefDescription_Base(entity
->isPublished()), manager_(manager
),
1135 name_(name
), entity_(entity
)
1136 { assert(manager
.is()); assert(entity
.is()); }
1139 virtual ~TypedefDescription() {}
1141 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1142 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1143 { return css::uno::TypeClass_TYPEDEF
; }
1145 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1148 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1149 getReferencedType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1150 { return manager_
->resolve(entity_
->getType()); }
1152 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1153 rtl::OUString name_
;
1154 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
1157 class ConstructorParameter
:
1158 public cppu::WeakImplHelper1
< css::reflection::XParameter
>
1161 ConstructorParameter(
1162 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1163 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1165 sal_Int32 position
):
1166 manager_(manager
), parameter_(parameter
), position_(position
)
1167 { assert(manager
.is()); }
1170 virtual ~ConstructorParameter() {}
1172 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1173 { return parameter_
.name
; }
1175 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1176 getType() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1177 { return manager_
->resolve(parameter_
.type
); }
1179 virtual sal_Bool SAL_CALL
isIn() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1182 virtual sal_Bool SAL_CALL
isOut() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1185 virtual sal_Int32 SAL_CALL
getPosition() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1186 { return position_
; }
1188 virtual sal_Bool SAL_CALL
isRestParameter()
1189 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1190 { return parameter_
.rest
; }
1192 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1193 unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
1195 sal_Int32 position_
;
1198 class ConstructorDescription
:
1199 public cppu::WeakImplHelper1
<
1200 css::reflection::XServiceConstructorDescription
>
1203 ConstructorDescription(
1204 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1205 unoidl::SingleInterfaceBasedServiceEntity::Constructor
const &
1207 manager_(manager
), constructor_(constructor
)
1208 { assert(manager
.is()); }
1211 virtual ~ConstructorDescription() {}
1213 virtual sal_Bool SAL_CALL
isDefaultConstructor()
1214 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1215 { return constructor_
.defaultConstructor
; }
1217 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1218 { return constructor_
.name
; }
1222 css::uno::Reference
< css::reflection::XParameter
> >
1223 SAL_CALL
getParameters() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1227 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1228 SAL_CALL
getExceptions() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1230 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1231 unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_
;
1234 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> >
1235 ConstructorDescription::getParameters() throw (css::uno::RuntimeException
, std::exception
) {
1236 assert(constructor_
.parameters
.size() <= SAL_MAX_INT32
);
1237 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.parameters
.size());
1238 css::uno::Sequence
< css::uno::Reference
< css::reflection::XParameter
> > s(
1240 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1241 s
[i
] = new ConstructorParameter(
1242 manager_
, constructor_
.parameters
[i
], i
);
1248 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
1249 ConstructorDescription::getExceptions() throw (css::uno::RuntimeException
, std::exception
) {
1250 assert(constructor_
.exceptions
.size() <= SAL_MAX_INT32
);
1251 sal_Int32 n
= static_cast< sal_Int32
>(constructor_
.exceptions
.size());
1253 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> > s(n
);
1254 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1256 manager_
->resolve(constructor_
.exceptions
[i
]),
1257 css::uno::UNO_QUERY_THROW
);
1262 typedef cppu::ImplInheritanceHelper1
<
1263 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1264 SingleInterfaceBasedServiceDescription_Base
;
1266 class SingleInterfaceBasedServiceDescription
:
1267 public SingleInterfaceBasedServiceDescription_Base
1270 SingleInterfaceBasedServiceDescription(
1271 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1272 rtl::OUString
const & name
,
1273 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
1275 SingleInterfaceBasedServiceDescription_Base(entity
->isPublished()),
1276 manager_(manager
), name_(name
), entity_(entity
)
1277 { assert(manager
.is()); assert(entity
.is()); }
1280 virtual ~SingleInterfaceBasedServiceDescription() {}
1282 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1283 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1284 { return css::uno::TypeClass_SERVICE
; }
1286 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1291 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1292 SAL_CALL
getMandatoryServices() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1294 return css::uno::Sequence
<
1295 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1300 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1301 SAL_CALL
getOptionalServices() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1303 return css::uno::Sequence
<
1304 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >();
1309 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1310 SAL_CALL
getMandatoryInterfaces() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1312 return css::uno::Sequence
<
1313 css::uno::Reference
<
1314 css::reflection::XInterfaceTypeDescription
> >();
1319 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1320 SAL_CALL
getOptionalInterfaces() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1322 return css::uno::Sequence
<
1323 css::uno::Reference
<
1324 css::reflection::XInterfaceTypeDescription
> >();
1329 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1330 SAL_CALL
getProperties() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1332 return css::uno::Sequence
<
1333 css::uno::Reference
<
1334 css::reflection::XPropertyTypeDescription
> >();
1337 virtual sal_Bool SAL_CALL
isSingleInterfaceBased()
1338 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1341 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1342 getInterface() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1343 { return manager_
->resolve(entity_
->getBase()); }
1347 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1348 SAL_CALL
getConstructors() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1350 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1351 rtl::OUString name_
;
1352 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> entity_
;
1356 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1357 SingleInterfaceBasedServiceDescription::getConstructors()
1358 throw (css::uno::RuntimeException
, std::exception
)
1360 assert(entity_
->getConstructors().size() <= SAL_MAX_INT32
);
1361 sal_Int32 n
= static_cast< sal_Int32
>(entity_
->getConstructors().size());
1363 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1365 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1366 s
[i
] = new ConstructorDescription(
1367 manager_
, entity_
->getConstructors()[i
]);
1372 class PropertyDescription
:
1373 public cppu::WeakImplHelper1
< css::reflection::XPropertyTypeDescription
>
1376 PropertyDescription(
1377 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1378 unoidl::AccumulationBasedServiceEntity::Property
const & property
):
1379 manager_(manager
), property_(property
)
1380 { assert(manager
.is()); }
1383 virtual ~PropertyDescription() {}
1385 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1386 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1387 { return css::uno::TypeClass_PROPERTY
; }
1389 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1390 { return property_
.name
; }
1392 virtual sal_Int16 SAL_CALL
getPropertyFlags()
1393 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1394 { return property_
.attributes
; }
1396 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1397 getPropertyTypeDescription() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1398 { return manager_
->resolve(property_
.type
); }
1400 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1401 unoidl::AccumulationBasedServiceEntity::Property property_
;
1404 typedef cppu::ImplInheritanceHelper1
<
1405 PublishableDescription
, css::reflection::XServiceTypeDescription2
>
1406 AccumulationBasedServiceDescription_Base
;
1408 class AccumulationBasedServiceDescription
:
1409 public AccumulationBasedServiceDescription_Base
1412 AccumulationBasedServiceDescription(
1413 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1414 rtl::OUString
const & name
,
1415 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const &
1417 AccumulationBasedServiceDescription_Base(entity
->isPublished()),
1418 manager_(manager
), name_(name
), entity_(entity
)
1419 { assert(manager
.is()); assert(entity
.is()); }
1422 virtual ~AccumulationBasedServiceDescription() {}
1424 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1425 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1426 { return css::uno::TypeClass_SERVICE
; }
1428 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1433 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1434 SAL_CALL
getMandatoryServices() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1438 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1439 SAL_CALL
getOptionalServices() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1443 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1444 SAL_CALL
getMandatoryInterfaces() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1448 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1449 SAL_CALL
getOptionalInterfaces() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1453 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1454 SAL_CALL
getProperties() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1456 virtual sal_Bool SAL_CALL
isSingleInterfaceBased()
1457 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1460 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1461 getInterface() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1462 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1466 css::uno::Reference
< css::reflection::XServiceConstructorDescription
> >
1467 SAL_CALL
getConstructors() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1469 return css::uno::Sequence
<
1470 css::uno::Reference
<
1471 css::reflection::XServiceConstructorDescription
> >();
1474 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1475 rtl::OUString name_
;
1476 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> entity_
;
1480 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1481 AccumulationBasedServiceDescription::getMandatoryServices()
1482 throw (css::uno::RuntimeException
, std::exception
)
1484 assert(entity_
->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32
);
1485 sal_Int32 n
= static_cast< sal_Int32
>(
1486 entity_
->getDirectMandatoryBaseServices().size());
1488 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1489 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1492 entity_
->getDirectMandatoryBaseServices()[i
].name
),
1493 css::uno::UNO_QUERY_THROW
);
1499 css::uno::Reference
< css::reflection::XServiceTypeDescription
> >
1500 AccumulationBasedServiceDescription::getOptionalServices()
1501 throw (css::uno::RuntimeException
, std::exception
)
1503 assert(entity_
->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32
);
1504 sal_Int32 n
= static_cast< sal_Int32
>(
1505 entity_
->getDirectOptionalBaseServices().size());
1507 css::uno::Reference
< css::reflection::XServiceTypeDescription
> > s(n
);
1508 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1510 manager_
->resolve(entity_
->getDirectOptionalBaseServices()[i
].name
),
1511 css::uno::UNO_QUERY_THROW
);
1517 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1518 AccumulationBasedServiceDescription::getMandatoryInterfaces()
1519 throw (css::uno::RuntimeException
, std::exception
)
1521 assert(entity_
->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32
);
1522 sal_Int32 n
= static_cast< sal_Int32
>(
1523 entity_
->getDirectMandatoryBaseInterfaces().size());
1525 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1527 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1531 entity_
->getDirectMandatoryBaseInterfaces()[i
].name
)),
1532 css::uno::UNO_QUERY_THROW
);
1538 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> >
1539 AccumulationBasedServiceDescription::getOptionalInterfaces()
1540 throw (css::uno::RuntimeException
, std::exception
)
1542 assert(entity_
->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32
);
1543 sal_Int32 n
= static_cast< sal_Int32
>(
1544 entity_
->getDirectOptionalBaseInterfaces().size());
1546 css::uno::Reference
< css::reflection::XInterfaceTypeDescription
> > s(
1548 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1552 entity_
->getDirectOptionalBaseInterfaces()[i
].name
)),
1553 css::uno::UNO_QUERY_THROW
);
1559 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> >
1560 AccumulationBasedServiceDescription::getProperties()
1561 throw (css::uno::RuntimeException
, std::exception
)
1563 assert(entity_
->getDirectProperties().size() <= SAL_MAX_INT32
);
1564 sal_Int32 n
= static_cast< sal_Int32
>(
1565 entity_
->getDirectProperties().size());
1567 css::uno::Reference
< css::reflection::XPropertyTypeDescription
> > s(n
);
1568 for (sal_Int32 i
= 0; i
!= n
; ++i
) {
1569 s
[i
] = new PropertyDescription(
1570 manager_
, entity_
->getDirectProperties()[i
]);
1575 typedef cppu::ImplInheritanceHelper1
<
1576 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1577 InterfaceBasedSingletonDescription_Base
;
1579 class InterfaceBasedSingletonDescription
:
1580 public InterfaceBasedSingletonDescription_Base
1583 InterfaceBasedSingletonDescription(
1584 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1585 rtl::OUString
const & name
,
1586 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
):
1587 InterfaceBasedSingletonDescription_Base(entity
->isPublished()),
1588 manager_(manager
), name_(name
), entity_(entity
)
1589 { assert(manager
.is()); assert(entity
.is()); }
1592 virtual ~InterfaceBasedSingletonDescription() {}
1594 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1595 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1596 { return css::uno::TypeClass_SINGLETON
; }
1598 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1601 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1602 SAL_CALL
getService() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1605 css::uno::Reference
< css::reflection::XServiceTypeDescription
>();
1608 virtual sal_Bool SAL_CALL
isInterfaceBased()
1609 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1612 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1613 SAL_CALL
getInterface() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1614 { return manager_
->resolve(entity_
->getBase()); }
1616 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1617 rtl::OUString name_
;
1618 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> entity_
;
1621 typedef cppu::ImplInheritanceHelper1
<
1622 PublishableDescription
, css::reflection::XSingletonTypeDescription2
>
1623 ServiceBasedSingletonDescription_Base
;
1625 class ServiceBasedSingletonDescription
:
1626 public ServiceBasedSingletonDescription_Base
1629 ServiceBasedSingletonDescription(
1630 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1631 rtl::OUString
const & name
,
1632 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> const & entity
):
1633 ServiceBasedSingletonDescription_Base(entity_
->isPublished()),
1634 manager_(manager
), name_(name
), entity_(entity
)
1635 { assert(manager
.is()); assert(entity
.is()); }
1638 virtual ~ServiceBasedSingletonDescription() {}
1640 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
1641 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1642 { return css::uno::TypeClass_SINGLETON
; }
1644 virtual rtl::OUString SAL_CALL
getName() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1647 virtual css::uno::Reference
< css::reflection::XServiceTypeDescription
>
1648 SAL_CALL
getService() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1650 return css::uno::Reference
< css::reflection::XServiceTypeDescription
>(
1651 manager_
->resolve(entity_
->getBase()), css::uno::UNO_QUERY_THROW
);
1654 virtual sal_Bool SAL_CALL
isInterfaceBased()
1655 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1658 virtual css::uno::Reference
< css::reflection::XTypeDescription
>
1659 SAL_CALL
getInterface() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1660 { return css::uno::Reference
< css::reflection::XTypeDescription
>(); }
1662 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1663 rtl::OUString name_
;
1664 rtl::Reference
< unoidl::ServiceBasedSingletonEntity
> entity_
;
1668 public cppu::WeakImplHelper1
< css::reflection::XTypeDescriptionEnumeration
>
1672 rtl::Reference
< cppuhelper::TypeManager
> const & manager
,
1673 rtl::OUString
const & prefix
,
1674 rtl::Reference
< unoidl::MapCursor
> const & cursor
,
1675 css::uno::Sequence
< css::uno::TypeClass
> const & types
, bool deep
):
1676 manager_(manager
), types_(types
), deep_(deep
)
1678 assert(manager
.is());
1679 positions_
.push(Position(prefix
, cursor
));
1684 virtual ~Enumeration() {}
1686 virtual sal_Bool SAL_CALL
hasMoreElements()
1687 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1688 { return !positions_
.empty(); }
1690 virtual css::uno::Any SAL_CALL
nextElement()
1692 css::container::NoSuchElementException
,
1693 css::lang::WrappedTargetException
, css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
1694 { return css::uno::makeAny(nextTypeDescription()); }
1696 virtual css::uno::Reference
< css::reflection::XTypeDescription
> SAL_CALL
1697 nextTypeDescription()
1699 css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
1701 bool matches(css::uno::TypeClass tc
) const;
1703 void findNextMatch();
1707 rtl::OUString
const & thePrefix
,
1708 rtl::Reference
< unoidl::MapCursor
> const & theCursor
):
1709 prefix(thePrefix
), cursor(theCursor
)
1710 { assert(theCursor
.is()); }
1713 rtl::OUString
const & thePrefix
,
1714 rtl::Reference
< unoidl::ConstantGroupEntity
> const &
1716 prefix(thePrefix
), constantGroup(theConstantGroup
),
1717 constantGroupIndex(constantGroup
->getMembers().begin())
1718 { assert(theConstantGroup
.is()); }
1720 Position(Position
const & other
):
1721 prefix(other
.prefix
), cursor(other
.cursor
),
1722 constantGroup(other
.constantGroup
)
1724 if (constantGroup
.is()) {
1725 constantGroupIndex
= other
.constantGroupIndex
;
1729 rtl::OUString prefix
;
1730 rtl::Reference
< unoidl::MapCursor
> cursor
;
1731 rtl::Reference
< unoidl::ConstantGroupEntity
> constantGroup
;
1732 std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
1736 rtl::Reference
< cppuhelper::TypeManager
> manager_
;
1737 css::uno::Sequence
< css::uno::TypeClass
> types_
;
1741 std::stack
< Position
> positions_
;
1742 rtl::OUString current_
;
1745 css::uno::Reference
< css::reflection::XTypeDescription
>
1746 Enumeration::nextTypeDescription()
1747 throw (css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
)
1751 osl::MutexGuard
g(mutex_
);
1752 if (positions_
.empty()) {
1753 throw css::container::NoSuchElementException(
1754 "exhausted XTypeDescriptionEnumeration",
1755 static_cast< cppu::OWeakObject
* >(this));
1760 return manager_
->resolve(name
);
1763 bool Enumeration::matches(css::uno::TypeClass tc
) const {
1764 if (types_
.getLength() == 0) {
1767 for (sal_Int32 i
= 0; i
!= types_
.getLength(); ++i
) {
1768 if (types_
[i
] == tc
) {
1775 void Enumeration::findNextMatch() {
1778 assert(!positions_
.empty());
1780 if (positions_
.top().cursor
.is()) { // root or module
1781 rtl::Reference
< unoidl::Entity
> ent(
1782 positions_
.top().cursor
->getNext(&name
));
1785 if (positions_
.empty()) {
1790 name
= positions_
.top().prefix
+ name
;
1791 css::uno::TypeClass tc
;
1792 switch (ent
->getSort()) {
1793 case unoidl::Entity::SORT_MODULE
:
1794 tc
= css::uno::TypeClass_MODULE
;
1799 static_cast< unoidl::ModuleEntity
* >(
1800 ent
.get())->createCursor()));
1803 case unoidl::Entity::SORT_ENUM_TYPE
:
1804 tc
= css::uno::TypeClass_ENUM
;
1806 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
1807 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
1808 tc
= css::uno::TypeClass_STRUCT
;
1810 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
1811 tc
= css::uno::TypeClass_EXCEPTION
;
1813 case unoidl::Entity::SORT_INTERFACE_TYPE
:
1814 tc
= css::uno::TypeClass_INTERFACE
;
1816 case unoidl::Entity::SORT_TYPEDEF
:
1817 tc
= css::uno::TypeClass_TYPEDEF
;
1819 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1820 tc
= css::uno::TypeClass_CONSTANTS
;
1821 if (deep_
&& matches(css::uno::TypeClass_CONSTANT
)) {
1825 static_cast< unoidl::ConstantGroupEntity
* >(
1829 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
1830 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
1831 tc
= css::uno::TypeClass_SERVICE
;
1833 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
1834 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
1835 tc
= css::uno::TypeClass_SINGLETON
;
1838 for (;;) { std::abort(); } // this cannot happen
1844 } else { // constant group
1845 if (positions_
.top().constantGroupIndex
1846 == positions_
.top().constantGroup
->getMembers().end())
1849 if (positions_
.empty()) {
1854 current_
= positions_
.top().prefix
1855 + positions_
.top().constantGroupIndex
++->name
;
1859 } catch (unoidl::FileFormatException
& e
) {
1860 throw css::uno::DeploymentException(
1861 e
.getUri() + ": " + e
.getDetail(),
1862 static_cast< cppu::OWeakObject
* >(this));
1868 cppuhelper::TypeManager::TypeManager():
1869 TypeManager_Base(m_aMutex
),
1870 manager_(new unoidl::Manager
)
1873 void cppuhelper::TypeManager::init(rtl::OUString
const & rdbUris
) {
1877 css::uno::Any
cppuhelper::TypeManager::find(rtl::OUString
const & name
) {
1878 //TODO: caching? (here or in unoidl::Manager?)
1880 char const * name
; sal_Int32 length
;
1881 css::uno::TypeClass typeClass
;
1883 static Simple
const simple
[] = {
1884 { RTL_CONSTASCII_STRINGPARAM("void"), css::uno::TypeClass_VOID
},
1885 { RTL_CONSTASCII_STRINGPARAM("boolean"), css::uno::TypeClass_BOOLEAN
},
1886 { RTL_CONSTASCII_STRINGPARAM("byte"), css::uno::TypeClass_BYTE
},
1887 { RTL_CONSTASCII_STRINGPARAM("short"), css::uno::TypeClass_SHORT
},
1888 { RTL_CONSTASCII_STRINGPARAM("unsigned short"),
1889 css::uno::TypeClass_UNSIGNED_SHORT
},
1890 { RTL_CONSTASCII_STRINGPARAM("long"), css::uno::TypeClass_LONG
},
1891 { RTL_CONSTASCII_STRINGPARAM("unsigned long"),
1892 css::uno::TypeClass_UNSIGNED_LONG
},
1893 { RTL_CONSTASCII_STRINGPARAM("hyper"), css::uno::TypeClass_HYPER
},
1894 { RTL_CONSTASCII_STRINGPARAM("unsigned hyper"),
1895 css::uno::TypeClass_UNSIGNED_HYPER
},
1896 { RTL_CONSTASCII_STRINGPARAM("float"), css::uno::TypeClass_FLOAT
},
1897 { RTL_CONSTASCII_STRINGPARAM("double"), css::uno::TypeClass_DOUBLE
},
1898 { RTL_CONSTASCII_STRINGPARAM("char"), css::uno::TypeClass_CHAR
},
1899 { RTL_CONSTASCII_STRINGPARAM("string"), css::uno::TypeClass_STRING
},
1900 { RTL_CONSTASCII_STRINGPARAM("type"), css::uno::TypeClass_TYPE
},
1901 { RTL_CONSTASCII_STRINGPARAM("any"), css::uno::TypeClass_ANY
} };
1902 for (std::size_t i
= 0; i
!= SAL_N_ELEMENTS(simple
); ++i
) {
1903 if (name
.equalsAsciiL(simple
[i
].name
, simple
[i
].length
)) {
1904 return css::uno::makeAny
<
1905 css::uno::Reference
< css::reflection::XTypeDescription
> >(
1906 new SimpleTypeDescription(simple
[i
].typeClass
, name
));
1909 if (name
.startsWith("[]")) {
1910 return getSequenceType(name
);
1912 sal_Int32 i
= name
.indexOf('<');
1914 return getInstantiatedStruct(name
, i
);
1916 i
= name
.indexOf("::");
1918 return getInterfaceMember(name
, i
);
1920 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
));
1922 return getNamed(name
, ent
);
1924 i
= name
.lastIndexOf('.');
1926 rtl::OUString
parent(name
.copy(0, i
));
1927 ent
= findEntity(parent
);
1929 switch (ent
->getSort()) {
1930 case unoidl::Entity::SORT_ENUM_TYPE
:
1931 return getEnumMember(
1932 static_cast< unoidl::EnumTypeEntity
* >(ent
.get()),
1934 case unoidl::Entity::SORT_CONSTANT_GROUP
:
1937 static_cast< unoidl::ConstantGroupEntity
* >(ent
.get()),
1944 return css::uno::Any();
1947 css::uno::Reference
< css::reflection::XTypeDescription
>
1948 cppuhelper::TypeManager::resolve(rtl::OUString
const & name
) {
1949 css::uno::Reference
< css::reflection::XTypeDescription
> desc(
1950 find(name
), css::uno::UNO_QUERY
);
1952 throw css::uno::DeploymentException(
1953 "cannot resolve type \"" + name
+ "\"",
1954 static_cast< cppu::OWeakObject
* >(this));
1959 cppuhelper::TypeManager::~TypeManager() throw () {}
1961 void cppuhelper::TypeManager::disposing() {} //TODO
1963 rtl::OUString
cppuhelper::TypeManager::getImplementationName()
1964 throw (css::uno::RuntimeException
, std::exception
)
1966 return rtl::OUString(
1967 "com.sun.star.comp.cppuhelper.bootstrap.TypeManager");
1970 sal_Bool
cppuhelper::TypeManager::supportsService(
1971 rtl::OUString
const & ServiceName
)
1972 throw (css::uno::RuntimeException
, std::exception
)
1974 return cppu::supportsService(this, ServiceName
);
1977 css::uno::Sequence
< rtl::OUString
>
1978 cppuhelper::TypeManager::getSupportedServiceNames()
1979 throw (css::uno::RuntimeException
, std::exception
)
1981 css::uno::Sequence
< rtl::OUString
> names(1);
1982 names
[0] = "com.sun.star.reflection.TypeDescriptionManager"; //TODO
1986 css::uno::Any
cppuhelper::TypeManager::getByHierarchicalName(
1987 rtl::OUString
const & aName
)
1988 throw (css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
)
1990 css::uno::Any
desc(find(aName
));
1991 if (!desc
.hasValue()) {
1992 throw css::container::NoSuchElementException(
1993 aName
, static_cast< cppu::OWeakObject
* >(this));
1998 sal_Bool
cppuhelper::TypeManager::hasByHierarchicalName(
1999 rtl::OUString
const & aName
)
2000 throw (css::uno::RuntimeException
, std::exception
)
2002 return find(aName
).hasValue();
2005 css::uno::Type
cppuhelper::TypeManager::getElementType()
2006 throw (css::uno::RuntimeException
, std::exception
)
2008 return cppu::UnoType
< rtl::OUString
>::get();
2011 sal_Bool
cppuhelper::TypeManager::hasElements()
2012 throw (css::uno::RuntimeException
, std::exception
)
2014 throw css::uno::RuntimeException(
2015 "TypeManager hasElements: method not supported",
2016 static_cast< cppu::OWeakObject
* >(this));
2019 css::uno::Reference
< css::container::XEnumeration
>
2020 cppuhelper::TypeManager::createEnumeration()
2021 throw (css::uno::RuntimeException
, std::exception
)
2023 throw css::uno::RuntimeException(
2024 "TypeManager createEnumeration: method not supported",
2025 static_cast< cppu::OWeakObject
* >(this));
2028 sal_Bool
cppuhelper::TypeManager::has(css::uno::Any
const &)
2029 throw (css::uno::RuntimeException
, std::exception
)
2031 throw css::uno::RuntimeException(
2032 "TypeManager has: method not supported",
2033 static_cast< cppu::OWeakObject
* >(this));
2036 void cppuhelper::TypeManager::insert(css::uno::Any
const & aElement
)
2038 css::lang::IllegalArgumentException
,
2039 css::container::ElementExistException
, css::uno::RuntimeException
, std::exception
)
2042 if (!(aElement
>>= uri
)) {
2043 throw css::lang::IllegalArgumentException(
2044 ("css.uno.theTypeDescriptionManager.insert expects a string URI"
2046 static_cast< cppu::OWeakObject
* >(this), 0);
2048 //TODO: check for ElementExistException
2049 //TODO: check for consistency with existing data
2050 readRdbFile(uri
, false);
2053 void cppuhelper::TypeManager::remove(css::uno::Any
const & aElement
)
2055 css::lang::IllegalArgumentException
,
2056 css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
)
2059 if (!(aElement
>>= uri
)) {
2060 throw css::lang::IllegalArgumentException(
2061 ("css.uno.theTypeDescriptionManager.remove expects a string URI"
2063 static_cast< cppu::OWeakObject
* >(this), 0);
2065 //TODO: remove requests are silently ignored for now
2068 css::uno::Reference
< css::reflection::XTypeDescriptionEnumeration
>
2069 cppuhelper::TypeManager::createTypeDescriptionEnumeration(
2070 rtl::OUString
const & moduleName
,
2071 css::uno::Sequence
< css::uno::TypeClass
> const & types
,
2072 css::reflection::TypeDescriptionSearchDepth depth
)
2074 css::reflection::NoSuchTypeNameException
,
2075 css::reflection::InvalidTypeNameException
,
2076 css::uno::RuntimeException
, std::exception
)
2078 rtl::Reference
< unoidl::MapCursor
> cursor
;
2080 cursor
= manager_
->createCursor(moduleName
);
2081 } catch (unoidl::FileFormatException
& e
) {
2082 throw css::uno::DeploymentException(
2083 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2085 static_cast< cppu::OWeakObject
* >(this));
2088 //TODO: css::reflection::InvalidTypeNameException if moduleName names a
2090 throw css::reflection::NoSuchTypeNameException(
2091 moduleName
, static_cast< cppu::OWeakObject
* >(this));
2093 return new Enumeration(
2094 this, makePrefix(moduleName
), cursor
, types
,
2095 depth
== css::reflection::TypeDescriptionSearchDepth_INFINITE
);
2098 void cppuhelper::TypeManager::readRdbs(rtl::OUString
const & uris
) {
2099 for (sal_Int32 i
= 0; i
!= -1;) {
2100 rtl::OUString
uri(uris
.getToken(0, ' ', i
));
2101 if (uri
.isEmpty()) {
2106 cppu::decodeRdbUri(&uri
, &optional
, &directory
);
2108 readRdbDirectory(uri
, optional
);
2110 readRdbFile(uri
, optional
);
2115 void cppuhelper::TypeManager::readRdbDirectory(
2116 rtl::OUString
const & uri
, bool optional
)
2118 osl::Directory
dir(uri
);
2119 switch (dir
.open()) {
2120 case osl::FileBase::E_None
:
2122 case osl::FileBase::E_NOENT
:
2124 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2129 throw css::uno::DeploymentException(
2130 "Cannot open directory " + uri
,
2131 static_cast< cppu::OWeakObject
* >(this));
2135 if (!cppu::nextDirectoryItem(dir
, &url
)) {
2138 readRdbFile(url
, false);
2142 void cppuhelper::TypeManager::readRdbFile(
2143 rtl::OUString
const & uri
, bool optional
)
2146 manager_
->addProvider(uri
);
2147 } catch (unoidl::NoSuchFileException
&) {
2149 throw css::uno::DeploymentException(
2150 uri
+ ": no such file",
2151 static_cast< cppu::OWeakObject
* >(this));
2153 SAL_INFO("cppuhelper", "Ignored optional " << uri
);
2154 } catch (unoidl::FileFormatException
& e
) {
2155 throw css::uno::DeploymentException(
2156 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2158 static_cast< cppu::OWeakObject
* >(this));
2162 css::uno::Any
cppuhelper::TypeManager::getSequenceType(
2163 rtl::OUString
const & name
)
2165 assert(name
.startsWith("[]"));
2166 return css::uno::makeAny
<
2167 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2168 new SequenceTypeDescription(
2169 this, name
, name
.copy(std::strlen("[]"))));
2172 css::uno::Any
cppuhelper::TypeManager::getInstantiatedStruct(
2173 rtl::OUString
const & name
, sal_Int32 separator
)
2175 assert(name
.indexOf('<') == separator
&& separator
!= -1);
2176 rtl::Reference
< unoidl::Entity
> ent(findEntity(name
.copy(0, separator
)));
2179 != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
))
2181 return css::uno::Any();
2183 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
2184 static_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
2186 std::vector
< rtl::OUString
> args
;
2187 sal_Int32 i
= separator
;
2189 ++i
; // skip '<' or ','
2191 for (sal_Int32 level
= 0; j
!= name
.getLength(); ++j
) {
2192 sal_Unicode c
= name
[j
];
2197 } else if (c
== '<') {
2199 } else if (c
== '>') {
2206 if (j
!= name
.getLength()) {
2207 args
.push_back(name
.copy(i
, j
- i
));
2210 } while (i
!= name
.getLength() && name
[i
] != '>');
2211 if (i
!= name
.getLength() - 1 || name
[i
] != '>'
2212 || args
.size() != ent2
->getTypeParameters().size())
2214 return css::uno::Any();
2216 return css::uno::makeAny
<
2217 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2218 new InstantiatedPolymorphicStructTypeDescription(
2219 this, name
, ent2
, args
));
2222 css::uno::Any
cppuhelper::TypeManager::getInterfaceMember(
2223 rtl::OUString
const & name
, sal_Int32 separator
)
2225 assert(name
.indexOf("::") == separator
&& separator
!= -1);
2226 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
> ifc(
2227 resolveTypedefs(find(name
.copy(0, separator
))), css::uno::UNO_QUERY
);
2229 return css::uno::Any();
2231 rtl::OUString
member(name
.copy(separator
+ std::strlen("::")));
2233 css::uno::Reference
<
2234 css::reflection::XInterfaceMemberTypeDescription
> > mems(
2236 for (sal_Int32 i
= 0; i
!= mems
.getLength(); ++i
) {
2237 if (mems
[i
]->getMemberName() == member
) {
2238 return css::uno::makeAny
<
2239 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2243 return css::uno::Any();
2246 css::uno::Any
cppuhelper::TypeManager::getNamed(
2247 rtl::OUString
const & name
, rtl::Reference
< unoidl::Entity
> const & entity
)
2249 assert(entity
.is());
2250 switch (entity
->getSort()) {
2251 case unoidl::Entity::SORT_MODULE
:
2252 return css::uno::makeAny
<
2253 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2254 new ModuleDescription(
2256 static_cast< unoidl::ModuleEntity
* >(entity
.get())));
2257 case unoidl::Entity::SORT_ENUM_TYPE
:
2258 return css::uno::makeAny
<
2259 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2260 new EnumTypeDescription(
2262 static_cast< unoidl::EnumTypeEntity
* >(entity
.get())));
2263 case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE
:
2264 return css::uno::makeAny
<
2265 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2266 new PlainStructTypeDescription(
2268 static_cast< unoidl::PlainStructTypeEntity
* >(
2270 case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
2271 return css::uno::makeAny
<
2272 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2273 new PolymorphicStructTypeTemplateDescription(
2276 unoidl::PolymorphicStructTypeTemplateEntity
* >(
2278 case unoidl::Entity::SORT_EXCEPTION_TYPE
:
2279 return css::uno::makeAny
<
2280 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2281 new ExceptionTypeDescription(
2283 static_cast< unoidl::ExceptionTypeEntity
* >(
2285 case unoidl::Entity::SORT_INTERFACE_TYPE
:
2286 return css::uno::makeAny
<
2287 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2288 new InterfaceTypeDescription(
2290 static_cast< unoidl::InterfaceTypeEntity
* >(
2292 case unoidl::Entity::SORT_TYPEDEF
:
2293 return css::uno::makeAny
<
2294 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2295 new TypedefDescription(
2297 static_cast< unoidl::TypedefEntity
* >(entity
.get())));
2298 case unoidl::Entity::SORT_CONSTANT_GROUP
:
2299 return css::uno::makeAny
<
2300 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2301 new ConstantGroupDescription(
2303 static_cast< unoidl::ConstantGroupEntity
* >(
2305 case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
2306 return css::uno::makeAny
<
2307 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2308 new SingleInterfaceBasedServiceDescription(
2310 static_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
2312 case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE
:
2313 return css::uno::makeAny
<
2314 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2315 new AccumulationBasedServiceDescription(
2317 static_cast< unoidl::AccumulationBasedServiceEntity
* >(
2319 case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON
:
2320 return css::uno::makeAny
<
2321 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2322 new InterfaceBasedSingletonDescription(
2324 static_cast< unoidl::InterfaceBasedSingletonEntity
* >(
2326 case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON
:
2327 return css::uno::makeAny
<
2328 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2329 new ServiceBasedSingletonDescription(
2331 static_cast< unoidl::ServiceBasedSingletonEntity
* >(
2334 for (;;) { std::abort(); } // this cannot happen
2338 css::uno::Any
cppuhelper::TypeManager::getEnumMember(
2339 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
2340 rtl::OUString
const & member
)
2342 for (std::vector
< unoidl::EnumTypeEntity::Member
>::const_iterator
i(
2343 entity
->getMembers().begin());
2344 i
!= entity
->getMembers().end(); ++i
)
2346 if (i
->name
== member
) {
2347 return css::uno::makeAny(i
->value
);
2350 return css::uno::Any();
2353 css::uno::Any
cppuhelper::TypeManager::getConstant(
2354 rtl::OUString
const & constantGroupName
,
2355 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
2356 rtl::OUString
const & member
)
2358 for (std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
i(
2359 entity
->getMembers().begin());
2360 i
!= entity
->getMembers().end(); ++i
)
2362 if (i
->name
== member
) {
2363 return css::uno::makeAny
<
2364 css::uno::Reference
< css::reflection::XTypeDescription
> >(
2365 new ConstantDescription(constantGroupName
, *i
));
2368 return css::uno::Any();
2371 rtl::Reference
< unoidl::Entity
> cppuhelper::TypeManager::findEntity(
2372 rtl::OUString
const & name
)
2375 return manager_
->findEntity(name
);
2376 } catch (unoidl::FileFormatException
& e
) {
2377 throw css::uno::DeploymentException(
2378 ("unoidl::FileFormatException for <" + e
.getUri() + ">: "
2380 static_cast< cppu::OWeakObject
* >(this));
2384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */