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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "sal/config.h"
22 #include "codemaker/codemaker.hxx"
23 #include "codemaker/commoncpp.hxx"
24 #include "codemaker/global.hxx"
26 #include "skeletoncommon.hxx"
27 #include "skeletoncpp.hxx"
29 using namespace ::codemaker::cpp
;
31 namespace skeletonmaker
{ namespace cpp
{
34 std::ostream
& o
, ProgramOptions
const & options
,
35 rtl::Reference
< TypeManager
> const & manager
,
36 codemaker::UnoType::Sort sort
, OUString
const & nucleus
, sal_Int32 rank
,
37 std::vector
< OUString
> const & arguments
,
38 rtl::Reference
< unoidl::Entity
> const & entity
, short referenceType
,
41 if (defaultvalue
&& rank
== 0 && sort
<= codemaker::UnoType::Sort::Char
) {
43 case codemaker::UnoType::Sort::Boolean
:
46 case codemaker::UnoType::Sort::Char
:
47 case codemaker::UnoType::Sort::Byte
:
48 case codemaker::UnoType::Sort::Short
:
49 case codemaker::UnoType::Sort::UnsignedShort
:
50 case codemaker::UnoType::Sort::Long
:
51 case codemaker::UnoType::Sort::UnsignedLong
:
52 case codemaker::UnoType::Sort::Hyper
:
53 case codemaker::UnoType::Sort::UnsignedHyper
:
54 case codemaker::UnoType::Sort::Float
:
55 case codemaker::UnoType::Sort::Double
:
63 if (defaultvalue
&& referenceType
== 16) {
64 if (sort
== codemaker::UnoType::Sort::Enum
) {
65 o
<< nucleus
.copy(nucleus
.lastIndexOf('.') + 1) << "_"
66 << dynamic_cast< unoidl::EnumTypeEntity
* >(entity
.get())->
71 bool bReference
= false;
72 if (((sort
> codemaker::UnoType::Sort::Char
||
73 rank
> 0) && referenceType
!= 8 &&
74 !(sort
== codemaker::UnoType::Sort::Enum
&& referenceType
== 4 && rank
== 0)) ||
75 (sort
<= codemaker::UnoType::Sort::Char
&& referenceType
== 2))
80 if (bReference
&& referenceType
== 4)
83 for (sal_Int32 i
= 0; i
< rank
; ++i
) {
84 o
<< ((options
.shortnames
) ? "css::uno::Sequence< " :
85 "::com::sun::star::uno::Sequence< ");
87 if (sort
== codemaker::UnoType::Sort::Interface
&& referenceType
> 0) {
88 o
<< ((options
.shortnames
) ? "css::uno::Reference< " :
89 "::com::sun::star::uno::Reference< ");
92 o
<< scopedCppName(codemaker::cpp::translateUnoToCppType(sort
, nucleus
),
93 options
.shortnames
&& referenceType
> 0);
95 if (sort
== codemaker::UnoType::Sort::Interface
&& referenceType
> 0)
98 if (!arguments
.empty()) {
100 for (std::vector
< OUString
>::const_iterator
i(arguments
.begin());
101 i
!= arguments
.end(); ++i
)
103 if (i
!= arguments
.begin())
106 printType(o
, options
, manager
, *i
, 1);
111 for (sal_Int32 i
= 0; i
< rank
; ++i
)
114 if (bReference
&& referenceType
> 1)
117 if (referenceType
== 8 && (sort
> codemaker::UnoType::Sort::Char
|| rank
> 0))
122 std::ostream
& o
, ProgramOptions
const & options
,
123 rtl::Reference
< TypeManager
> const & manager
, OUString
const & name
,
124 short referenceType
, bool defaultvalue
)
128 std::vector
< OUString
> arguments
;
129 rtl::Reference
< unoidl::Entity
> entity
;
130 codemaker::UnoType::Sort sort
= manager
->decompose(
131 name
, true, &nucleus
, &rank
, &arguments
, &entity
);
133 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
134 referenceType
, defaultvalue
);
137 bool printConstructorParameters(
138 std::ostream
& o
, ProgramOptions
const & options
,
139 rtl::Reference
< TypeManager
> const & manager
,
140 codemaker::UnoType::Sort sort
,
141 rtl::Reference
< unoidl::Entity
> const & entity
, OUString
const & name
,
142 std::vector
< OUString
> const & arguments
)
144 bool previous
= false;
146 case codemaker::UnoType::Sort::PlainStruct
:
148 rtl::Reference
< unoidl::PlainStructTypeEntity
> ent2(
149 dynamic_cast< unoidl::PlainStructTypeEntity
* >(entity
.get()));
151 if (!ent2
->getDirectBase().isEmpty()) {
152 rtl::Reference
< unoidl::Entity
> baseEnt
;
153 codemaker::UnoType::Sort baseSort
= manager
->getSort(
154 ent2
->getDirectBase(), &baseEnt
);
155 previous
= printConstructorParameters(
156 o
, options
, manager
, baseSort
, baseEnt
,
157 ent2
->getDirectBase(), std::vector
< OUString
>());
159 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
160 const_iterator
i(ent2
->getDirectMembers().begin());
161 i
!= ent2
->getDirectMembers().end(); ++i
)
167 printType(o
, options
, manager
, i
->type
, 4);
169 << codemaker::cpp::translateUnoToCppIdentifier(
170 u2b(i
->name
), "param");
174 case codemaker::UnoType::Sort::PolymorphicStructTemplate
:
176 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
177 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
181 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
182 const_iterator
i(ent2
->getMembers().begin());
183 i
!= ent2
->getMembers().end(); ++i
)
189 if (i
->parameterized
) {
192 printType(o
, options
, manager
, i
->type
, 4);
195 << codemaker::cpp::translateUnoToCppIdentifier(
196 u2b(i
->name
), "param");
200 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct
:
202 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
203 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
207 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
208 const_iterator
i(ent2
->getMembers().begin());
209 i
!= ent2
->getMembers().end(); ++i
)
215 if (i
->parameterized
) {
216 for (std::vector
< OUString
>::const_iterator
j(
217 ent2
->getTypeParameters().begin());
218 j
!= ent2
->getTypeParameters().end(); ++j
)
222 j
- ent2
->getTypeParameters().begin()];
227 printType(o
, options
, manager
, i
->type
, 4);
230 << codemaker::cpp::translateUnoToCppIdentifier(
231 u2b(i
->name
), "param");
235 case codemaker::UnoType::Sort::Exception
:
237 rtl::Reference
< unoidl::ExceptionTypeEntity
> ent2(
238 dynamic_cast< unoidl::ExceptionTypeEntity
* >(entity
.get()));
240 if (!ent2
->getDirectBase().isEmpty()) {
241 rtl::Reference
< unoidl::Entity
> baseEnt
;
242 codemaker::UnoType::Sort baseSort
= manager
->getSort(
243 ent2
->getDirectBase(), &baseEnt
);
244 previous
= printConstructorParameters(
245 o
, options
, manager
, baseSort
, baseEnt
,
246 ent2
->getDirectBase(), std::vector
< OUString
>());
248 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::
249 const_iterator
i(ent2
->getDirectMembers().begin());
250 i
!= ent2
->getDirectMembers().end(); ++i
)
256 printType(o
, options
, manager
, i
->type
, 4);
258 << codemaker::cpp::translateUnoToCppIdentifier(
259 u2b(i
->name
), "param");
264 throw CannotDumpException(
265 "unexpected entity \"" + name
266 + "\" in call to skeletonmaker::cpp::printConstructorParameters");
271 void printConstructor(
272 std::ostream
& o
, ProgramOptions
const & options
,
273 rtl::Reference
< TypeManager
> const & manager
,
274 codemaker::UnoType::Sort sort
,
275 rtl::Reference
< unoidl::Entity
> const & entity
, OUString
const & name
,
276 std::vector
< OUString
> const & arguments
)
278 o
<< "public " << name
.copy(name
.lastIndexOf('.') + 1) << '(';
279 printConstructorParameters(
280 o
, options
, manager
, sort
, entity
, name
, arguments
);
284 void printMethodParameters(
285 std::ostream
& o
, ProgramOptions
const & options
,
286 rtl::Reference
< TypeManager
> const & manager
,
287 std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
> const &
291 for (std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
>::
292 const_iterator
i(parameters
.begin());
293 i
!= parameters
.end(); ++i
)
295 if (i
!= parameters
.begin()) {
301 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
307 printType(o
, options
, manager
, i
->type
, referenceType
);
310 o
<< codemaker::cpp::translateUnoToCppIdentifier(u2b(i
->name
), "param");
314 void printExceptionSpecification(
316 ProgramOptions
const & options
,
317 rtl::Reference
< TypeManager
> const & manager
,
318 std::vector
< OUString
> const & exceptions
)
320 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException" :
321 " throw (::com::sun::star::uno::RuntimeException");
322 for (std::vector
< OUString
>::const_iterator
i(exceptions
.begin());
323 i
!= exceptions
.end(); ++i
)
326 printType(o
, options
, manager
, *i
, 1);
331 void printSetPropertyMixinBody(
332 std::ostream
& o
, unoidl::InterfaceTypeEntity::Attribute
const & attribute
)
334 unoidl::AccumulationBasedServiceEntity::Property::Attributes propFlags
335 = checkAdditionalPropertyFlags(attribute
);
340 o
<< " BoundListeners l;\n";
342 if (propFlags
& unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED
) {
343 OString fieldtype
= codemaker::convertString(attribute
.type
);
345 sal_Int32 index
= fieldtype
.lastIndexOf('<');
348 bool optional
= false;
349 OStringBuffer
buffer1(64);
350 OStringBuffer
buffer2(64);
353 OString
s(fieldtype
.getToken(0, '<', nPos
));
354 OString t
= s
.copy(s
.lastIndexOf('/')+1);
356 if (t
.equals("Optional")) {
360 buffer1
.append("the_value.IsPresent");
361 buffer2
.append("the_value.Value");
363 buffer1
.insert(0, t
);
364 buffer1
.append(".IsPresent");
365 buffer2
.insert(0, t
);
366 buffer2
.append(".Value");
372 buffer1
.append("the_value.Value");
374 buffer2
.append("the_value.Value");
377 buffer1
.insert(0, t
);
378 buffer1
.append(".Value");
380 buffer2
.insert(0, t
);
381 buffer2
.append(".Value");
384 } while( nPos
<= index
);
386 o
<< " css::uno::Any v;\n";
388 o
<< " if(" << buffer1
.makeStringAndClear() << ")\n {\n v <<= " << buffer2
.makeStringAndClear() << ";\n }\n";
390 o
<< " v <<= " << buffer2
.makeStringAndClear() << ";\n\n";
393 o
<< " prepareSet(\n rtl::OUString(\""
394 << attribute
.name
<< "\"),\n css::uno::Any(), v, ";
396 o
<< " prepareSet(\n rtl::OUString(\""
397 << attribute
.name
<< "\"),\n css::uno::Any(), css::uno::Any(), ";
405 o
<< " {\n osl::MutexGuard g(m_aMutex);\n m_"
406 << attribute
.name
<< " = the_value;\n }\n";
409 o
<< " l.notify();\n";
414 void printMethods(std::ostream
& o
,
415 ProgramOptions
const & options
, rtl::Reference
< TypeManager
> const & manager
,
416 OUString
const & name
, codemaker::GeneratedTypeSet
& generated
,
417 OString
const & delegate
, OString
const & classname
,
418 OString
const & indentation
, bool defaultvalue
,
419 OUString
const & propertyhelper
)
421 if (generated
.contains(u2b(name
)) || name
== "com.sun.star.uno.XInterface" ||
423 ( name
== "com.sun.star.lang.XComponent" ||
424 name
== "com.sun.star.lang.XTypeProvider" ||
425 name
== "com.sun.star.uno.XWeak" ) ) )
430 static OString
sd("_");
431 bool body
= !delegate
.isEmpty();
432 bool defaultbody
= delegate
.equals(sd
);
434 if (body
&& propertyhelper
.getLength() > 1) {
435 if (name
== "com.sun.star.beans.XPropertySet") {
436 generated
.add(u2b(name
));
437 generateXPropertySetBodies(
438 o
, classname
, scopedCppName(u2b(propertyhelper
)));
440 } else if (name
== "com.sun.star.beans.XFastPropertySet") {
441 generated
.add(u2b(name
));
442 generateXFastPropertySetBodies(
443 o
, classname
, scopedCppName(u2b(propertyhelper
)));
445 } else if (name
== "com.sun.star.beans.XPropertyAccess") {
446 generated
.add(u2b(name
));
447 generateXPropertyAccessBodies(
448 o
, classname
, scopedCppName(u2b(propertyhelper
)));
453 if (body
&& options
.componenttype
== 2) {
454 if (name
== "com.sun.star.lang.XServiceName") {
455 o
<< "// ::com::sun::star::lang::XServiceName:\n"
456 "::rtl::OUString SAL_CALL " << classname
<< "getServiceName() "
457 "throw (css::uno::RuntimeException)\n{\n "
458 "return ::rtl::OUString("
459 "sADDIN_SERVICENAME);\n}\n";
460 generated
.add(u2b(name
));
462 } else if (name
== "com.sun.star.sheet.XAddIn") {
463 generateXAddInBodies(o
, classname
);
464 generated
.add(u2b(name
));
466 // special handling of XLocalizable -> parent of XAddIn
467 if (!generated
.contains("com.sun.star.lang.XLocalizable")) {
468 generateXLocalizable(o
, classname
);
469 generated
.add("com.sun.star.lang.XLocalizable");
472 } else if (name
== "com.sun.star.lang.XLocalizable") {
473 generateXLocalizable(o
, classname
);
474 generated
.add(u2b(name
));
476 } else if (name
== "com.sun.star.sheet.XCompatibilityNames") {
477 generateXCompatibilityNamesBodies(o
, classname
);
478 generated
.add(u2b(name
));
483 if (body
&& options
.componenttype
== 3) {
484 if (name
== "com.sun.star.lang.XInitialization") {
485 generateXInitialization(o
, classname
);
486 generated
.add(u2b(name
));
488 } else if (name
== "com.sun.star.frame.XDispatch") {
489 generateXDispatch(o
, classname
, options
.protocolCmdMap
);
490 generated
.add(u2b(name
));
492 } else if (name
== "com.sun.star.frame.XDispatchProvider") {
493 generateXDispatchProvider(o
, classname
, options
.protocolCmdMap
);
494 generated
.add(u2b(name
));
499 generated
.add(u2b(name
));
500 rtl::Reference
< unoidl::Entity
> ent
;
501 if (manager
->getSort(name
, &ent
) != codemaker::UnoType::Sort::Interface
)
503 throw CannotDumpException(
504 "unexpected entity \"" + name
505 + "\" in call to skeletonmaker::cpp::printMethods");
507 rtl::Reference
< unoidl::InterfaceTypeEntity
> ent2(
508 dynamic_cast< unoidl::InterfaceTypeEntity
* >(ent
.get()));
510 if (options
.all
|| defaultvalue
) {
511 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
512 ent2
->getDirectMandatoryBases().begin());
513 i
!= ent2
->getDirectMandatoryBases().end(); ++i
)
516 o
, options
, manager
, i
->name
, generated
, delegate
, classname
,
517 indentation
, defaultvalue
, propertyhelper
);
519 if (!(ent2
->getDirectAttributes().empty()
520 && ent2
->getDirectMethods().empty()))
522 o
<< indentation
<< "// ";
523 printType(o
, options
, manager
, name
, 0);
527 for (std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::const_iterator
528 i(ent2
->getDirectAttributes().begin());
529 i
!= ent2
->getDirectAttributes().end(); ++i
)
535 printType(o
, options
, manager
, i
->type
, 1);
537 if (!classname
.isEmpty())
540 o
<< "get" << i
->name
<< "()";
541 printExceptionSpecification(o
, options
, manager
, i
->getExceptions
);
544 if (!propertyhelper
.isEmpty()) {
545 o
<< "\n{\n osl::MutexGuard g(m_aMutex);\n return m_"
546 << i
->name
<< ";\n}\n\n";
548 o
<< "\n{\n return ";
549 if (options
.componenttype
== 1) {
550 o
<< "m_" << i
->name
;
552 printType(o
, options
, manager
, i
->type
, 8, true);
557 o
<< "\n" << indentation
<< "{\n" << indentation
<< " return "
558 << delegate
.getStr() << "get" << i
->name
<< "();\n"
559 << indentation
<< "}\n\n";
570 o
<< "void SAL_CALL ";
571 if (!classname
.isEmpty())
574 o
<< "set" << i
->name
<< '(';
575 printType(o
, options
, manager
, i
->type
, 4);
577 printExceptionSpecification(o
, options
, manager
, i
->setExceptions
);
580 if (!propertyhelper
.isEmpty()) {
581 printSetPropertyMixinBody(o
, *i
);
583 if (options
.componenttype
== 1) {
584 o
<< "\n{\n m_" << i
->name
585 << " = the_value;\n}\n\n";
591 o
<< "\n" << indentation
<< "{\n" << indentation
<< " "
592 << delegate
.getStr() << "set" << i
->name
593 << "(the_value);\n" << indentation
<< "}\n\n";
600 for (std::vector
< unoidl::InterfaceTypeEntity::Method
>::const_iterator
i(
601 ent2
->getDirectMethods().begin());
602 i
!= ent2
->getDirectMethods().end(); ++i
)
608 printType(o
, options
, manager
, i
->returnType
, 1);
610 if (!classname
.isEmpty())
614 printMethodParameters(o
, options
, manager
, i
->parameters
, true);
616 printExceptionSpecification(o
, options
, manager
, i
->exceptions
);
620 if (i
->returnType
!= "void") {
621 o
<< " // TODO: Exchange the default return implementation for \""
622 << i
->name
<< "\" !!!\n";
623 o
<< " // Exchange the default return implementation.\n"
624 " // NOTE: Default initialized polymorphic structs "
625 "can cause problems because of\n // missing default "
626 "initialization of primitive types of some C++ compilers or"
627 "\n // different Any initialization in Java and C++ "
628 "polymorphic structs.\n return ";
629 printType(o
, options
, manager
, i
->returnType
, 8, true);
632 o
<< " // TODO: Insert your implementation for \""
633 << i
->name
<< "\" here.";
637 o
<< "\n" << indentation
<< "{\n" << indentation
<< " ";
638 if (i
->returnType
!= "void")
641 o
<< delegate
.getStr() << i
->name
<< '(';
642 printMethodParameters(
643 o
, options
, manager
, i
->parameters
, false);
644 o
<< ");\n" << indentation
<< "}\n\n";
655 void printConstructors(
656 std::ostream
& o
, ProgramOptions
const & options
,
657 rtl::Reference
< TypeManager
> const & manager
, OUString
const & name
)
659 rtl::Reference
< unoidl::Entity
> ent
;
660 if (manager
->getSort(name
, &ent
)
661 != codemaker::UnoType::Sort::SingleInterfaceBasedService
)
663 throw CannotDumpException(
664 "unexpected entity \"" + name
665 + "\" in call to skeletonmaker::java::printConstructors");
667 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> ent2(
668 dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(ent
.get()));
670 for (std::vector
< unoidl::SingleInterfaceBasedServiceEntity::Constructor
>::
671 const_iterator
i(ent2
->getConstructors().begin());
672 i
!= ent2
->getConstructors().end(); ++i
)
675 printType(o
, options
, manager
, ent2
->getBase(), 1);
677 if (i
->defaultConstructor
) {
680 o
<< codemaker::cpp::translateUnoToCppIdentifier(
681 u2b(i
->name
), "method");
683 o
<< ((options
.shortnames
) ? "(css::uno::Reference< css" :
684 "(::com::sun::star::uno::Reference< ::com::sun::star")
685 << "::uno::XComponentContext > const & the_context";
687 unoidl::SingleInterfaceBasedServiceEntity::Constructor::
688 Parameter
>::const_iterator
j(i
->parameters
.begin());
689 j
!= i
->parameters
.end(); ++j
)
692 printType(o
, options
, manager
, j
->type
, 4);
694 << codemaker::cpp::translateUnoToCppIdentifier(
695 u2b(j
->name
), "param");
698 printExceptionSpecification(o
, options
, manager
, i
->exceptions
);
703 void printServiceMembers(
704 std::ostream
& o
, ProgramOptions
const & options
,
705 rtl::Reference
< TypeManager
> const & manager
,
706 OUString
const & name
,
707 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const & entity
,
708 OString
const & delegate
)
711 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
712 entity
->getDirectMandatoryBaseServices().begin());
713 i
!= entity
->getDirectMandatoryBaseServices().end(); ++i
)
715 o
<< "\n// exported service " << i
->name
<< "\n";
716 generateDocumentation(o
, options
, manager
, u2b(i
->name
), delegate
);
717 o
<< "\n// end of exported service " << i
->name
<< "\n";
719 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
720 entity
->getDirectMandatoryBaseInterfaces().begin());
721 i
!= entity
->getDirectMandatoryBaseInterfaces().end(); ++i
)
723 o
<< "\n// supported interface " << i
->name
<< "\n";
724 generateDocumentation(o
, options
, manager
, u2b(i
->name
), delegate
);
726 if (delegate
.isEmpty()) {
727 o
<< "\n// properties of service \""<< name
<< "\"\n";
728 for (std::vector
< unoidl::AccumulationBasedServiceEntity::Property
>::
729 const_iterator
i(entity
->getDirectProperties().begin());
730 i
!= entity
->getDirectProperties().end(); ++i
)
733 printType(o
, options
, manager
, i
->type
, 1);
735 << codemaker::cpp::translateUnoToCppIdentifier(
736 u2b(i
->name
), "property")
742 void printMapsToCppType(
743 std::ostream
& o
, ProgramOptions
const & options
,
744 rtl::Reference
< TypeManager
> const & manager
,
745 codemaker::UnoType::Sort sort
, OUString
const & nucleus
, sal_Int32 rank
,
746 std::vector
< OUString
> const & arguments
,
747 rtl::Reference
< unoidl::Entity
> const & entity
, const char * cppTypeSort
)
750 if (cppTypeSort
!= nullptr)
751 o
<< cppTypeSort
<< ' ';
754 if (rank
== 0 && nucleus
== "com.sun.star.uno.XInterface") {
755 o
<< "Reference< com::sun::star::uno::XInterface >";
758 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
, 0,
764 void generateDocumentation(std::ostream
& o
,
765 ProgramOptions
const & options
, rtl::Reference
< TypeManager
> const & manager
,
766 OString
const & type
, OString
const & delegate
)
770 codemaker::UnoType::Sort sort
= manager
->decompose(
771 b2u(type
), false, &nucleus
, &rank
, nullptr, nullptr);
774 if (!delegate
.isEmpty()) {
775 if (sort
!= codemaker::UnoType::Sort::Interface
&&
776 sort
!= codemaker::UnoType::Sort::SingleInterfaceBasedService
&&
777 sort
!= codemaker::UnoType::Sort::AccumulationBasedService
)
787 o
<< " sequence type";
788 } else if (sort
<= codemaker::UnoType::Sort::Any
) {
792 case codemaker::UnoType::Sort::Interface
:
793 o
<< " interface type";
796 case codemaker::UnoType::Sort::Module
:
800 case codemaker::UnoType::Sort::PlainStruct
:
801 o
<< " simple struct type";
804 case codemaker::UnoType::Sort::PolymorphicStructTemplate
:
805 o
<< " polymorphic struct type template";
808 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct
:
809 o
<< " instantiated polymorphic struct type";
812 case codemaker::UnoType::Sort::Enum
:
816 case codemaker::UnoType::Sort::Exception
:
817 o
<< " exception type";
820 case codemaker::UnoType::Sort::Typedef
:
824 case codemaker::UnoType::Sort::SingleInterfaceBasedService
:
825 o
<< " single-inheritance--based service";
828 case codemaker::UnoType::Sort::AccumulationBasedService
:
829 o
<< "IDL accumulation-based service";
832 case codemaker::UnoType::Sort::InterfaceBasedSingleton
:
833 o
<< " inheritance-based singleton";
836 case codemaker::UnoType::Sort::ServiceBasedSingleton
:
837 o
<< "IDL service-based singleton";
840 case codemaker::UnoType::Sort::ConstantGroup
:
841 o
<< "IDL constant group";
849 o
<< " \"" << type
<< "\" ";
851 std::vector
< OUString
> arguments
;
852 rtl::Reference
< unoidl::Entity
> entity
;
853 sort
= manager
->decompose(
854 b2u(type
), true, &nucleus
, &rank
, &arguments
, &entity
);
858 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
862 } else if (sort
<= codemaker::UnoType::Sort::Any
) {
865 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
, nullptr);
870 case codemaker::UnoType::Sort::Interface
:
873 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
875 if (nucleus
== "com.sun.star.uno.XInterface") {
880 o
<< "; " << (options
.all
? "all" : "direct") << " methods:\n";
882 codemaker::GeneratedTypeSet generated
;
884 o
, options
, manager
, nucleus
, generated
, delegate
,
885 options
.implname
, "");
889 case codemaker::UnoType::Sort::Module
:
891 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
896 case codemaker::UnoType::Sort::PlainStruct
:
898 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
900 o
<< "; full constructor:\n";
902 o
, options
, manager
, codemaker::UnoType::Sort::PlainStruct
,
903 entity
, nucleus
, arguments
);
906 case codemaker::UnoType::Sort::PolymorphicStructTemplate
:
908 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
910 o
<< "; full constructor:\n";
913 codemaker::UnoType::Sort::PolymorphicStructTemplate
,
914 entity
, nucleus
, arguments
);
917 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct
:
919 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
920 "class template instantiation");
921 o
<< "; full constructor:\n";
924 codemaker::UnoType::Sort::InstantiatedPolymorphicStruct
,
925 entity
, nucleus
, arguments
);
928 case codemaker::UnoType::Sort::Enum
:
930 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
935 case codemaker::UnoType::Sort::ConstantGroup
:
937 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
942 case codemaker::UnoType::Sort::Exception
:
944 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
946 o
<< "; full constructor:\n";
948 o
, options
, manager
, codemaker::UnoType::Sort::Exception
,
949 entity
, nucleus
, arguments
);
952 case codemaker::UnoType::Sort::SingleInterfaceBasedService
:
955 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
957 o
<< "; construction methods:\n";
958 printConstructors(o
, options
, manager
, nucleus
);
960 generateDocumentation(
962 u2b(dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
963 entity
.get())->getBase()),
967 case codemaker::UnoType::Sort::AccumulationBasedService
:
969 o
<< ("does not map to C++\n"
970 "// the service members are generated instead\n");
972 o
, options
, manager
, nucleus
,
973 dynamic_cast< unoidl::AccumulationBasedServiceEntity
* >(
978 case codemaker::UnoType::Sort::InterfaceBasedSingleton
:
980 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
982 o
<< "; get method:\nstatic ";
985 dynamic_cast< unoidl::InterfaceBasedSingletonEntity
* >(
986 entity
.get())->getBase(),
988 o
<< " get(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);\n";
991 case codemaker::UnoType::Sort::ServiceBasedSingleton
:
992 o
<< "does not map to C++\n";
1005 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */