1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "codemaker/commoncpp.hxx"
31 #include "ostringostreaminserter.hxx"
32 #include "skeletoncommon.hxx"
33 #include "skeletoncpp.hxx"
35 using namespace ::rtl
;
36 using namespace ::codemaker::cpp
;
38 namespace skeletonmaker
{ namespace cpp
{
40 void printType(std::ostream
& o
,
41 ProgramOptions
const & options
, TypeManager
const & manager
,
42 codemaker::UnoType::Sort sort
, RTTypeClass typeClass
,
43 OString
const & name
, sal_Int32 rank
,
44 std::vector
< OString
> const & arguments
, short referenceType
,
47 if (defaultvalue
&& rank
== 0 && sort
<= codemaker::UnoType::SORT_CHAR
) {
50 case codemaker::UnoType::SORT_BOOLEAN
:
53 case codemaker::UnoType::SORT_CHAR
:
54 case codemaker::UnoType::SORT_BYTE
:
55 case codemaker::UnoType::SORT_SHORT
:
56 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
57 case codemaker::UnoType::SORT_LONG
:
58 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
59 case codemaker::UnoType::SORT_HYPER
:
60 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
61 case codemaker::UnoType::SORT_FLOAT
:
62 case codemaker::UnoType::SORT_DOUBLE
:
65 case codemaker::UnoType::SORT_VOID
:
66 case codemaker::UnoType::SORT_STRING
:
67 case codemaker::UnoType::SORT_TYPE
:
68 case codemaker::UnoType::SORT_ANY
:
69 case codemaker::UnoType::SORT_COMPLEX
:
74 if (defaultvalue
&& referenceType
== 16) {
75 if (typeClass
== RT_TYPE_ENUM
) {
76 typereg::Reader
reader(manager
.getTypeReader(name
));
77 o
<< name
.copy(name
.lastIndexOf('/'))
79 << codemaker::convertString(reader
.getFieldName(0));
83 bool bReference
= false;
84 if (((sort
> codemaker::UnoType::SORT_CHAR
||
85 rank
> 0) && referenceType
!= 8 &&
86 !(typeClass
== RT_TYPE_ENUM
&& referenceType
== 4 && rank
== 0)) ||
87 (sort
<= codemaker::UnoType::SORT_CHAR
&& referenceType
== 2))
92 if (bReference
&& referenceType
== 4)
95 for (sal_Int32 i
= 0; i
< rank
; ++i
) {
96 o
<< ((options
.shortnames
) ? "css::uno::Sequence< " :
97 "::com::sun::star::uno::Sequence< ");
99 if (typeClass
== RT_TYPE_INTERFACE
&& referenceType
> 0) {
100 o
<< ((options
.shortnames
) ? "css::uno::Reference< " :
101 "::com::sun::star::uno::Reference< ");
104 o
<< scopedCppName(codemaker::cpp::translateUnoToCppType(
105 sort
, typeClass
, name
, false),
106 false, options
.shortnames
&& referenceType
> 0);
108 if (typeClass
== RT_TYPE_INTERFACE
&& referenceType
> 0)
111 if (!arguments
.empty()) {
113 for (std::vector
< OString
>::const_iterator
i(arguments
.begin());
114 i
!= arguments
.end(); ++i
)
116 if (i
!= arguments
.begin())
119 printType(o
, options
, manager
, *i
, 1, false);
124 for (sal_Int32 i
= 0; i
< rank
; ++i
)
127 if (bReference
&& referenceType
> 1)
130 if (referenceType
== 8 && (sort
> codemaker::UnoType::SORT_CHAR
|| rank
> 0))
134 void printType(std::ostream
& o
,
135 ProgramOptions
const & options
, TypeManager
const & manager
,
136 OString
const & type
, short referenceType
, bool defaultvalue
)
138 RTTypeClass typeClass
;
141 std::vector
< OString
> arguments
;
142 codemaker::UnoType::Sort sort
= codemaker::decomposeAndResolve(
143 manager
, type
, true, true, true, &typeClass
, &name
, &rank
, &arguments
);
145 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
146 referenceType
, defaultvalue
);
149 bool printConstructorParameters(std::ostream
& o
,
150 ProgramOptions
const & options
, TypeManager
const & manager
,
151 typereg::Reader
const & reader
, typereg::Reader
const & outerReader
,
152 std::vector
< OString
> const & arguments
)
154 bool previous
= false;
155 if (reader
.getSuperTypeCount() != 0) {
157 codemaker::convertString(reader
.getSuperTypeName(0)));
158 typereg::Reader
superReader(manager
.getTypeReader(super
));
159 if (!superReader
.isValid())
160 throw CannotDumpException("Bad type library entity " + super
);
162 previous
= printConstructorParameters(o
,
163 options
, manager
, superReader
, outerReader
, arguments
);
165 for (sal_uInt16 i
= 0; i
< reader
.getFieldCount(); ++i
) {
171 if ((reader
.getFieldFlags(i
) & RT_ACCESS_PARAMETERIZED_TYPE
) == 0) {
172 printType(o
, options
, manager
,
173 codemaker::convertString(reader
.getFieldTypeName(i
)), 4);
174 } else if (arguments
.empty()) {
176 // o << "com::sun::star::uno::Any";
178 sal_uInt16 tparam
= 0;
179 while (outerReader
.getReferenceTypeName(tparam
)
180 != reader
.getFieldTypeName(i
))
183 OSL_ASSERT(tparam
< outerReader
.getReferenceCount());
185 // assume std::vector< OString >::size_type is at least as
186 // large as sal_uInt16:
187 printType(o
, options
, manager
, arguments
[tparam
], 4);
190 << (codemaker::cpp::translateUnoToCppIdentifier(
191 codemaker::convertString(reader
.getFieldName(i
)),
198 void printConstructor(std::ostream
& o
,
199 ProgramOptions
const & options
, TypeManager
const & manager
,
200 typereg::Reader
const & reader
,
201 std::vector
< OString
> const & arguments
)
203 OString
type(codemaker::convertString(reader
.getTypeName()));
205 o
<< type
.copy(type
.lastIndexOf('/') + 1) << '(';
206 printConstructorParameters(o
, options
, manager
, reader
, reader
,
211 void printMethodParameters(std::ostream
& o
,
212 ProgramOptions
const & options
, TypeManager
const & manager
,
213 typereg::Reader
const & reader
, sal_uInt16 method
, bool previous
,
216 short referenceType
= 4;
217 for (sal_uInt16 i
= 0; i
< reader
.getMethodParameterCount(method
); ++i
) {
223 if (reader
.getMethodParameterFlags(method
, i
) == RT_PARAM_OUT
224 || reader
.getMethodParameterFlags(method
, i
) == RT_PARAM_INOUT
)
232 printType(o
, options
, manager
,
233 codemaker::convertString(
234 reader
.getMethodParameterTypeName(method
, i
)),
239 o
<< (codemaker::cpp::translateUnoToCppIdentifier(
240 codemaker::convertString(
241 reader
.getMethodParameterName(method
, i
)),
247 void printExceptionSpecification(std::ostream
& o
,
248 ProgramOptions
const & options
, TypeManager
const & manager
,
249 typereg::Reader
const & reader
, sal_uInt16 method
)
251 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException" :
252 " throw (::com::sun::star::uno::RuntimeException");
253 if (reader
.getMethodExceptionCount(method
) > 0) {
254 for (sal_uInt16 i
= 0; i
< reader
.getMethodExceptionCount(method
); ++i
) {
256 printType(o
, options
, manager
,
257 codemaker::convertString(
258 reader
.getMethodExceptionTypeName(method
, i
)), 1);
264 void printSetPropertyMixinBody(std::ostream
& o
,
265 typereg::Reader
const & reader
,
269 RTFieldAccess propFlags
= checkAdditionalPropertyFlags(reader
, field
, method
);
270 OString fieldname
= codemaker::convertString(reader
.getFieldName(field
));
271 bool bound
= (reader
.getFieldFlags(field
) & RT_ACCESS_BOUND
? true : false);
276 o
<< " BoundListeners l;\n";
278 if (propFlags
& RT_ACCESS_CONSTRAINED
) {
279 OString fieldtype
= codemaker::convertString(
280 reader
.getFieldTypeName(field
));
282 sal_Int32 index
= fieldtype
.lastIndexOf('<');
285 bool optional
= false;
286 OStringBuffer
buffer1(64);
287 OStringBuffer
buffer2(64);
290 OString
s(fieldtype
.getToken(0, '<', nPos
));
291 OString t
= s
.copy(s
.lastIndexOf('/')+1);
293 if (t
.equals("Optional")) {
297 buffer1
.append("the_value.IsPresent");
298 buffer2
.append("the_value.Value");
300 buffer1
.insert(0, t
);
301 buffer1
.append(".IsPresent");
302 buffer2
.insert(0, t
);
303 buffer2
.append(".Value");
309 buffer1
.append("the_value.Value");
311 buffer2
.append("the_value.Value");
314 buffer1
.insert(0, t
);
315 buffer1
.append(".Value");
317 buffer2
.insert(0, t
);
318 buffer2
.append(".Value");
321 } while( nPos
<= index
);
323 o
<< " css::uno::Any v;\n";
325 o
<< " if(" << buffer1
.makeStringAndClear() << ")\n {\n"
326 << " v <<= " << buffer2
.makeStringAndClear() << ";\n }\n";
328 o
<< " v <<= " << buffer2
.makeStringAndClear() << ";\n\n";
331 o
<< " prepareSet(\n rtl::OUString(\""
332 << fieldname
<< "\"),\n css::uno::Any(), v, ";
334 o
<< " prepareSet(\n rtl::OUString(\""
335 << fieldname
<< "\"),\n css::uno::Any(), css::uno::Any(), ";
343 o
<< " {\n osl::MutexGuard g(m_aMutex);\n m_"
344 << fieldname
<< " = the_value;\n }\n";
347 o
<< " l.notify();\n";
352 void generateXPropertySetBodies(std::ostream
& o
,
353 const OString
& classname
,
354 const OString
& interfaceName
);
355 void generateXFastPropertySetBodies(std::ostream
& o
,
356 const OString
& classname
,
357 const OString
& interfaceName
);
358 void generateXPropertyAccessBodies(std::ostream
& o
,
359 const OString
& classname
,
360 const OString
& interfaceName
);
362 void generateXAddInBodies(std::ostream
& o
, const OString
& classname
);
364 void generateXLocalizable(std::ostream
& o
, const OString
& classname
);
366 void generateXCompatibilityNamesBodies(std::ostream
& o
, const OString
& classname
);
368 void generateXInitialization(std::ostream
& o
, const OString
& classname
);
370 void generateXDispatch(std::ostream
& o
,
371 const OString
& classname
,
372 const ProtocolCmdMap
& protocolCmdMap
);
374 void generateXDispatchProvider(std::ostream
& o
,
375 const OString
& classname
,
376 const ProtocolCmdMap
& protocolCmdMap
);
379 void printMethods(std::ostream
& o
,
380 ProgramOptions
const & options
, TypeManager
const & manager
,
381 typereg::Reader
const & reader
, codemaker::GeneratedTypeSet
& generated
,
382 OString
const & delegate
, OString
const & classname
,
383 OString
const & indentation
, bool defaultvalue
,
384 OString
const & propertyhelper
)
386 OString
type(codemaker::convertString(reader
.getTypeName()));
387 if (generated
.contains(type
) || type
.equals("com/sun/star/uno/XInterface") ||
389 ( type
.equals("com/sun/star/lang/XComponent") ||
390 type
.equals("com/sun/star/lang/XTypeProvider") ||
391 type
.equals("com/sun/star/uno/XWeak")) ) )
396 static OString
sd(RTL_CONSTASCII_STRINGPARAM("_"));
397 bool body
= !delegate
.isEmpty();
398 bool defaultbody
= ((delegate
.equals(sd
)) ? true : false);
400 if (body
&& propertyhelper
.getLength() > 1) {
401 if ( type
.equals("com/sun/star/beans/XPropertySet")) {
403 generateXPropertySetBodies(
404 o
, classname
, scopedCppName(propertyhelper
, false, true));
406 } else if ( type
.equals("com/sun/star/beans/XFastPropertySet")) {
408 generateXFastPropertySetBodies(
409 o
, classname
, scopedCppName(propertyhelper
, false, true));
411 } else if ( type
.equals("com/sun/star/beans/XPropertyAccess")) {
413 generateXPropertyAccessBodies(
414 o
, classname
, scopedCppName(propertyhelper
, false, true));
419 if (body
&& options
.componenttype
== 2) {
420 if (type
.equals("com/sun/star/lang/XServiceName")) {
421 o
<< "// ::com::sun::star::lang::XServiceName:\n"
422 "::rtl::OUString SAL_CALL " << classname
<< "getServiceName() "
423 "throw (css::uno::RuntimeException)\n{\n "
424 "return ::rtl::OUString("
425 "sADDIN_SERVICENAME);\n}\n";
428 } else if (type
.equals("com/sun/star/sheet/XAddIn")) {
429 generateXAddInBodies(o
, classname
);
432 // special handling of XLocalizable -> parent of XAddIn
433 if (!generated
.contains("com/sun/star/lang/XLocalizable")) {
434 generateXLocalizable(o
, classname
);
435 generated
.add("com/sun/star/lang/XLocalizable");
438 } else if (type
.equals("com/sun/star/lang/XLocalizable")) {
439 generateXLocalizable(o
, classname
);
442 } else if (type
.equals("com/sun/star/sheet/XCompatibilityNames")) {
443 generateXCompatibilityNamesBodies(o
, classname
);
449 if (body
&& options
.componenttype
== 3) {
450 if (type
.equals("com/sun/star/lang/XInitialization")) {
451 generateXInitialization(o
, classname
);
454 } else if (type
.equals("com/sun/star/frame/XDispatch")) {
455 generateXDispatch(o
, classname
, options
.protocolCmdMap
);
458 } else if (type
.equals("com/sun/star/frame/XDispatchProvider")) {
459 generateXDispatchProvider(o
, classname
, options
.protocolCmdMap
);
466 if (options
.all
|| defaultvalue
) {
467 for (sal_uInt16 i
= 0; i
< reader
.getSuperTypeCount(); ++i
) {
468 typereg::Reader
super(
469 manager
.getTypeReader(
470 codemaker::convertString(
471 reader
.getSuperTypeName(i
))));
472 if (!super
.isValid()) {
473 throw CannotDumpException(
474 "Bad type library entity "
475 + codemaker::convertString(
476 reader
.getSuperTypeName(i
)));
479 OString
stype(codemaker::convertString(super
.getTypeName()));
480 printMethods(o
, options
, manager
, super
, generated
, delegate
,
481 classname
, indentation
, defaultvalue
, propertyhelper
);
484 if (reader
.getFieldCount() > 0 || reader
.getMethodCount() > 0) {
485 o
<< indentation
<< "// ";
486 printType(o
, options
, manager
, type
, 0);
490 sal_uInt16 method
= 0;
491 for (sal_uInt16 i
= 0; i
< reader
.getFieldCount(); ++i
) {
496 printType(o
, options
, manager
,
497 codemaker::convertString(reader
.getFieldTypeName(i
)), 1);
499 if (!classname
.isEmpty())
503 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
505 if (method
< reader
.getMethodCount()
506 && reader
.getMethodFlags(method
) == RT_MODE_ATTRIBUTE_GET
507 && reader
.getMethodName(method
) == reader
.getFieldName(i
))
509 printExceptionSpecification(o
, options
, manager
, reader
, method
++);
511 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException)" :
512 " throw (::com::sun::star::uno::RuntimeException)");
516 if (!propertyhelper
.isEmpty()) {
517 o
<< "\n{\n osl::MutexGuard g(m_aMutex);\n return m_"
518 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
521 o
<< "\n{\n return ";
522 if (options
.componenttype
== 1) {
524 << codemaker::convertString(
525 reader
.getFieldName(i
)).getStr();
527 printType(o
, options
, manager
,
528 codemaker::convertString(
529 reader
.getFieldTypeName(i
)),
535 o
<< "\n" << indentation
<< "{\n" << indentation
<< " return "
536 << delegate
.getStr() << "get"
537 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
538 << "();\n" << indentation
<< "}\n\n";
544 if ((reader
.getFieldFlags(i
) & RT_ACCESS_READONLY
) == 0) {
549 o
<< "void SAL_CALL ";
550 if (!classname
.isEmpty())
554 << (codemaker::convertString(reader
.getFieldName(i
)).getStr())
556 printType(o
, options
, manager
,
557 codemaker::convertString(reader
.getFieldTypeName(i
)), 4);
559 if (method
< reader
.getMethodCount()
560 && reader
.getMethodFlags(method
) == RT_MODE_ATTRIBUTE_SET
561 && reader
.getMethodName(method
) == reader
.getFieldName(i
))
563 printExceptionSpecification(o
, options
, manager
, reader
, method
++);
565 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException)" :
566 " throw (::com::sun::star::uno::RuntimeException)");
570 if (!propertyhelper
.isEmpty()) {
571 printSetPropertyMixinBody(o
, reader
, i
, method
);
573 if (options
.componenttype
== 1) {
575 << codemaker::convertString(
576 reader
.getFieldName(i
)).getStr()
577 << " = the_value;\n}\n\n";
583 o
<< "\n" << indentation
<< "{\n" << indentation
<< " "
584 << delegate
.getStr() << "set"
585 << codemaker::convertString(reader
.getFieldName(i
)).getStr()
586 << "(the_value);\n" << indentation
<< "}\n\n";
593 for (; method
< reader
.getMethodCount(); ++method
) {
598 printType(o
, options
, manager
,
599 codemaker::convertString(
600 reader
.getMethodReturnTypeName(method
)), 1);
602 if (!classname
.isEmpty())
605 const OString
methodName(codemaker::convertString(reader
.getMethodName(method
)));
607 o
<< methodName
<< '(';
608 printMethodParameters(o
, options
, manager
, reader
, method
, false, true);
610 printExceptionSpecification(o
, options
, manager
, reader
, method
);
612 static OUString
s("void");
615 if (!reader
.getMethodReturnTypeName(method
).equals(s
)) {
616 o
<< " // TODO: Exchange the default return implementation for \""
617 << methodName
<< "\" !!!\n";
618 o
<< " // Exchange the default return implementation.\n"
619 " // NOTE: Default initialized polymorphic structs "
620 "can cause problems because of\n // missing default "
621 "initialization of primitive types of some C++ compilers or"
622 "\n // different Any initialization in Java and C++ "
623 "polymorphic structs.\n return ";
624 printType(o
, options
, manager
,
625 codemaker::convertString(
626 reader
.getMethodReturnTypeName(method
)), 8, true);
629 o
<< " // TODO: Insert your implementation for \""
630 << methodName
<< "\" here.";
634 o
<< "\n" << indentation
<< "{\n" << indentation
<< " ";
635 if (!reader
.getMethodReturnTypeName(method
).equals(s
))
638 o
<< delegate
.getStr()
639 << (codemaker::convertString(
640 reader
.getMethodName(method
)).getStr())
642 printMethodParameters(o
, options
, manager
, reader
, method
,
644 o
<< ");\n" << indentation
<< "}\n\n";
651 if (method
> 0 && !body
)
655 void printConstructionMethods(std::ostream
& o
,
656 ProgramOptions
const & options
, TypeManager
const & manager
,
657 typereg::Reader
const & reader
)
659 for (sal_uInt16 i
= 0; i
< reader
.getMethodCount(); ++i
) {
663 codemaker::convertString(reader
.getSuperTypeName(0)), 1);
665 if (reader
.getMethodName(i
).isEmpty()) {
668 o
<< (codemaker::cpp::translateUnoToCppIdentifier(
669 codemaker::convertString(reader
.getMethodName(i
)),
673 o
<< ((options
.shortnames
) ? "(css::uno::Reference< css" :
674 "(::com::sun::star::uno::Reference< ::com::sun::star")
675 << "::uno::XComponentContext > const & the_context";
676 printMethodParameters(o
, options
, manager
, reader
, i
,
679 printExceptionSpecification(o
, options
, manager
, reader
, i
);
684 void printServiceMembers(std::ostream
& o
,
685 ProgramOptions
const & options
, TypeManager
const & manager
,
686 typereg::Reader
const & reader
, OString
const & type
,
687 OString
const & delegate
)
689 for (sal_uInt16 i
= 0; i
< reader
.getReferenceCount(); ++i
) {
690 OString
referenceType(
691 codemaker::convertString(
692 reader
.getReferenceTypeName(i
)).replace('/', '.'));
694 if ( reader
.getReferenceSort(i
) == RT_REF_SUPPORTS
) {
695 o
<< "\n// supported interface " << referenceType
.getStr() << "\n";
696 generateDocumentation(o
, options
, manager
, referenceType
, delegate
);
697 } else if ( reader
.getReferenceSort(i
) == RT_REF_EXPORTS
) {
698 o
<< "\n// exported service " << referenceType
.getStr() << "\n";
699 generateDocumentation(o
, options
, manager
, referenceType
, delegate
);
700 o
<< "\n// end of exported service " << referenceType
.getStr() << "\n";
704 if (delegate
.isEmpty()) {
705 o
<< "\n// properties of service \""<< type
.getStr() << "\"\n";
706 for (sal_uInt16 i
= 0; i
< reader
.getFieldCount(); ++i
) {
708 codemaker::convertString(reader
.getFieldName(i
)));
710 codemaker::convertString(reader
.getFieldTypeName(i
)));
713 printType(o
, options
, manager
, fieldType
, 1);
715 << codemaker::cpp::translateUnoToCppIdentifier(
716 fieldName
, "property").getStr()
722 void printMapsToCppType(std::ostream
& o
,
723 ProgramOptions
const & options
, TypeManager
const & manager
,
724 codemaker::UnoType::Sort sort
, RTTypeClass typeClass
,
725 OString
const & name
, sal_Int32 rank
,
726 std::vector
< OString
> const & arguments
, const char * cppTypeSort
)
729 if (cppTypeSort
!= 0)
730 o
<< cppTypeSort
<< ' ';
733 if (rank
== 0 && name
== "com/sun/star/uno/XInterface") {
734 o
<< "Reference< com::sun::star::uno::XInterface >";
736 printType(o
, options
, manager
, sort
, typeClass
, name
, rank
, arguments
, 0);
741 void generateDocumentation(std::ostream
& o
,
742 ProgramOptions
const & options
, TypeManager
const & manager
,
743 OString
const & type
, OString
const & delegate
)
745 if (type
.indexOf('/') >= 0)
746 throw CannotDumpException("Illegal type name " + type
);
748 OString
binType(type
.replace('.', '/'));
749 RTTypeClass typeClass
;
752 std::vector
< OString
> arguments
;
753 codemaker::UnoType::Sort sort
= decomposeResolveAndCheck(
754 manager
, binType
, false, true, true, &typeClass
, &name
, &rank
,
758 if (!delegate
.isEmpty()) {
759 if (typeClass
!= RT_TYPE_INTERFACE
&&
760 typeClass
!= RT_TYPE_SERVICE
)
770 o
<< " sequence type";
771 } else if (sort
!= codemaker::UnoType::SORT_COMPLEX
) {
774 typereg::Reader
reader(manager
.getTypeReader(name
));
775 if (!reader
.isValid())
776 throw CannotDumpException("Bad type library entity " + name
);
780 case RT_TYPE_INTERFACE
:
781 o
<< " interface type";
789 if (reader
.getReferenceCount() == 0)
790 o
<< " simple struct type";
791 else if (arguments
.empty())
792 o
<< " polymorphic struct type template";
794 o
<< " instantiated polymorphic struct type";
801 case RT_TYPE_EXCEPTION
:
802 o
<< " exception type";
805 case RT_TYPE_TYPEDEF
:
809 case RT_TYPE_SERVICE
:
810 if (reader
.getSuperTypeCount() > 0)
811 o
<< " single-inheritance--based service";
813 o
<< "IDL accumulation-based service";
816 case RT_TYPE_SINGLETON
:
817 if ((manager
.getTypeReader(
818 codemaker::convertString(
819 reader
.getSuperTypeName(0))).getTypeClass())
820 == RT_TYPE_INTERFACE
)
821 o
<< " inheritance-based singleton";
823 o
<< "IDL service-based singleton";
826 case RT_TYPE_CONSTANTS
:
827 o
<< "IDL constant group";
835 o
<< " \"" << type
.getStr() << "\" ";
837 sort
= codemaker::decomposeAndResolve(
838 manager
, binType
, true, true, true, &typeClass
, &name
, &rank
,
842 printMapsToCppType(o
,
843 options
, manager
, sort
, typeClass
, name
, rank
, arguments
, "array");
846 } else if (sort
!= codemaker::UnoType::SORT_COMPLEX
) {
848 printMapsToCppType(o
,
849 options
, manager
, sort
, typeClass
, name
, rank
, arguments
, 0);
853 typereg::Reader
reader(manager
.getTypeReader(name
));
854 if (!reader
.isValid())
855 throw CannotDumpException("Bad type library entity " + name
);
859 case RT_TYPE_INTERFACE
:
861 printMapsToCppType(o
,
862 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
864 if (name
== "com/sun/star/uno/XInterface") {
869 o
<< "; " << (options
.all
? "all" : "direct") << " methods:\n";
871 codemaker::GeneratedTypeSet generated
;
872 printMethods(o
, options
, manager
, reader
, generated
,
873 delegate
, options
.implname
, "");
878 printMapsToCppType(o
,
879 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
885 if (reader
.getReferenceCount() == 0) {
886 printMapsToCppType(o
,
887 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
889 } else if (arguments
.empty()) {
890 printMapsToCppType(o
,
891 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
892 options
.java5
? "generic class" : "class");
894 printMapsToCppType(o
,
895 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
896 options
.java5
? "generic class instantiation" : "class");
898 o
<< "; full constructor:\n";
899 printConstructor(o
, options
, manager
, reader
, arguments
);
903 printMapsToCppType(o
,
904 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
909 case RT_TYPE_CONSTANTS
:
910 printMapsToCppType(o
,
911 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
916 case RT_TYPE_EXCEPTION
:
917 printMapsToCppType(o
,
918 options
, manager
, sort
, typeClass
, name
, rank
, arguments
,
920 o
<< "; full constructor:\n";
921 printConstructor(o
, options
, manager
, reader
, arguments
);
924 case RT_TYPE_SERVICE
:
925 if (reader
.getSuperTypeCount() > 0) {
927 printMapsToCppType(o
, options
, manager
, sort
, typeClass
,
928 name
, rank
, arguments
, "class");
929 o
<< "; construction methods:\n";
930 printConstructionMethods(o
, options
, manager
, reader
);
934 codemaker::convertString(
935 reader
.getSuperTypeName(0)).replace('/', '.'));
936 generateDocumentation(o
, options
, manager
, super
, delegate
);
939 o
<< ("does not map to C++\n"
940 "// the service members are generated instead\n");
941 printServiceMembers(o
, options
, manager
, reader
, type
, delegate
);
945 case RT_TYPE_SINGLETON
:
946 if (reader
.getSuperTypeCount() > 0 &&
947 ((manager
.getTypeReader(
948 codemaker::convertString(
949 reader
.getSuperTypeName(0))).
950 getTypeClass()) == RT_TYPE_INTERFACE
) )
952 printMapsToCppType(o
, options
, manager
, sort
, typeClass
,
953 name
, rank
, arguments
,
955 o
<< "; get method:\nstatic ";
956 printType(o
, options
, manager
,
957 codemaker::convertString(reader
.getSuperTypeName(0)), 1);
958 o
<< " get(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);\n";
960 o
<< "does not map to C++\n";
974 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */