LCOV - code coverage report
Current view: top level - libreoffice/codemaker/source/cppumaker - cpputype.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2462 2599 94.7 %
Date: 2012-12-27 Functions: 130 141 92.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include <algorithm>
      22             : #include <map>
      23             : #include <set>
      24             : #include <stdio.h>
      25             : #include <string.h>
      26             : #include <vector>
      27             : 
      28             : #include "registry/reader.hxx"
      29             : #include "rtl/alloc.h"
      30             : #include "rtl/ustring.hxx"
      31             : #include "rtl/strbuf.hxx"
      32             : 
      33             : #include "codemaker/dependencies.hxx"
      34             : #include "codemaker/exceptiontree.hxx"
      35             : #include "codemaker/generatedtypeset.hxx"
      36             : #include "codemaker/unotype.hxx"
      37             : 
      38             : #include "cpputype.hxx"
      39             : #include "cppuoptions.hxx"
      40             : #include "dumputils.hxx"
      41             : #include "includes.hxx"
      42             : 
      43             : using namespace codemaker::cpp;
      44             : 
      45             : using ::rtl::OUString;
      46             : using ::rtl::OString;
      47             : using ::rtl::OStringBuffer;
      48             : 
      49             : namespace {
      50             : 
      51       45618 : rtl::OString translateSimpleUnoType(rtl::OString const & unoType, bool cppuUnoType=false) {
      52             :     static rtl::OString const trans[codemaker::UnoType::SORT_COMPLEX + 1] = {
      53             :         "void", "::sal_Bool", "::sal_Int8", "::sal_Int16", "::sal_uInt16",
      54             :         "::sal_Int32", "::sal_uInt32", "::sal_Int64", "::sal_uInt64", "float",
      55             :         "double", "::sal_Unicode", "::rtl::OUString",
      56             :         "::com::sun::star::uno::Type", "::com::sun::star::uno::Any",
      57       45628 :         rtl::OString() };
      58             : 
      59       45618 :     const codemaker::UnoType::Sort sort = codemaker::UnoType::getSort(unoType);
      60       45618 :     if (cppuUnoType &&
      61             :         (sort == codemaker::UnoType::SORT_UNSIGNED_SHORT ||
      62             :          sort == codemaker::UnoType::SORT_CHAR) )
      63             :     {
      64           7 :         if (sort == codemaker::UnoType::SORT_CHAR)
      65           4 :             return "::cppu::UnoCharType";
      66             :         else
      67           3 :             return "::cppu::UnoUnsignedShortType";
      68             :     }
      69             : 
      70       45611 :     return trans[sort];
      71             : }
      72             : 
      73        6392 : bool isBootstrapType(rtl::OString const & name) {
      74             :     static char const * const names[] = {
      75             :         "com/sun/star/beans/PropertyAttribute",
      76             :         "com/sun/star/beans/PropertyValue",
      77             :         "com/sun/star/beans/XFastPropertySet",
      78             :         "com/sun/star/beans/XMultiPropertySet",
      79             :         "com/sun/star/beans/XPropertyAccess",
      80             :         "com/sun/star/beans/XPropertySet",
      81             :         "com/sun/star/beans/XPropertySetOption",
      82             :         "com/sun/star/bridge/UnoUrlResolver",
      83             :         "com/sun/star/bridge/XUnoUrlResolver",
      84             :         "com/sun/star/connection/SocketPermission",
      85             :         "com/sun/star/container/XElementAccess",
      86             :         "com/sun/star/container/XEnumerationAccess",
      87             :         "com/sun/star/container/XHierarchicalNameAccess",
      88             :         "com/sun/star/container/XNameAccess",
      89             :         "com/sun/star/container/XNameContainer",
      90             :         "com/sun/star/container/XNameReplace",
      91             :         "com/sun/star/container/XSet",
      92             :         "com/sun/star/io/FilePermission",
      93             :         "com/sun/star/io/IOException",
      94             :         "com/sun/star/lang/DisposedException",
      95             :         "com/sun/star/lang/WrappedTargetRuntimeException",
      96             :         "com/sun/star/lang/XComponent",
      97             :         "com/sun/star/lang/XEventListener",
      98             :         "com/sun/star/lang/XInitialization",
      99             :         "com/sun/star/lang/XMultiComponentFactory",
     100             :         "com/sun/star/lang/XMultiServiceFactory",
     101             :         "com/sun/star/lang/XServiceInfo",
     102             :         "com/sun/star/lang/XSingleComponentFactory",
     103             :         "com/sun/star/lang/XSingleServiceFactory",
     104             :         "com/sun/star/lang/XTypeProvider",
     105             :         "com/sun/star/loader/XImplementationLoader",
     106             :         "com/sun/star/reflection/XArrayTypeDescription",
     107             :         "com/sun/star/reflection/XCompoundTypeDescription",
     108             :         "com/sun/star/reflection/XEnumTypeDescription",
     109             :         "com/sun/star/reflection/XIdlClass",
     110             :         "com/sun/star/reflection/XIdlField2",
     111             :         "com/sun/star/reflection/XIdlReflection",
     112             :         "com/sun/star/reflection/XIndirectTypeDescription",
     113             :         "com/sun/star/reflection/XInterfaceAttributeTypeDescription",
     114             :         "com/sun/star/reflection/XInterfaceAttributeTypeDescription2",
     115             :         "com/sun/star/reflection/XInterfaceMemberTypeDescription",
     116             :         "com/sun/star/reflection/XInterfaceMethodTypeDescription",
     117             :         "com/sun/star/reflection/XInterfaceTypeDescription",
     118             :         "com/sun/star/reflection/XInterfaceTypeDescription2",
     119             :         "com/sun/star/reflection/XMethodParameter",
     120             :         "com/sun/star/reflection/XStructTypeDescription",
     121             :         "com/sun/star/reflection/XTypeDescription",
     122             :         "com/sun/star/reflection/XTypeDescriptionEnumerationAccess",
     123             :         "com/sun/star/reflection/XUnionTypeDescription",
     124             :         "com/sun/star/registry/XImplementationRegistration",
     125             :         "com/sun/star/registry/XRegistryKey",
     126             :         "com/sun/star/registry/XSimpleRegistry",
     127             :         "com/sun/star/security/RuntimePermission",
     128             :         "com/sun/star/security/XAccessController",
     129             :         "com/sun/star/uno/DeploymentException",
     130             :         "com/sun/star/uno/RuntimeException",
     131             :         "com/sun/star/uno/XAggregation",
     132             :         "com/sun/star/uno/XComponentContext",
     133             :         "com/sun/star/uno/XCurrentContext",
     134             :         "com/sun/star/uno/XUnloadingPreference",
     135             :         "com/sun/star/uno/XWeak",
     136             :         "com/sun/star/util/XMacroExpander"
     137             :     }; // cf. cppuhelper/unotypes/Makefile UNOTYPES (plus missing dependencies)
     138      397023 :     for (std::size_t i = 0; i < SAL_N_ELEMENTS(names); ++i) {
     139      390814 :         if (name.equals(names[i])) {
     140         183 :             return true;
     141             :         }
     142             :     }
     143        6209 :     return false;
     144             : }
     145             : 
     146             : }
     147             : 
     148             : //*************************************************************************
     149             : // CppuType
     150             : //*************************************************************************
     151       10444 : CppuType::CppuType(typereg::Reader& typeReader,
     152             :                    const OString& typeName,
     153             :                    const TypeManager& typeMgr)
     154             :     : m_inheritedMemberCount(0)
     155             :     , m_cppuTypeLeak(false)
     156             :     , m_cppuTypeDynamic(true)
     157             :     , m_indentLength(0)
     158             :     , m_typeName(typeName)
     159       10444 :     , m_name(typeName.copy(typeName.lastIndexOf('/') + 1))
     160             :     , m_reader(typeReader)
     161             :     , m_typeMgr(typeMgr)
     162       20888 :     , m_dependencies(typeMgr, typeName)
     163       10444 : {}
     164             : 
     165       10444 : CppuType::~CppuType()
     166             : {
     167             : 
     168       10444 : }
     169             : 
     170        7923 : void CppuType::addGetCppuTypeIncludes(codemaker::cppumaker::Includes & includes)
     171             :     const
     172             : {
     173       31686 :     if (m_typeName.equals("com/sun/star/uno/XInterface")
     174       23763 :         || m_typeName.equals("com/sun/star/uno/Exception"))
     175             :     {
     176           6 :         includes.addType();
     177           6 :         includes.addCppuUnotypeHxx();
     178           6 :         includes.addSalTypesH();
     179           6 :         includes.addTypelibTypeclassH();
     180           6 :         includes.addTypelibTypedescriptionH();
     181        7917 :     } else if (m_cppuTypeLeak) {
     182        2888 :         addLightGetCppuTypeIncludes(includes);
     183        5029 :     } else if (m_cppuTypeDynamic) {
     184        1832 :         addNormalGetCppuTypeIncludes(includes);
     185             :     } else {
     186        3197 :         addComprehensiveGetCppuTypeIncludes(includes);
     187             :     }
     188        7923 : }
     189             : 
     190           0 : void CppuType::dumpDeclaration(FileStream &) throw (CannotDumpException) {
     191             :     OSL_ASSERT(false);
     192           0 : }
     193             : 
     194        7126 : bool CppuType::dumpFiles(CppuOptions * options, rtl::OString const & outPath) {
     195       21378 :     return dumpFile(options, ".hdl", m_typeName, outPath)
     196       28504 :         && dumpFile(options, ".hpp", m_typeName, outPath);
     197             : }
     198             : 
     199        2491 : void CppuType::addLightGetCppuTypeIncludes(
     200             :     codemaker::cppumaker::Includes & includes) const
     201             : {
     202             :     //TODO: Determine what is really needed, instead of relying on
     203             :     // addDefaultHxxIncludes
     204        2491 :     includes.addCppuUnotypeHxx();
     205        2491 : }
     206             : 
     207        1796 : void CppuType::addNormalGetCppuTypeIncludes(
     208             :     codemaker::cppumaker::Includes & includes) const
     209             : {
     210             :     //TODO: Determine what is really needed, instead of relying on
     211             :     // addDefaultHxxIncludes
     212        1796 :     includes.addCppuUnotypeHxx();
     213        1796 : }
     214             : 
     215        1035 : void CppuType::addComprehensiveGetCppuTypeIncludes(
     216             :     codemaker::cppumaker::Includes & includes) const
     217             : {
     218             :     //TODO: Determine what is really needed, instead of relying on
     219             :     // addDefaultHxxIncludes
     220        1035 :     includes.addCppuUnotypeHxx();
     221        1035 : }
     222             : 
     223       18459 : bool CppuType::isPolymorphic() const { return false; }
     224             : 
     225        9364 : void CppuType::dumpTemplateHead(FileStream &) const {}
     226             : 
     227       14043 : void CppuType::dumpTemplateParameters(FileStream &) const {}
     228             : 
     229        5514 : void CppuType::dumpGetCppuTypePreamble(FileStream & out) {
     230        5514 :     if (isPolymorphic()) {
     231          16 :         out << "namespace cppu {\n\n";
     232          16 :         dumpTemplateHead(out);
     233          16 :         out << "class UnoType< ";
     234          16 :         dumpType(out, m_typeName);
     235          16 :         dumpTemplateParameters(out);
     236          16 :         out << " > {\npublic:\n";
     237          16 :         inc();
     238          32 :         out << indent()
     239          16 :             << "static inline ::com::sun::star::uno::Type const & get() {\n";
     240             :     } else {
     241        5498 :         if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false)) {
     242        5482 :             out << "\n\n";
     243             :         }
     244             :         out << ("inline ::com::sun::star::uno::Type const &"
     245        5498 :                 " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ");
     246        5498 :         dumpType(out, m_typeName, false, false, true);
     247        5498 :         out << " const *) {\n";
     248             :     }
     249        5514 :     inc();
     250        5514 : }
     251             : 
     252        5514 : void CppuType::dumpGetCppuTypePostamble(FileStream & out) {
     253        5514 :     dec();
     254        5514 :     if (isPolymorphic()) {
     255          32 :         out << indent() << "}\n\nprivate:\n"
     256          48 :             << indent() << "UnoType(UnoType &); // not defined\n"
     257          48 :             << indent() << "~UnoType(); // not defined\n"
     258          48 :             << indent()
     259          16 :             << "void operator =(UnoType); // not defined\n};\n\n}\n\n";
     260             :     } else {
     261        5498 :         out << "}\n\n";
     262        5498 :         if (codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false)) {
     263        5482 :             out << "\n\n";
     264             :         }
     265             :     }
     266        5514 :     dumpTemplateHead(out);
     267             :     out << ("inline ::com::sun::star::uno::Type const & SAL_CALL"
     268        5514 :             " getCppuType(SAL_UNUSED_PARAMETER ");
     269        5514 :     dumpType(out, m_typeName);
     270        5514 :     dumpTemplateParameters(out);
     271        5514 :     out << " const *) SAL_THROW(()) {\n";
     272        5514 :     inc();
     273        5514 :     out << indent() << "return ::cppu::UnoType< ";
     274        5514 :     dumpType(out, m_typeName);
     275        5514 :     dumpTemplateParameters(out);
     276        5514 :     out << " >::get();\n";
     277        5514 :     dec();
     278        5514 :     out << indent() << "}\n";
     279        5514 : }
     280             : 
     281        6392 : sal_Bool CppuType::dump(CppuOptions* pOptions)
     282             :     throw( CannotDumpException )
     283             : {
     284        6392 :     if (!m_dependencies.isValid()) {
     285           0 :         return false;
     286             :     }
     287        6392 :     addSpecialDependencies();
     288             : 
     289        6392 :     if (isBootstrapType(m_typeName)) {
     290         183 :         m_cppuTypeDynamic = false;
     291             :     } else {
     292             :         // -CS was used as an undocumented option to generate static getCppuType
     293             :         // functions; since the introduction of cppu::UnoType this no longer is
     294             :         // meaningful (getCppuType is just a forward to cppu::UnoType::get now),
     295             :         // and -CS is handled the same way as -C now:
     296        6209 :         if (pOptions->isValid("-L"))
     297        2890 :             m_cppuTypeLeak = true;
     298        6209 :         if (pOptions->isValid("-C") || pOptions->isValid("-CS"))
     299        3016 :             m_cppuTypeDynamic = false;
     300             :     }
     301             : 
     302        6392 :     OString outPath;
     303        6392 :     if (pOptions->isValid("-O"))
     304        6392 :         outPath = pOptions->getOption("-O");
     305             : 
     306        6392 :     return dumpFiles(pOptions, outPath);
     307             : }
     308             : 
     309       15049 : sal_Bool CppuType::dumpFile(CppuOptions* pOptions,
     310             :                             const OString& sExtension,
     311             :                             const OString& sName,
     312             :                             const OString& sOutPath )
     313             :     throw( CannotDumpException )
     314             : {
     315       15049 :     sal_Bool ret = sal_False;
     316             : 
     317       15049 :     OString sTmpExt(".tml");
     318       15049 :     sal_Bool bHdl = sal_True;    ;
     319       15049 :     if (sExtension.equals(".hpp")) {
     320        7923 :         sTmpExt = ".tmp";
     321        7923 :         bHdl = sal_False;
     322             :     }
     323             : 
     324       15049 :     OString sFileName = createFileNameFromType(sOutPath, sName, sExtension);
     325       15049 :     if (sFileName.isEmpty())
     326           0 :         return sal_False;
     327             : 
     328       15049 :     sal_Bool bFileExists = fileExists( sFileName );
     329       15049 :     sal_Bool bFileCheck = sal_False;
     330             : 
     331       15049 :     if ( bFileExists && pOptions->isValid("-G") )
     332           0 :         return sal_True;
     333             : 
     334       15049 :     if ( bFileExists && pOptions->isValid("-Gc") )
     335           0 :         bFileCheck = sal_True;
     336             : 
     337       15049 :     OString sTmpDir = getTempDir(sFileName);
     338       15049 :     FileStream oFile;
     339       15049 :     oFile.createTempFile(sTmpDir);
     340       15049 :     OString sTmpFileName;
     341             : 
     342       15049 :     if(!oFile.isValid())
     343             :     {
     344           0 :         OString message("cannot open ");
     345           0 :         message += sFileName + " for writing";
     346           0 :         throw CannotDumpException(message);
     347             :     } else
     348       15049 :         sTmpFileName = oFile.getName();
     349             : 
     350       15049 :     codemaker::cppumaker::Includes includes(m_typeMgr, m_dependencies, !bHdl);
     351       15049 :     if (bHdl)
     352        7126 :         ret = dumpHFile(oFile, includes);
     353             :     else {
     354        7923 :         addGetCppuTypeIncludes(includes);
     355        7923 :         ret = dumpHxxFile(oFile, includes);
     356             :     }
     357             : 
     358       15049 :     oFile.close();
     359             : 
     360       15049 :     if (ret) {
     361       15049 :         ret = makeValidTypeFile(sFileName, sTmpFileName, bFileCheck);
     362             :     } else {
     363             :         // remove existing type file if something goes wrong to ensure consistency
     364           0 :         if (fileExists(sFileName))
     365           0 :             removeTypeFile(sFileName);
     366             : 
     367             :         // remove tmp file if something goes wrong
     368           0 :         removeTypeFile(sTmpFileName);
     369             :     }
     370             : 
     371       15049 :     return ret;
     372             : }
     373             : 
     374        6392 : void CppuType::dumpDependedTypes(
     375             :     codemaker::GeneratedTypeSet & generated, CppuOptions * options)
     376             : {
     377        6392 :     codemaker::Dependencies::Map const & map(m_dependencies.getMap());
     378       69330 :     for (codemaker::Dependencies::Map::const_iterator i(map.begin());
     379       46220 :          i != map.end(); ++i)
     380             :     {
     381       16718 :         if (!produceType(i->first, m_typeMgr, generated, options)) {
     382             :             fprintf(
     383             :                 stderr, "%s ERROR: cannot dump Type '%s'\n",
     384           0 :                 options->getProgramName().getStr(), i->first.getStr());
     385           0 :             exit(99);
     386             :         }
     387             :     }
     388        6392 : }
     389             : 
     390       15049 : OString CppuType::dumpHeaderDefine(
     391             :     FileStream& o, char const * prefix, sal_Bool bExtended)
     392             : {
     393       15049 :     if (m_typeName.equals("/"))
     394             :     {
     395           0 :         bExtended = sal_False;
     396           0 :         m_typeName = "global";
     397             :     }
     398             : 
     399       15049 :     sal_uInt32 length = 3 + m_typeName.getLength() + strlen(prefix);
     400             : 
     401       15049 :     if (bExtended)
     402           0 :         length += m_name.getLength() + 1;
     403             : 
     404       15049 :     OStringBuffer tmpBuf(length);
     405             : 
     406       15049 :     tmpBuf.append("INCLUDED_");
     407       15049 :     tmpBuf.append(m_typeName);
     408       15049 :     tmpBuf.append('_');
     409       15049 :     if (bExtended)
     410             :     {
     411           0 :         tmpBuf.append(m_name);
     412           0 :         tmpBuf.append('_');
     413             :     }
     414       15049 :     tmpBuf.append(prefix);
     415             : 
     416       15049 :     OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toAsciiUpperCase());
     417             : 
     418       15049 :     o << "#ifndef " << tmp << "\n#define " << tmp << "\n";
     419             : 
     420       15049 :     return tmp;
     421             : }
     422             : 
     423        7126 : void CppuType::addDefaultHIncludes(codemaker::cppumaker::Includes & includes)
     424             :     const
     425             : {
     426             :     //TODO: Only include what is really needed
     427        7126 :     includes.addCppuMacrosHxx();
     428        7126 :     if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE) {
     429        3731 :         includes.addReference();
     430             :     }
     431        7126 : }
     432             : 
     433        4760 : void CppuType::addDefaultHxxIncludes(codemaker::cppumaker::Includes & includes)
     434             :     const
     435             : {
     436             :     //TODO: Only include what is really needed
     437        4760 :     includes.addRtlInstanceHxx();
     438        4760 :     includes.addOslMutexHxx();
     439        4760 :     includes.addType();
     440        4760 :     if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE) {
     441        3731 :         includes.addReference();
     442             :     }
     443        4760 : }
     444             : 
     445        3219 : void CppuType::dumpInitializer(
     446             :     FileStream & out, bool parameterized, rtl::OUString const & type) const
     447             : {
     448        3219 :     out << "(";
     449        3219 :     if (!parameterized) {
     450          44 :         for (rtl::OString t(
     451        3200 :                  rtl::OUStringToOString(type, RTL_TEXTENCODING_UTF8));;)
     452             :         {
     453             :             sal_Int32 rank;
     454        3244 :             std::vector< rtl::OString > args;
     455        3244 :             t = codemaker::UnoType::decompose(t, &rank, &args);
     456        3244 :             if (rank == 0) {
     457        3063 :                 switch (codemaker::UnoType::getSort(t)) {
     458             :                 case codemaker::UnoType::SORT_BOOLEAN:
     459         276 :                     out << "false";
     460         276 :                     break;
     461             : 
     462             :                 case codemaker::UnoType::SORT_BYTE:
     463             :                 case codemaker::UnoType::SORT_SHORT:
     464             :                 case codemaker::UnoType::SORT_UNSIGNED_SHORT:
     465             :                 case codemaker::UnoType::SORT_LONG:
     466             :                 case codemaker::UnoType::SORT_UNSIGNED_LONG:
     467             :                 case codemaker::UnoType::SORT_HYPER:
     468             :                 case codemaker::UnoType::SORT_UNSIGNED_HYPER:
     469             :                 case codemaker::UnoType::SORT_FLOAT:
     470             :                 case codemaker::UnoType::SORT_DOUBLE:
     471             :                 case codemaker::UnoType::SORT_CHAR:
     472        1321 :                     out << "0";
     473        1321 :                     break;
     474             : 
     475             :                 case codemaker::UnoType::SORT_COMPLEX:
     476         533 :                     switch (m_typeMgr.getTypeClass(t)) {
     477             :                     case RT_TYPE_ENUM:
     478             :                         {
     479         129 :                             typereg::Reader reader(m_typeMgr.getTypeReader(t));
     480             :                             OSL_ASSERT(reader.isValid());
     481         258 :                             out << scopedCppName(t) << "_"
     482             :                                 << rtl::OUStringToOString(
     483             :                                     reader.getFieldName(0),
     484         387 :                                     RTL_TEXTENCODING_UTF8);
     485         129 :                             break;
     486             :                         }
     487             : 
     488             :                     case RT_TYPE_TYPEDEF:
     489          44 :                         t = resolveTypedefs(t);
     490          44 :                         continue;
     491             : 
     492             :                     default:
     493         360 :                         break;
     494             :                     }
     495         489 :                     break;
     496             : 
     497             :                 default:
     498         933 :                     break;
     499             :                 }
     500             :             }
     501             :             break;
     502        6444 :         }
     503             :     }
     504        3219 :     out << ")";
     505        3219 : }
     506             : 
     507        5520 : void CppuType::dumpHFileContent(
     508             :     FileStream & out, codemaker::cppumaker::Includes & includes)
     509             : {
     510        5520 :     addDefaultHIncludes(includes);
     511        5520 :     dumpHeaderDefine(out, "HDL");
     512        5520 :     out << "\n";
     513        5520 :     includes.dump(out, 0);
     514             :     out << ("\nnamespace com { namespace sun { namespace star { namespace uno"
     515        5520 :             " { class Type; } } } }\n\n");
     516        5520 :     if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false)) {
     517        5503 :         out << "\n";
     518             :     }
     519        5520 :     dumpDeclaration(out);
     520        5520 :     if (!(m_typeName.equalsL(
     521        5520 :               RTL_CONSTASCII_STRINGPARAM("com/sun/star/uno/XInterface")) ||
     522             :           m_typeName.equalsL(
     523        5517 :               RTL_CONSTASCII_STRINGPARAM("com/sun/star/uno/Exception")) ||
     524       11037 :           isPolymorphic()))
     525             :     {
     526       10996 :         out << "\n" << indent()
     527             :             << ("inline ::com::sun::star::uno::Type const &"
     528        5498 :                 " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ");
     529        5498 :         dumpType(out, m_typeName, false, false, true);
     530        5498 :         out << " const *);\n";
     531             :     }
     532        5520 :     if (codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false)) {
     533        5503 :         out << "\n";
     534             :     }
     535        5520 :     out << "\n";
     536        5520 :     dumpTemplateHead(out);
     537        5520 :     out << "inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType(";
     538        5520 :     dumpType(out, m_typeName, true);
     539        5520 :     dumpTemplateParameters(out);
     540        5520 :     out << " *) SAL_THROW(());\n\n#endif\n";
     541        5520 : }
     542             : 
     543        5520 : void CppuType::dumpGetCppuType(FileStream & out) {
     544        5520 :     if (m_typeName.equals("com/sun/star/uno/XInterface")) {
     545           6 :         out << indent()
     546             :             << ("inline ::com::sun::star::uno::Type const & SAL_CALL"
     547           3 :                 " getCppuType(SAL_UNUSED_PARAMETER ");
     548           3 :         dumpType(out, m_typeName, true, false);
     549           3 :         out << " *) SAL_THROW(()) {\n";
     550           3 :         inc();
     551           6 :         out << indent()
     552             :             << ("return ::cppu::UnoType< ::com::sun::star::uno::XInterface"
     553           3 :                 " >::get();\n");
     554           3 :         dec();
     555           3 :         out << indent() << "}\n";
     556        5517 :     } else if (m_typeName.equals("com/sun/star/uno/Exception")) {
     557           6 :         out << indent()
     558             :             << ("inline ::com::sun::star::uno::Type const & SAL_CALL"
     559           3 :                 " getCppuType(SAL_UNUSED_PARAMETER ");
     560           3 :         dumpType(out, m_typeName, true, false);
     561           3 :         out << " *) SAL_THROW(()) {\n";
     562           3 :         inc();
     563           6 :         out << indent()
     564             :             << ("return ::cppu::UnoType< ::com::sun::star::uno::Exception"
     565           3 :                 " >::get();\n");
     566           3 :         dec();
     567           3 :         out << indent() << "}\n";
     568        5514 :     } else if (m_cppuTypeLeak) {
     569        2628 :         dumpLightGetCppuType(out);
     570        2886 :     } else if (m_cppuTypeDynamic) {
     571         273 :         dumpNormalGetCppuType(out);
     572             :     } else {
     573        2613 :         dumpComprehensiveGetCppuType(out);
     574             :     }
     575        5520 : }
     576             : 
     577        2231 : void CppuType::dumpLightGetCppuType(FileStream& o)
     578             : {
     579        2231 :     dumpGetCppuTypePreamble(o);
     580        4462 :     o << indent()
     581        2231 :       << "static typelib_TypeDescriptionReference * the_type = 0;\n";
     582             : 
     583        2231 :     o << indent() << "if ( !the_type )\n" << indent() << "{\n";
     584        2231 :     inc();
     585        4462 :     o << indent() << "typelib_static_type_init( &the_type, "
     586        6693 :       << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\" );\n";
     587        2231 :     dec();
     588        2231 :     o << indent() << "}\n";
     589        4462 :     o << indent()
     590             :       << ("return * reinterpret_cast< ::com::sun::star::uno::Type * >("
     591        2231 :           " &the_type );\n");
     592        2231 :     dumpGetCppuTypePostamble(o);
     593        2231 : }
     594             : 
     595          58 : void CppuType::dumpNormalGetCppuType(FileStream& o)
     596             : {
     597          58 :     dumpGetCppuTypePreamble(o);
     598             : 
     599         116 :     o << indent()
     600          58 :       << "static typelib_TypeDescriptionReference * the_type = 0;\n";
     601             : 
     602          58 :     o << indent() << "if ( !the_type )\n" << indent() << "{\n";
     603          58 :     inc();
     604             : 
     605          58 :     OString superType;
     606          58 :     if (m_reader.getSuperTypeCount() >= 1) {
     607             :         superType = rtl::OUStringToOString(
     608          58 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
     609             :     }
     610          58 :     sal_Bool bIsBaseException = sal_False;
     611          58 :     if (!superType.isEmpty())
     612             :     {
     613          58 :         if ( superType.equals("com/sun/star/uno/Exception") )
     614             :         {
     615          35 :             bIsBaseException = sal_True;
     616             :         } else
     617             :         {
     618          23 :             o << indent() << "const ::com::sun::star::uno::Type& rBaseType = ::cppu::UnoType< ";
     619          23 :             dumpType(o, superType, true, false, false, true);
     620          23 :             o << " >::get();\n\n";
     621             :         }
     622             :     }
     623             : 
     624          58 :     sal_uInt32 count = getMemberCount();
     625          58 :     if (count)
     626             :     {
     627           9 :         o << indent() << "typelib_TypeDescriptionReference * aMemberRefs[" << count << "];\n";
     628             : 
     629           9 :         sal_uInt16      fieldCount = m_reader.getFieldCount();
     630           9 :         RTFieldAccess   access = RT_ACCESS_INVALID;
     631           9 :         OString         fieldType, fieldName;
     632           9 :         OString         scope = m_typeName.replace('/', '.');
     633           9 :         OString         modFieldType;
     634           9 :         StringSet       generatedTypeSet;
     635           9 :         StringSet::iterator findIter;
     636             : 
     637          24 :         for (sal_uInt16 i=0; i < fieldCount; i++)
     638             :         {
     639          15 :             access = m_reader.getFieldFlags(i);
     640             : 
     641          15 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
     642           0 :                 continue;
     643             : 
     644             :             fieldName = rtl::OUStringToOString(
     645          15 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
     646             :             fieldType = checkRealBaseType(
     647             :                 rtl::OUStringToOString(
     648             :                     m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8),
     649          15 :                 sal_True);
     650             : 
     651          15 :             modFieldType = typeToIdentifier(fieldType);
     652             : 
     653          15 :             findIter = generatedTypeSet.find(fieldType);
     654          15 :             if ( findIter == generatedTypeSet.end() )
     655             :             {
     656          12 :                 generatedTypeSet.insert(fieldType);
     657          24 :                  o << indent() << "const ::com::sun::star::uno::Type& rMemberType_"
     658          12 :                   << modFieldType/*i*/ << " = ::cppu::UnoType< ";
     659          12 :                 dumpType(o, fieldType, false, false, false, true);
     660          12 :                 o << " >::get();\n";
     661             :             }
     662             : 
     663          30 :             o << indent() << "aMemberRefs[" << i << "] = rMemberType_"
     664          15 :               << modFieldType/*i*/ << ".getTypeLibType();\n";
     665             :         }
     666           9 :         o << "\n";
     667             :     }
     668             : 
     669         116 :     o << indent() << "typelib_static_compound_type_init( &the_type, "
     670         174 :       << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\", ";
     671          58 :     if ( !superType.isEmpty() || bIsBaseException )
     672             :     {
     673          58 :         if ( bIsBaseException )
     674             :         {
     675          35 :             o << "* ::typelib_static_type_getByTypeClass( typelib_TypeClass_EXCEPTION ), "
     676          35 :               << count << ", ";
     677             :         } else
     678             :         {
     679          23 :             o << "rBaseType.getTypeLibType(), " << count << ", ";
     680             :         }
     681             :     } else
     682             :     {
     683           0 :         o << "0, " << count << ", ";
     684             :     }
     685             : 
     686          58 :     if (count)
     687             :     {
     688           9 :         o << " aMemberRefs );\n";
     689             :     } else
     690             :     {
     691          49 :         o << " 0 );\n";
     692             :     }
     693          58 :     dec();
     694          58 :     o << indent() << "}\n";
     695         116 :     o << indent()
     696             :       << ("return * reinterpret_cast< const ::com::sun::star::uno::Type * >("
     697          58 :           " &the_type );\n");
     698             : 
     699          58 :     dumpGetCppuTypePostamble(o);
     700          58 : }
     701             : 
     702         258 : void CppuType::dumpComprehensiveGetCppuType(FileStream& o)
     703             : {
     704         258 :     if (!isPolymorphic())
     705         258 :         codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false);
     706             :     else
     707           0 :         o << "namespace cppu { ";
     708         258 :     o << " namespace detail {\n\n";
     709             : 
     710         258 :     OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
     711         258 :     OString sStaticTypeClass = "the" + sType + "Type";
     712         258 :     o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type *, " << sStaticTypeClass << " >\n";
     713         258 :     o << indent() << "{\n";
     714         258 :     inc();
     715         258 :     o << indent() << "::com::sun::star::uno::Type * operator()() const\n";
     716         258 :     o << indent() << "{\n";
     717         258 :     inc();
     718             : 
     719         516 :     o << indent() << "::rtl::OUString sTypeName( \""
     720         774 :       << m_typeName.replace('/', '.') << "\" );\n\n";
     721             : 
     722         516 :     o << indent() << "// Start inline typedescription generation\n"
     723         774 :       << indent() << "typelib_TypeDescription * pTD = 0;\n";
     724             : 
     725         258 :     OString superType;
     726         258 :     if (m_reader.getSuperTypeCount() >= 1) {
     727             :         superType = rtl::OUStringToOString(
     728         258 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
     729             :     }
     730         258 :     if (!superType.isEmpty()) {
     731         516 :         o << indent()
     732         258 :           << "const ::com::sun::star::uno::Type& rSuperType = ::cppu::UnoType< ";
     733         258 :         dumpType(o, superType, false, false, false, true);
     734         258 :         o << " >::get();\n";
     735             :     }
     736             : 
     737         258 :     dumpCppuGetTypeMemberDecl(o, CPPUTYPEDECL_ALLTYPES);
     738             : 
     739         258 :     sal_uInt32 count = getMemberCount();
     740         258 :     if (count)
     741             :     {
     742         200 :         o << "\n" << indent() << "typelib_CompoundMember_Init aMembers["
     743         100 :           << count << "];\n";
     744             : 
     745         100 :         sal_uInt16      fieldCount = m_reader.getFieldCount();
     746         100 :         RTFieldAccess   access = RT_ACCESS_INVALID;
     747         100 :         OString         fieldType, fieldName;
     748         100 :         OString         scope = m_typeName.replace('/', '.');
     749         260 :         for (sal_uInt16 i=0; i < fieldCount; i++)
     750             :         {
     751         160 :             access = m_reader.getFieldFlags(i);
     752             : 
     753         160 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) {
     754           0 :                 continue;
     755             :             }
     756             : 
     757             :             fieldName = rtl::OUStringToOString(
     758         160 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
     759             :             fieldType = checkRealBaseType(
     760             :                 rtl::OUStringToOString(
     761             :                     m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8),
     762         160 :                 sal_True);
     763             : 
     764         320 :             o << indent() << "::rtl::OUString sMemberType" << i
     765         160 :               << "( \""
     766         480 :               << fieldType.replace('/', '.') << "\" );\n";
     767         320 :             o << indent() << "::rtl::OUString sMemberName" << i
     768         160 :               << "( \"";
     769         160 :             o << fieldName << "\" );\n";
     770         320 :             o << indent() << "aMembers[" << i << "].eTypeClass = "
     771         480 :               << "(typelib_TypeClass)" << getTypeClass(fieldType) << ";\n"
     772         480 :               << indent() << "aMembers[" << i << "].pTypeName = sMemberType"
     773         320 :               << i << ".pData;\n"
     774         480 :               << indent() << "aMembers[" << i << "].pMemberName = sMemberName"
     775         320 :               << i << ".pData;\n";
     776         100 :         }
     777             :     }
     778             : 
     779         258 :     o << "\n" << indent() << "typelib_typedescription_new(\n";
     780         258 :     inc();
     781         516 :     o << indent() << "&pTD,\n" << indent() << "(typelib_TypeClass)"
     782         774 :       << getTypeClass() << ", sTypeName.pData,\n";
     783             : 
     784         258 :     if (!superType.isEmpty()) {
     785         258 :         o << indent() << "rSuperType.getTypeLibType(),\n";
     786             :     } else {
     787           0 :         o << indent() << "0,\n";
     788             :     }
     789             : 
     790         258 :     if ( count ) {
     791         100 :         o << indent() << count << ",\n" << indent() << "aMembers );\n\n";
     792             :     } else {
     793         158 :         o << indent() << count << ",\n" << indent() << "0 );\n\n";
     794             :     }
     795         258 :     dec();
     796             : 
     797         516 :     o << indent()
     798             :       << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
     799         258 :           " );\n\n");
     800             : 
     801         516 :     o << indent() << "typelib_typedescription_release( pTD );\n"
     802         774 :       << indent() << "// End inline typedescription generation\n\n";
     803             : 
     804         516 :     o << indent() << "return new ::com::sun::star::uno::Type( "
     805         774 :       << getTypeClass(m_typeName) << ", sTypeName ); // leaked\n";
     806             : 
     807         258 :     dec();
     808         258 :     o << indent() << "}\n";
     809         258 :     dec();
     810         258 :     o << indent() << "};\n\n";
     811             : 
     812         258 :     if (!isPolymorphic())
     813         258 :         codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
     814             :     else
     815           0 :         o << " }";
     816             : 
     817         258 :     o << " }\n\n";
     818             : 
     819         258 :     dumpGetCppuTypePreamble(o);
     820         258 :     o  << indent() << "return *detail::" << sStaticTypeClass << "::get();\n";
     821         258 :     dumpGetCppuTypePostamble(o);
     822         258 : }
     823             : 
     824         258 : void CppuType::dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag)
     825             : {
     826         258 :     sal_uInt16      fieldCount = m_reader.getFieldCount();
     827         258 :     RTFieldAccess   access = RT_ACCESS_INVALID;
     828             : 
     829         258 :     StringSet aFinishedTypes;
     830         418 :     for (sal_uInt16 i=0; i < fieldCount; i++)
     831             :     {
     832         160 :         access = m_reader.getFieldFlags(i);
     833             : 
     834         160 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID
     835             :             || (access & RT_ACCESS_PARAMETERIZED_TYPE) != 0)
     836           0 :             continue;
     837             : 
     838             :         rtl::OString typeName(
     839             :             rtl::OUStringToOString(
     840         160 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
     841         160 :         if (aFinishedTypes.count(typeName) == 0)
     842             :         {
     843         126 :             aFinishedTypes.insert(typeName);
     844         126 :             dumpCppuGetType(o, typeName, sal_True, eDeclFlag);
     845             :         }
     846         418 :     }
     847         258 : }
     848             : 
     849         797 : IdentifierTranslationMode CppuType::isGlobal() const {
     850         797 :     if ( m_typeName.indexOf('/') < 0 )
     851           4 :         return ITM_GLOBAL;
     852             :     else
     853         793 :         return ITM_NONGLOBAL;
     854             : }
     855             : 
     856         316 : sal_uInt32 CppuType::getMemberCount()
     857             : {
     858         316 :     sal_uInt16 count = m_reader.getMethodCount();
     859             : 
     860         316 :     sal_uInt16 fieldCount = m_reader.getFieldCount();
     861         316 :     RTFieldAccess access = RT_ACCESS_INVALID;
     862         491 :     for (sal_uInt16 i=0; i < fieldCount; i++)
     863             :     {
     864         175 :         access = m_reader.getFieldFlags(i);
     865             : 
     866         175 :         if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
     867         175 :             count++;
     868             :     }
     869         316 :     return count;
     870             : }
     871             : 
     872         950 : sal_uInt32 CppuType::checkInheritedMemberCount(const typereg::Reader* pReader)
     873             : {
     874         950 :     sal_Bool bSelfCheck = sal_True;
     875         950 :     if (!pReader)
     876             :     {
     877         352 :         bSelfCheck = sal_False;
     878         352 :         pReader = &m_reader;
     879             :     }
     880             : 
     881         950 :     sal_uInt32 count = 0;
     882         950 :     OString superType;
     883         950 :     if (pReader->getSuperTypeCount() >= 1) {
     884             :         superType = rtl::OUStringToOString(
     885         598 :             pReader->getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
     886             :     }
     887         950 :     if (!superType.isEmpty())
     888             :     {
     889         598 :         typereg::Reader aSuperReader(m_typeMgr.getTypeReader(superType));
     890         598 :         if ( aSuperReader.isValid() )
     891             :         {
     892         598 :             count = checkInheritedMemberCount(&aSuperReader);
     893         598 :         }
     894             :     }
     895             : 
     896         950 :     if (bSelfCheck)
     897             :     {
     898         598 :         count += pReader->getMethodCount();
     899         598 :         sal_uInt16 fieldCount = pReader->getFieldCount();
     900         598 :         RTFieldAccess access = RT_ACCESS_INVALID;
     901        1366 :         for (sal_uInt16 i=0; i < fieldCount; i++)
     902             :         {
     903         768 :             access = pReader->getFieldFlags(i);
     904             : 
     905         768 :             if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
     906             :             {
     907         768 :                 count++;
     908             :             }
     909             :         }
     910             :     }
     911             : 
     912         950 :     return count;
     913             : }
     914             : 
     915         704 : sal_uInt32 CppuType::getInheritedMemberCount()
     916             : {
     917         704 :     if (m_inheritedMemberCount == 0)
     918             :     {
     919         352 :         m_inheritedMemberCount = checkInheritedMemberCount(0);
     920             :     }
     921             : 
     922         704 :     return m_inheritedMemberCount;
     923             : }
     924             : 
     925       19815 : OString CppuType::getTypeClass(const OString& type, sal_Bool bCStyle)
     926             : {
     927       19815 :     OString     typeName = (!type.isEmpty() ? type : m_typeName);
     928       19815 :     RTTypeClass rtTypeClass = RT_TYPE_INVALID;
     929             : 
     930       19815 :     if (!type.isEmpty())
     931             :     {
     932       19557 :         typeName = type;
     933       19557 :         rtTypeClass = m_typeMgr.getTypeClass(typeName);
     934             :     } else
     935             :     {
     936         258 :         typeName = m_typeName;
     937         258 :         rtTypeClass = m_reader.getTypeClass();
     938             :     }
     939             : 
     940       19815 :     if (codemaker::UnoType::isSequenceType(typeName))
     941        1147 :         return bCStyle ? "typelib_TypeClass_SEQUENCE" : "::com::sun::star::uno::TypeClass_SEQUENCE";
     942             : 
     943       18668 :     switch (rtTypeClass)
     944             :     {
     945             :         case RT_TYPE_INTERFACE:
     946        6027 :             return bCStyle ? "typelib_TypeClass_INTERFACE" : "::com::sun::star::uno::TypeClass_INTERFACE";
     947             :         case RT_TYPE_MODULE:
     948           0 :             return bCStyle ? "typelib_TypeClass_MODULE" : "::com::sun::star::uno::TypeClass_MODULE";
     949             :         case RT_TYPE_STRUCT:
     950        1817 :             return bCStyle ? "typelib_TypeClass_STRUCT" : "::com::sun::star::uno::TypeClass_STRUCT";
     951             :         case RT_TYPE_ENUM:
     952         570 :             return bCStyle ? "typelib_TypeClass_ENUM" : "::com::sun::star::uno::TypeClass_ENUM";
     953             :         case RT_TYPE_EXCEPTION:
     954         812 :             return bCStyle ? "typelib_TypeClass_EXCEPTION" : "::com::sun::star::uno::TypeClass_EXCEPTION";
     955             :         case RT_TYPE_TYPEDEF:
     956             :             {
     957          23 :                 OString realType = checkRealBaseType( typeName );
     958          23 :                 return getTypeClass( realType, bCStyle );
     959             :             }
     960             :         case RT_TYPE_SERVICE:
     961           0 :             return bCStyle ? "typelib_TypeClass_SERVICE" : "::com::sun::star::uno::TypeClass_SERVICE";
     962             :         case RT_TYPE_INVALID:
     963             :             {
     964        9419 :                 if (type.equals("long"))
     965        1736 :                     return bCStyle ? "typelib_TypeClass_LONG" : "::com::sun::star::uno::TypeClass_LONG";
     966        7683 :                 if (type.equals("short"))
     967         533 :                     return bCStyle ? "typelib_TypeClass_SHORT" : "::com::sun::star::uno::TypeClass_SHORT";
     968        7150 :                 if (type.equals("hyper"))
     969          58 :                     return bCStyle ? "typelib_TypeClass_HYPER" : "::com::sun::star::uno::TypeClass_HYPER";
     970        7092 :                 if (type.equals("string"))
     971        2447 :                     return bCStyle ? "typelib_TypeClass_STRING" : "::com::sun::star::uno::TypeClass_STRING";
     972        4645 :                 if (type.equals("boolean"))
     973        1213 :                     return bCStyle ? "typelib_TypeClass_BOOLEAN" : "::com::sun::star::uno::TypeClass_BOOLEAN";
     974        3432 :                 if (type.equals("char"))
     975          19 :                     return bCStyle ? "typelib_TypeClass_CHAR" : "::com::sun::star::uno::TypeClass_CHAR";
     976        3413 :                 if (type.equals("byte"))
     977          68 :                     return bCStyle ? "typelib_TypeClass_BYTE" : "::com::sun::star::uno::TypeClass_BYTE";
     978        3345 :                 if (type.equals("any"))
     979         442 :                     return bCStyle ? "typelib_TypeClass_ANY" : "::com::sun::star::uno::TypeClass_ANY";
     980        2903 :                 if (type.equals("type"))
     981          34 :                     return bCStyle ? "typelib_TypeClass_TYPE" : "::com::sun::star::uno::TypeClass_TYPE";
     982        2869 :                 if (type.equals("float"))
     983          24 :                     return bCStyle ? "typelib_TypeClass_FLOAT" : "::com::sun::star::uno::TypeClass_FLOAT";
     984        2845 :                 if (type.equals("double"))
     985         373 :                     return bCStyle ? "typelib_TypeClass_DOUBLE" : "::com::sun::star::uno::TypeClass_DOUBLE";
     986        2472 :                 if (type.equals("void"))
     987        2386 :                     return bCStyle ? "typelib_TypeClass_VOID" : "::com::sun::star::uno::TypeClass_VOID";
     988          86 :                 if (type.equals("unsigned long"))
     989          28 :                     return bCStyle ? "typelib_TypeClass_UNSIGNED_LONG" : "::com::sun::star::uno::TypeClass_UNSIGNED_LONG";
     990          58 :                 if (type.equals("unsigned short"))
     991          41 :                     return bCStyle ? "typelib_TypeClass_UNSIGNED_SHORT" : "::com::sun::star::uno::TypeClass_UNSIGNED_SHORT";
     992          17 :                 if (type.equals("unsigned hyper"))
     993           1 :                     return bCStyle ? "typelib_TypeClass_UNSIGNED_HYPER" : "::com::sun::star::uno::TypeClass_UNSIGNED_HYPER";
     994             :             }
     995          16 :             break;
     996             :         default:
     997             :             OSL_ASSERT(false);
     998           0 :             break;
     999             :     }
    1000             : 
    1001          16 :     return bCStyle ? "typelib_TypeClass_UNKNOWN" : "::com::sun::star::uno::TypeClass_UNKNOWN";
    1002             : }
    1003             : 
    1004       97300 : void CppuType::dumpType(FileStream& o, const OString& type,
    1005             :                         bool bConst, bool bRef, bool bNative, bool cppuUnoType)
    1006             :     const throw( CannotDumpException )
    1007             : {
    1008             :     sal_Int32 seqNum;
    1009       97300 :     std::vector< rtl::OString > args;
    1010             :     rtl::OString relType(
    1011             :         codemaker::UnoType::decompose(
    1012       97300 :             checkRealBaseType(type, true), &seqNum, &args));
    1013             : 
    1014       97300 :     RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
    1015             : 
    1016       97300 :     if (bConst) o << "const ";
    1017             : 
    1018      101242 :     {for (sal_Int32 i = 0; i < seqNum; ++i) {
    1019        3942 :         if (cppuUnoType)
    1020         820 :             o << "::cppu::UnoSequenceType< ";
    1021             :         else
    1022        3122 :             o << "::com::sun::star::uno::Sequence< ";
    1023             :     }}
    1024             : 
    1025       97300 :     switch (typeClass)
    1026             :     {
    1027             :         case RT_TYPE_INTERFACE:
    1028       33335 :             if (bNative)
    1029        7456 :                 o << scopedCppName(relType);
    1030             :             else
    1031       25879 :                 o << "::com::sun::star::uno::Reference< "
    1032       51758 :                   << scopedCppName(relType) << " >";
    1033       33335 :             break;
    1034             :         case RT_TYPE_INVALID:
    1035             :             {
    1036       45618 :                 OString tmp(translateSimpleUnoType(relType, cppuUnoType));
    1037       45618 :                 if (!tmp.isEmpty())
    1038             :                 {
    1039       45618 :                     o << tmp;
    1040             :                 } else
    1041             :                     throw CannotDumpException("Unknown type '" + relType +
    1042           0 :                                               "', incomplete type library.");
    1043             :             }
    1044       45618 :             break;
    1045             :         case RT_TYPE_STRUCT:
    1046             :         case RT_TYPE_ENUM:
    1047             :         case RT_TYPE_TYPEDEF:
    1048             :         case RT_TYPE_EXCEPTION:
    1049             :             {
    1050       18347 :                 o << scopedCppName(relType);
    1051       18347 :                 if (!args.empty()) {
    1052         172 :                     o << "< ";
    1053        1218 :                     for (std::vector< rtl::OString >::iterator i(args.begin());
    1054         812 :                          i != args.end(); ++i)
    1055             :                     {
    1056         234 :                         if (i != args.begin()) {
    1057          62 :                             o << ", ";
    1058             :                         }
    1059         234 :                         dumpType(o, *i);
    1060             :                     }
    1061         172 :                     o << " >";
    1062             :                 }
    1063       18347 :                 break;
    1064             :             }
    1065             :         default:
    1066             :             OSL_ASSERT(false);
    1067           0 :             break;
    1068             :     }
    1069             : 
    1070      101242 :     {for (sal_Int32 i = 0; i < seqNum; ++i) {
    1071        3942 :         o << " >";
    1072             :     }}
    1073             : 
    1074       97300 :     if (bRef) o << "&";
    1075       97300 : }
    1076             : 
    1077        9080 : void CppuType::dumpCppuGetType(FileStream& o, const OString& type, sal_Bool bDecl, CppuTypeDecl eDeclFlag)
    1078             : {
    1079             :     rtl::OString relType(
    1080        9080 :         codemaker::UnoType::decompose(checkRealBaseType(type, true)));
    1081             : 
    1082        9080 :     if (eDeclFlag == CPPUTYPEDECL_ONLYINTERFACES)
    1083             :     {
    1084           0 :          if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE)
    1085             :         {
    1086           0 :             o << indent() << "::cppu::UnoType< ";
    1087           0 :             dumpType(o, type, false, false, false, true);
    1088           0 :             o << " >::get()";
    1089             : 
    1090           0 :             if (bDecl)
    1091           0 :                 o << ";\n";
    1092             :         }
    1093             :     } else
    1094             :     {
    1095        9080 :         if (codemaker::UnoType::getSort(type)
    1096             :             != codemaker::UnoType::SORT_COMPLEX)
    1097             :         {
    1098             :             return;
    1099             :         } else
    1100             :         {
    1101        6132 :             if (eDeclFlag == CPPUTYPEDECL_NOINTERFACES &&
    1102           0 :                 m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE)
    1103             :                 return;
    1104             : 
    1105        6132 :             o << indent() << "::cppu::UnoType< ";
    1106        6132 :             dumpType(o, type, false, false, false, true);
    1107        6132 :             o << " >::get()";
    1108             :         }
    1109        6132 :         if (bDecl)
    1110        6132 :             o << ";\n";
    1111        9080 :     }
    1112             : }
    1113             : 
    1114          15 : OString CppuType::typeToIdentifier(const OString& type)
    1115             : {
    1116             :     sal_Int32 seqNum;
    1117          15 :     rtl::OString relType(codemaker::UnoType::decompose(type, &seqNum));
    1118          15 :     OString sIdentifier;
    1119             : 
    1120          30 :     while( seqNum > 0 )
    1121             :     {
    1122           0 :         sIdentifier += OString("seq");
    1123             : 
    1124           0 :         if ( --seqNum == 0 )
    1125             :         {
    1126           0 :             sIdentifier += OString("_");
    1127             :         }
    1128             :     }
    1129             : 
    1130             :     sIdentifier += relType.replace(
    1131          15 :         ((codemaker::UnoType::getSort(relType)
    1132             :           == codemaker::UnoType::SORT_COMPLEX)
    1133             :          ? '/' : ' '),
    1134          15 :         '_');
    1135             : 
    1136             :     // TODO: find better solution to create an identifier
    1137          15 :     sIdentifier = sIdentifier.replace('<', '_');
    1138          15 :     sIdentifier = sIdentifier.replace('>', '_');
    1139          15 :     sIdentifier = sIdentifier.replace(',', '_');
    1140             : 
    1141          15 :     return sIdentifier;
    1142             : }
    1143             : 
    1144       14582 : bool CppuType::passByReference(rtl::OString const & unoType) {
    1145       14582 :     rtl::OString type(resolveTypedefs(unoType));
    1146       14582 :     switch (codemaker::UnoType::getSort(type)) {
    1147             :     default:
    1148        4573 :         return false;
    1149             : 
    1150             :     case codemaker::UnoType::SORT_STRING:
    1151             :     case codemaker::UnoType::SORT_TYPE:
    1152             :     case codemaker::UnoType::SORT_ANY:
    1153        4485 :         return true;
    1154             : 
    1155             :     case codemaker::UnoType::SORT_COMPLEX:
    1156        5524 :         return m_typeMgr.getTypeClass(type) != RT_TYPE_ENUM;
    1157       14582 :     }
    1158             : }
    1159             : 
    1160       14626 : OString CppuType::resolveTypedefs(const OString& type) const
    1161             : {
    1162       14626 :     OString baseType(type);
    1163             : 
    1164       14626 :     RegistryKey     key;
    1165             :     RTTypeClass     typeClass;
    1166       14626 :     sal_Bool        isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
    1167       14626 :     typereg::Reader reader;
    1168             : 
    1169       14626 :     while (isTypeDef)
    1170             :     {
    1171         471 :         reader = m_typeMgr.getTypeReader(baseType);
    1172             : 
    1173         471 :         if (reader.isValid())
    1174             :         {
    1175         242 :             typeClass = reader.getTypeClass();
    1176             : 
    1177         242 :             if (typeClass == RT_TYPE_TYPEDEF)
    1178             :                 baseType = rtl::OUStringToOString(
    1179         236 :                     reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    1180             :             else
    1181           6 :                 isTypeDef = sal_False;
    1182             :         } else
    1183             :         {
    1184         229 :             break;
    1185             :         }
    1186             :     }
    1187             : 
    1188       14626 :     return baseType;
    1189             : }
    1190             : 
    1191      120095 : OString CppuType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOnly) const
    1192             : {
    1193             :     sal_Int32 rank;
    1194      120095 :     rtl::OString baseType(codemaker::UnoType::decompose(type, &rank));
    1195             : 
    1196      120095 :     RegistryKey     key;
    1197             :     RTTypeClass     typeClass;
    1198      120095 :     sal_Bool        mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
    1199      120095 :     typereg::Reader reader;
    1200             : 
    1201      120095 :     while (mustBeChecked)
    1202             :     {
    1203        1362 :         reader = m_typeMgr.getTypeReader(baseType);
    1204             : 
    1205        1362 :         if (reader.isValid())
    1206             :         {
    1207         850 :             typeClass = reader.getTypeClass();
    1208             : 
    1209         850 :             if (typeClass == RT_TYPE_TYPEDEF)
    1210             :             {
    1211             :                 sal_Int32 n;
    1212             :                 baseType = codemaker::UnoType::decompose(
    1213             :                     rtl::OUStringToOString(
    1214             :                         reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8),
    1215         684 :                     &n);
    1216             :                 OSL_ASSERT(n <= SAL_MAX_INT32 - rank); //TODO
    1217         684 :                 rank += n;
    1218             :             } else
    1219         166 :                 mustBeChecked = sal_False;
    1220             :         } else
    1221             :         {
    1222         512 :             break;
    1223             :         }
    1224             :     }
    1225             : 
    1226      120095 :     if (bResolveTypeOnly) {
    1227      120072 :         rtl::OStringBuffer buf;
    1228      125970 :         for (sal_Int32 i = 0; i < rank; ++i) {
    1229        5898 :             buf.append(RTL_CONSTASCII_STRINGPARAM("[]"));
    1230             :         }
    1231      120072 :         baseType = buf.makeStringAndClear() + baseType;
    1232             :     }
    1233             : 
    1234      120095 :     return baseType;
    1235             : }
    1236             : 
    1237       15008 : void CppuType::dumpConstantValue(FileStream& o, sal_uInt16 index)
    1238             : {
    1239       15008 :     RTConstValue constValue = m_reader.getFieldValue(index);
    1240             : 
    1241       15008 :     switch (constValue.m_type)
    1242             :     {
    1243             :         case RT_TYPE_NONE:
    1244           0 :             break;
    1245             :         case RT_TYPE_BOOL:
    1246           0 :             if (constValue.m_value.aBool)
    1247           0 :                 o << "sal_True";
    1248             :             else
    1249           0 :                 o << "sal_False";
    1250           0 :             break;
    1251             :         case RT_TYPE_BYTE:
    1252         493 :             o << "(sal_Int8)" << constValue.m_value.aByte;
    1253         493 :             break;
    1254             :         case RT_TYPE_INT16:
    1255        4112 :             o << "(sal_Int16)" << constValue.m_value.aShort;
    1256        4112 :             break;
    1257             :         case RT_TYPE_UINT16:
    1258           2 :             o << "(sal_uInt16)" << constValue.m_value.aUShort;
    1259           2 :             break;
    1260             :         case RT_TYPE_INT32:
    1261             :             // Avoid C++ compiler warnings about (un)signedness of literal
    1262             :             // -2^31:
    1263       10297 :             if (constValue.m_value.aLong == SAL_MIN_INT32) {
    1264           9 :                 o << "SAL_MIN_INT32";
    1265             :             } else {
    1266       10288 :                 o << "(sal_Int32)" << constValue.m_value.aLong;
    1267             :             }
    1268       10297 :             break;
    1269             :         case RT_TYPE_UINT32:
    1270           2 :             o << "(sal_uInt32)"
    1271             :               << OString::valueOf(
    1272           6 :                   static_cast< sal_Int64 >(constValue.m_value.aULong)).getStr()
    1273           2 :               << "U";
    1274           2 :             break;
    1275             :         case RT_TYPE_INT64:
    1276             :             // Avoid C++ compiler warnings about (un)signedness of literal
    1277             :             // -2^63:
    1278          60 :             if (constValue.m_value.aHyper == SAL_MIN_INT64) {
    1279           1 :                 o << "SAL_MIN_INT64";
    1280             :             } else {
    1281          59 :                 ::rtl::OString tmp(OString::valueOf(constValue.m_value.aHyper));
    1282          59 :                 o << "(sal_Int64) SAL_CONST_INT64(" << tmp.getStr() << ")";
    1283             :             }
    1284          60 :             break;
    1285             :         case RT_TYPE_UINT64:
    1286             :             {
    1287           2 :                 o << "SAL_CONST_UINT64(";
    1288           2 :                 sal_uInt64 n = constValue.m_value.aUHyper;
    1289           2 :                 if (n == 0) {
    1290           1 :                     o << "0";
    1291             :                 } else {
    1292           1 :                     std::vector< char > buf;
    1293          21 :                     for (; n != 0; n /= 10) {
    1294          20 :                         buf.push_back('0' + static_cast< char >(n % 10));
    1295             :                     }
    1296          63 :                     for (std::vector< char >::reverse_iterator i(buf.rbegin());
    1297          42 :                          i != buf.rend(); ++i)
    1298             :                     {
    1299          20 :                         o << rtl::OString::valueOf(*i).getStr();
    1300           1 :                     }
    1301             :                 }
    1302           2 :                 o << ")";
    1303             :             }
    1304           2 :             break;
    1305             :         case RT_TYPE_FLOAT:
    1306             :             {
    1307          40 :                 ::rtl::OString tmp( OString::valueOf(constValue.m_value.aFloat) );
    1308          40 :                 o << "(float)" << tmp.getStr();
    1309             :             }
    1310          40 :             break;
    1311             :         case RT_TYPE_DOUBLE:
    1312             :             {
    1313           0 :                 ::rtl::OString tmp( OString::valueOf(constValue.m_value.aDouble) );
    1314           0 :                 o << "(double)" << tmp.getStr();
    1315             :             }
    1316           0 :             break;
    1317             :         case RT_TYPE_STRING:
    1318             :             {
    1319           0 :                 ::rtl::OUString aUStr(constValue.m_value.aString);
    1320           0 :                 ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US);
    1321           0 :                 o << "::rtl::OUString( \"" << aStr.getStr() << "\" )";
    1322             :             }
    1323           0 :             break;
    1324       15008 :     }
    1325       15008 : }
    1326             : 
    1327       67858 : void CppuType::inc(sal_Int32 num)
    1328             : {
    1329       67858 :     m_indentLength += num;
    1330       67858 : }
    1331             : 
    1332       67842 : void CppuType::dec(sal_Int32 num)
    1333             : {
    1334       67842 :     m_indentLength = std::max< sal_Int32 >(m_indentLength - num, 0);
    1335       67842 : }
    1336             : 
    1337      370315 : OString CppuType::indent() const
    1338             : {
    1339      370315 :     OStringBuffer tmp(m_indentLength);
    1340             : 
    1341     4478091 :     for (sal_Int32 i=0; i < m_indentLength; i++)
    1342             :     {
    1343     4107776 :         tmp.append(' ');
    1344             :     }
    1345      370315 :     return tmp.makeStringAndClear();
    1346             : }
    1347             : 
    1348             : //*************************************************************************
    1349             : // InterfaceType
    1350             : //*************************************************************************
    1351             : 
    1352             : namespace {
    1353             : 
    1354       17064 : bool isDocumentedDeprecated(OUString const & documentation) {
    1355       17064 :     return documentation.indexOf("@deprecated") != -1;
    1356             :         //TODO: this check is somewhat crude
    1357             : }
    1358             : 
    1359       15231 : void dumpDeprecation(FileStream & o, bool deprecated) {
    1360       15231 :     if (deprecated) {
    1361         696 :         o << "SAL_DEPRECATED_INTERNAL(\"marked @deprecated in UNOIDL\") ";
    1362             :     }
    1363       15231 : }
    1364             : 
    1365             : }
    1366             : 
    1367        3731 : InterfaceType::InterfaceType(typereg::Reader& typeReader,
    1368             :                               const OString& typeName,
    1369             :                              const TypeManager& typeMgr)
    1370        3731 :     : CppuType(typeReader, typeName, typeMgr)
    1371             : {
    1372        3731 :     m_inheritedMemberCount = 0;
    1373        3731 :     m_hasAttributes = false;
    1374        3731 :     m_hasMethods = false;
    1375        3731 :     m_isDeprecated = isDocumentedDeprecated(m_reader.getDocumentation());
    1376        3731 : }
    1377             : 
    1378        3731 : InterfaceType::~InterfaceType()
    1379             : {
    1380             : 
    1381        3731 : }
    1382             : 
    1383        3731 : sal_Bool InterfaceType::dumpHFile(
    1384             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    1385             :     throw( CannotDumpException )
    1386             : {
    1387        3731 :     if (m_reader.getMethodCount() != 0) {
    1388        3431 :         includes.add("com/sun/star/uno/RuntimeException");
    1389             :     }
    1390        3731 :     dumpHFileContent(o, includes);
    1391        3731 :     return sal_True;
    1392             : }
    1393             : 
    1394        3731 : void InterfaceType::dumpDeclaration(FileStream& o)
    1395             :     throw( CannotDumpException )
    1396             : {
    1397        3731 :     o << "\nclass SAL_NO_VTABLE " << m_name;
    1398             : 
    1399        7834 :     for (sal_Int16 i = 0; i < m_reader.getSuperTypeCount(); ++i) {
    1400        4103 :         o << (i == 0 ? " :" : ",") << " public "
    1401             :           << scopedCppName(rtl::OUStringToOString(
    1402        8206 :                             m_reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8));
    1403             :     }
    1404             : 
    1405        3731 :     o << "\n{\npublic:\n";
    1406             : 
    1407        3731 :     inc();
    1408             : 
    1409        3731 :     dumpAttributes(o);
    1410        3731 :     dumpMethods(o);
    1411             : 
    1412        7462 :     o << "\n" << indent()
    1413             :       << ("static inline ::com::sun::star::uno::Type const & SAL_CALL"
    1414        3731 :           " static_type(void * = 0);\n\n");
    1415        3731 :     dec();
    1416        3731 :     o << "protected:\n";
    1417        3731 :     inc();
    1418        7462 :     o << indent() << "~" << m_name
    1419             :       << ("() throw () {} // avoid warnings about virtual members and"
    1420        3731 :           " non-virtual dtor\n");
    1421        3731 :     dec();
    1422        3731 :     o << "};\n\n";
    1423        3731 : }
    1424             : 
    1425        3731 : sal_Bool InterfaceType::dumpHxxFile(
    1426             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    1427             :     throw( CannotDumpException )
    1428             : {
    1429        3731 :     OString headerDefine(dumpHeaderDefine(o, "HPP"));
    1430        3731 :     o << "\n";
    1431             : 
    1432        3731 :     addDefaultHxxIncludes(includes);
    1433        3731 :     includes.dump(o, &m_typeName);
    1434        3731 :     o << "\n";
    1435             : 
    1436        3731 :     dumpGetCppuType(o);
    1437             : 
    1438        3731 :     o << "\n::com::sun::star::uno::Type const & "
    1439       11193 :       << scopedCppName(m_typeName)
    1440        3731 :       << "::static_type(SAL_UNUSED_PARAMETER void *) {\n";
    1441        3731 :     inc();
    1442        3731 :     o << indent() << "return ::getCppuType(static_cast< ";
    1443        3731 :     dumpType(o, m_typeName);
    1444        3731 :     o << " * >(0));\n";
    1445        3731 :     dec();
    1446        3731 :     o << "}\n";
    1447             : 
    1448        3731 :     o << "\n#endif // "<< headerDefine << "\n";
    1449        3731 :     return sal_True;
    1450             : }
    1451             : 
    1452        3731 : void InterfaceType::dumpAttributes(FileStream& o)
    1453             : {
    1454        3731 :     sal_uInt16 fieldCount = m_reader.getFieldCount();
    1455        3731 :     sal_Bool first=sal_True;
    1456             : 
    1457        3731 :     RTFieldAccess access = RT_ACCESS_INVALID;
    1458        3731 :     OString fieldName;
    1459        3731 :     OString fieldType;
    1460        5357 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    1461             :     {
    1462        1626 :         access = m_reader.getFieldFlags(i);
    1463             : 
    1464        1626 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    1465           0 :             continue;
    1466             : 
    1467        1626 :         rtl::OUString name(m_reader.getFieldName(i));
    1468        1626 :         fieldName = rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8);
    1469             :         fieldType = rtl::OUStringToOString(
    1470        1626 :             m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    1471             : 
    1472             :         bool depr = m_isDeprecated
    1473        1626 :             || isDocumentedDeprecated(m_reader.getFieldDocumentation(i));
    1474             : 
    1475        1626 :         if (first)
    1476             :         {
    1477         325 :             first = sal_False;
    1478         325 :             o << "\n" << indent() << "// Attributes\n";
    1479             :         }
    1480             : 
    1481        1626 :         o << indent();
    1482        1626 :         dumpDeprecation(o, depr);
    1483        1626 :         o << "virtual ";
    1484        1626 :         dumpType(o, fieldType);
    1485        1626 :         o << " SAL_CALL get" << fieldName << "()";
    1486        1626 :         dumpAttributeExceptionSpecification(o, name, RT_MODE_ATTRIBUTE_GET);
    1487        1626 :         o << " = 0;\n";
    1488             : 
    1489        1626 :         if ((access & RT_ACCESS_READONLY) == 0)
    1490             :         {
    1491        1224 :             bool byRef = passByReference(fieldType);
    1492        1224 :             o << indent();
    1493        1224 :             dumpDeprecation(o, depr);
    1494        1224 :             o << "virtual void SAL_CALL set" << fieldName << "( ";
    1495        1224 :             dumpType(o, fieldType, byRef, byRef);
    1496        1224 :             o << " _" << fieldName.toAsciiLowerCase() << " )";
    1497        1224 :             dumpAttributeExceptionSpecification(o, name, RT_MODE_ATTRIBUTE_SET);
    1498        1224 :             o << " = 0;\n";
    1499             :         }
    1500        5357 :     }
    1501        3731 : }
    1502             : 
    1503        3731 : void InterfaceType::dumpMethods(FileStream& o)
    1504             : {
    1505        3731 :     sal_uInt16 methodCount = m_reader.getMethodCount();
    1506        3731 :     sal_Bool first=sal_True;
    1507             : 
    1508        3731 :     OString methodName, returnType, paramType, paramName;
    1509        3731 :     sal_uInt16 paramCount = 0;
    1510        3731 :     RTMethodMode methodMode = RT_MODE_INVALID;
    1511        3731 :     RTParamMode  paramMode = RT_PARAM_INVALID;
    1512             : 
    1513        3731 :     sal_Bool bRef = sal_False;
    1514        3731 :     sal_Bool bConst = sal_False;
    1515        3731 :     sal_Bool bWithRunTimeExcp = sal_True;
    1516             : 
    1517       16497 :     for (sal_uInt16 i=0; i < methodCount; i++)
    1518             :     {
    1519       12766 :         methodMode = m_reader.getMethodFlags(i);
    1520       12766 :         if (methodMode == RT_MODE_ATTRIBUTE_GET
    1521             :             || methodMode == RT_MODE_ATTRIBUTE_SET)
    1522             :         {
    1523         385 :             continue;
    1524             :         }
    1525             : 
    1526             :         methodName = rtl::OUStringToOString(
    1527       12381 :             m_reader.getMethodName(i), RTL_TEXTENCODING_UTF8);
    1528             :         returnType = rtl::OUStringToOString(
    1529       12381 :             m_reader.getMethodReturnTypeName(i), RTL_TEXTENCODING_UTF8);
    1530       12381 :         paramCount = m_reader.getMethodParameterCount(i);
    1531             : 
    1532       12381 :         if ( methodName.equals("acquire") || methodName.equals("release") )
    1533             :         {
    1534           6 :             bWithRunTimeExcp = sal_False;
    1535             :         }
    1536             : 
    1537       12381 :         if (first)
    1538             :         {
    1539        3413 :             first = sal_False;
    1540        3413 :             o << "\n" << indent() << "// Methods\n";
    1541             :         }
    1542             : 
    1543       12381 :         o << indent();
    1544             :         dumpDeprecation(
    1545             :             o,
    1546             :             (m_isDeprecated
    1547       12381 :              || isDocumentedDeprecated(m_reader.getMethodDocumentation(i))));
    1548       12381 :         o << "virtual ";
    1549       12381 :         dumpType(o, returnType);
    1550       12381 :         if ( !paramCount )
    1551             :         {
    1552             :             // prettier output for nullary methods
    1553        4580 :             o << " SAL_CALL " << methodName << "()";
    1554             :         }
    1555             :         else
    1556             :         {
    1557        7801 :             o << " SAL_CALL " << methodName << "( ";
    1558       20832 :             for (sal_uInt16 j=0; j < paramCount; j++)
    1559             :             {
    1560             :                 paramName = rtl::OUStringToOString(
    1561       13031 :                     m_reader.getMethodParameterName(i, j), RTL_TEXTENCODING_UTF8);
    1562             :                 paramType = rtl::OUStringToOString(
    1563             :                     m_reader.getMethodParameterTypeName(i, j),
    1564       13031 :                     RTL_TEXTENCODING_UTF8);
    1565       13031 :                 paramMode = m_reader.getMethodParameterFlags(i, j);
    1566             : 
    1567       13031 :                 switch (paramMode)
    1568             :                 {
    1569             :                     case RT_PARAM_IN:
    1570       12785 :                         bConst = passByReference(paramType);
    1571       12785 :                         bRef = bConst;
    1572       12785 :                         break;
    1573             :                     case RT_PARAM_OUT:
    1574             :                     case RT_PARAM_INOUT:
    1575         246 :                         bConst = sal_False;
    1576         246 :                         bRef = sal_True;
    1577         246 :                         break;
    1578             :                     default:
    1579           0 :                         break;
    1580             :                 }
    1581             : 
    1582       13031 :                 dumpType(o, paramType, bConst, bRef);
    1583       13031 :                 o << " " << paramName;
    1584             : 
    1585       13031 :                 if (j+1 < (sal_uInt16)paramCount) o << ", ";
    1586             :             }
    1587        7801 :             o << " )";
    1588             :         }
    1589       12381 :         dumpExceptionSpecification(o, i, bWithRunTimeExcp);
    1590       12381 :         o << " = 0;\n";
    1591        3731 :     }
    1592        3731 : }
    1593             : 
    1594         167 : void InterfaceType::dumpNormalGetCppuType(FileStream& o)
    1595             : {
    1596         167 :     dumpGetCppuTypePreamble(o);
    1597             : 
    1598         334 :     o << indent()
    1599         167 :       << "static typelib_TypeDescriptionReference * the_type = 0;\n";
    1600             : 
    1601         167 :     o << indent() << "if ( !the_type )\n" << indent() << "{\n";
    1602         167 :     inc();
    1603         167 :     sal_Int16 nBases = m_reader.getSuperTypeCount();
    1604             :     OSL_ASSERT(nBases > 0);
    1605         167 :     if (nBases == 1 && m_reader.getSuperTypeName(0) == "com/sun/star/uno/XInterface" )
    1606             :     {
    1607         109 :         nBases = 0;
    1608             :     }
    1609         167 :     if (nBases > 0) {
    1610         116 :         o << indent() << "typelib_TypeDescriptionReference * aSuperTypes["
    1611         116 :           << nBases << "];\n";
    1612         122 :         for (sal_Int16 i = 0; i < nBases; ++i) {
    1613          64 :             o << indent() << "aSuperTypes[" << i << "] = ::cppu::UnoType< ";
    1614             :             dumpType(
    1615             :                 o,
    1616             :                 rtl::OUStringToOString(
    1617             :                     m_reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8),
    1618          64 :                 true, false, false, true);
    1619          64 :             o << " >::get().getTypeLibType();\n";
    1620             :         }
    1621             :     }
    1622             : 
    1623         334 :     o << indent() << "typelib_static_mi_interface_type_init( &the_type, \""
    1624         501 :       << m_typeName.replace('/', '.') << "\", " << nBases << ", ";
    1625             : 
    1626         167 :     if ( nBases > 0 )
    1627             :     {
    1628          58 :         o << "aSuperTypes );\n";
    1629             :     } else
    1630             :     {
    1631         109 :         o << "0 );\n";
    1632             :     }
    1633             : 
    1634         167 :     dec();
    1635         167 :     o << indent() << "}\n";
    1636         334 :     o << indent()
    1637             :       << ("return * reinterpret_cast< ::com::sun::star::uno::Type * >("
    1638         167 :           " &the_type );\n");
    1639             : 
    1640         167 :     dumpGetCppuTypePostamble(o);
    1641         167 : }
    1642             : 
    1643        1760 : void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
    1644             : {
    1645        1760 :     if (!isPolymorphic())
    1646        1760 :         codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false);
    1647             :     else
    1648           0 :         o << "namespace cppu { ";
    1649        1760 :     o << " namespace detail {\n\n";
    1650             : 
    1651        1760 :     OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
    1652        1760 :     OString sStaticTypeClass = "the" + sType + "Type";
    1653        1760 :     o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type *, " << sStaticTypeClass << " >\n";
    1654        1760 :     o << indent() << "{\n";
    1655        1760 :     inc();
    1656        1760 :     o << indent() << "::com::sun::star::uno::Type * operator()() const\n";
    1657        1760 :     o << indent() << "{\n";
    1658             : 
    1659        1760 :     inc();
    1660        3520 :     o << indent() << "::rtl::OUString sTypeName( \""
    1661        5280 :       << m_typeName.replace('/', '.') << "\" );\n\n";
    1662             : 
    1663        3520 :     o << indent() << "// Start inline typedescription generation\n"
    1664        5280 :       << indent() << "typelib_InterfaceTypeDescription * pTD = 0;\n\n";
    1665             : 
    1666             :     OSL_ASSERT(m_reader.getSuperTypeCount() > 0);
    1667        3520 :     o << indent() << "typelib_TypeDescriptionReference * aSuperTypes["
    1668        3520 :       << m_reader.getSuperTypeCount() << "];\n";
    1669        3692 :     for (sal_Int16 i = 0; i < m_reader.getSuperTypeCount(); ++i) {
    1670        1932 :         o << indent() << "aSuperTypes[" << i << "] = ::cppu::UnoType< ";
    1671             :         dumpType(
    1672             :             o,
    1673             :             rtl::OUStringToOString(
    1674             :                 m_reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8),
    1675        1932 :             false, false, false, true);
    1676        1932 :         o << " >::get().getTypeLibType();\n";
    1677             :     }
    1678             : 
    1679        1760 :     sal_uInt32 count = getMemberCount();
    1680        1760 :     if (count)
    1681             :     {
    1682        3380 :         o << indent() << "typelib_TypeDescriptionReference * pMembers[" << count
    1683        1690 :           << "] = { ";
    1684        8179 :         for (sal_uInt32 i = 0; i < count; i++)
    1685             :         {
    1686        6489 :             o << "0";
    1687        6489 :             if (i+1 < count) {
    1688        4799 :                 o << ",";
    1689             :             } else {
    1690        1690 :                 o << " };\n";
    1691             :             }
    1692             :         }
    1693             : 
    1694        1690 :         sal_uInt32 index = 0;
    1695        1690 :         dumpCppuAttributeRefs(o, index);
    1696        1690 :         dumpCppuMethodRefs(o, index);
    1697             :     }
    1698             : 
    1699        1760 :     o << "\n" << indent() << "typelib_typedescription_newMIInterface(\n";
    1700        1760 :     inc();
    1701        1760 :     o << indent() << "&pTD,\n" << indent() << "sTypeName.pData, ";
    1702             : 
    1703        1760 :     o << "0x00000000, 0x0000, 0x0000, 0x00000000, 0x00000000,\n"; // UIK
    1704             : 
    1705        1760 :     o << indent() << m_reader.getSuperTypeCount() << ", aSuperTypes,\n";
    1706             : 
    1707        1760 :     if ( count ) {
    1708        1690 :         o << indent() << count << ",\n" << indent() << "pMembers );\n\n";
    1709             :     } else {
    1710          70 :         o << indent() << count << ",\n" << indent() << "0 );\n\n";
    1711             :     }
    1712        1760 :     dec();
    1713             : 
    1714        3520 :     o << indent()
    1715             :       << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
    1716        1760 :           " );\n");
    1717        1760 :     if ( count )
    1718             :     {
    1719        8179 :         for (sal_uInt16 i=0; i < count; i++)
    1720             :         {
    1721       12978 :             o << indent()
    1722       12978 :               << "typelib_typedescriptionreference_release( pMembers[" << i
    1723        6489 :               << "] );\n";
    1724             :         }
    1725             :     }
    1726        3520 :     o << indent()
    1727             :       << ("typelib_typedescription_release( (typelib_TypeDescription*)pTD"
    1728        1760 :           " );\n\n");
    1729             : 
    1730        3520 :     o << indent() << "return new ::com::sun::star::uno::Type( "
    1731        5280 :       << getTypeClass(m_typeName) << ", sTypeName ); // leaked\n";
    1732             : 
    1733        1760 :     dec();
    1734             : 
    1735        1760 :     o << indent() << "}\n";
    1736        1760 :     dec();
    1737        1760 :     o << indent() << "};\n\n";
    1738             : 
    1739        1760 :     if (!isPolymorphic())
    1740        1760 :         codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
    1741             :     else
    1742           0 :         o << " }";
    1743        1760 :     o << " }\n\n";
    1744             : 
    1745        1760 :     dumpGetCppuTypePreamble(o);
    1746        1760 :     o  << indent() << "const ::com::sun::star::uno::Type &rRet = *detail::" << sStaticTypeClass << "::get();\n";
    1747             : 
    1748        1760 :     o << indent() << "// End inline typedescription generation\n";
    1749             : 
    1750        1760 :     o  << indent() << "static bool bInitStarted = false;\n";
    1751        1760 :     o  << indent() << "if (!bInitStarted)\n";
    1752        1760 :     o  << indent() << "{\n";
    1753        1760 :     inc();
    1754        1760 :     o  << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
    1755        1760 :     o  << indent() << "if (!bInitStarted)\n";
    1756        1760 :     o  << indent() << "{\n";
    1757        1760 :     inc();
    1758        1760 :     o  << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
    1759        1760 :     o  << indent() << "bInitStarted = true;\n";
    1760             : 
    1761        1760 :     StringSet   aTypes;
    1762             :     // type for RuntimeException is always needed
    1763        1760 :     OString     sRunTimeExceptionType("com/sun/star/uno/RuntimeException");
    1764        1760 :     aTypes.insert(sRunTimeExceptionType);
    1765        1760 :     dumpCppuGetType(o, sRunTimeExceptionType, sal_True, CPPUTYPEDECL_ALLTYPES);
    1766             : 
    1767        1760 :     dumpAttributesCppuDecl(o, &aTypes, CPPUTYPEDECL_ALLTYPES);
    1768        1760 :     dumpMethodsCppuDecl(o, &aTypes, CPPUTYPEDECL_ALLTYPES);
    1769             : 
    1770        1760 :     if (count)
    1771             :     {
    1772        1690 :         sal_uInt32 index = getInheritedMemberCount();
    1773        1690 :         dumpCppuAttributes(o, index);
    1774        1690 :         dumpCppuMethods(o, index);
    1775             :     }
    1776             : 
    1777        1760 :     dec();
    1778        1760 :     o  << indent() << "}\n";
    1779        1760 :     dec();
    1780        1760 :     o  << indent() << "}\n";
    1781        1760 :     o  << indent() << "else\n";
    1782        1760 :     o  << indent() << "{\n";
    1783        1760 :     inc();
    1784        1760 :     o  << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
    1785        1760 :     dec();
    1786        1760 :     o  << indent() << "}\n";
    1787             : 
    1788        1760 :     o  << indent() << "return rRet;\n";
    1789        1760 :     dumpGetCppuTypePostamble(o);
    1790        1760 : }
    1791             : 
    1792        1690 : void InterfaceType::dumpCppuAttributeRefs(FileStream& o, sal_uInt32& index)
    1793             : {
    1794        1690 :     sal_uInt16 fieldCount = m_reader.getFieldCount();
    1795             : 
    1796        1690 :     RTFieldAccess access = RT_ACCESS_INVALID;
    1797        1690 :     OString fieldName;
    1798        1690 :     OString scope = m_typeName.replace('/', '.');
    1799             : 
    1800        2209 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    1801             :     {
    1802         519 :         access = m_reader.getFieldFlags(i);
    1803             : 
    1804         519 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    1805           0 :             continue;
    1806             : 
    1807             :         fieldName = rtl::OUStringToOString(
    1808         519 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    1809             : 
    1810        1038 :         o << indent() << "::rtl::OUString sAttributeName" << i << "( \""
    1811        1557 :           << scope.replace('/', '.') << "::" << fieldName << "\" );\n";
    1812        1038 :         o << indent() << "typelib_typedescriptionreference_new( &pMembers["
    1813        1038 :           << index << "],\n";
    1814         519 :         inc(38);
    1815        1038 :         o << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_ATTRIBUTE,\n"
    1816        1557 :           << indent() << "sAttributeName" << i << ".pData );\n";
    1817         519 :         dec(38);
    1818         519 :         index++;
    1819        1690 :     }
    1820        1690 : }
    1821             : 
    1822        1690 : void InterfaceType::dumpCppuMethodRefs(FileStream& o, sal_uInt32& index)
    1823             : {
    1824        1690 :     sal_uInt16  methodCount = m_reader.getMethodCount();
    1825        1690 :     OString     methodName;
    1826        1690 :     OString     scope = m_typeName.replace('/', '.');
    1827             : 
    1828        7853 :     for (sal_uInt16 i = 0; i < methodCount; i++)
    1829             :     {
    1830        6163 :         RTMethodMode flags = m_reader.getMethodFlags(i);
    1831        6163 :         if (flags == RT_MODE_ATTRIBUTE_GET || flags == RT_MODE_ATTRIBUTE_SET) {
    1832         193 :             continue;
    1833             :         }
    1834             : 
    1835             :         methodName = rtl::OUStringToOString(
    1836        5970 :             m_reader.getMethodName(i), RTL_TEXTENCODING_UTF8);
    1837             : 
    1838       11940 :         o << indent() << "::rtl::OUString sMethodName" << i << "( \""
    1839       17910 :           << scope.replace('/', '.') << "::" << methodName << "\" );\n";
    1840       11940 :         o << indent() << "typelib_typedescriptionreference_new( &pMembers["
    1841       11940 :           << index << "],\n";
    1842        5970 :         inc(38);
    1843       11940 :         o << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_METHOD,\n"
    1844       17910 :           << indent() << "sMethodName" << i << ".pData );\n";
    1845        5970 :         dec(38);
    1846        5970 :         index++;
    1847        1690 :     }
    1848        1690 : }
    1849             : 
    1850        1760 : sal_uInt32 InterfaceType::getMemberCount() {
    1851        1760 :     sal_uInt16 count = 0;
    1852        1760 :     sal_uInt16 methodCount = m_reader.getMethodCount();
    1853        7923 :     {for (sal_uInt16 i = 0; i < methodCount; ++i) {
    1854        6163 :         RTMethodMode flags = m_reader.getMethodFlags(i);
    1855        6163 :         if (flags != RT_MODE_ATTRIBUTE_GET && flags != RT_MODE_ATTRIBUTE_SET) {
    1856        5970 :             m_hasMethods = true;
    1857        5970 :             ++count;
    1858             :         }
    1859             :     }}
    1860        1760 :     sal_uInt16 fieldCount = m_reader.getFieldCount();
    1861        2279 :     {for (sal_uInt16 i = 0; i < fieldCount; ++i) {
    1862         519 :         RTFieldAccess flags = m_reader.getFieldFlags(i);
    1863         519 :         if (flags != RT_ACCESS_CONST && flags != RT_ACCESS_INVALID) {
    1864         519 :             m_hasAttributes = true;
    1865         519 :             ++count;
    1866             :         }
    1867             :     }}
    1868        1760 :     return count;
    1869             : }
    1870             : 
    1871             : namespace {
    1872             : 
    1873        1690 : class BaseOffset {
    1874             : public:
    1875             :     BaseOffset(TypeManager const & theManager, typereg::Reader const & reader);
    1876             : 
    1877        1690 :     sal_Int32 get() const { return offset; }
    1878             : 
    1879             : private:
    1880             :     void calculateBases(typereg::Reader const & reader);
    1881             : 
    1882             :     void calculate(typereg::Reader const & reader);
    1883             : 
    1884             :     TypeManager const & manager;
    1885             :     std::set< rtl::OString > set;
    1886             :     sal_Int32 offset;
    1887             : };
    1888             : 
    1889        1690 : BaseOffset::BaseOffset(
    1890             :     TypeManager const & theManager, typereg::Reader const & reader):
    1891        1690 :     manager(theManager)
    1892             : {
    1893        1690 :     offset = 0;
    1894        1690 :     calculateBases(reader);
    1895        1690 : }
    1896             : 
    1897        4346 : void BaseOffset::calculateBases(typereg::Reader const & reader) {
    1898        7156 :     for (sal_Int16 i = 0; i < reader.getSuperTypeCount(); ++i) {
    1899             :         typereg::Reader super(
    1900             :             manager.getTypeReader(
    1901             :                 rtl::OUStringToOString(
    1902        2810 :                     reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8)));
    1903        2810 :         if (super.isValid()) {
    1904        2810 :             calculate(super);
    1905             :         }
    1906        2810 :     }
    1907        4346 : }
    1908             : 
    1909        2810 : void BaseOffset::calculate(typereg::Reader const & reader) {
    1910        5620 :     if (set.insert(
    1911        5620 :             rtl::OUStringToOString(reader.getTypeName(), RTL_TEXTENCODING_UTF8))
    1912             :         .second)
    1913             :     {
    1914        2656 :         calculateBases(reader);
    1915       11884 :         {for (sal_uInt16 i = 0; i < reader.getMethodCount(); ++i) {
    1916        9228 :             RTMethodMode flags = reader.getMethodFlags(i);
    1917        9228 :             if (flags != RT_MODE_ATTRIBUTE_GET
    1918             :                 && flags != RT_MODE_ATTRIBUTE_SET)
    1919             :             {
    1920        8250 :                 ++offset;
    1921             :             }
    1922             :         }}
    1923        3411 :         {for (sal_uInt16 i = 0; i < reader.getFieldCount(); ++i) {
    1924         755 :             RTFieldAccess flags = reader.getFieldFlags(i);
    1925         755 :             if (flags != RT_ACCESS_CONST && flags != RT_ACCESS_INVALID) {
    1926         755 :                 ++offset;
    1927             :             }
    1928             :         }}
    1929             :     }
    1930        2810 : }
    1931             : 
    1932             : }
    1933             : 
    1934        3731 : void InterfaceType::addSpecialDependencies() {
    1935        3731 :     if (m_reader.getMethodCount() > 0 || m_reader.getFieldCount() > 0) {
    1936        3552 :         m_dependencies.add("com/sun/star/uno/RuntimeException");
    1937             :     }
    1938        3731 : }
    1939             : 
    1940        1760 : void InterfaceType::addComprehensiveGetCppuTypeIncludes(
    1941             :     codemaker::cppumaker::Includes & includes) const
    1942             : {
    1943             :     // The comprehensive getCppuType method always includes a line
    1944             :     // "getCppuType( (const ::com::sun::star::uno::RuntimeException*)0 );":
    1945        1760 :     includes.addCppuUnotypeHxx();
    1946        1760 :     includes.add("com/sun/star/uno/RuntimeException");
    1947        1760 : }
    1948             : 
    1949        1690 : sal_uInt32 InterfaceType::checkInheritedMemberCount(const typereg::Reader*)
    1950             : {
    1951        1690 :     return BaseOffset(m_typeMgr, m_reader).get();
    1952             : }
    1953             : 
    1954        1690 : sal_uInt32 InterfaceType::getInheritedMemberCount()
    1955             : {
    1956        1690 :     if (m_inheritedMemberCount == 0)
    1957             :     {
    1958        1690 :         m_inheritedMemberCount = checkInheritedMemberCount(0);
    1959             :     }
    1960             : 
    1961        1690 :     return m_inheritedMemberCount;
    1962             : }
    1963             : 
    1964        1690 : void InterfaceType::dumpCppuAttributes(FileStream& o, sal_uInt32& index)
    1965             : {
    1966        1690 :     sal_uInt16 fieldCount = m_reader.getFieldCount();
    1967             : 
    1968        1690 :     RTFieldAccess access = RT_ACCESS_INVALID;
    1969        1690 :     OString fieldName;
    1970        1690 :     OString fieldType;
    1971        1690 :     OString scope = m_typeName.replace('/', '.');
    1972             : 
    1973        1690 :     sal_uInt32 absoluteIndex = index;
    1974             : 
    1975        1690 :     if (m_hasAttributes)
    1976             :     {
    1977         109 :         o << "\n" << indent() << "typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n";
    1978             : 
    1979         628 :         for (sal_uInt16 i=0; i < fieldCount; i++)
    1980             :         {
    1981         519 :             access = m_reader.getFieldFlags(i);
    1982             : 
    1983         519 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    1984           0 :                 continue;
    1985             : 
    1986         519 :             rtl::OUString name(m_reader.getFieldName(i));
    1987         519 :             fieldName = rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8);
    1988             :             fieldType = checkRealBaseType(
    1989             :                 rtl::OUStringToOString(
    1990             :                     m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8),
    1991         519 :                 sal_True);
    1992             : 
    1993         519 :             o << indent() << "{\n";
    1994         519 :             inc();
    1995        1038 :             o << indent() << "::rtl::OUString sAttributeType" << i << "( \""
    1996        1557 :               << fieldType.replace('/', '.') << "\" );\n";
    1997             : 
    1998        1038 :             o << indent() << "::rtl::OUString sAttributeName" << i << "( \""
    1999        1557 :               << scope.replace('/', '.') << "::" << fieldName << "\" );\n";
    2000             : 
    2001             :             sal_Int32 getExceptions = dumpAttributeExceptionTypeNames(
    2002         519 :                 o, "get", name, RT_MODE_ATTRIBUTE_GET);
    2003             :             sal_Int32 setExceptions = dumpAttributeExceptionTypeNames(
    2004         519 :                 o, "set", name, RT_MODE_ATTRIBUTE_SET);
    2005        1038 :             o << indent()
    2006             :               << ("typelib_typedescription_newExtendedInterfaceAttribute("
    2007         519 :                   " &pAttribute,\n");
    2008         519 :             inc();
    2009         519 :             o << indent() << absoluteIndex++ << ", sAttributeName" << i << ".pData,\n";
    2010        1038 :             o << indent() << "(typelib_TypeClass)" << getTypeClass(fieldType)
    2011        1038 :               << ", sAttributeType" << i << ".pData,\n";
    2012        1038 :             o << indent() << "sal_"
    2013        1038 :               << ((access & RT_ACCESS_READONLY) == 0 ? "False" : "True") << ", "
    2014        1038 :               << getExceptions << ", "
    2015        1038 :               << (getExceptions == 0 ? "0" : "the_getExceptions") << ", "
    2016        1038 :               << setExceptions << ", "
    2017        1038 :               << (setExceptions == 0 ? "0" : "the_setExceptions") << " );\n";
    2018         519 :             dec();
    2019         519 :             o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pAttribute );\n";
    2020         519 :             dec();
    2021         519 :             o << indent() << "}\n";
    2022         519 :         }
    2023         109 :          o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pAttribute );\n";
    2024             : 
    2025         109 :         index = absoluteIndex;
    2026        1690 :     }
    2027        1690 : }
    2028             : 
    2029        1690 : void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index)
    2030             : {
    2031        1690 :     sal_uInt16      methodCount = m_reader.getMethodCount();
    2032        1690 :     OString         methodName, returnType, paramType, paramName;
    2033        1690 :     RTMethodMode    methodMode = RT_MODE_INVALID;
    2034        1690 :     RTParamMode     paramMode = RT_PARAM_INVALID;
    2035        1690 :     sal_Bool        bWithRuntimeException = sal_True;
    2036             : 
    2037        1690 :     sal_uInt32 absoluteIndex = index;
    2038             : 
    2039        1690 :     if (m_hasMethods)
    2040             :     {
    2041        1641 :         o << "\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n";
    2042        1641 :         OString             scope = m_typeName.replace('/', '.');
    2043             : 
    2044        1641 :         sal_uInt16 paramCount = 0;
    2045        7645 :         for (sal_uInt16 i=0; i < methodCount; i++)
    2046             :         {
    2047        6004 :             methodMode = m_reader.getMethodFlags(i);
    2048        6004 :             if (methodMode == RT_MODE_ATTRIBUTE_GET
    2049             :                 || methodMode == RT_MODE_ATTRIBUTE_SET)
    2050             :             {
    2051          34 :                 continue;
    2052             :             }
    2053             : 
    2054             :             methodName = rtl::OUStringToOString(
    2055        5970 :                 m_reader.getMethodName(i), RTL_TEXTENCODING_UTF8);
    2056             :             returnType = checkRealBaseType(
    2057             :                 rtl::OUStringToOString(
    2058             :                     m_reader.getMethodReturnTypeName(i), RTL_TEXTENCODING_UTF8),
    2059        5970 :                 sal_True);
    2060        5970 :             paramCount = m_reader.getMethodParameterCount(i);
    2061             : 
    2062        5970 :             if ( methodName.equals("acquire") || methodName.equals("release") )
    2063             :             {
    2064           0 :                 bWithRuntimeException = sal_False;
    2065             :             }
    2066             : 
    2067        5970 :             o << indent() << "{\n";
    2068        5970 :             inc();
    2069             : 
    2070        5970 :             if (paramCount)
    2071             :             {
    2072        3755 :                 o << indent() << "typelib_Parameter_Init aParameters[" << paramCount << "];\n";
    2073             :             }
    2074             : 
    2075       12170 :             for (sal_uInt16 j = 0; j < paramCount; j++)
    2076             :             {
    2077             :                 paramName = rtl::OUStringToOString(
    2078             :                     m_reader.getMethodParameterName(i, j),
    2079        6200 :                     RTL_TEXTENCODING_UTF8);
    2080             :                 paramType = checkRealBaseType(
    2081             :                     rtl::OUStringToOString(
    2082             :                         m_reader.getMethodParameterTypeName(i, j),
    2083             :                         RTL_TEXTENCODING_UTF8),
    2084        6200 :                     sal_True);
    2085        6200 :                 paramMode = m_reader.getMethodParameterFlags(i, j);
    2086             : 
    2087       12400 :                 o << indent() << "::rtl::OUString sParamName" << j << "( \""
    2088        6200 :                   << paramName << "\" );\n";
    2089       12400 :                 o << indent() << "::rtl::OUString sParamType" << j << "( \""
    2090       18600 :                   << paramType.replace('/', '.') << "\" );\n";
    2091        6200 :                 o << indent() << "aParameters[" << j << "].pParamName = sParamName" << j << ".pData;\n";
    2092       12400 :                 o << indent() << "aParameters[" << j << "].eTypeClass = (typelib_TypeClass)"
    2093       18600 :                   << getTypeClass(paramType) << ";\n";
    2094        6200 :                 o << indent() << "aParameters[" << j << "].pTypeName = sParamType" << j << ".pData;\n";
    2095             : 
    2096        6200 :                 if (paramMode == RT_PARAM_IN || paramMode == RT_PARAM_INOUT)
    2097        6136 :                     o << indent() << "aParameters[" << j << "].bIn = sal_True;\n";
    2098             :                 else
    2099          64 :                     o << indent() << "aParameters[" << j << "].bIn = sal_False;\n";
    2100             : 
    2101        6200 :                 if (paramMode == RT_PARAM_OUT || paramMode == RT_PARAM_INOUT)
    2102          84 :                     o << indent() << "aParameters[" << j << "].bOut = sal_True;\n";
    2103             :                 else
    2104        6116 :                     o << indent() << "aParameters[" << j << "].bOut = sal_False;\n";
    2105             :             }
    2106             : 
    2107             :             sal_Int32 excCount = dumpExceptionTypeNames(
    2108        5970 :                 o, "", i, bWithRuntimeException);
    2109             : 
    2110       11940 :             o << indent() << "::rtl::OUString sReturnType" << i << "( \""
    2111       17910 :               << returnType.replace('/', '.') << "\" );\n";
    2112       11940 :             o << indent() << "::rtl::OUString sMethodName" << i <<
    2113        5970 :                 "( \""
    2114       17910 :               << scope.replace('/', '.') << "::" << methodName << "\" );\n";
    2115        5970 :             o << indent() << "typelib_typedescription_newInterfaceMethod( &pMethod,\n";
    2116        5970 :             inc();
    2117        5970 :             o << indent() << absoluteIndex++ << ", ";
    2118        5970 :             if (methodMode == RT_MODE_ONEWAY || methodMode == RT_MODE_ONEWAY_CONST)
    2119           0 :                 o << "sal_True,\n";
    2120             :             else
    2121        5970 :                 o << "sal_False,\n";
    2122             : 
    2123        5970 :             o << indent() << "sMethodName" << i << ".pData,\n";
    2124       11940 :             o << indent() << "(typelib_TypeClass)" << getTypeClass(returnType)
    2125       11940 :               << ", sReturnType" << i << ".pData,\n";
    2126        5970 :             if (paramCount)
    2127        3755 :                 o << indent() << paramCount << ", aParameters,\n";
    2128             :             else
    2129        2215 :                 o << indent() << "0, 0,\n";
    2130       11940 :             o << indent() << excCount << ", "
    2131       11940 :               << (excCount == 0 ? "0" : "the_Exceptions") << " );\n";
    2132             : 
    2133        5970 :             dec();
    2134        5970 :             o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );\n";
    2135             : 
    2136        5970 :             dec();
    2137        5970 :             o << indent() << "}\n";
    2138             :         }
    2139        1641 :         o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pMethod );\n";
    2140             : 
    2141        1641 :         index = absoluteIndex;
    2142        1690 :     }
    2143        1690 : }
    2144             : 
    2145        1760 : void InterfaceType::dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag)
    2146             : {
    2147        1760 :     sal_uInt16 fieldCount = m_reader.getFieldCount();
    2148             : 
    2149        1760 :     RTFieldAccess access = RT_ACCESS_INVALID;
    2150        1760 :     OString fieldName;
    2151        1760 :     OString fieldType;
    2152        2279 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    2153             :     {
    2154         519 :         access = m_reader.getFieldFlags(i);
    2155             : 
    2156         519 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    2157           0 :             continue;
    2158             : 
    2159             :         fieldName = rtl::OUStringToOString(
    2160         519 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    2161             :         fieldType = rtl::OUStringToOString(
    2162         519 :             m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    2163             : 
    2164         519 :         if (pFinishedTypes->count(fieldType) == 0)
    2165             :         {
    2166         266 :             pFinishedTypes->insert(fieldType);
    2167         266 :             dumpCppuGetType(o, fieldType, sal_True, eDeclFlag);
    2168             :         }
    2169        1760 :     }
    2170        1760 : }
    2171             : 
    2172        1760 : void InterfaceType::dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag)
    2173             : {
    2174        1760 :     sal_uInt16      methodCount = m_reader.getMethodCount();
    2175        1760 :     OString         returnType, paramType, excType;
    2176        1760 :     sal_uInt16      paramCount = 0;
    2177        1760 :     sal_uInt16      excCount = 0;
    2178             : 
    2179        7923 :     for (sal_uInt16 i=0; i < methodCount; i++)
    2180             :     {
    2181             :         returnType = rtl::OUStringToOString(
    2182        6163 :             m_reader.getMethodReturnTypeName(i), RTL_TEXTENCODING_UTF8);
    2183        6163 :         paramCount = m_reader.getMethodParameterCount(i);
    2184        6163 :         excCount = m_reader.getMethodExceptionCount(i);
    2185             : 
    2186        6163 :         if (pFinishedTypes->count(returnType) == 0)
    2187             :         {
    2188        3031 :             pFinishedTypes->insert(returnType);
    2189        3031 :             dumpCppuGetType(o, returnType, sal_True, eDeclFlag);
    2190             :         }
    2191             :         sal_uInt16 j;
    2192       12363 :         for (j=0; j < paramCount; j++)
    2193             :         {
    2194             :             paramType = rtl::OUStringToOString(
    2195             :                 m_reader.getMethodParameterTypeName(i, j),
    2196        6200 :                 RTL_TEXTENCODING_UTF8);
    2197             : 
    2198        6200 :             if (pFinishedTypes->count(paramType) == 0)
    2199             :             {
    2200        2239 :                 pFinishedTypes->insert(paramType);
    2201        2239 :                 dumpCppuGetType(o, paramType, sal_True, eDeclFlag);
    2202             :             }
    2203             :         }
    2204             : 
    2205        9329 :         for (j=0; j < excCount; j++)
    2206             :         {
    2207             :             excType = rtl::OUStringToOString(
    2208             :                 m_reader.getMethodExceptionTypeName(i, j),
    2209        3166 :                 RTL_TEXTENCODING_UTF8);
    2210        3166 :             if (pFinishedTypes->count(excType) == 0)
    2211             :             {
    2212        1140 :                 pFinishedTypes->insert(excType);
    2213        1140 :                 dumpCppuGetType(o, excType, sal_True, eDeclFlag);
    2214             :             }
    2215             :         }
    2216        1760 :     }
    2217        1760 : }
    2218             : 
    2219       15231 : void InterfaceType::dumpExceptionSpecification(
    2220             :     FileStream & out, sal_uInt32 methodIndex, bool runtimeException)
    2221             : {
    2222             :     // exception specifications are undesirable in production code, but make
    2223             :     // for useful assertions in debug builds (on platforms where they are
    2224             :     // enforced at runtime)
    2225             : #ifndef DBG_UTIL
    2226             :     (void) out;
    2227             :     (void) methodIndex;
    2228             :     (void) runtimeException;
    2229             : #else
    2230             :     out << " throw (";
    2231             :     bool first = true;
    2232             :     if (methodIndex <= SAL_MAX_UINT16) {
    2233             :         sal_uInt16 count = m_reader.getMethodExceptionCount(
    2234             :             static_cast< sal_uInt16 >(methodIndex));
    2235             :         for (sal_uInt16 i = 0; i < count; ++i) {
    2236             :             rtl::OUString name(
    2237             :                 m_reader.getMethodExceptionTypeName(
    2238             :                     static_cast< sal_uInt16 >(methodIndex), i));
    2239             :             if ( name != "com/sun/star/uno/RuntimeException" )
    2240             :             {
    2241             :                 if (!first) {
    2242             :                     out << ", ";
    2243             :                 }
    2244             :                 first = false;
    2245             :                 out << scopedCppName(
    2246             :                     rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8));
    2247             :             }
    2248             :         }
    2249             :     }
    2250             :     if (runtimeException) {
    2251             :         if (!first) {
    2252             :             out << ", ";
    2253             :         }
    2254             :         out << "::com::sun::star::uno::RuntimeException";
    2255             :     }
    2256             :     out << ")";
    2257             : #endif
    2258       15231 : }
    2259             : 
    2260        2850 : void InterfaceType::dumpAttributeExceptionSpecification(
    2261             :     FileStream & out, rtl::OUString const & name, RTMethodMode sort)
    2262             : {
    2263        2850 :     sal_uInt16 methodCount = m_reader.getMethodCount();
    2264       30834 :     for (sal_uInt16 i = 0; i < methodCount; ++i) {
    2265       74202 :         if (m_reader.getMethodFlags(i) == sort
    2266       45833 :             && m_reader.getMethodName(i) == name)
    2267             :         {
    2268         385 :             dumpExceptionSpecification(out, i, true);
    2269        3235 :             return;
    2270             :         }
    2271             :     }
    2272        2465 :     dumpExceptionSpecification(out, 0xFFFFFFFF, true);
    2273             : }
    2274             : 
    2275        9135 : void InterfaceType::dumpExceptionTypeName(
    2276             :     FileStream & out, char const * prefix, sal_uInt32 index, rtl::OUString name)
    2277             : {
    2278       18270 :     out << indent() << "::rtl::OUString the_" << prefix << "ExceptionName"
    2279        9135 :         << index << "( \""
    2280       27405 :         << rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8).replace('/', '.')
    2281        9135 :         << "\" );\n";
    2282        9135 : }
    2283             : 
    2284        6163 : sal_Int32 InterfaceType::dumpExceptionTypeNames(
    2285             :     FileStream & out, char const * prefix, sal_uInt16 methodIndex,
    2286             :     bool runtimeException)
    2287             : {
    2288        6163 :     sal_Int32 count = 0;
    2289        6163 :     sal_uInt16 n = m_reader.getMethodExceptionCount(methodIndex);
    2290        9329 :     for (sal_uInt16 i = 0; i < n; ++i) {
    2291        3166 :         rtl::OUString name(m_reader.getMethodExceptionTypeName(methodIndex, i));
    2292        3166 :         if ( name != "com/sun/star/uno/RuntimeException" )
    2293             :         {
    2294        3165 :             dumpExceptionTypeName(out, prefix, count++, name);
    2295             :         }
    2296        3166 :     }
    2297        6163 :     if (runtimeException) {
    2298             :         dumpExceptionTypeName(
    2299             :             out, prefix, count++,
    2300        5970 :             rtl::OUString("com/sun/star/uno/RuntimeException"));
    2301             :     }
    2302        6163 :     if (count > 0) {
    2303        6162 :         out << indent() << "rtl_uString * the_" << prefix << "Exceptions[] = {";
    2304       15297 :         for (sal_Int32 i = 0; i < count; ++i) {
    2305        9135 :             out << (i == 0 ? " " : ", ") << "the_" << prefix << "ExceptionName"
    2306       18270 :                 << i << ".pData";
    2307             :         }
    2308        6162 :         out << " };\n";
    2309             :     }
    2310        6163 :     return count;
    2311             : }
    2312             : 
    2313        1038 : sal_Int32 InterfaceType::dumpAttributeExceptionTypeNames(
    2314             :     FileStream & out, char const * prefix, rtl::OUString const & name,
    2315             :     RTMethodMode sort)
    2316             : {
    2317        1038 :     sal_uInt16 methodCount = m_reader.getMethodCount();
    2318       11522 :     for (sal_uInt16 i = 0; i < methodCount; ++i) {
    2319       30172 :         if (m_reader.getMethodFlags(i) == sort
    2320       19495 :             && m_reader.getMethodName(i) == name)
    2321             :         {
    2322         193 :             return dumpExceptionTypeNames(out, prefix, i, false);
    2323             :         }
    2324             :     }
    2325         845 :     return 0;
    2326             : }
    2327             : 
    2328             : //*************************************************************************
    2329             : // ConstantsType
    2330             : //*************************************************************************
    2331        1848 : ConstantsType::ConstantsType(typereg::Reader& typeReader,
    2332             :                              const OString& typeName,
    2333             :                              const TypeManager& typeMgr)
    2334        1848 :     : CppuType(typeReader, typeName, typeMgr)
    2335             : {
    2336        1848 : }
    2337             : 
    2338        1848 : ConstantsType::~ConstantsType()
    2339             : {
    2340             : 
    2341        1848 : }
    2342             : 
    2343        1531 : sal_Bool ConstantsType::dump(CppuOptions* pOptions)
    2344             :     throw( CannotDumpException )
    2345             : {
    2346        1531 :     if (!m_dependencies.isValid()) {
    2347           0 :         return false;
    2348             :     }
    2349        1531 :     addSpecialDependencies();
    2350             : 
    2351        1531 :     if (pOptions->isValid("-U"))
    2352           0 :         m_cppuTypeDynamic = true;
    2353             : 
    2354        1531 :     OString outPath;
    2355        1531 :     if (pOptions->isValid("-O"))
    2356        1531 :         outPath = pOptions->getOption("-O");
    2357             : 
    2358        1531 :     return dumpFiles(pOptions, outPath);
    2359             : }
    2360             : 
    2361        1531 : sal_Bool ConstantsType::dumpHFile(
    2362             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    2363             :     throw( CannotDumpException )
    2364             : {
    2365        1531 :     sal_Bool bSpecialDefine = sal_True;
    2366             : 
    2367        1531 :     if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS)
    2368             :     {
    2369        1531 :         bSpecialDefine = sal_False;
    2370             :     }
    2371             : 
    2372        1531 :     OString headerDefine(dumpHeaderDefine(o, "HDL", bSpecialDefine));
    2373        1531 :     o << "\n";
    2374             : 
    2375        1531 :     addDefaultHIncludes(includes);
    2376        1531 :     includes.dump(o, 0);
    2377        1531 :     o << "\n";
    2378             : 
    2379        1531 :     if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, true)) {
    2380        1531 :         o << "\n";
    2381             :     }
    2382        1531 :     o << "\n";
    2383             : 
    2384        1531 :     dumpDeclaration(o);
    2385        1531 :     o << "\n";
    2386             : 
    2387        1531 :     if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, true)) {
    2388        1531 :         o << "\n";
    2389             :     }
    2390        1531 :     o << "\n#endif // "<< headerDefine << "\n";
    2391             : 
    2392        1531 :     return sal_True;
    2393             : }
    2394             : 
    2395        1531 : void ConstantsType::dumpDeclaration(FileStream& o)
    2396             :     throw( CannotDumpException )
    2397             : {
    2398        1531 :     sal_uInt16      fieldCount = m_reader.getFieldCount();
    2399        1531 :     OString         fieldName;
    2400        1531 :     OString         fieldType;
    2401       16539 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    2402             :     {
    2403             :         fieldName = rtl::OUStringToOString(
    2404       15008 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    2405             :         fieldType = rtl::OUStringToOString(
    2406       15008 :             m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    2407             : 
    2408       15008 :         o << "static const ";
    2409       15008 :         dumpType(o, fieldType);
    2410       15008 :         o << " " << fieldName << " = ";
    2411       15008 :         dumpConstantValue(o, i);
    2412       15008 :         o << ";\n";
    2413        1531 :     }
    2414        1531 : }
    2415             : 
    2416        1848 : sal_Bool ConstantsType::hasConstants()
    2417             : {
    2418        1848 :     return m_reader.getFieldCount() > 0;
    2419             : }
    2420             : 
    2421        1531 : sal_Bool ConstantsType::dumpHxxFile(
    2422             :     FileStream& o, codemaker::cppumaker::Includes &)
    2423             :     throw( CannotDumpException )
    2424             : {
    2425        1531 :     sal_Bool bSpecialDefine = sal_True;
    2426             : 
    2427        1531 :     if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS)
    2428             :     {
    2429        1531 :         bSpecialDefine = sal_False;
    2430             :     }
    2431             : 
    2432        1531 :     OString headerDefine(dumpHeaderDefine(o, "HPP", bSpecialDefine));
    2433        1531 :     o << "\n";
    2434             : 
    2435        1531 :     rtl::OString suffix;
    2436        1531 :     if (bSpecialDefine) {
    2437           0 :         suffix = m_name;
    2438             :     }
    2439        1531 :     codemaker::cppumaker::Includes::dumpInclude(o, m_typeName, false, suffix);
    2440             : 
    2441        1531 :     o << "\n#endif // "<< headerDefine << "\n";
    2442             : 
    2443        1531 :     return sal_True;
    2444             : }
    2445             : 
    2446             : //*************************************************************************
    2447             : // ModuleType
    2448             : //*************************************************************************
    2449         317 : ModuleType::ModuleType(typereg::Reader& typeReader,
    2450             :                        const OString& typeName,
    2451             :                        const TypeManager& typeMgr)
    2452         317 :     : ConstantsType(typeReader, typeName, typeMgr)
    2453             : {
    2454         317 : }
    2455             : 
    2456         317 : ModuleType::~ModuleType()
    2457             : {
    2458             : 
    2459         317 : }
    2460             : 
    2461           0 : bool ModuleType::dumpFiles(
    2462             :     CppuOptions * options, rtl::OString const & outPath)
    2463             : {
    2464           0 :     rtl::OString tmpName(m_typeName);
    2465           0 :     if (tmpName.equals("/")) {
    2466           0 :         tmpName = "global";
    2467             :     } else {
    2468           0 :         tmpName += "/" + m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
    2469             :     }
    2470           0 :     return dumpFile(options, ".hdl", tmpName, outPath)
    2471           0 :         && dumpFile(options, ".hpp", tmpName, outPath);
    2472             : }
    2473             : 
    2474             : //*************************************************************************
    2475             : // StructureType
    2476             : //*************************************************************************
    2477             : 
    2478             : namespace {
    2479             : 
    2480         447 : void dumpTypeParameterName(FileStream & out, rtl::OString const & name) {
    2481             :     // Prefix all type parameters with "typeparam_" to avoid problems when a
    2482             :     // struct member has the same name as a type parameter, as in
    2483             :     // struct<T> { T T; };
    2484         447 :     out << "typeparam_" << name;
    2485         447 : }
    2486             : 
    2487             : }
    2488             : 
    2489         835 : StructureType::StructureType(typereg::Reader& typeReader,
    2490             :                               const OString& typeName,
    2491             :                              const TypeManager& typeMgr)
    2492         835 :     : CppuType(typeReader, typeName, typeMgr)
    2493             : {
    2494         835 : }
    2495             : 
    2496         835 : StructureType::~StructureType()
    2497             : {
    2498             : 
    2499         835 : }
    2500             : 
    2501         835 : sal_Bool StructureType::dumpHFile(
    2502             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    2503             :     throw( CannotDumpException )
    2504             : {
    2505         835 :     dumpHFileContent(o, includes);
    2506         835 :     return sal_True;
    2507             : }
    2508             : 
    2509         835 : void StructureType::dumpDeclaration(FileStream& o)
    2510             :     throw( CannotDumpException )
    2511             : {
    2512         835 :     o << "\n#ifdef SAL_W32\n"
    2513         835 :       << "#   pragma pack(push, 8)\n"
    2514         835 :       << "#endif\n\n";
    2515             : 
    2516             :     OSL_ASSERT(!isPolymorphic() || m_reader.getSuperTypeCount() == 0); //TODO
    2517         835 :     o << indent();
    2518         835 :     dumpTemplateHead(o);
    2519         835 :     o << "struct " << m_name;
    2520         835 :     rtl::OString base;
    2521         835 :     if (m_reader.getSuperTypeCount() != 0) {
    2522             :         base = rtl::OUStringToOString(
    2523         208 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    2524             :         OSL_ASSERT(!base.isEmpty()); //TODO
    2525             :     }
    2526         835 :     if (!base.isEmpty()) {
    2527         208 :         o << ": public " << scopedCppName(base);
    2528             :     }
    2529         835 :     o << " {\n";
    2530         835 :     inc();
    2531         835 :     o << indent() << "inline " << m_name << "() SAL_THROW(());\n";
    2532         835 :     sal_uInt16 members = m_reader.getFieldCount();
    2533         835 :     if (members > 0 || getInheritedMemberCount() > 0) {
    2534         835 :         o << "\n" << indent() << "inline " << m_name << "(";
    2535         835 :         bool prev = dumpSuperMember(o, base, true);
    2536        3724 :         for (sal_uInt16 i = 0; i < members; ++i) {
    2537        2889 :             if (prev) {
    2538        2262 :                 o << ", ";
    2539             :             }
    2540        2889 :             prev = true;
    2541             :             rtl::OString type(
    2542             :                 rtl::OUStringToOString(
    2543        2889 :                     m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
    2544        2889 :             if ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) != 0)
    2545             :             {
    2546          19 :                 dumpTypeParameterName(o, type);
    2547          19 :                 o << " const &";
    2548             :             } else {
    2549        2870 :                 dumpType(o, type, true, true);
    2550             :             }
    2551        2889 :             o << " "
    2552             :               << rtl::OUStringToOString(
    2553        8667 :                   m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8)
    2554        2889 :               << "_";
    2555        2889 :         }
    2556         835 :         o << ") SAL_THROW(());\n";
    2557             :     }
    2558         835 :     if (members > 0) {
    2559         835 :         o << "\n";
    2560        3724 :         for (sal_uInt16 i = 0; i < members; ++i) {
    2561        2889 :             o << indent();
    2562             :             bool parameterized
    2563        2889 :                 = ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE)
    2564        2889 :                    != 0);
    2565             :             rtl::OString type(
    2566             :                 rtl::OUStringToOString(
    2567        2889 :                     m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
    2568        2889 :             if (parameterized) {
    2569          19 :                 dumpTypeParameterName(o, type);
    2570             :             } else {
    2571        2870 :                 dumpType(o, type);
    2572             :             }
    2573        2889 :             o << " "
    2574             :                 << rtl::OUStringToOString(
    2575        5778 :                     m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    2576        3305 :             if (i == 0 && !base.isEmpty() && type != "double"
    2577         416 :                 && type != "hyper" && type != "unsigned hyper")
    2578             :             {
    2579             :                 OSL_ASSERT(!parameterized);
    2580         208 :                 o << " CPPU_GCC3_ALIGN(" << scopedCppName(base) << ")";
    2581             :             }
    2582        2889 :             o << ";\n";
    2583        2889 :         }
    2584             :     }
    2585         835 :     dec();
    2586         835 :     o << "};\n\n";
    2587             : 
    2588         835 :     o << "#ifdef SAL_W32\n"
    2589         835 :       << "#   pragma pack(pop)\n"
    2590         835 :       << "#endif\n\n";
    2591         835 : }
    2592             : 
    2593         835 : sal_Bool StructureType::dumpHxxFile(
    2594             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    2595             :     throw( CannotDumpException )
    2596             : {
    2597         835 :     OString headerDefine(dumpHeaderDefine(o, "HPP"));
    2598         835 :     o << "\n";
    2599             : 
    2600         835 :     includes.dump(o, &m_typeName);
    2601         835 :     o << "\n";
    2602             : 
    2603         835 :     if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
    2604         829 :         o << "\n";
    2605             :     }
    2606         835 :     o << "\n";
    2607             : 
    2608         835 :     dumpTemplateHead(o);
    2609         835 :     o << "inline " << m_name;
    2610         835 :     dumpTemplateParameters(o);
    2611         835 :     o << "::" << m_name << "() SAL_THROW(())\n";
    2612         835 :     inc();
    2613         835 :     OString superType;
    2614         835 :     if (m_reader.getSuperTypeCount() >= 1) {
    2615             :         superType = rtl::OUStringToOString(
    2616         208 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    2617             :     }
    2618         835 :     sal_Bool first = sal_True;
    2619         835 :     if (!superType.isEmpty())
    2620             :     {
    2621         208 :         o << indent() << ": " << scopedCppName(superType) << "()\n";
    2622         208 :         first = sal_False;
    2623             :     }
    2624             : 
    2625         835 :     sal_uInt16      fieldCount = m_reader.getFieldCount();
    2626         835 :     RTFieldAccess   access = RT_ACCESS_INVALID;
    2627         835 :     OString         fieldName;
    2628         835 :     OString         fieldType;
    2629             : 
    2630        3724 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    2631             :     {
    2632        2889 :         access = m_reader.getFieldFlags(i);
    2633             : 
    2634        2889 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    2635           0 :             continue;
    2636             : 
    2637             :         fieldName = rtl::OUStringToOString(
    2638        2889 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    2639             : 
    2640        2889 :         if (first)
    2641             :         {
    2642         627 :             first = sal_False;
    2643         627 :             o << indent() << ": ";
    2644             :         } else
    2645        2262 :             o << indent() << ", ";
    2646             : 
    2647        2889 :         o << fieldName;
    2648             :         dumpInitializer(
    2649             :             o, (access & RT_ACCESS_PARAMETERIZED_TYPE) != 0,
    2650        2889 :             m_reader.getFieldTypeName(i));
    2651        2889 :         o << "\n";
    2652             :     }
    2653         835 :     dec();
    2654         835 :     o << "{\n}\n\n";
    2655             : 
    2656         835 :     if (fieldCount > 0 || getInheritedMemberCount() > 0)
    2657             :     {
    2658         835 :         dumpTemplateHead(o);
    2659         835 :         o << "inline " << m_name;
    2660         835 :         dumpTemplateParameters(o);
    2661         835 :         o << "::" << m_name << "(";
    2662             : 
    2663         835 :         sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
    2664             : 
    2665        3724 :         for (sal_uInt16 i=0; i < fieldCount; i++)
    2666             :         {
    2667        2889 :             access = m_reader.getFieldFlags(i);
    2668             : 
    2669        2889 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    2670           0 :                 continue;
    2671             : 
    2672             :             fieldName = rtl::OUStringToOString(
    2673        2889 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    2674             :             fieldType = rtl::OUStringToOString(
    2675        2889 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    2676             : 
    2677        2889 :             if (superHasMember)
    2678        2262 :                 o << ", ";
    2679             :             else
    2680         627 :                 superHasMember = sal_True;
    2681             : 
    2682        2889 :             if ((access & RT_ACCESS_PARAMETERIZED_TYPE) != 0) {
    2683          19 :                 dumpTypeParameterName(o, fieldType);
    2684          19 :                 o << " const &";
    2685             :             } else {
    2686        2870 :                 dumpType(o, fieldType, sal_True, sal_True);
    2687             :             }
    2688        2889 :             o << " " << fieldName << "_";
    2689             :         }
    2690         835 :         o << ") SAL_THROW(())\n";
    2691             : 
    2692         835 :         inc();
    2693         835 :         first = sal_True;
    2694         835 :         if (!superType.isEmpty())
    2695             :         {
    2696         208 :             o << indent() << ": " << scopedCppName(superType) << "(";
    2697         208 :             dumpSuperMember(o, superType, sal_False);
    2698         208 :             o << ")\n";
    2699         208 :             first = sal_False;
    2700             :         }
    2701             : 
    2702        3724 :         for (sal_uInt16 i=0; i < fieldCount; i++)
    2703             :         {
    2704        2889 :             access = m_reader.getFieldFlags(i);
    2705             : 
    2706        2889 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    2707           0 :                 continue;
    2708             : 
    2709             :             fieldName = rtl::OUStringToOString(
    2710        2889 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    2711             : 
    2712        2889 :             if (first)
    2713             :             {
    2714         627 :                 first = sal_False;
    2715         627 :                 o << indent() << ": ";
    2716             :             } else
    2717        2262 :                 o << indent() << ", ";
    2718             : 
    2719        2889 :             o << fieldName << "(" << fieldName << "_)\n";
    2720             :         }
    2721             : 
    2722         835 :         dec();
    2723         835 :         o << "{\n}\n\n";
    2724             :     }
    2725             : 
    2726         835 :     if (isPolymorphic() && fieldCount > 0) {
    2727          16 :         o << indent();
    2728          16 :         dumpTemplateHead(o);
    2729          16 :         o << "\n";
    2730          16 :         o << indent();
    2731          16 :         o << "inline " << m_name;
    2732          16 :         dumpTemplateParameters(o);
    2733          16 :         o << "\n";
    2734          16 :         o << indent();
    2735          16 :         o << "make_" << m_name << "(";
    2736          46 :         for (sal_uInt16 i = 0; i < fieldCount; ++i) {
    2737          30 :             if (i > 0) {
    2738          14 :                 o << ", ";
    2739             :             }
    2740             :             rtl::OString type(
    2741             :                 rtl::OUStringToOString(
    2742          30 :                     m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
    2743          30 :             if ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) != 0)
    2744             :             {
    2745          19 :                 dumpTypeParameterName(o, type);
    2746          19 :                 o << " const &";
    2747             :             } else {
    2748          11 :                 dumpType(o, type, true, true);
    2749             :             }
    2750          30 :             o << " "
    2751             :               << rtl::OUStringToOString(
    2752          90 :                   m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8)
    2753          30 :               << "_";
    2754          30 :         }
    2755          16 :         o << ") SAL_THROW(())\n";
    2756          16 :         o << indent() << "{\n";
    2757          16 :         inc();
    2758          16 :         o << indent() << "return " << m_name;
    2759          16 :         dumpTemplateParameters(o);
    2760          16 :         o << "(";
    2761          46 :         for (sal_uInt16 i = 0; i < fieldCount; ++i) {
    2762          30 :             if (i > 0) {
    2763          14 :                 o << ", ";
    2764             :             }
    2765             :             o << rtl::OUStringToOString(
    2766          60 :                   m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8)
    2767          30 :               << "_";
    2768             :         }
    2769          16 :         o << ");\n";
    2770          16 :         dec();
    2771          16 :         o << indent() << "}\n\n";
    2772             :     }
    2773             : 
    2774         835 :     if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
    2775         829 :         o << "\n";
    2776             :     }
    2777             : 
    2778         835 :     o << "\n";
    2779         835 :     dumpGetCppuType(o);
    2780             : 
    2781         835 :     o << "\n#endif // "<< headerDefine << "\n";
    2782             : 
    2783         835 :     return sal_True;
    2784             : }
    2785             : 
    2786         397 : void StructureType::dumpLightGetCppuType(FileStream & out) {
    2787         397 :     dumpGetCppuTypePreamble(out);
    2788         794 :     out << indent()
    2789             :         << ("//TODO: On certain platforms with weak memory models, the"
    2790             :             " following code can result in some threads observing that the_type"
    2791         397 :             " points to garbage\n")
    2792        1191 :         << indent()
    2793         397 :         << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
    2794        1191 :         << indent() << "if (the_type == 0) {\n";
    2795         397 :     inc();
    2796         397 :     if (isPolymorphic()) {
    2797          12 :         out << indent() << "::rtl::OStringBuffer the_buffer(\""
    2798          18 :             << m_typeName.replace('/', '.') << "<\");\n";
    2799           6 :         sal_uInt16 n = m_reader.getReferenceCount();
    2800          14 :         for (sal_uInt16 i = 0; i < n; ++i) {
    2801          16 :             out << indent()
    2802             :                 << ("the_buffer.append(::rtl::OUStringToOString("
    2803           8 :                     "::cppu::getTypeFavourChar(static_cast< ");
    2804             :             dumpTypeParameterName(
    2805             :                 out,
    2806             :                 rtl::OUStringToOString(
    2807           8 :                     m_reader.getReferenceTypeName(i), RTL_TEXTENCODING_UTF8));
    2808           8 :             out << " * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));\n";
    2809           8 :             if (i != n - 1) {
    2810           2 :                 out << indent() << "the_buffer.append(',');\n";
    2811             :             }
    2812             :         }
    2813           6 :         out << indent() << "the_buffer.append('>');\n";
    2814             :     }
    2815         794 :     out << indent() << "::typelib_static_type_init(&the_type, "
    2816        1191 :         << getTypeClass(m_typeName, true) << ", ";
    2817         397 :     if (isPolymorphic()) {
    2818           6 :         out << "the_buffer.getStr()";
    2819             :     } else {
    2820         391 :         out << "\"" << m_typeName.replace('/', '.') << "\"";
    2821             :     }
    2822         397 :     out << ");\n";
    2823         397 :     dec();
    2824         794 :     out << indent() << "}\n" << indent()
    2825             :         << ("return *reinterpret_cast< ::com::sun::star::uno::Type * >("
    2826         397 :             "&the_type);\n");
    2827         397 :     dumpGetCppuTypePostamble(out);
    2828         397 : }
    2829             : 
    2830          36 : void StructureType::dumpNormalGetCppuType(FileStream & out) {
    2831          36 :     dumpGetCppuTypePreamble(out);
    2832          72 :     out << indent()
    2833             :         << ("//TODO: On certain platforms with weak memory models, the"
    2834             :             " following code can result in some threads observing that the_type"
    2835          36 :             " points to garbage\n")
    2836         108 :         << indent()
    2837          36 :         << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
    2838         108 :         << indent() << "if (the_type == 0) {\n";
    2839          36 :     inc();
    2840          36 :     if (isPolymorphic()) {
    2841           8 :         out << indent() << "::rtl::OStringBuffer the_buffer(\""
    2842          12 :             << m_typeName.replace('/', '.') << "<\");\n";
    2843           4 :         sal_uInt16 n = m_reader.getReferenceCount();
    2844           9 :         for (sal_uInt16 i = 0; i < n; ++i) {
    2845          10 :             out << indent()
    2846             :                 << ("the_buffer.append(::rtl::OUStringToOString("
    2847           5 :                     "::cppu::getTypeFavourChar(static_cast< ");
    2848             :             dumpTypeParameterName(
    2849             :                 out,
    2850             :                 rtl::OUStringToOString(
    2851           5 :                     m_reader.getReferenceTypeName(i), RTL_TEXTENCODING_UTF8));
    2852           5 :             out << " * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));\n";
    2853           5 :             if (i != n - 1) {
    2854           1 :                 out << indent() << "the_buffer.append(',');\n";
    2855             :             }
    2856             :         }
    2857           4 :         out << indent() << "the_buffer.append('>');\n";
    2858             :     }
    2859          72 :     out << indent()
    2860          36 :         << "::typelib_TypeDescriptionReference * the_members[] = {\n";
    2861          36 :     inc();
    2862          36 :     sal_uInt16 fields = m_reader.getFieldCount();
    2863         142 :     for (sal_uInt16 i = 0; i < fields; ++i) {
    2864         106 :         out << indent();
    2865             :         rtl::OString type(
    2866             :             rtl::OUStringToOString(
    2867         106 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
    2868         106 :         if ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) != 0) {
    2869           5 :             out << "::cppu::getTypeFavourChar(static_cast< ";
    2870           5 :             dumpTypeParameterName(out, type);
    2871           5 :             out << " * >(0))";
    2872             :         } else {
    2873         101 :             out << "::cppu::UnoType< ";
    2874         101 :             dumpType(out, type, false, false, false, true);
    2875         101 :             out << " >::get()";
    2876             :         }
    2877         106 :         out << ".getTypeLibType()" << (i == fields - 1 ? " };" : ",")
    2878         106 :             << "\n";
    2879         106 :     }
    2880          36 :     dec();
    2881          36 :     if (isPolymorphic()) {
    2882           8 :         out << indent()
    2883           4 :             << "static ::sal_Bool const the_parameterizedTypes[] = { ";
    2884          12 :         for (sal_uInt16 i = 0; i < fields; ++i) {
    2885           8 :             if (i != 0) {
    2886           4 :                 out << ", ";
    2887             :             }
    2888           8 :             out << (((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE)
    2889             :                      == 0)
    2890           8 :                     ? "false" : "true");
    2891             :         }
    2892           4 :         out << " };\n";
    2893             :     }
    2894          36 :     out << indent() << "::typelib_static_struct_type_init(&the_type, ";
    2895          36 :     if (isPolymorphic()) {
    2896           4 :         out << "the_buffer.getStr()";
    2897             :     } else {
    2898          32 :         out << "\"" << m_typeName.replace('/', '.') << "\"";
    2899             :     }
    2900          36 :     out << ", ";
    2901          36 :     if (m_reader.getSuperTypeCount() == 0) {
    2902          26 :         out << "0";
    2903             :     } else {
    2904          10 :         out << "::cppu::UnoType< ";
    2905             :         dumpType(
    2906             :             out,
    2907             :             rtl::OUStringToOString(
    2908             :                 m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8),
    2909          10 :             false, false, false, true);
    2910          10 :         out << " >::get().getTypeLibType()";
    2911             :     }
    2912          36 :     out << ", " << fields << ", the_members, "
    2913          72 :         << (isPolymorphic() ? "the_parameterizedTypes" : "0") << ");\n";
    2914          36 :     dec();
    2915          72 :     out << indent() << "}\n" << indent()
    2916             :         << ("return *reinterpret_cast< ::com::sun::star::uno::Type * >("
    2917          36 :             "&the_type);\n");
    2918          36 :     dumpGetCppuTypePostamble(out);
    2919          36 : }
    2920             : 
    2921         402 : void StructureType::dumpComprehensiveGetCppuType(FileStream & out)
    2922             : {
    2923         402 :     if (!isPolymorphic())
    2924         396 :         codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false);
    2925             :     else
    2926           6 :         out << "namespace cppu { ";
    2927         402 :     out << " namespace detail {\n\n";
    2928             : 
    2929         402 :     OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
    2930         402 :     OString sStaticTypeClass = "the" + sType + "Type";
    2931         402 :     out << indent();
    2932         402 :     if (isPolymorphic())
    2933           6 :         dumpTemplateHead(out);
    2934         402 :     out << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type *, ";
    2935         402 :     out << sStaticTypeClass;
    2936         402 :     if (isPolymorphic())
    2937           6 :         dumpTemplateParameters(out);
    2938         402 :     out << " >\n";
    2939             : 
    2940         402 :     out << indent() << "{\n";
    2941         402 :     inc();
    2942         402 :     out << indent() << "::com::sun::star::uno::Type * operator()() const\n";
    2943         402 :     out << indent() << "{\n";
    2944             : 
    2945         402 :     inc();
    2946         402 :     if (isPolymorphic()) {
    2947          12 :         out << indent() << "::rtl::OUStringBuffer the_buffer;\n" << indent()
    2948           6 :             << "the_buffer.appendAscii(RTL_CONSTASCII_STRINGPARAM(\""
    2949          18 :             << m_typeName.replace('/', '.') << "<\"));\n";
    2950           6 :         sal_uInt16 n = m_reader.getReferenceCount();
    2951          14 :         for (sal_uInt16 i = 0; i < n; ++i) {
    2952          16 :             out << indent()
    2953           8 :                 << "the_buffer.append(::cppu::getTypeFavourChar(static_cast< ";
    2954             :             dumpTypeParameterName(
    2955             :                 out,
    2956             :                 rtl::OUStringToOString(
    2957           8 :                     m_reader.getReferenceTypeName(i), RTL_TEXTENCODING_UTF8));
    2958           8 :             out << " * >(0)).getTypeName());\n";
    2959           8 :             if (i != n - 1) {
    2960           4 :                 out << indent()
    2961             :                     << ("the_buffer.append("
    2962           2 :                         "static_cast< ::sal_Unicode >(','));\n");
    2963             :             }
    2964             :         }
    2965          12 :         out << indent()
    2966           6 :             << "the_buffer.append(static_cast< ::sal_Unicode >('>'));\n"
    2967          18 :             << indent()
    2968           6 :             << "::rtl::OUString the_name(the_buffer.makeStringAndClear());\n";
    2969             :     } else {
    2970         792 :         out << indent()
    2971         396 :             << "::rtl::OUString the_name( \""
    2972        1188 :             << m_typeName.replace('/', '.') << "\" );\n";
    2973             :     }
    2974         402 :     sal_uInt16 fields = m_reader.getFieldCount();
    2975             :     typedef std::map< rtl::OString, sal_uInt32 > Map;
    2976         402 :     Map parameters;
    2977         402 :     Map types;
    2978        1794 :     {for (sal_uInt16 i = 0; i < fields; ++i) {
    2979             :         rtl::OString type(
    2980             :             rtl::OUStringToOString(
    2981        1392 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
    2982        1392 :         if ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) != 0) {
    2983          12 :             if (parameters.insert(
    2984             :                     Map::value_type(
    2985          12 :                         type, static_cast< sal_uInt32 >(parameters.size()))).
    2986             :                 second)
    2987             :             {
    2988           6 :                 sal_uInt32 n = static_cast< sal_uInt32 >(parameters.size() - 1);
    2989          12 :                 out << indent()
    2990           6 :                     << "::com::sun::star::uno::Type const & the_ptype" << n
    2991           6 :                     << " = ::cppu::getTypeFavourChar(static_cast< ";
    2992           6 :                 dumpTypeParameterName(out, type);
    2993          12 :                 out << " * >(0));\n" << indent()
    2994           6 :                     << "::typelib_TypeClass the_pclass" << n
    2995           6 :                     << " = (::typelib_TypeClass) the_ptype" << n
    2996          18 :                     << ".getTypeClass();\n" << indent()
    2997           6 :                     << "::rtl::OUString the_pname" << n << "(the_ptype" << n
    2998           6 :                     << ".getTypeName());\n";
    2999             :             }
    3000        2772 :         } else if (types.insert(
    3001             :                        Map::value_type(
    3002        2772 :                            type, static_cast< sal_uInt32 >(types.size()))).
    3003             :                    second)
    3004             :         {
    3005        2176 :             if ((codemaker::UnoType::getSort(type) ==
    3006             :                  codemaker::UnoType::SORT_COMPLEX) &&
    3007        1348 :                 codemaker::UnoType::decompose(type) != m_typeName)
    3008             :                     // take care of recursion like struct S { sequence<S> x; };
    3009             :             {
    3010         259 :                 out << indent() << "::cppu::UnoType< ";
    3011         259 :                 dumpType(out, type, false, false, false, true);
    3012         259 :                 out << " >::get();\n";
    3013             :             }
    3014             :             // For typedefs, use the resolved type name, as there will be no
    3015             :             // information available about the typedef itself at runtime (the
    3016             :             // above getCppuType call will make available information about the
    3017             :             // resolved type); no extra #include for the resolved type is
    3018             :             // needed, as the header for the typedef includes it already:
    3019        1656 :             out << indent() << "::rtl::OUString the_tname"
    3020        1656 :                 << static_cast< sal_uInt32 >(types.size() - 1)
    3021         828 :                 << "( \""
    3022        2484 :                 << checkRealBaseType(type, true).replace('/', '.') << "\" );\n";
    3023             :         }
    3024        2784 :         out << indent() << "::rtl::OUString the_name" << i
    3025        1392 :             << "( \""
    3026             :             << rtl::OUStringToOString(
    3027             :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8).replace(
    3028        4176 :                     '/', '.')
    3029        1392 :             << "\" );\n";
    3030        1392 :     }}
    3031         402 :     out << indent() << "::typelib_StructMember_Init the_members[] = {\n";
    3032         402 :     inc();
    3033        1794 :     {for (sal_uInt16 i = 0; i < fields; ++i) {
    3034        1392 :         out << indent() << "{ { ";
    3035             :         rtl::OString type(
    3036             :             rtl::OUStringToOString(
    3037        1392 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8));
    3038        1392 :         if ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) != 0) {
    3039           6 :             sal_uInt32 n = parameters.find(type)->second;
    3040           6 :             out << "the_pclass" << n << ", the_pname" << n << ".pData";
    3041             :         } else {
    3042        2772 :             out << getTypeClass(type, true) << ", the_tname"
    3043        4158 :                 << types.find(type)->second << ".pData";
    3044             :         }
    3045        1392 :         out << ", the_name" << i << ".pData }, "
    3046        1392 :             << ((m_reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) == 0
    3047        2784 :                 ? "false" : "true")
    3048        2784 :             << " }" << (i == fields - 1 ? " };" : ",") << "\n";
    3049        1392 :     }}
    3050         402 :     dec();
    3051         402 :     out << indent() << "::typelib_TypeDescription * the_newType = 0;\n";
    3052         804 :     out << indent()
    3053         402 :         << "::typelib_typedescription_newStruct(&the_newType, the_name.pData, ";
    3054         402 :     if (m_reader.getSuperTypeCount() == 0) {
    3055         303 :         out << "0";
    3056             :     } else {
    3057          99 :         out << "::cppu::UnoType< ";
    3058             :         dumpType(
    3059             :             out,
    3060             :             rtl::OUStringToOString(
    3061             :                 m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8),
    3062          99 :             false, false, false, true);
    3063          99 :         out << " >::get().getTypeLibType()";
    3064             :     }
    3065         402 :     out << ", " << fields << ", the_members);\n";
    3066         402 :     out << indent() << "::typelib_typedescription_register(&the_newType);\n";
    3067         402 :     out << indent() << "::typelib_typedescription_release(the_newType);\n";
    3068             : 
    3069         804 :     out << indent() << "return new ::com::sun::star::uno::Type("
    3070        1206 :         << getTypeClass(m_typeName) << ", the_name); // leaked\n";
    3071         402 :     dec();
    3072         402 :     out << indent() << "}\n";
    3073         402 :     dec();
    3074         402 :     out << indent() << "};\n";
    3075             : 
    3076         402 :     if (!isPolymorphic())
    3077         396 :         codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false);
    3078             :     else
    3079           6 :         out << " }";
    3080         402 :     out << " }\n\n";
    3081             : 
    3082         402 :     dumpGetCppuTypePreamble(out);
    3083         402 :     out  << indent() << "return *detail::" << sStaticTypeClass;
    3084         402 :     if (isPolymorphic())
    3085           6 :         dumpTemplateParameters(out);
    3086         402 :     out  << "::get();\n";
    3087         402 :     dumpGetCppuTypePostamble(out);
    3088         402 : }
    3089             : 
    3090        2595 : sal_Bool StructureType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType)
    3091             : {
    3092        2595 :     sal_Bool hasMember = sal_False;
    3093             : 
    3094        2595 :     if (!superType.isEmpty())
    3095             :     {
    3096         717 :         typereg::Reader aSuperReader(m_typeMgr.getTypeReader(superType));
    3097             : 
    3098         717 :         if (aSuperReader.isValid())
    3099             :         {
    3100         717 :             rtl::OString superSuper;
    3101         717 :             if (aSuperReader.getSuperTypeCount() >= 1) {
    3102             :                 superSuper = rtl::OUStringToOString(
    3103          93 :                     aSuperReader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    3104             :             }
    3105         717 :             hasMember = dumpSuperMember(o, superSuper, bWithType);
    3106             : 
    3107         717 :             sal_uInt16      fieldCount = aSuperReader.getFieldCount();
    3108         717 :             RTFieldAccess   access = RT_ACCESS_INVALID;
    3109         717 :             OString         fieldName;
    3110         717 :             OString         fieldType;
    3111        1842 :             for (sal_uInt16 i=0; i < fieldCount; i++)
    3112             :             {
    3113        1125 :                 access = aSuperReader.getFieldFlags(i);
    3114             : 
    3115        1125 :                 if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3116           0 :                     continue;
    3117             : 
    3118             :                 fieldName = rtl::OUStringToOString(
    3119        1125 :                     aSuperReader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3120             :                 fieldType = rtl::OUStringToOString(
    3121        1125 :                     aSuperReader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    3122             : 
    3123        1125 :                 if (hasMember)
    3124             :                 {
    3125         501 :                     o << ", ";
    3126             :                 } else
    3127             :                 {
    3128         624 :                     hasMember = (fieldCount > 0);
    3129             :                 }
    3130             : 
    3131        1125 :                 if (bWithType)
    3132             :                 {
    3133         750 :                     dumpType(o, fieldType, sal_True, sal_True);
    3134         750 :                     o << " ";
    3135             :                 }
    3136        1125 :                 o << fieldName << "_";
    3137         717 :             }
    3138         717 :         }
    3139             :     }
    3140             : 
    3141        2595 :     return hasMember;
    3142             : }
    3143             : 
    3144         397 : void StructureType::addLightGetCppuTypeIncludes(
    3145             :     codemaker::cppumaker::Includes & includes) const
    3146             : {
    3147         397 :     includes.addType();
    3148         397 :     includes.addCppuUnotypeHxx();
    3149         397 :     includes.addSalTypesH();
    3150         397 :     includes.addTypelibTypeclassH();
    3151         397 :     includes.addTypelibTypedescriptionH();
    3152         397 :     if (isPolymorphic()) {
    3153           6 :         includes.addRtlStrbufHxx();
    3154           6 :         includes.addRtlTextencH();
    3155           6 :         includes.addRtlUstringHxx();
    3156             :     }
    3157         397 : }
    3158             : 
    3159          36 : void StructureType::addNormalGetCppuTypeIncludes(
    3160             :     codemaker::cppumaker::Includes & includes) const
    3161             : {
    3162          36 :     includes.addType();
    3163          36 :     includes.addCppuUnotypeHxx();
    3164          36 :     includes.addSalTypesH();
    3165          36 :     includes.addTypelibTypeclassH();
    3166          36 :     includes.addTypelibTypedescriptionH();
    3167          36 :     if (isPolymorphic()) {
    3168           4 :         includes.addRtlStrbufHxx();
    3169           4 :         includes.addRtlTextencH();
    3170           4 :         includes.addRtlUstringHxx();
    3171             :     }
    3172          36 : }
    3173             : 
    3174         402 : void StructureType::addComprehensiveGetCppuTypeIncludes(
    3175             :     codemaker::cppumaker::Includes & includes) const
    3176             : {
    3177         402 :     includes.addType();
    3178         402 :     includes.addCppuUnotypeHxx();
    3179         402 :     includes.addRtlInstanceHxx();
    3180         402 :     includes.addOslMutexHxx();
    3181         402 :     includes.addRtlUstringH();
    3182         402 :     includes.addRtlUstringHxx();
    3183         402 :     includes.addSalTypesH();
    3184         402 :     includes.addTypelibTypeclassH();
    3185         402 :     includes.addTypelibTypedescriptionH();
    3186         402 :     if (isPolymorphic()) {
    3187           6 :         includes.addRtlStringH();
    3188           6 :         includes.addRtlUstrbufHxx();
    3189             :     }
    3190         402 : }
    3191             : 
    3192       15973 : bool StructureType::isPolymorphic() const {
    3193       15973 :     return m_reader.getReferenceCount() > 0;
    3194             : }
    3195             : 
    3196        4213 : void StructureType::dumpTemplateHead(FileStream & out) const {
    3197        4213 :     if (isPolymorphic()) {
    3198         118 :         out << "template< ";
    3199         273 :         for (sal_uInt16 i = 0; i < m_reader.getReferenceCount(); ++i) {
    3200         155 :             if (i != 0) {
    3201          37 :                 out << ", ";
    3202             :             }
    3203             :             OSL_ASSERT(
    3204             :                 m_reader.getReferenceFlags(i) == RT_ACCESS_INVALID
    3205             :                 && m_reader.getReferenceSort(i) == RT_REF_TYPE_PARAMETER);
    3206         155 :             out << "typename ";
    3207             :             dumpTypeParameterName(
    3208             :                 out,
    3209             :                 rtl::OUStringToOString(
    3210         155 :                     m_reader.getReferenceTypeName(i), RTL_TEXTENCODING_UTF8));
    3211             :         }
    3212         118 :         out << " > ";
    3213             :     }
    3214        4213 : }
    3215             : 
    3216        4235 : void StructureType::dumpTemplateParameters(FileStream & out) const {
    3217        4235 :     if (isPolymorphic()) {
    3218         140 :         out << "< ";
    3219         324 :         for (sal_uInt16 i = 0; i < m_reader.getReferenceCount(); ++i) {
    3220         184 :             if (i != 0) {
    3221          44 :                 out << ", ";
    3222             :             }
    3223             :             OSL_ASSERT(
    3224             :                 m_reader.getReferenceFlags(i) == RT_ACCESS_INVALID
    3225             :                 && m_reader.getReferenceSort(i) == RT_REF_TYPE_PARAMETER);
    3226             :             dumpTypeParameterName(
    3227             :                 out,
    3228             :                 rtl::OUStringToOString(
    3229         184 :                     m_reader.getReferenceTypeName(i), RTL_TEXTENCODING_UTF8));
    3230             :         }
    3231         140 :         out << " >";
    3232             :     }
    3233        4235 : }
    3234             : 
    3235             : //*************************************************************************
    3236             : // ExceptionType
    3237             : //*************************************************************************
    3238         557 : ExceptionType::ExceptionType(typereg::Reader& typeReader,
    3239             :                               const OString& typeName,
    3240             :                              const TypeManager& typeMgr)
    3241         557 :     : CppuType(typeReader, typeName, typeMgr)
    3242             : {
    3243         557 : }
    3244             : 
    3245         557 : ExceptionType::~ExceptionType()
    3246             : {
    3247             : 
    3248         557 : }
    3249             : 
    3250         557 : sal_Bool ExceptionType::dumpHFile(
    3251             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    3252             :     throw( CannotDumpException )
    3253             : {
    3254         557 :     dumpHFileContent(o, includes);
    3255         557 :     return sal_True;
    3256             : }
    3257             : 
    3258         557 : void ExceptionType::dumpDeclaration(FileStream& o)
    3259             :     throw( CannotDumpException )
    3260             : {
    3261         557 :     o << "\nclass CPPU_GCC_DLLPUBLIC_EXPORT " << m_name;
    3262             : 
    3263         557 :     OString superType;
    3264         557 :     if (m_reader.getSuperTypeCount() >= 1) {
    3265             :         superType = rtl::OUStringToOString(
    3266         554 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    3267             :     }
    3268         557 :     if (!superType.isEmpty())
    3269         554 :                     o << " : public " << scopedCppName(superType);
    3270             : 
    3271         557 :     o << "\n{\npublic:\n";
    3272         557 :     inc();
    3273        1114 :     o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name
    3274         557 :       << "() SAL_THROW(());\n\n";
    3275             : 
    3276         557 :     sal_uInt16      fieldCount = m_reader.getFieldCount();
    3277         557 :     RTFieldAccess   access = RT_ACCESS_INVALID;
    3278         557 :     OString         fieldName;
    3279         557 :     OString         fieldType;
    3280         557 :     sal_uInt16      i = 0;
    3281             : 
    3282         557 :     if (fieldCount > 0 || getInheritedMemberCount() > 0)
    3283             :     {
    3284         557 :         o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name << "(";
    3285             : 
    3286         557 :         sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
    3287             : 
    3288         887 :         for (i=0; i < fieldCount; i++)
    3289             :         {
    3290         330 :             access = m_reader.getFieldFlags(i);
    3291             : 
    3292         330 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3293           0 :                             continue;
    3294             : 
    3295             :             fieldName = rtl::OUStringToOString(
    3296         330 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3297             :             fieldType = rtl::OUStringToOString(
    3298         330 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    3299             : 
    3300         330 :             if (superHasMember)
    3301         327 :                 o << ", ";
    3302             :             else
    3303           3 :                 superHasMember = sal_True;
    3304             : 
    3305         330 :             dumpType(o, fieldType, sal_True, sal_True);
    3306         330 :             o << " " << fieldName << "_";
    3307             :         }
    3308         557 :         o << ") SAL_THROW(());\n\n";
    3309             :     }
    3310        1114 :     o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name << "(" << m_name
    3311         557 :       << " const &);\n\n"
    3312        1671 :       << indent() << "inline CPPU_GCC_DLLPRIVATE ~" << m_name << "();\n\n"
    3313        1671 :       << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name << " & operator =("
    3314        1114 :       << m_name << " const &);\n\n";
    3315             : 
    3316         887 :     for (i=0; i < fieldCount; i++)
    3317             :     {
    3318         330 :         access = m_reader.getFieldFlags(i);
    3319             : 
    3320         330 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3321           0 :             continue;
    3322             : 
    3323             :         fieldName = rtl::OUStringToOString(
    3324         330 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3325             :         fieldType = rtl::OUStringToOString(
    3326         330 :             m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    3327             : 
    3328         330 :         o << indent();
    3329         330 :         dumpType(o, fieldType);
    3330         330 :         o << " " << fieldName;
    3331        1872 :         if (i == 0 && !superType.isEmpty() &&
    3332        1542 :             !fieldType.equals("double") && !fieldType.equals("hyper") && !fieldType.equals("unsigned hyper"))
    3333             :         {
    3334         202 :             o << " CPPU_GCC3_ALIGN( " << scopedCppName(superType) << " )";
    3335             :         }
    3336         330 :         o << ";\n";
    3337             :     }
    3338             : 
    3339             : 
    3340         557 :     dec();
    3341         557 :     o << "};\n\n";
    3342         557 : }
    3343             : 
    3344         557 : sal_Bool ExceptionType::dumpHxxFile(
    3345             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    3346             :     throw( CannotDumpException )
    3347             : {
    3348         557 :     OString headerDefine(dumpHeaderDefine(o, "HPP"));
    3349         557 :     o << "\n";
    3350             : 
    3351         557 :     addDefaultHxxIncludes(includes);
    3352         557 :     includes.dump(o, &m_typeName);
    3353         557 :     o << "\n";
    3354             : 
    3355         557 :     if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
    3356         553 :         o << "\n";
    3357             :     }
    3358         557 :     o << "\n";
    3359             : 
    3360         557 :     o << "inline " << m_name << "::" << m_name << "() SAL_THROW(())\n";
    3361         557 :     inc();
    3362         557 :     OString superType;
    3363         557 :     if (m_reader.getSuperTypeCount() >= 1) {
    3364             :         superType = rtl::OUStringToOString(
    3365         554 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    3366             :     }
    3367         557 :     sal_Bool first = sal_True;
    3368         557 :     if (!superType.isEmpty())
    3369             :     {
    3370         554 :         o << indent() << ": " << scopedCppName(superType) << "()\n";
    3371         554 :         first = sal_False;
    3372             :     }
    3373             : 
    3374         557 :     sal_uInt16      fieldCount = m_reader.getFieldCount();
    3375         557 :     RTFieldAccess   access = RT_ACCESS_INVALID;
    3376         557 :     OString         fieldName;
    3377         557 :     OString         fieldType;
    3378             : 
    3379         887 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    3380             :     {
    3381         330 :         access = m_reader.getFieldFlags(i);
    3382             : 
    3383         330 :         if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3384           0 :             continue;
    3385             : 
    3386             :         fieldName = rtl::OUStringToOString(
    3387         330 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3388             : 
    3389         330 :         if (first)
    3390             :         {
    3391           3 :             first = sal_False;
    3392           3 :             o << indent() << ": ";
    3393             :         } else
    3394         327 :             o << indent() << ", ";
    3395             : 
    3396         330 :         o << fieldName;
    3397         330 :         dumpInitializer(o, false, m_reader.getFieldTypeName(i));
    3398         330 :         o << "\n";
    3399             :     }
    3400         557 :     dec();
    3401         557 :     if ( !m_cppuTypeDynamic )
    3402             :     {
    3403         259 :         o << "{\n";
    3404         259 :         inc();
    3405         259 :         dumpCppuGetType(o, m_typeName, sal_True);
    3406         259 :         dec();
    3407         259 :         o << "}\n\n";
    3408             :     } else
    3409             :     {
    3410         298 :         o << "{ }\n\n";
    3411             :     }
    3412             : 
    3413         557 :     if (fieldCount > 0 || getInheritedMemberCount() > 0)
    3414             :     {
    3415         557 :         o << indent() << "inline " << m_name << "::" << m_name << "(";
    3416             : 
    3417         557 :         sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
    3418             : 
    3419         887 :         for (sal_uInt16 i=0; i < fieldCount; i++)
    3420             :         {
    3421         330 :             access = m_reader.getFieldFlags(i);
    3422             : 
    3423         330 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3424           0 :                 continue;
    3425             : 
    3426             :             fieldName = rtl::OUStringToOString(
    3427         330 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3428             :             fieldType = rtl::OUStringToOString(
    3429         330 :                 m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    3430             : 
    3431         330 :             if (superHasMember)
    3432         327 :                 o << ", ";
    3433             :             else
    3434           3 :                 superHasMember = sal_True;
    3435             : 
    3436         330 :             dumpType(o, fieldType, sal_True, sal_True);
    3437         330 :             o << " " << fieldName << "_";
    3438             :         }
    3439         557 :         o << ") SAL_THROW(())\n";
    3440             : 
    3441         557 :         inc();
    3442         557 :         first = sal_True;
    3443         557 :         if (!superType.isEmpty())
    3444             :         {
    3445         554 :             o << indent() << ": " << scopedCppName(superType) << "(";
    3446         554 :             dumpSuperMember(o, superType, sal_False);
    3447         554 :             o << ")\n";
    3448         554 :             first = sal_False;
    3449             :         }
    3450             : 
    3451         887 :         for (sal_uInt16 i=0; i < fieldCount; i++)
    3452             :         {
    3453         330 :             access = m_reader.getFieldFlags(i);
    3454             : 
    3455         330 :             if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3456           0 :                 continue;
    3457             : 
    3458             :             fieldName = rtl::OUStringToOString(
    3459         330 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3460             : 
    3461         330 :             if (first)
    3462             :             {
    3463           3 :                 first = sal_False;
    3464           3 :                 o << indent() << ": ";
    3465             :             } else
    3466         327 :                 o << indent() << ", ";
    3467             : 
    3468         330 :             o << fieldName << "(" << fieldName << "_)\n";
    3469             :         }
    3470             : 
    3471         557 :         dec();
    3472         557 :         if ( !m_cppuTypeDynamic )
    3473             :         {
    3474         259 :             o << "{\n";
    3475         259 :             inc();
    3476         259 :             dumpCppuGetType(o, m_typeName, sal_True);
    3477         259 :             dec();
    3478         259 :             o << "}\n\n";
    3479             :         } else
    3480             :         {
    3481         298 :             o << "{ }\n\n";
    3482             :         }
    3483             :     }
    3484        1114 :     o << indent() << m_name << "::" << m_name << "(" << m_name
    3485         557 :       << " const & the_other)";
    3486         557 :     first = true;
    3487         557 :     if (!superType.isEmpty()) {
    3488         554 :         o << ": " << scopedCppName(superType) << "(the_other)";
    3489         554 :         first = false;
    3490             :     }
    3491         887 :     for (sal_uInt16 i = 0; i < fieldCount; ++i) {
    3492             :         rtl::OString name(
    3493             :             rtl::OUStringToOString(
    3494         330 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8));
    3495         330 :         o << (first ? ": " : ", ") << name << "(the_other." << name << ")";
    3496         330 :         first = false;
    3497         330 :     }
    3498        1114 :     o << indent() << " {}\n\n"
    3499        1671 :       << indent() << m_name << "::~" << m_name << "() {}\n\n"
    3500        1671 :       << indent() << m_name << " & " << m_name << "::operator =(" << m_name
    3501         557 :       << " const & the_other) {\n";
    3502         557 :     inc();
    3503        1114 :     o << indent()
    3504             :       << ("//TODO: Just like its implicitly-defined counterpart, this function"
    3505         557 :           " definition is not exception-safe\n");
    3506         557 :     if (!superType.isEmpty()) {
    3507        1108 :         o << indent() << scopedCppName(superType)
    3508         554 :           << "::operator =(the_other);\n";
    3509             :     }
    3510         887 :     for (sal_uInt16 i = 0; i < fieldCount; ++i) {
    3511             :         rtl::OString name(
    3512             :             rtl::OUStringToOString(
    3513         330 :                 m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8));
    3514         330 :         o << indent() << name << " = the_other." << name << ";\n";
    3515         330 :     }
    3516         557 :     o << indent() << "return *this;\n";
    3517         557 :     dec();
    3518         557 :     o << indent() << "}\n\n";
    3519             : 
    3520         557 :     if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
    3521         553 :         o << "\n";
    3522             :     }
    3523             : 
    3524         557 :     o << "\n";
    3525         557 :     dumpGetCppuType(o);
    3526             : 
    3527         557 :     o << "\n#endif // "<< headerDefine << "\n";
    3528         557 :     return sal_True;
    3529             : }
    3530             : 
    3531        4524 : sal_Bool ExceptionType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType)
    3532             : {
    3533        4524 :     sal_Bool hasMember = sal_False;
    3534             : 
    3535        4524 :     if (!superType.isEmpty())
    3536             :     {
    3537        2856 :         typereg::Reader aSuperReader(m_typeMgr.getTypeReader(superType));
    3538             : 
    3539        2856 :         if (aSuperReader.isValid())
    3540             :         {
    3541        2856 :             rtl::OString superSuper;
    3542        2856 :             if (aSuperReader.getSuperTypeCount() >= 1) {
    3543             :                 superSuper = rtl::OUStringToOString(
    3544        1194 :                     aSuperReader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
    3545             :             }
    3546        2856 :             hasMember = dumpSuperMember(o, superSuper, bWithType);
    3547             : 
    3548        2856 :             sal_uInt16      fieldCount = aSuperReader.getFieldCount();
    3549        2856 :             RTFieldAccess   access = RT_ACCESS_INVALID;
    3550        2856 :             OString         fieldName;
    3551        2856 :             OString         fieldType;
    3552        6729 :             for (sal_uInt16 i=0; i < fieldCount; i++)
    3553             :             {
    3554        3873 :                 access = aSuperReader.getFieldFlags(i);
    3555             : 
    3556        3873 :                 if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
    3557           0 :                     continue;
    3558             : 
    3559             :                 fieldName = rtl::OUStringToOString(
    3560        3873 :                     aSuperReader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3561             :                 fieldType = rtl::OUStringToOString(
    3562        3873 :                     aSuperReader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
    3563             : 
    3564        3873 :                 if (hasMember)
    3565             :                 {
    3566        2211 :                     o << ", ";
    3567             :                 } else
    3568             :                 {
    3569        1662 :                     hasMember = (fieldCount > 0);
    3570             :                 }
    3571             : 
    3572        3873 :                 if (bWithType)
    3573             :                 {
    3574        2582 :                     dumpType(o, fieldType, sal_True, sal_True);
    3575        2582 :                     o << " ";
    3576             :                 }
    3577        3873 :                 o << fieldName << "_";
    3578        2856 :             }
    3579        2856 :         }
    3580             :     }
    3581             : 
    3582        4524 :     return hasMember;
    3583             : }
    3584             : 
    3585             : //*************************************************************************
    3586             : // EnumType
    3587             : //*************************************************************************
    3588         397 : EnumType::EnumType(typereg::Reader& typeReader,
    3589             :                     const OString& typeName,
    3590             :                    const TypeManager& typeMgr)
    3591         397 :     : CppuType(typeReader, typeName, typeMgr)
    3592             : {
    3593         397 : }
    3594             : 
    3595         397 : EnumType::~EnumType()
    3596             : {
    3597             : 
    3598         397 : }
    3599             : 
    3600         397 : sal_Bool EnumType::dumpHFile(
    3601             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    3602             :     throw( CannotDumpException )
    3603             : {
    3604         397 :     dumpHFileContent(o, includes);
    3605         397 :     return sal_True;
    3606             : }
    3607             : 
    3608         397 : void EnumType::dumpDeclaration(FileStream& o)
    3609             :     throw( CannotDumpException )
    3610             : {
    3611         397 :     o << "\nenum " << m_name << "\n{\n";
    3612         397 :     inc();
    3613             : 
    3614         397 :     sal_uInt16      fieldCount = m_reader.getFieldCount();
    3615         397 :     RTFieldAccess   access = RT_ACCESS_INVALID;
    3616         397 :     RTConstValue    constValue;
    3617         397 :     OString         fieldName;
    3618         397 :     sal_Int32       value=0;
    3619        3080 :     for (sal_uInt16 i=0; i < fieldCount; i++)
    3620             :     {
    3621        2683 :         access = m_reader.getFieldFlags(i);
    3622             : 
    3623        2683 :         if (access != RT_ACCESS_CONST)
    3624           0 :             continue;
    3625             : 
    3626             :         fieldName = rtl::OUStringToOString(
    3627        2683 :             m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8);
    3628        2683 :         constValue = m_reader.getFieldValue(i);
    3629             : 
    3630        2683 :         if (constValue.m_type == RT_TYPE_INT32)
    3631        2683 :             value = constValue.m_value.aLong;
    3632             :         else
    3633           0 :             value++;
    3634             : 
    3635        2683 :         o << indent() << m_name << "_" << fieldName << " = " << value << ",\n";
    3636             :     }
    3637             : 
    3638         397 :     o << indent() << m_name << "_MAKE_FIXED_SIZE = SAL_MAX_ENUM\n";
    3639             : 
    3640         397 :     dec();
    3641         397 :     o << "};\n\n";
    3642         397 : }
    3643             : 
    3644         397 : sal_Bool EnumType::dumpHxxFile(
    3645             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    3646             :     throw( CannotDumpException )
    3647             : {
    3648         397 :     OString headerDefine(dumpHeaderDefine(o, "HPP"));
    3649         397 :     o << "\n";
    3650             : 
    3651         397 :     addDefaultHxxIncludes(includes);
    3652         397 :     includes.dump(o, &m_typeName);
    3653         397 :     o << "\n";
    3654             : 
    3655         397 :     dumpGetCppuType(o);
    3656             : 
    3657         397 :     o << "\n#endif // "<< headerDefine << "\n";
    3658         397 :     return sal_True;
    3659             : }
    3660             : 
    3661          12 : void EnumType::dumpNormalGetCppuType(FileStream& o)
    3662             : {
    3663          12 :     dumpGetCppuTypePreamble(o);
    3664             : 
    3665          24 :     o << indent()
    3666          12 :       << "static typelib_TypeDescriptionReference * the_type = 0;\n";
    3667             : 
    3668          12 :     o << indent() << "if ( !the_type )\n" << indent() << "{\n";
    3669          12 :     inc();
    3670             : 
    3671          12 :     o << indent() << "typelib_static_enum_type_init( &the_type,\n";
    3672          12 :     inc(31);
    3673          24 :     o << indent() << "\"" << m_typeName.replace('/', '.') << "\",\n"
    3674          36 :       << indent() << scopedCppName(m_typeName) << "_"
    3675          36 :       << rtl::OUStringToOString(m_reader.getFieldName(0), RTL_TEXTENCODING_UTF8)
    3676          12 :       << " );\n";
    3677          12 :     dec(31);
    3678          12 :     dec();
    3679          12 :     o << indent() << "}\n";
    3680          24 :     o << indent()
    3681             :       << ("return * reinterpret_cast< ::com::sun::star::uno::Type * >("
    3682          12 :           " &the_type );\n");
    3683          12 :     dumpGetCppuTypePostamble(o);
    3684          12 : }
    3685             : 
    3686         193 : void EnumType::dumpComprehensiveGetCppuType(FileStream& o)
    3687             : {
    3688         193 :     if (!isPolymorphic())
    3689         193 :         codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false);
    3690             :     else
    3691           0 :         o << "namespace cppu { ";
    3692         193 :     o << " namespace detail {\n\n";
    3693             : 
    3694         193 :     OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
    3695         193 :     OString sStaticTypeClass = "the" + sType + "Type";
    3696         193 :     o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type *, " << sStaticTypeClass << " >\n";
    3697         193 :     o << indent() << "{\n";
    3698         193 :     inc();
    3699         193 :     o << indent() << "::com::sun::star::uno::Type * operator()() const\n";
    3700         193 :     o << indent() << "{\n";
    3701             : 
    3702         193 :     inc();
    3703         386 :     o << indent() << "::rtl::OUString sTypeName( \""
    3704         579 :       << m_typeName.replace('/', '.') << "\" );\n\n";
    3705             : 
    3706         386 :     o << indent() << "// Start inline typedescription generation\n"
    3707         579 :       << indent() << "typelib_TypeDescription * pTD = 0;\n\n";
    3708             : 
    3709         193 :     sal_uInt16 count = m_reader.getFieldCount();
    3710         193 :     o << indent() << "rtl_uString* enumValueNames[" << count << "];\n";
    3711             :     sal_uInt16 i;
    3712        1498 :     for (i = 0; i < count; i++)
    3713             :     {
    3714        2610 :         o << indent() << "::rtl::OUString sEnumValue" << i
    3715        1305 :           << "( \""
    3716             :           << rtl::OUStringToOString(
    3717        3915 :               m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8)
    3718        1305 :           << "\" );\n";
    3719        2610 :         o << indent() << "enumValueNames[" << i << "] = sEnumValue" << i
    3720        1305 :           << ".pData;\n";
    3721             :     }
    3722             : 
    3723         193 :     o << "\n" << indent() << "sal_Int32 enumValues[" << count << "];\n";
    3724         193 :     RTConstValue    constValue;
    3725         193 :     sal_Int32       value=0;
    3726        1498 :     for (i = 0; i < count; i++)
    3727             :     {
    3728        1305 :         o << indent() << "enumValues[" << i << "] = ";
    3729        1305 :         constValue = m_reader.getFieldValue(i);
    3730        1305 :         if (constValue.m_type == RT_TYPE_INT32)
    3731        1305 :             value = constValue.m_value.aLong;
    3732             :         else
    3733           0 :             value++;
    3734        1305 :         o << value << ";\n";
    3735             :     }
    3736             : 
    3737         193 :     o << "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n";
    3738         193 :     inc();
    3739         386 :     o << indent() << "sTypeName.pData,\n"
    3740         579 :       << indent() << "(sal_Int32)" << scopedCppName(m_typeName, sal_False)
    3741         193 :       << "_"
    3742         579 :       << rtl::OUStringToOString(m_reader.getFieldName(0), RTL_TEXTENCODING_UTF8)
    3743         193 :       << ",\n"
    3744         579 :       << indent() << count << ", enumValueNames, enumValues );\n\n";
    3745         193 :     dec();
    3746             : 
    3747         386 :     o << indent()
    3748             :       << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
    3749         193 :           " );\n");
    3750         386 :     o << indent() << "typelib_typedescription_release( pTD );\n"
    3751         579 :       << indent() << "// End inline typedescription generation\n\n";
    3752             : 
    3753         386 :     o << indent() << "return new ::com::sun::star::uno::Type( "
    3754         579 :       << getTypeClass(m_typeName) << ", sTypeName ); // leaked\n";
    3755             : 
    3756         193 :     dec();
    3757         193 :     o << indent() << "}\n";
    3758         193 :     dec();
    3759         193 :     o << indent() << "};\n\n";
    3760             : 
    3761         193 :     if (!isPolymorphic())
    3762         193 :         codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
    3763             :     else
    3764           0 :         o << " }";
    3765         193 :     o << " }\n\n";
    3766             : 
    3767         193 :     dumpGetCppuTypePreamble(o);
    3768         193 :     o  << indent() << "return *detail::" << sStaticTypeClass << "::get();\n";
    3769         193 :     dumpGetCppuTypePostamble(o);
    3770         193 : }
    3771             : 
    3772             : //*************************************************************************
    3773             : // TypeDefType
    3774             : //*************************************************************************
    3775          75 : TypeDefType::TypeDefType(typereg::Reader& typeReader,
    3776             :                              const OString& typeName,
    3777             :                             const TypeManager& typeMgr)
    3778          75 :     : CppuType(typeReader, typeName, typeMgr)
    3779             : {
    3780          75 : }
    3781             : 
    3782          75 : TypeDefType::~TypeDefType()
    3783             : {
    3784             : 
    3785          75 : }
    3786             : 
    3787          75 : sal_Bool TypeDefType::dumpHFile(
    3788             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    3789             :     throw( CannotDumpException )
    3790             : {
    3791          75 :     OString headerDefine(dumpHeaderDefine(o, "HDL"));
    3792          75 :     o << "\n";
    3793             : 
    3794          75 :     addDefaultHIncludes(includes);
    3795          75 :     includes.dump(o, 0);
    3796          75 :     o << "\n";
    3797             : 
    3798          75 :     if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
    3799          75 :         o << "\n";
    3800             :     }
    3801             : 
    3802          75 :     dumpDeclaration(o);
    3803             : 
    3804          75 :     if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
    3805          75 :         o << "\n";
    3806             :     }
    3807             : 
    3808          75 :     o << "#endif // "<< headerDefine << "\n";
    3809             : 
    3810          75 :     return sal_True;
    3811             : }
    3812             : 
    3813          75 : void TypeDefType::dumpDeclaration(FileStream& o)
    3814             :     throw( CannotDumpException )
    3815             : {
    3816          75 :     o << "\ntypedef ";
    3817             :     dumpType(
    3818             :         o,
    3819             :         rtl::OUStringToOString(
    3820          75 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8));
    3821          75 :     o << " " << m_name << ";\n\n";
    3822          75 : }
    3823             : 
    3824          75 : sal_Bool TypeDefType::dumpHxxFile(
    3825             :     FileStream& o, codemaker::cppumaker::Includes & includes)
    3826             :     throw( CannotDumpException )
    3827             : {
    3828          75 :     OString headerDefine(dumpHeaderDefine(o, "HPP"));
    3829          75 :     o << "\n";
    3830             : 
    3831          75 :     addDefaultHxxIncludes(includes);
    3832          75 :     includes.dump(o, &m_typeName);
    3833          75 :     o << "\n";
    3834             : 
    3835          75 :     o << "\n#endif // "<< headerDefine << "\n";
    3836          75 :     return sal_True;
    3837             : }
    3838             : 
    3839             : //*************************************************************************
    3840             : // ConstructiveType
    3841             : //*************************************************************************
    3842             : 
    3843           0 : sal_Bool ConstructiveType::dumpHFile(
    3844             :     FileStream &, codemaker::cppumaker::Includes &) throw (CannotDumpException)
    3845             : {
    3846             :     OSL_ASSERT(false);
    3847           0 :     return false;
    3848             : }
    3849             : 
    3850         797 : bool ConstructiveType::dumpFiles(
    3851             :     CppuOptions * options, rtl::OString const & outPath)
    3852             : {
    3853         797 :     return dumpFile(options, ".hpp", m_typeName, outPath);
    3854             : }
    3855             : 
    3856             : //*************************************************************************
    3857             : // ServiceType
    3858             : //*************************************************************************
    3859             : 
    3860             : namespace {
    3861             : 
    3862         356 : void includeExceptions(
    3863             :     codemaker::cppumaker::Includes & includes,
    3864             :     codemaker::ExceptionTreeNode const * node)
    3865             : {
    3866         356 :     if (node->present) {
    3867          18 :         includes.add(node->name);
    3868             :     } else {
    3869        1068 :         for (codemaker::ExceptionTreeNode::Children::const_iterator i(
    3870         338 :                  node->children.begin());
    3871         712 :              i != node->children.end(); ++i)
    3872             :         {
    3873          18 :             includeExceptions(includes, *i);
    3874             :         }
    3875             :     }
    3876         356 : }
    3877             : 
    3878             : }
    3879             : 
    3880        2820 : bool ServiceType::isSingleInterfaceBased() {
    3881        2820 :     return m_reader.getSuperTypeCount() == 1;
    3882             : }
    3883             : 
    3884         626 : sal_Bool ServiceType::dumpHxxFile(
    3885             :     FileStream & o, codemaker::cppumaker::Includes & includes)
    3886             :     throw (CannotDumpException)
    3887             : {
    3888         626 :     sal_uInt16 ctors = m_reader.getMethodCount();
    3889         626 :     if (ctors > 0) {
    3890             :         //TODO: Decide whether the types added to includes should rather be
    3891             :         // added to m_dependencies (and thus be generated during
    3892             :         // dumpDependedTypes):
    3893         584 :         includes.addCassert();
    3894         584 :         includes.addReference();
    3895         584 :         includes.addRtlUstringH();
    3896         584 :         includes.addRtlUstringHxx();
    3897         584 :         includes.add("com/sun/star/uno/DeploymentException");
    3898         584 :         includes.add("com/sun/star/uno/XComponentContext");
    3899        1240 :         for (sal_uInt16 i = 0; i < ctors; ++i) {
    3900         656 :             if (isDefaultConstructor(i)) {
    3901         311 :                 includes.add("com/sun/star/uno/Exception");
    3902         311 :                 includes.add("com/sun/star/uno/RuntimeException");
    3903             :             } else {
    3904         345 :                 if (!hasRestParameter(i)) {
    3905         343 :                     includes.addAny();
    3906         343 :                     includes.addSequence();
    3907         343 :                     sal_uInt16 params = m_reader.getMethodParameterCount(i);
    3908         826 :                     for (sal_uInt16 j = 0; j < params; ++j) {
    3909         970 :                         if (codemaker::UnoType::getSort(
    3910             :                                 codemaker::UnoType::decompose(
    3911             :                                     rtl::OUStringToOString(
    3912             :                                         m_reader.getMethodParameterTypeName(
    3913             :                                             i, j),
    3914             :                                         RTL_TEXTENCODING_UTF8),
    3915         970 :                                     0, 0))
    3916             :                             == codemaker::UnoType::SORT_CHAR)
    3917             :                         {
    3918           2 :                             includes.addCppuUnotypeHxx();
    3919           2 :                             break;
    3920             :                         }
    3921             :                     }
    3922             :                 }
    3923         345 :                 codemaker::ExceptionTree tree;
    3924         447 :                 for (sal_uInt16 j = 0; j < m_reader.getMethodExceptionCount(i);
    3925             :                      ++j)
    3926             :                 {
    3927             :                     tree.add(
    3928             :                         rtl::OUStringToOString(
    3929             :                             m_reader.getMethodExceptionTypeName(i, j),
    3930             :                             RTL_TEXTENCODING_UTF8),
    3931         102 :                         m_typeMgr);
    3932             :                 }
    3933         345 :                 if (!tree.getRoot()->present) {
    3934         338 :                     includes.add("com/sun/star/uno/Exception");
    3935         338 :                     includes.add("com/sun/star/uno/RuntimeException");
    3936         338 :                     includeExceptions(includes, tree.getRoot());
    3937         345 :                 }
    3938             :             }
    3939             :         }
    3940             :     }
    3941             :     rtl::OString cppName(translateUnoToCppIdentifier(
    3942         626 :                              m_name, "service", isGlobal()));
    3943         626 :     rtl::OString headerDefine(dumpHeaderDefine(o, "HPP"));
    3944         626 :     o << "\n";
    3945         626 :     includes.dump(o, 0);
    3946         626 :     o << "\n";
    3947         626 :     if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
    3948         626 :         o << "\n";
    3949             :     }
    3950         626 :     o << "\nclass " << cppName << " {\n";
    3951         626 :     inc();
    3952         626 :     if (ctors > 0) {
    3953         584 :         rtl::OString fullName(m_typeName.replace('/', '.'));
    3954             :         rtl::OString baseName(
    3955             :             rtl::OUStringToOString(
    3956         584 :                 m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8));
    3957         584 :         rtl::OString fullBaseName(baseName.replace('/', '.'));
    3958         584 :         rtl::OString scopedBaseName(scopedCppName(baseName));
    3959         584 :         o << "public:\n";
    3960        1240 :         for (sal_uInt16 i = 0; i < ctors; ++i) {
    3961         656 :             if (isDefaultConstructor(i)) {
    3962         622 :                 o << indent() << "static ::com::sun::star::uno::Reference< "
    3963         311 :                   << scopedBaseName << " > "
    3964             :                   << translateUnoToCppIdentifier(
    3965         933 :                       "create", "method", ITM_NONGLOBAL, &cppName)
    3966             :                   << ("(::com::sun::star::uno::Reference<"
    3967             :                       " ::com::sun::star::uno::XComponentContext > const &"
    3968         311 :                       " the_context) {\n");
    3969         311 :                 inc();
    3970         622 :                 o << indent() << "assert(the_context.is());\n" << indent()
    3971         311 :                   << "::com::sun::star::uno::Reference< " << scopedBaseName
    3972         933 :                   << " > the_instance;\n" << indent() << "try {\n";
    3973         311 :                 inc();
    3974         622 :                 o << indent()
    3975         311 :                   << "the_instance = ::com::sun::star::uno::Reference< "
    3976         311 :                   << scopedBaseName
    3977             :                   << (" >(the_context->getServiceManager()->"
    3978             :                       "createInstanceWithContext(::rtl::OUString("
    3979         311 :                       " \"")
    3980         311 :                   << fullName
    3981         311 :                   << "\" ), the_context), ::com::sun::star::uno::UNO_QUERY);\n";
    3982         311 :                 dec();
    3983         622 :                 o << indent()
    3984         311 :                   << "} catch (::com::sun::star::uno::RuntimeException &) {\n";
    3985         311 :                 inc();
    3986         311 :                 o << indent() << "throw;\n";
    3987         311 :                 dec();
    3988         622 :                 o << indent()
    3989             :                   << ("} catch (::com::sun::star::uno::Exception &"
    3990         311 :                       " the_exception) {\n");
    3991         311 :                 inc();
    3992         622 :                 o << indent()
    3993             :                   << ("throw ::com::sun::star::uno::DeploymentException("
    3994             :                       "::rtl::OUString( "
    3995         311 :                       "\"component context fails to supply service ")
    3996         311 :                   << fullName << " of type " << fullBaseName
    3997         311 :                   << ": \" ) + the_exception.Message, the_context);\n";
    3998         311 :                 dec();
    3999         622 :                 o << indent() << "}\n" << indent()
    4000         311 :                   << "if (!the_instance.is()) {\n";
    4001         311 :                 inc();
    4002         622 :                 o << indent()
    4003             :                   << ("throw ::com::sun::star::uno::DeploymentException("
    4004             :                       "::rtl::OUString( "
    4005         311 :                       "\"component context fails to supply service ")
    4006         311 :                   << fullName << " of type " << fullBaseName
    4007         311 :                   << "\" ), the_context);\n";
    4008         311 :                 dec();
    4009         311 :                 o << indent() << "}\n" << indent() << "return the_instance;\n";
    4010         311 :                 dec();
    4011         311 :                 o << indent() << "}\n\n";
    4012             :             } else {
    4013         690 :                 o << indent() << "static ::com::sun::star::uno::Reference< "
    4014         345 :                   << scopedBaseName << " > "
    4015             :                   << translateUnoToCppIdentifier(
    4016             :                       rtl::OUStringToOString(
    4017             :                           m_reader.getMethodName(i), RTL_TEXTENCODING_UTF8),
    4018        1035 :                       "method", ITM_NONGLOBAL, &cppName)
    4019             :                   << ("(::com::sun::star::uno::Reference<"
    4020             :                       " ::com::sun::star::uno::XComponentContext > const &"
    4021         345 :                       " the_context");
    4022         345 :                 sal_uInt16 params = m_reader.getMethodParameterCount(i);
    4023         345 :                 bool rest = hasRestParameter(i);
    4024         918 :                 for (sal_uInt16 j = 0; j < params; ++j) {
    4025         573 :                     o << ", ";
    4026         573 :                     rtl::OStringBuffer buf;
    4027         573 :                     if ((m_reader.getMethodParameterFlags(i, j) & RT_PARAM_REST)
    4028             :                         != 0)
    4029             :                     {
    4030           2 :                         buf.append(RTL_CONSTASCII_STRINGPARAM("[]"));
    4031             :                     }
    4032             :                     buf.append(
    4033             :                         rtl::OUStringToOString(
    4034             :                             m_reader.getMethodParameterTypeName(i, j),
    4035         573 :                             RTL_TEXTENCODING_UTF8));
    4036         573 :                     rtl::OString type(buf.makeStringAndClear());
    4037         573 :                     bool byRef = passByReference(type);
    4038         573 :                     dumpType(o, type, byRef, byRef);
    4039         573 :                     o << " "
    4040             :                       << translateUnoToCppIdentifier(
    4041             :                           rtl::OUStringToOString(
    4042             :                               m_reader.getMethodParameterName(i, j),
    4043             :                               RTL_TEXTENCODING_UTF8),
    4044        1146 :                           "param", ITM_NONGLOBAL);
    4045         573 :                 }
    4046         345 :                 o << ") {\n";
    4047         345 :                 inc();
    4048         345 :                 o << indent() << "assert(the_context.is());\n";
    4049         345 :                 if (!rest && params > 0) {
    4050         596 :                     o << indent()
    4051             :                       << ("::com::sun::star::uno::Sequence<"
    4052         298 :                           " ::com::sun::star::uno::Any > the_arguments(")
    4053         596 :                       << params << ");\n";
    4054         869 :                     for (sal_uInt16 j = 0; j < params; ++j) {
    4055         571 :                         o << indent() << "the_arguments[" << j << "] ";
    4056             :                         rtl::OString param(
    4057             :                             translateUnoToCppIdentifier(
    4058             :                                 rtl::OUStringToOString(
    4059             :                                     m_reader.getMethodParameterName(i, j),
    4060             :                                     RTL_TEXTENCODING_UTF8),
    4061         571 :                                 "param", ITM_NONGLOBAL));
    4062             :                         sal_Int32 rank;
    4063        1142 :                         if (codemaker::UnoType::getSort(
    4064             :                                 codemaker::UnoType::decompose(
    4065             :                                     rtl::OUStringToOString(
    4066             :                                         m_reader.getMethodParameterTypeName(
    4067             :                                             i, j),
    4068             :                                         RTL_TEXTENCODING_UTF8),
    4069        1142 :                                     &rank, 0))
    4070             :                             == codemaker::UnoType::SORT_CHAR)
    4071             :                         {
    4072           5 :                             o << "= ::com::sun::star::uno::Any(&" << param
    4073           5 :                               << ", ::cppu::UnoType< ";
    4074          10 :                             for (sal_Int32 k = 0; k < rank; ++k) {
    4075           5 :                                 o << "::cppu::UnoSequenceType< ";
    4076             :                             }
    4077           5 :                             o << "::cppu::UnoCharType";
    4078          10 :                             for (sal_Int32 k = 0; k < rank; ++k) {
    4079           5 :                                 o << " >";
    4080             :                             }
    4081           5 :                             o << " >::get())";
    4082             :                         } else {
    4083         566 :                             o << "<<= " << param;
    4084             :                         }
    4085         571 :                         o << ";\n";
    4086         571 :                     }
    4087             :                 }
    4088         690 :                 o << indent() << "::com::sun::star::uno::Reference< "
    4089         345 :                   << scopedBaseName << " > the_instance;\n";
    4090         345 :                 codemaker::ExceptionTree tree;
    4091         345 :                 sal_uInt16 exceptions = m_reader.getMethodExceptionCount(i);
    4092         447 :                 for (sal_uInt16 j = 0; j < exceptions; ++j) {
    4093             :                     tree.add(
    4094             :                         rtl::OUStringToOString(
    4095             :                             m_reader.getMethodExceptionTypeName(i, j),
    4096             :                             RTL_TEXTENCODING_UTF8),
    4097         102 :                         m_typeMgr);
    4098             :                 }
    4099         345 :                 if (!tree.getRoot()->present) {
    4100         338 :                     o << indent() << "try {\n";
    4101         338 :                     inc();
    4102             :                 }
    4103         690 :                 o << indent()
    4104         345 :                   << "the_instance = ::com::sun::star::uno::Reference< "
    4105         345 :                   << scopedBaseName
    4106             :                   << (" >(the_context->getServiceManager()->"
    4107             :                       "createInstanceWithArgumentsAndContext(::rtl::OUString("
    4108         345 :                       " \"")
    4109         345 :                   << fullName << "\" ), ";
    4110         345 :                 if (rest) {
    4111             :                     o << translateUnoToCppIdentifier(
    4112             :                         rtl::OUStringToOString(
    4113             :                             m_reader.getMethodParameterName(i, 0),
    4114             :                             RTL_TEXTENCODING_UTF8),
    4115           2 :                         "param", ITM_NONGLOBAL);
    4116         343 :                 } else if (params == 0) {
    4117             :                     o << ("::com::sun::star::uno::Sequence<"
    4118          45 :                           " ::com::sun::star::uno::Any >()");
    4119             :                 } else {
    4120         298 :                     o << "the_arguments";
    4121             :                 }
    4122         345 :                 o << ", the_context), ::com::sun::star::uno::UNO_QUERY);\n";
    4123         345 :                 if (!tree.getRoot()->present) {
    4124         338 :                     dec();
    4125         676 :                     o << indent()
    4126             :                       << ("} catch (::com::sun::star::uno::RuntimeException &)"
    4127         338 :                           " {\n");
    4128         338 :                     inc();
    4129         338 :                     o << indent() << "throw;\n";
    4130         338 :                     dec();
    4131         338 :                     dumpCatchClauses(o, tree.getRoot());
    4132         676 :                     o << indent()
    4133             :                       << ("} catch (::com::sun::star::uno::Exception &"
    4134         338 :                           " the_exception) {\n");
    4135         338 :                     inc();
    4136         676 :                     o << indent()
    4137             :                       << ("throw ::com::sun::star::uno::DeploymentException("
    4138             :                           "::rtl::OUString( "
    4139         338 :                           "\"component context fails to supply service ")
    4140         338 :                       << fullName << " of type " << fullBaseName
    4141         338 :                       << ": \" ) + the_exception.Message, the_context);\n";
    4142         338 :                     dec();
    4143         338 :                     o << indent() << "}\n";
    4144             :                 }
    4145         345 :                 o << indent() << "if (!the_instance.is()) {\n";
    4146         345 :                 inc();
    4147         690 :                 o << indent()
    4148             :                   << ("throw ::com::sun::star::uno::DeploymentException("
    4149             :                       "::rtl::OUString( "
    4150         345 :                       "\"component context fails to supply service ")
    4151         345 :                   << fullName << " of type " << fullBaseName
    4152         345 :                   << "\" ), the_context);\n";
    4153         345 :                 dec();
    4154         345 :                 o << indent() << "}\n" << indent() << "return the_instance;\n";
    4155         345 :                 dec();
    4156         345 :                 o << indent() << "}\n\n";
    4157             :             }
    4158         584 :         }
    4159             :     }
    4160         626 :     o << "private:\n";
    4161        1252 :     o << indent() << cppName << "(); // not implemented\n"
    4162        1878 :       << indent() << cppName << "(" << cppName << " &); // not implemented\n"
    4163        1878 :       << indent() << "~" << cppName << "(); // not implemented\n"
    4164        1878 :       << indent() << "void operator =(" << cppName << "); // not implemented\n";
    4165         626 :     dec();
    4166         626 :     o << "};\n\n";
    4167         626 :     if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
    4168         626 :         o << "\n";
    4169             :     }
    4170         626 :     o << "\n#endif // "<< headerDefine << "\n";
    4171         626 :     return true;
    4172             : }
    4173             : 
    4174         626 : void ServiceType::addSpecialDependencies() {
    4175         626 :     if (m_reader.getMethodCount() > 0) {
    4176             :         OSL_ASSERT(m_reader.getSuperTypeCount() == 1);
    4177             :         m_dependencies.add(
    4178             :             rtl::OUStringToOString(
    4179         584 :                 m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8));
    4180             :     }
    4181         626 : }
    4182             : 
    4183        1312 : bool ServiceType::isDefaultConstructor(sal_uInt16 ctorIndex) const {
    4184        1312 :     return m_reader.getMethodName(ctorIndex).isEmpty();
    4185             : }
    4186             : 
    4187         690 : bool ServiceType::hasRestParameter(sal_uInt16 ctorIndex) const {
    4188         690 :     return m_reader.getMethodParameterCount(ctorIndex) == 1
    4189         442 :         && ((m_reader.getMethodParameterFlags(ctorIndex, 0) & RT_PARAM_REST)
    4190        1132 :             != 0);
    4191             : }
    4192             : 
    4193         356 : void ServiceType::dumpCatchClauses(
    4194             :     FileStream & out, codemaker::ExceptionTreeNode const * node)
    4195             : {
    4196         356 :     if (node->present) {
    4197          18 :         out << indent() << "} catch (";
    4198          18 :         dumpType(out, node->name);
    4199          18 :         out << " &) {\n";
    4200          18 :         inc();
    4201          18 :         out << indent() << "throw;\n";
    4202          18 :         dec();
    4203             :     } else {
    4204        1068 :         for (codemaker::ExceptionTreeNode::Children::const_iterator i(
    4205         338 :                  node->children.begin());
    4206         712 :              i != node->children.end(); ++i)
    4207             :         {
    4208          18 :             dumpCatchClauses(out, *i);
    4209             :         }
    4210             :     }
    4211         356 : }
    4212             : 
    4213             : //*************************************************************************
    4214             : // SingletonType
    4215             : //*************************************************************************
    4216             : 
    4217         181 : bool SingletonType::isInterfaceBased() {
    4218             :     return (m_typeMgr.getTypeClass(
    4219             :                 rtl::OUStringToOString(
    4220         362 :                     m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8)))
    4221         362 :         == RT_TYPE_INTERFACE;
    4222             : }
    4223             : 
    4224         171 : sal_Bool SingletonType::dumpHxxFile(
    4225             :     FileStream & o, codemaker::cppumaker::Includes & includes)
    4226             :     throw (CannotDumpException)
    4227             : {
    4228             :     rtl::OString cppName(translateUnoToCppIdentifier(
    4229         171 :                              m_name, "singleton", isGlobal()));
    4230         171 :     rtl::OString fullName(m_typeName.replace('/', '.'));
    4231             :     rtl::OString baseName(
    4232             :         rtl::OUStringToOString(
    4233         171 :             m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8));
    4234         171 :     rtl::OString fullBaseName(baseName.replace('/', '.'));
    4235         171 :     rtl::OString scopedBaseName(scopedCppName(baseName));
    4236         171 :     rtl::OString headerDefine(dumpHeaderDefine(o, "HPP"));
    4237         171 :     o << "\n";
    4238             :     //TODO: Decide whether the types added to includes should rather be added to
    4239             :     // m_dependencies (and thus be generated during dumpDependedTypes):
    4240         171 :     includes.add("com/sun/star/uno/DeploymentException");
    4241         171 :     includes.add("com/sun/star/uno/XComponentContext");
    4242         171 :     includes.addCassert();
    4243         171 :     includes.addAny();
    4244         171 :     includes.addReference();
    4245         171 :     includes.addRtlUstringH();
    4246         171 :     includes.addRtlUstringHxx();
    4247         171 :     includes.dump(o, 0);
    4248         171 :     o << "\n";
    4249         171 :     if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
    4250         167 :         o << "\n";
    4251             :     }
    4252         171 :     o << "\nclass " << cppName << " {\npublic:\n";
    4253         171 :     inc();
    4254         342 :     o << indent() << "static ::com::sun::star::uno::Reference< "
    4255         171 :       << scopedBaseName << " > "
    4256         513 :       << translateUnoToCppIdentifier("get", "method", ITM_NONGLOBAL, &cppName)
    4257             :       << ("(::com::sun::star::uno::Reference<"
    4258             :           " ::com::sun::star::uno::XComponentContext > const & the_context)"
    4259         171 :           " {\n");
    4260         171 :     inc();
    4261         342 :     o << indent() << "assert(the_context.is());\n" << indent()
    4262         171 :       << "::com::sun::star::uno::Reference< " << scopedBaseName
    4263         513 :       << " > instance;\n" << indent()
    4264             :       << ("if (!(the_context->getValueByName("
    4265         171 :           "::rtl::OUString( \"/singletons/")
    4266         171 :       << fullName << "\" )) >>= instance) || !instance.is()) {\n";
    4267         171 :     inc();
    4268         342 :     o << indent()
    4269             :       << ("throw ::com::sun::star::uno::DeploymentException("
    4270             :           "::rtl::OUString( \"component context"
    4271         171 :           " fails to supply singleton ")
    4272         171 :       << fullName << " of type " << fullBaseName << "\" ), the_context);\n";
    4273         171 :     dec();
    4274         171 :     o << indent() << "}\n" << indent() << "return instance;\n";
    4275         171 :     dec();
    4276         171 :     o << indent() << "}\n\n";
    4277         171 :     o << "private:\n";
    4278         342 :     o << indent() << cppName << "(); // not implemented\n"
    4279         513 :       << indent() << cppName << "(" << cppName << " &); // not implemented\n"
    4280         513 :       << indent() << "~" << cppName << "(); // not implemented\n"
    4281         513 :       << indent() << "void operator =(" << cppName << "); // not implemented\n";
    4282         171 :     dec();
    4283         171 :     o << "};\n\n";
    4284         171 :     if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
    4285         167 :         o << "\n";
    4286             :     }
    4287         171 :     o << "\n#endif // "<< headerDefine << "\n";
    4288         171 :     return true;
    4289             : }
    4290             : 
    4291             : //*************************************************************************
    4292             : // produceType
    4293             : //*************************************************************************
    4294       16758 : bool produceType(const OString& typeName,
    4295             :                  TypeManager const & typeMgr,
    4296             :                  codemaker::GeneratedTypeSet & generated,
    4297             :                  CppuOptions* pOptions)
    4298             :     throw( CannotDumpException )
    4299             : {
    4300       50254 :     if (typeName.equals("/") || typeName.equals(typeMgr.getBase()) ||
    4301       33496 :         TypeManager::isBaseType(typeName) || generated.contains(typeName))
    4302             :     {
    4303       14340 :         return true;
    4304             :     }
    4305             : 
    4306        2418 :     sal_Bool bIsExtraType = sal_False;
    4307        2418 :     typereg::Reader reader(typeMgr.getTypeReader(typeName, &bIsExtraType));
    4308        2418 :     if (bIsExtraType) {
    4309         221 :         generated.add(typeName);
    4310         221 :         return true;
    4311             :     }
    4312             : 
    4313        2197 :     if (!reader.isValid()) {
    4314           0 :         return false;
    4315             :     }
    4316             : 
    4317        2197 :     RTTypeClass typeClass = reader.getTypeClass();
    4318        2197 :     bool ret = false;
    4319        2197 :     switch (typeClass)
    4320             :     {
    4321             :         case RT_TYPE_INTERFACE:
    4322             :             {
    4323        1350 :                 InterfaceType iType(reader, typeName, typeMgr);
    4324        1350 :                 ret = iType.dump(pOptions);
    4325        1350 :                 if (ret) generated.add(typeName);
    4326        1350 :                 iType.dumpDependedTypes(generated, pOptions);
    4327             :             }
    4328        1350 :             break;
    4329             :         case RT_TYPE_MODULE:
    4330             :             {
    4331           0 :                 ModuleType mType(reader, typeName, typeMgr);
    4332           0 :                 if (mType.hasConstants())
    4333             :                 {
    4334           0 :                     ret = mType.dump(pOptions);
    4335           0 :                     if (ret) generated.add(typeName);
    4336             :                 } else
    4337             :                 {
    4338           0 :                     generated.add(typeName);
    4339           0 :                     ret = true;
    4340           0 :                 }
    4341             :             }
    4342           0 :             break;
    4343             :         case RT_TYPE_STRUCT:
    4344             :             {
    4345         443 :                 StructureType sType(reader, typeName, typeMgr);
    4346         443 :                 ret = sType.dump(pOptions);
    4347         443 :                 if (ret) generated.add(typeName);
    4348         443 :                 sType.dumpDependedTypes(generated, pOptions);
    4349             :             }
    4350         443 :             break;
    4351             :         case RT_TYPE_ENUM:
    4352             :             {
    4353         148 :                 EnumType enType(reader, typeName, typeMgr);
    4354         148 :                 ret = enType.dump(pOptions);
    4355         148 :                 if (ret) generated.add(typeName);
    4356         148 :                 enType.dumpDependedTypes(generated, pOptions);
    4357             :             }
    4358         148 :             break;
    4359             :         case RT_TYPE_EXCEPTION:
    4360             :             {
    4361         225 :                 ExceptionType eType(reader, typeName, typeMgr);
    4362         225 :                 ret = eType.dump(pOptions);
    4363         225 :                 if (ret) generated.add(typeName);
    4364         225 :                 eType.dumpDependedTypes(generated, pOptions);
    4365             :             }
    4366         225 :             break;
    4367             :         case RT_TYPE_TYPEDEF:
    4368             :             {
    4369          31 :                 TypeDefType tdType(reader, typeName, typeMgr);
    4370          31 :                 ret = tdType.dump(pOptions);
    4371          31 :                 if (ret) generated.add(typeName);
    4372          31 :                 tdType.dumpDependedTypes(generated, pOptions);
    4373             :             }
    4374          31 :             break;
    4375             :         case RT_TYPE_CONSTANTS:
    4376             :             {
    4377           0 :                 ConstantsType cType(reader, typeName, typeMgr);
    4378           0 :                 if (cType.hasConstants())
    4379             :                 {
    4380           0 :                     ret = cType.dump(pOptions);
    4381           0 :                     if (ret) generated.add(typeName);
    4382             :                 } else
    4383             :                 {
    4384           0 :                     generated.add(typeName);
    4385           0 :                     ret = true;
    4386           0 :                 }
    4387             :             }
    4388           0 :             break;
    4389             :         case RT_TYPE_SERVICE:
    4390             :             {
    4391           0 :                 ServiceType t(reader, typeName, typeMgr);
    4392           0 :                 if (t.isSingleInterfaceBased()) {
    4393           0 :                     ret = t.dump(pOptions);
    4394           0 :                     if (ret) {
    4395           0 :                         generated.add(typeName);
    4396           0 :                         t.dumpDependedTypes(generated, pOptions);
    4397             :                     }
    4398             :                 } else {
    4399           0 :                     ret = true;
    4400           0 :                 }
    4401             :             }
    4402           0 :             break;
    4403             :         case RT_TYPE_SINGLETON:
    4404             :             {
    4405           0 :                 SingletonType t(reader, typeName, typeMgr);
    4406           0 :                 if (t.isInterfaceBased()) {
    4407           0 :                     ret = t.dump(pOptions);
    4408           0 :                     if (ret) {
    4409           0 :                         generated.add(typeName);
    4410           0 :                         t.dumpDependedTypes(generated, pOptions);
    4411             :                     }
    4412             :                 } else {
    4413           0 :                     ret = true;
    4414           0 :                 }
    4415             :             }
    4416           0 :             break;
    4417             :         case RT_TYPE_OBJECT:
    4418           0 :             ret = true;
    4419           0 :             break;
    4420             :         default:
    4421             :             OSL_ASSERT(false);
    4422           0 :             break;
    4423             :     }
    4424             : 
    4425        2197 :     return ret;
    4426             : }
    4427             : 
    4428       10444 : bool produceType(RegistryKey& rTypeKey, bool bIsExtraType,
    4429             :                      TypeManager const & typeMgr,
    4430             :                      codemaker::GeneratedTypeSet & generated,
    4431             :                      CppuOptions* pOptions)
    4432             :     throw( CannotDumpException )
    4433             : {
    4434       10444 :     OString typeName = typeMgr.getTypeName(rTypeKey);
    4435             : 
    4436       31332 :     if (typeName.equals("/") ||typeName.equals(typeMgr.getBase()) ||
    4437       20888 :         TypeManager::isBaseType(typeName) || generated.contains(typeName))
    4438             :     {
    4439        2197 :         return true;
    4440             :     }
    4441             : 
    4442        8247 :     if (bIsExtraType) {
    4443           0 :         generated.add(typeName);
    4444           0 :         return true;
    4445             :     }
    4446             : 
    4447        8247 :     typereg::Reader reader(typeMgr.getTypeReader(rTypeKey));
    4448        8247 :     if (!reader.isValid()) {
    4449           0 :         return false;
    4450             :     }
    4451             : 
    4452        8247 :     RTTypeClass typeClass = reader.getTypeClass();
    4453        8247 :     bool ret = false;
    4454        8247 :     switch (typeClass)
    4455             :     {
    4456             :         case RT_TYPE_INTERFACE:
    4457             :             {
    4458        2381 :                 InterfaceType iType(reader, typeName, typeMgr);
    4459        2381 :                 ret = iType.dump(pOptions);
    4460        2381 :                 if (ret) generated.add(typeName);
    4461        2381 :                 iType.dumpDependedTypes(generated, pOptions);
    4462             :             }
    4463        2381 :             break;
    4464             :         case RT_TYPE_MODULE:
    4465             :             {
    4466         317 :                 ModuleType mType(reader, typeName, typeMgr);
    4467         317 :                 if (mType.hasConstants())
    4468             :                 {
    4469           0 :                     ret = mType.dump(pOptions);
    4470           0 :                     if (ret) generated.add(typeName);
    4471             :                 } else
    4472             :                 {
    4473         317 :                     generated.add(typeName);
    4474         317 :                     ret = true;
    4475         317 :                 }
    4476             :             }
    4477         317 :             break;
    4478             :         case RT_TYPE_STRUCT:
    4479             :             {
    4480         392 :                 StructureType sType(reader, typeName, typeMgr);
    4481         392 :                 ret = sType.dump(pOptions);
    4482         392 :                 if (ret) generated.add(typeName);
    4483         392 :                 sType.dumpDependedTypes(generated, pOptions);
    4484             :             }
    4485         392 :             break;
    4486             :         case RT_TYPE_ENUM:
    4487             :             {
    4488         249 :                 EnumType enType(reader, typeName, typeMgr);
    4489         249 :                 ret = enType.dump(pOptions);
    4490         249 :                 if (ret) generated.add(typeName);
    4491         249 :                 enType.dumpDependedTypes(generated, pOptions);
    4492             :             }
    4493         249 :             break;
    4494             :         case RT_TYPE_EXCEPTION:
    4495             :             {
    4496         332 :                 ExceptionType eType(reader, typeName, typeMgr);
    4497         332 :                 ret = eType.dump(pOptions);
    4498         332 :                 if (ret) generated.add(typeName);
    4499         332 :                 eType.dumpDependedTypes(generated, pOptions);
    4500             :             }
    4501         332 :             break;
    4502             :         case RT_TYPE_TYPEDEF:
    4503             :             {
    4504          44 :                 TypeDefType tdType(reader, typeName, typeMgr);
    4505          44 :                 ret = tdType.dump(pOptions);
    4506          44 :                 if (ret) generated.add(typeName);
    4507          44 :                 tdType.dumpDependedTypes(generated, pOptions);
    4508             :             }
    4509          44 :             break;
    4510             :         case RT_TYPE_CONSTANTS:
    4511             :             {
    4512        1531 :                 ConstantsType cType(reader, typeName, typeMgr);
    4513        1531 :                 if (cType.hasConstants())
    4514             :                 {
    4515        1531 :                     ret = cType.dump(pOptions);
    4516        1531 :                     if (ret) generated.add(typeName);
    4517             :                 } else
    4518             :                 {
    4519           0 :                     generated.add(typeName);
    4520           0 :                     ret = true;
    4521        1531 :                 }
    4522             :             }
    4523        1531 :             break;
    4524             :         case RT_TYPE_SERVICE:
    4525             :             {
    4526        2820 :                 ServiceType t(reader, typeName, typeMgr);
    4527        2820 :                 if (t.isSingleInterfaceBased()) {
    4528         626 :                     ret = t.dump(pOptions);
    4529         626 :                     if (ret) {
    4530         626 :                         generated.add(typeName);
    4531         626 :                         t.dumpDependedTypes(generated, pOptions);
    4532             :                     }
    4533             :                 } else {
    4534        2194 :                     ret = true;
    4535        2820 :                 }
    4536             :             }
    4537        2820 :             break;
    4538             :         case RT_TYPE_SINGLETON:
    4539             :             {
    4540         181 :                 SingletonType t(reader, typeName, typeMgr);
    4541         181 :                 if (t.isInterfaceBased()) {
    4542         171 :                     ret = t.dump(pOptions);
    4543         171 :                     if (ret) {
    4544         171 :                         generated.add(typeName);
    4545         171 :                         t.dumpDependedTypes(generated, pOptions);
    4546             :                     }
    4547             :                 } else {
    4548          10 :                     ret = true;
    4549         181 :                 }
    4550             :             }
    4551         181 :             break;
    4552             :         case RT_TYPE_OBJECT:
    4553           0 :             ret = true;
    4554           0 :             break;
    4555             :         default:
    4556             :             OSL_ASSERT(false);
    4557           0 :             break;
    4558             :     }
    4559             : 
    4560        8247 :     return ret;
    4561             : }
    4562             : 
    4563             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10