1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cpptypemaker.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "codemaker/commoncpp.hxx"
33 #include "skeletoncommon.hxx"
34 #include "skeletoncpp.hxx"
36 using namespace ::rtl
;
37 using namespace ::codemaker::cpp
;
39 namespace skeletonmaker
{ namespace cpp
{
41 void printType(std::ostream
& o
,
42 ProgramOptions
const & options
, TypeManager
const & manager
,
43 codemaker::UnoType::Sort sort
, RTTypeClass typeClass
,
44 OString
const & name
, sal_Int32 rank
,
45 std::vector
< OString
> const & arguments
, short referenceType
,
48 if (defaultvalue
&& rank
== 0 && sort
<= codemaker::UnoType::SORT_CHAR
) {
51 case codemaker::UnoType::SORT_BOOLEAN
:
54 case codemaker::UnoType::SORT_CHAR
:
55 case codemaker::UnoType::SORT_BYTE
:
56 case codemaker::UnoType::SORT_SHORT
:
57 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
58 case codemaker::UnoType::SORT_LONG
:
59 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
60 case codemaker::UnoType::SORT_HYPER
:
61 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
62 case codemaker::UnoType::SORT_FLOAT
:
63 case codemaker::UnoType::SORT_DOUBLE
:
66 case codemaker::UnoType::SORT_VOID
:
67 case codemaker::UnoType::SORT_STRING
:
68 case codemaker::UnoType::SORT_TYPE
:
69 case codemaker::UnoType::SORT_ANY
:
70 case codemaker::UnoType::SORT_COMPLEX
:
75 if (defaultvalue
&& referenceType
== 16) {
76 if (typeClass
== RT_TYPE_ENUM
) {
77 typereg::Reader
reader(manager
.getTypeReader(name
));
78 o
<< name
.copy(name
.lastIndexOf('/'))
80 << codemaker::convertString(reader
.getFieldName(0));
84 bool bReference
= false;
85 if (((sort
> codemaker::UnoType::SORT_CHAR
||
86 rank
> 0) && referenceType
!= 8 &&
87 !(typeClass
== RT_TYPE_ENUM
&& referenceType
== 4 && rank
== 0)) ||
88 (sort
<= codemaker::UnoType::SORT_CHAR
&& referenceType
== 2))
93 if (bReference
&& referenceType
== 4)
96 for (sal_Int32 i
= 0; i
< rank
; ++i
) {
97 o
<< ((options
.shortnames
) ? "css::uno::Sequence< " :
98 "::com::sun::star::uno::Sequence< ");
100 if (typeClass
== RT_TYPE_INTERFACE
&& referenceType
> 0) {
101 o
<< ((options
.shortnames
) ? "css::uno::Reference< " :
102 "::com::sun::star::uno::Reference< ");
105 o
<< scopedCppName(codemaker::cpp::translateUnoToCppType(
106 sort
, typeClass
, name
, false),
107 false, options
.shortnames
&& referenceType
> 0);
109 if (typeClass
== RT_TYPE_INTERFACE
&& referenceType
> 0)
112 if (!arguments
.empty()) {
114 for (std::vector
< OString
>::const_iterator
i(arguments
.begin());
115 i
!= arguments
.end(); ++i
)
117 if (i
!= arguments
.begin())
120 printType(o
, options
, manager
, *i
, 1, false);
125 for (sal_Int32 i
= 0; i
< rank
; ++i
)
128 if (bReference
&& referenceType
> 1)
131 if (referenceType
== 8 && (sort
> codemaker::UnoType::SORT_CHAR
|| rank
> 0))
135 void printType(std::ostream
& o
,
136 ProgramOptions
const & options
, TypeManager
const & manager
,
137 OString
const & type
, short referenceType
, bool defaultvalue
)
139 RTTypeClass typeClass
;
142 std::vector
< OString
> arguments
;
143 codemaker::UnoType::Sort sort
= codemaker::decomposeAndResolve(
144 manager
, type
, true, true, true, &typeClass
, &name
, &rank
, &arguments
);
146 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
147 referenceType
, defaultvalue
);
150 bool printConstructorParameters(std::ostream
& o
,
151 ProgramOptions
const & options
, TypeManager
const & manager
,
152 typereg::Reader
const & reader
, typereg::Reader
const & outerReader
,
153 std::vector
< OString
> const & arguments
)
155 bool previous
= false;
156 if (reader
.getSuperTypeCount() != 0) {
158 codemaker::convertString(reader
.getSuperTypeName(0)));
159 typereg::Reader
superReader(manager
.getTypeReader(super
));
160 if (!superReader
.isValid())
161 throw CannotDumpException("Bad type library entity " + super
);
163 previous
= printConstructorParameters(o
,
164 options
, manager
, superReader
, outerReader
, arguments
);
166 for (sal_uInt16 i
= 0; i
< reader
.getFieldCount(); ++i
) {
172 if ((reader
.getFieldFlags(i
) & RT_ACCESS_PARAMETERIZED_TYPE
) == 0) {
173 printType(o
, options
, manager
,
174 codemaker::convertString(reader
.getFieldTypeName(i
)), 4);
175 } else if (arguments
.empty()) {
177 // o << "com::sun::star::uno::Any";
179 sal_uInt16 tparam
= 0;
180 while (outerReader
.getReferenceTypeName(tparam
)
181 != reader
.getFieldTypeName(i
))
184 OSL_ASSERT(tparam
< outerReader
.getReferenceCount());
186 // assume std::vector< OString >::size_type is at least as
187 // large as sal_uInt16:
188 printType(o
, options
, manager
, arguments
[tparam
], 4);
191 << (codemaker::cpp::translateUnoToCppIdentifier(
192 codemaker::convertString(reader
.getFieldName(i
)),
199 void printConstructor(std::ostream
& o
,
200 ProgramOptions
const & options
, TypeManager
const & manager
,
201 typereg::Reader
const & reader
,
202 std::vector
< OString
> const & arguments
)
204 OString
type(codemaker::convertString(reader
.getTypeName()));
206 o
<< type
.copy(type
.lastIndexOf('/') + 1) << '(';
207 printConstructorParameters(o
, options
, manager
, reader
, reader
,
212 void printMethodParameters(std::ostream
& o
,
213 ProgramOptions
const & options
, TypeManager
const & manager
,
214 typereg::Reader
const & reader
, sal_uInt16 method
, bool previous
,
217 short referenceType
= 4;
218 for (sal_uInt16 i
= 0; i
< reader
.getMethodParameterCount(method
); ++i
) {
224 if (reader
.getMethodParameterFlags(method
, i
) == RT_PARAM_OUT
225 || reader
.getMethodParameterFlags(method
, i
) == RT_PARAM_INOUT
)
233 printType(o
, options
, manager
,
234 codemaker::convertString(
235 reader
.getMethodParameterTypeName(method
, i
)),
240 o
<< (codemaker::cpp::translateUnoToCppIdentifier(
241 codemaker::convertString(
242 reader
.getMethodParameterName(method
, i
)),
248 void printExceptionSpecification(std::ostream
& o
,
249 ProgramOptions
const & options
, TypeManager
const & manager
,
250 typereg::Reader
const & reader
, sal_uInt16 method
)
252 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException" :
253 " throw (::com::sun::star::uno::RuntimeException");
254 if (reader
.getMethodExceptionCount(method
) > 0) {
255 for (sal_uInt16 i
= 0; i
< reader
.getMethodExceptionCount(method
); ++i
) {
257 printType(o
, options
, manager
,
258 codemaker::convertString(
259 reader
.getMethodExceptionTypeName(method
, i
)), 1);
265 void printSetPropertyMixinBody(std::ostream
& o
,
266 typereg::Reader
const & reader
,
270 RTFieldAccess propFlags
= checkAdditionalPropertyFlags(reader
, field
, method
);
271 OString fieldname
= codemaker::convertString(reader
.getFieldName(field
));
272 bool bound
= (reader
.getFieldFlags(field
) & RT_ACCESS_BOUND
? true : false);
277 o
<< " BoundListeners l;\n";
279 if (propFlags
& RT_ACCESS_CONSTRAINED
) {
280 OString fieldtype
= codemaker::convertString(
281 reader
.getFieldTypeName(field
));
283 sal_Int32 index
= fieldtype
.lastIndexOf('<');
286 bool optional
= false;
287 OStringBuffer
buffer1(64);
288 OStringBuffer
buffer2(64);
291 OString
s(fieldtype
.getToken(0, '<', nPos
));
292 OString t
= s
.copy(s
.lastIndexOf('/')+1);
294 if (t
.equals("Optional")) {
298 buffer1
.append("the_value.IsPresent");
299 buffer2
.append("the_value.Value");
301 buffer1
.insert(0, t
);
302 buffer1
.append(".IsPresent");
303 buffer2
.insert(0, t
);
304 buffer2
.append(".Value");
310 buffer1
.append("the_value.Value");
312 buffer2
.append("the_value.Value");
315 buffer1
.insert(0, t
);
316 buffer1
.append(".Value");
318 buffer2
.insert(0, t
);
319 buffer2
.append(".Value");
322 } while( nPos
<= index
);
324 o
<< " css::uno::Any v;\n";
326 o
<< " if(" << buffer1
.makeStringAndClear() << ")\n {\n"
327 << " v <<= " << buffer2
.makeStringAndClear() << ";\n }\n";
329 o
<< " v <<= " << buffer2
.makeStringAndClear() << ";\n\n";
332 o
<< " prepareSet(\n rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\""
333 << fieldname
<< "\")),\n css::uno::Any(), v, ";
335 o
<< " prepareSet(\n rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\""
336 << fieldname
<< "\")),\n css::uno::Any(), css::uno::Any(), ";
344 o
<< " {\n osl::MutexGuard g(m_aMutex);\n m_"
345 << fieldname
<< " = the_value;\n }\n";
348 o
<< " l.notify();\n";
353 void generateXPropertySetBodies(std::ostream
& o
,
354 const OString
& classname
,
355 const OString
& interfaceName
);
356 void generateXFastPropertySetBodies(std::ostream
& o
,
357 const OString
& classname
,
358 const OString
& interfaceName
);
359 void generateXPropertyAccessBodies(std::ostream
& o
,
360 const OString
& classname
,
361 const OString
& interfaceName
);
363 void generateXAddInBodies(std::ostream
& o
, const OString
& classname
);
365 void generateXLocalizable(std::ostream
& o
, const OString
& classname
);
367 void generateXCompatibilityNamesBodies(std::ostream
& o
, const OString
& classname
);
369 void generateXInitialization(std::ostream
& o
, const OString
& classname
);
371 void generateXDispatch(std::ostream
& o
,
372 const OString
& classname
,
373 const ProtocolCmdMap
& protocolCmdMap
);
375 void generateXDispatchProvider(std::ostream
& o
,
376 const OString
& classname
,
377 const ProtocolCmdMap
& protocolCmdMap
);
380 void printMethods(std::ostream
& o
,
381 ProgramOptions
const & options
, TypeManager
const & manager
,
382 typereg::Reader
const & reader
, codemaker::GeneratedTypeSet
& generated
,
383 OString
const & delegate
, OString
const & classname
,
384 OString
const & indentation
, bool defaultvalue
,
385 OString
const & propertyhelper
)
387 OString
type(codemaker::convertString(reader
.getTypeName()));
388 if (generated
.contains(type
) || type
.equals("com/sun/star/uno/XInterface") ||
390 ( type
.equals("com/sun/star/lang/XComponent") ||
391 type
.equals("com/sun/star/lang/XTypeProvider") ||
392 type
.equals("com/sun/star/uno/XWeak")) ) )
397 static OString
sd(RTL_CONSTASCII_STRINGPARAM("_"));
398 bool body
= ((delegate
.getLength() > 0) ? true : false);
399 bool defaultbody
= ((delegate
.equals(sd
)) ? true : false);
401 if (body
&& propertyhelper
.getLength() > 1) {
402 if ( type
.equals("com/sun/star/beans/XPropertySet")) {
404 generateXPropertySetBodies(
405 o
, classname
, scopedCppName(propertyhelper
, false, true));
407 } else if ( type
.equals("com/sun/star/beans/XFastPropertySet")) {
409 generateXFastPropertySetBodies(
410 o
, classname
, scopedCppName(propertyhelper
, false, true));
412 } else if ( type
.equals("com/sun/star/beans/XPropertyAccess")) {
414 generateXPropertyAccessBodies(
415 o
, classname
, scopedCppName(propertyhelper
, false, true));
420 if (body
&& options
.componenttype
== 2) {
421 if (type
.equals("com/sun/star/lang/XServiceName")) {
422 o
<< "// ::com::sun::star::lang::XServiceName:\n"
423 "::rtl::OUString SAL_CALL " << classname
<< "getServiceName() "
424 "throw (css::uno::RuntimeException)\n{\n "
425 "return ::rtl::OUString::createFromAscii("
426 "sADDIN_SERVICENAME);\n}\n";
429 } else if (type
.equals("com/sun/star/sheet/XAddIn")) {
430 generateXAddInBodies(o
, classname
);
433 // special handling of XLocalizable -> parent of XAddIn
434 if (!generated
.contains("com/sun/star/lang/XLocalizable")) {
435 generateXLocalizable(o
, classname
);
436 generated
.add("com/sun/star/lang/XLocalizable");
439 } else if (type
.equals("com/sun/star/lang/XLocalizable")) {
440 generateXLocalizable(o
, classname
);
443 } else if (type
.equals("com/sun/star/sheet/XCompatibilityNames")) {
444 generateXCompatibilityNamesBodies(o
, classname
);
450 if (body
&& options
.componenttype
== 3) {
451 if (type
.equals("com/sun/star/lang/XInitialization")) {
452 generateXInitialization(o
, classname
);
455 } else if (type
.equals("com/sun/star/frame/XDispatch")) {
456 generateXDispatch(o
, classname
, options
.protocolCmdMap
);
459 } else if (type
.equals("com/sun/star/frame/XDispatchProvider")) {
460 generateXDispatchProvider(o
, classname
, options
.protocolCmdMap
);
467 if (options
.all
|| defaultvalue
) {
468 for (sal_uInt16 i
= 0; i
< reader
.getSuperTypeCount(); ++i
) {
469 typereg::Reader
super(
470 manager
.getTypeReader(
471 codemaker::convertString(
472 reader
.getSuperTypeName(i
))));
473 if (!super
.isValid()) {
474 throw CannotDumpException(
475 "Bad type library entity "
476 + codemaker::convertString(
477 reader
.getSuperTypeName(i
)));
480 OString
stype(codemaker::convertString(super
.getTypeName()));
481 printMethods(o
, options
, manager
, super
, generated
, delegate
,
482 classname
, indentation
, defaultvalue
, propertyhelper
);
485 if (reader
.getFieldCount() > 0 || reader
.getMethodCount() > 0) {
486 o
<< indentation
<< "// ";
487 printType(o
, options
, manager
, type
, 0);
491 sal_uInt16 method
= 0;
492 for (sal_uInt16 i
= 0; i
< reader
.getFieldCount(); ++i
) {
497 printType(o
, options
, manager
,
498 codemaker::convertString(reader
.getFieldTypeName(i
)), 1);
500 if (classname
.getLength() > 0)
504 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
506 if (method
< reader
.getMethodCount()
507 && reader
.getMethodFlags(method
) == RT_MODE_ATTRIBUTE_GET
508 && reader
.getMethodName(method
) == reader
.getFieldName(i
))
510 printExceptionSpecification(o
, options
, manager
, reader
, method
++);
512 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException)" :
513 " throw (::com::sun::star::uno::RuntimeException)");
517 if (propertyhelper
.getLength() > 0) {
518 o
<< "\n{\n osl::MutexGuard g(m_aMutex);\n return m_"
519 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
522 o
<< "\n{\n return ";
523 if (options
.componenttype
== 1) {
525 << codemaker::convertString(
526 reader
.getFieldName(i
)).getStr();
528 printType(o
, options
, manager
,
529 codemaker::convertString(
530 reader
.getFieldTypeName(i
)),
536 o
<< "\n" << indentation
<< "{\n" << indentation
<< " return "
537 << delegate
.getStr() << "get"
538 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
539 << "();\n" << indentation
<< "}\n\n";
545 if ((reader
.getFieldFlags(i
) & RT_ACCESS_READONLY
) == 0) {
550 o
<< "void SAL_CALL ";
551 if (classname
.getLength() > 0)
555 << (codemaker::convertString(reader
.getFieldName(i
)).getStr())
557 printType(o
, options
, manager
,
558 codemaker::convertString(reader
.getFieldTypeName(i
)), 4);
560 if (method
< reader
.getMethodCount()
561 && reader
.getMethodFlags(method
) == RT_MODE_ATTRIBUTE_SET
562 && reader
.getMethodName(method
) == reader
.getFieldName(i
))
564 printExceptionSpecification(o
, options
, manager
, reader
, method
++);
566 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException)" :
567 " throw (::com::sun::star::uno::RuntimeException)");
571 if (propertyhelper
.getLength() > 0) {
572 printSetPropertyMixinBody(o
, reader
, i
, method
);
574 if (options
.componenttype
== 1) {
576 << codemaker::convertString(
577 reader
.getFieldName(i
)).getStr()
578 << " = the_value;\n}\n\n";
584 o
<< "\n" << indentation
<< "{\n" << indentation
<< " "
585 << delegate
.getStr() << "set"
586 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
587 << "(the_value);\n" << indentation
<< "}\n\n";
594 for (; method
< reader
.getMethodCount(); ++method
) {
599 printType(o
, options
, manager
,
600 codemaker::convertString(
601 reader
.getMethodReturnTypeName(method
)), 1);
603 if (classname
.getLength() > 0)
606 const OString
methodName(codemaker::convertString(reader
.getMethodName(method
)));
608 o
<< methodName
<< '(';
609 printMethodParameters(o
, options
, manager
, reader
, method
, false, true);
611 printExceptionSpecification(o
, options
, manager
, reader
, method
);
613 static OUString
s(RTL_CONSTASCII_USTRINGPARAM("void"));
616 if (!reader
.getMethodReturnTypeName(method
).equals(s
)) {
617 o
<< " // TODO: Exchange the default return implementation for \""
618 << methodName
<< "\" !!!\n";
619 o
<< " // Exchange the default return implementation.\n"
620 " // NOTE: Default initialized polymorphic structs "
621 "can cause problems because of\n // missing default "
622 "initialization of primitive types of some C++ compilers or"
623 "\n // different Any initialization in Java and C++ "
624 "polymorphic structs.\n return ";
625 printType(o
, options
, manager
,
626 codemaker::convertString(
627 reader
.getMethodReturnTypeName(method
)), 8, true);
630 o
<< " // TODO: Insert your implementation for \""
631 << methodName
<< "\" here.";
635 o
<< "\n" << indentation
<< "{\n" << indentation
<< " ";
636 if (!reader
.getMethodReturnTypeName(method
).equals(s
))
639 o
<< delegate
.getStr()
640 << (codemaker::convertString(
641 reader
.getMethodName(method
)).getStr())
643 printMethodParameters(o
, options
, manager
, reader
, method
,
645 o
<< ");\n" << indentation
<< "}\n\n";
652 if (method
> 0 && !body
)
656 void printConstructionMethods(std::ostream
& o
,
657 ProgramOptions
const & options
, TypeManager
const & manager
,
658 typereg::Reader
const & reader
)
660 for (sal_uInt16 i
= 0; i
< reader
.getMethodCount(); ++i
) {
664 codemaker::convertString(reader
.getSuperTypeName(0)), 1);
666 if (reader
.getMethodName(i
).getLength() == 0) {
669 o
<< (codemaker::cpp::translateUnoToCppIdentifier(
670 codemaker::convertString(reader
.getMethodName(i
)),
674 o
<< ((options
.shortnames
) ? "(css::uno::Reference< css" :
675 "(::com::sun::star::uno::Reference< ::com::sun::star")
676 << "::uno::XComponentContext > const & the_context";
677 printMethodParameters(o
, options
, manager
, reader
, i
,
680 printExceptionSpecification(o
, options
, manager
, reader
, i
);
685 void printServiceMembers(std::ostream
& o
,
686 ProgramOptions
const & options
, TypeManager
const & manager
,
687 typereg::Reader
const & reader
, OString
const & type
,
688 OString
const & delegate
)
690 for (sal_uInt16 i
= 0; i
< reader
.getReferenceCount(); ++i
) {
691 OString
referenceType(
692 codemaker::convertString(
693 reader
.getReferenceTypeName(i
)).replace('/', '.'));
695 if ( reader
.getReferenceSort(i
) == RT_REF_SUPPORTS
) {
696 o
<< "\n// supported interface " << referenceType
.getStr() << "\n";
697 generateDocumentation(o
, options
, manager
, referenceType
, delegate
);
698 } else if ( reader
.getReferenceSort(i
) == RT_REF_EXPORTS
) {
699 o
<< "\n// exported service " << referenceType
.getStr() << "\n";
700 generateDocumentation(o
, options
, manager
, referenceType
, delegate
);
701 o
<< "\n// end of exported service " << referenceType
.getStr() << "\n";
705 if (delegate
.getLength() == 0) {
706 o
<< "\n// properties of service \""<< type
.getStr() << "\"\n";
707 for (sal_uInt16 i
= 0; i
< reader
.getFieldCount(); ++i
) {
709 codemaker::convertString(reader
.getFieldName(i
)));
711 codemaker::convertString(reader
.getFieldTypeName(i
)));
714 printType(o
, options
, manager
, fieldType
, 1);
716 << codemaker::cpp::translateUnoToCppIdentifier(
717 fieldName
, "property").getStr()
723 void printMapsToCppType(std::ostream
& o
,
724 ProgramOptions
const & options
, TypeManager
const & manager
,
725 codemaker::UnoType::Sort sort
, RTTypeClass typeClass
,
726 OString
const & name
, sal_Int32 rank
,
727 std::vector
< OString
> const & arguments
, const char * cppTypeSort
)
730 if (cppTypeSort
!= 0)
731 o
<< cppTypeSort
<< ' ';
734 if (rank
== 0 && name
== "com/sun/star/uno/XInterface") {
735 o
<< "Reference< com::sun::star::uno::XInterface >";
737 printType(o
, options
, manager
, sort
, typeClass
, name
, rank
, arguments
, 0);
742 void generateDocumentation(std::ostream
& o
,
743 ProgramOptions
const & options
, TypeManager
const & manager
,
744 OString
const & type
, OString
const & delegate
)
746 if (type
.indexOf('/') >= 0)
747 throw CannotDumpException("Illegal type name " + type
);
749 OString
binType(type
.replace('.', '/'));
750 RTTypeClass typeClass
;
753 std::vector
< OString
> arguments
;
754 codemaker::UnoType::Sort sort
= decomposeResolveAndCheck(
755 manager
, binType
, false, true, true, &typeClass
, &name
, &rank
,
759 if (delegate
.getLength() > 0) {
760 if (typeClass
!= RT_TYPE_INTERFACE
&&
761 typeClass
!= RT_TYPE_SERVICE
)
771 o
<< " sequence type";
772 } else if (sort
!= codemaker::UnoType::SORT_COMPLEX
) {
775 typereg::Reader
reader(manager
.getTypeReader(name
));
776 if (!reader
.isValid())
777 throw CannotDumpException("Bad type library entity " + name
);
781 case RT_TYPE_INTERFACE
:
782 o
<< " interface type";
790 if (reader
.getReferenceCount() == 0)
791 o
<< " simple struct type";
792 else if (arguments
.empty())
793 o
<< " polymorphic struct type template";
795 o
<< " instantiated polymorphic struct type";
802 case RT_TYPE_EXCEPTION
:
803 o
<< " exception type";
806 case RT_TYPE_TYPEDEF
:
810 case RT_TYPE_SERVICE
:
811 if (reader
.getSuperTypeCount() > 0)
812 o
<< " single-inheritance--based service";
814 o
<< "IDL accumulation-based service";
817 case RT_TYPE_SINGLETON
:
818 if ((manager
.getTypeReader(
819 codemaker::convertString(
820 reader
.getSuperTypeName(0))).getTypeClass())
821 == RT_TYPE_INTERFACE
)
822 o
<< " inheritance-based singleton";
824 o
<< "IDL service-based singleton";
827 case RT_TYPE_CONSTANTS
:
828 o
<< "IDL constant group";
836 o
<< " \"" << type
.getStr() << "\" ";
838 sort
= codemaker::decomposeAndResolve(
839 manager
, binType
, true, true, true, &typeClass
, &name
, &rank
,
843 printMapsToCppType(o
,
844 options
, manager
, sort
, typeClass
, name
, rank
, arguments
, "array");
847 } else if (sort
!= codemaker::UnoType::SORT_COMPLEX
) {
849 printMapsToCppType(o
,
850 options
, manager
, sort
, typeClass
, name
, rank
, arguments
, 0);
854 typereg::Reader
reader(manager
.getTypeReader(name
));
855 if (!reader
.isValid())
856 throw CannotDumpException("Bad type library entity " + name
);
860 case RT_TYPE_INTERFACE
:
862 printMapsToCppType(o
,
863 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
865 if (name
== "com/sun/star/uno/XInterface") {
870 o
<< "; " << (options
.all
? "all" : "direct") << " methods:\n";
872 codemaker::GeneratedTypeSet generated
;
873 printMethods(o
, options
, manager
, reader
, generated
,
874 delegate
, options
.implname
, "");
879 printMapsToCppType(o
,
880 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
886 if (reader
.getReferenceCount() == 0) {
887 printMapsToCppType(o
,
888 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
890 } else if (arguments
.empty()) {
891 printMapsToCppType(o
,
892 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
893 options
.java5
? "generic class" : "class");
895 printMapsToCppType(o
,
896 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
897 options
.java5
? "generic class instantiation" : "class");
899 o
<< "; full constructor:\n";
900 printConstructor(o
, options
, manager
, reader
, arguments
);
904 printMapsToCppType(o
,
905 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
910 case RT_TYPE_CONSTANTS
:
911 printMapsToCppType(o
,
912 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
917 case RT_TYPE_EXCEPTION
:
918 printMapsToCppType(o
,
919 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
921 o
<< "; full constructor:\n";
922 printConstructor(o
, options
, manager
, reader
, arguments
);
925 case RT_TYPE_SERVICE
:
926 if (reader
.getSuperTypeCount() > 0) {
928 printMapsToCppType(o
, options
, manager
, sort
, typeClass
,
929 name
, rank
, arguments
, "class");
930 o
<< "; construction methods:\n";
931 printConstructionMethods(o
, options
, manager
, reader
);
935 codemaker::convertString(
936 reader
.getSuperTypeName(0)).replace('/', '.'));
937 generateDocumentation(o
, options
, manager
, super
, delegate
);
940 o
<< ("does not map to C++\n"
941 "// the service members are generated instead\n");
942 printServiceMembers(o
, options
, manager
, reader
, type
, delegate
);
946 case RT_TYPE_SINGLETON
:
947 if (reader
.getSuperTypeCount() > 0 &&
948 ((manager
.getTypeReader(
949 codemaker::convertString(
950 reader
.getSuperTypeName(0))).
951 getTypeClass()) == RT_TYPE_INTERFACE
) )
953 printMapsToCppType(o
, options
, manager
, sort
, typeClass
,
954 name
, rank
, arguments
,
956 o
<< "; get method:\nstatic ";
957 printType(o
, options
, manager
,
958 codemaker::convertString(reader
.getSuperTypeName(0)), 1);
959 o
<< " get(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);\n";
961 o
<< "does not map to C++\n";