diff options
Diffstat (limited to 'codemaker/source')
46 files changed, 266 insertions, 10834 deletions
diff --git a/codemaker/source/bonobowrappermaker/corbamaker.cxx b/codemaker/source/bonobowrappermaker/corbamaker.cxx deleted file mode 100644 index 85221b53f9ec..000000000000 --- a/codemaker/source/bonobowrappermaker/corbamaker.cxx +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" - -#include <stdio.h> - -#include "sal/main.h" - -#include <codemaker/typemanager.hxx> -#include <codemaker/dependency.hxx> - -#include "corbaoptions.hxx" -#include "corbatype.hxx" - -using namespace rtl; - -sal_Bool produceAllTypes(const OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - CorbaOptions* pOptions, - sal_Bool bFullScope, - FileStream& o, - TypeSet* pAllreadyDumped, - TypeSet* generatedConversion) - - throw( CannotDumpException ) -{ - if (!produceType(typeName, typeMgr, typeDependencies, pOptions, o, pAllreadyDumped, generatedConversion)) - { - fprintf(stderr, "%s ERROR: %s\n", - pOptions->getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - - RegistryKey typeKey = typeMgr.getTypeKey(typeName); - RegistryKeyNames subKeys; - - if (typeKey.getKeyNames(OUString(), subKeys)) - return sal_False; - - OString tmpName; - for (sal_uInt32 i=0; i < subKeys.getLength(); i++) - { - tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8); - - if (pOptions->isValid("-B")) - tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1); - else - tmpName = tmpName.copy(1); - - if (bFullScope) - { - if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True, o, pAllreadyDumped, generatedConversion)) - return sal_False; - } else - { - if (!produceType(tmpName, typeMgr, typeDependencies, pOptions, o, pAllreadyDumped, generatedConversion)) - return sal_False; - } - } - - return sal_True; -} - -SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) -{ - CorbaOptions options; - - try - { - if (!options.initOptions(argc, argv)) - { - exit(1); - } - } - catch( IllegalArgument& e) - { - fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr()); - exit(99); - } - - RegistryTypeManager typeMgr; - TypeDependency typeDependencies; - - if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles())) - { - fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr()); - exit(99); - } - - if (options.isValid("-B")) - { - typeMgr.setBase(options.getOption("-B")); - } - - try - { - TypeSet generatedConversion; - FileStream cppFile; - OString outPath; - if (options.isValid("-O")) - outPath = options.getOption("-O"); - - cppFile.open(outPath); - - if(!cppFile.isValid()) - { - OString message("cannot open "); - message += outPath + " for writing"; - throw CannotDumpException(message); - } - - if (options.isValid("-H")) - { - OString corbaHeader = options.getOption("-H"); - - cppFile << "#include <" - << corbaHeader - << ">\n\n"; - - CorbaType::dumpDefaultHxxIncludes(cppFile); - cppFile << "\n"; - } - - if (options.isValid("-T")) - { - OString tOption(options.getOption("-T")); - - OString typeName, tmpName; - sal_Bool ret = sal_False; - sal_Int32 nIndex = 0; - do - { - typeName = tOption.getToken(0, ';', nIndex); - - sal_Int32 nPos = typeName.lastIndexOf( '.' ); - tmpName = typeName.copy( nPos != -1 ? nPos+1 : 0 ); - if (tmpName == "*") - { - // produce this type and his scope, but the scope is not recursively generated. - if (typeName.equals("*")) - { - tmpName = "/"; - } else - { - tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/'); - if (tmpName.getLength() == 0) - tmpName = "/"; - else - tmpName.replace('.', '/'); - } - ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False, cppFile, NULL, &generatedConversion); - } else - { - // produce only this type - ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options, cppFile, NULL, &generatedConversion); - } - - if (!ret) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - } while( nIndex != -1 ); - } else - { - // produce all types - if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True, cppFile, NULL, &generatedConversion)) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - "an error occurs while dumping all types."); - exit(99); - } - } - - cppFile << "namespace bonobobridge {\n" - << "const ConversionInfo* get_conversion_functions() {\n" - << " static ConversionInfo allFunctions[" << generatedConversion.size()+1<< "] = {\n"; - - for (TypeSet::iterator iter = generatedConversion.begin(); iter != generatedConversion.end(); iter++) - { - cppFile << " {\"" << (*iter).getStr() << "\"" - << ", &TC_" << (*iter).replace('/','_').getStr() << "_struct" - << ", sizeof(" << (*iter).replace('/','_').getStr() << ")" - << ", convert_b2u_" << (*iter).replace('/','_').getStr() - << ", convert_u2b_" << (*iter).replace('/','_').getStr() - << " },\n"; - } - - cppFile << " {NULL, NULL, 0 , NULL, NULL} };\n" - << " return allFunctions;\n" - << "}\n" - << "}; // namespace bonobobridge\n"; - - cppFile.close(); - } - catch( CannotDumpException& e) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - e.m_message.getStr()); - exit(99); - } - - return 0; -} - - diff --git a/codemaker/source/bonobowrappermaker/corbaoptions.cxx b/codemaker/source/bonobowrappermaker/corbaoptions.cxx deleted file mode 100644 index 1bb75810031a..000000000000 --- a/codemaker/source/bonobowrappermaker/corbaoptions.cxx +++ /dev/null @@ -1,255 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" -#include <stdio.h> - -#include "corbaoptions.hxx" - -using namespace rtl; - -sal_Bool CorbaOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) - throw( IllegalArgument ) -{ - sal_Bool ret = sal_True; - sal_uInt16 i=0; - - if (!bCmdFile) - { - bCmdFile = sal_True; - - m_program = av[0]; - - if (ac < 2) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - ret = sal_False; - } - - i = 1; - } else - { - i = 0; - } - - char *s=NULL; - for (i; i < ac; i++) - { - if (av[i][0] == '-') - { - switch (av[i][1]) - { - case 'O': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-O', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-O"] = OString(s); - break; - case 'H': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-H', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-H"] = OString(s); - break; - case 'B': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-B', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-B"] = OString(s); - break; - case 'T': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-T', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - if (m_options.count("-T") > 0) - { - OString tmp(m_options["-T"]); - tmp = tmp + ";" + s; - m_options["-T"] = tmp; - } else - { - m_options["-T"] = OString(s); - } - break; - case 'G': - if (av[i][2] != '\0') - { - OString tmp("'-G', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - m_options["-G"] = OString(""); - break; - default: - throw IllegalArgument("the option is unknown" + OString(av[i])); - break; - } - } else - { - if (av[i][0] == '@') - { - FILE* cmdFile = fopen(av[i]+1, "r"); - if( cmdFile == NULL ) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - ret = sal_False; - } else - { - int rargc=0; - char* rargv[512]; - char buffer[512]; - - while ( fscanf(cmdFile, "%s", buffer) != EOF ) - { - rargv[rargc]= strdup(buffer); - rargc++; - } - fclose(cmdFile); - - ret = initOptions(rargc, rargv, bCmdFile); - - for (long i=0; i < rargc; i++) - { - free(rargv[i]); - } - } - } else - { - m_inputFiles.push_back(av[i]); - } - } - } - printf("-T: %s\n", m_options["-T"].getStr()); - - return ret; -} - -OString CorbaOptions::prepareHelp() -{ - OString help("\nusing: "); - help += m_program + " [-options] file_1 ... file_n\nOptions:\n"; - help += " -O<file> = file name for the generated output.\n"; - help += " The output directory tree is generated under this directory.\n"; - help += " -T<name> = name specifies a type or a list of types. The output for this\n"; - help += " [t1;...] type is generated. If no '-T' option is specified,\n"; - help += " then output for all types is generated.\n"; - help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n"; - help += " -B<name> = name specifies the base node. All types are searched under this\n"; - help += " node. Default is the root '/' of the registry files.\n"; - help += " -G = generate only target files which does not exists.\n"; - help += " -H<header> = include CORBA generated <header>.\n"; - help += prepareVersion(); - - return help; -} - -OString CorbaOptions::prepareVersion() -{ - OString version(m_program); - version += m_program + " Version 2.0\n\n"; - return version; -} - - diff --git a/codemaker/source/bonobowrappermaker/corbaoptions.hxx b/codemaker/source/bonobowrappermaker/corbaoptions.hxx deleted file mode 100644 index aa08016f5ee7..000000000000 --- a/codemaker/source/bonobowrappermaker/corbaoptions.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _CORBAMAKER_CPPUOPTIONS_HXX_ -#define _CORBAMAKER_CPPUOPTIONS_HXX_ - -#include <codemaker/options.hxx> - -class CorbaOptions : public Options -{ -public: - CorbaOptions() - : Options() {} - - ~CorbaOptions() {} - - sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) - throw( IllegalArgument ); - - ::rtl::OString prepareHelp(); - - ::rtl::OString prepareVersion(); - -protected: -}; - -#endif // _CORBAMAKER_CPPUOPTIONS_HXX_ diff --git a/codemaker/source/bonobowrappermaker/corbatype.cxx b/codemaker/source/bonobowrappermaker/corbatype.cxx deleted file mode 100644 index 417af55b326e..000000000000 --- a/codemaker/source/bonobowrappermaker/corbatype.cxx +++ /dev/null @@ -1,2782 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" - -#include <stdio.h> -#include <rtl/alloc.h> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> - -#include "corbatype.hxx" -#include "corbaoptions.hxx" - -#include <hash_set> -#include <list> - -using namespace rtl; - - -//************************************************************************* -// CorbaType -//************************************************************************* -CorbaType::CorbaType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : m_inheritedMemberCount(0) - , m_indentLength(0) - , m_typeName(typeName) - , m_reader(typeReader) - , m_typeMgr((TypeManager&)typeMgr) - , m_dependencies(typeDependencies) - , m_generatedConversions(generatedConversions) -{ - sal_Int32 i = typeName.lastIndexOf('/'); - m_name = typeName.copy( i != -1 ? i+1 : 0 ); -} - -CorbaType::~CorbaType() -{ - -} - -sal_Bool CorbaType::isNestedTypeByName(const ::rtl::OString& type) -{ - sal_Bool ret = sal_False; - - sal_Int32 i = type.lastIndexOf('/'); - - if (i >= 0) - { - OString outerTypeName(type.copy(0, i)); - ret = (m_typeMgr.getTypeClass(outerTypeName) == RT_TYPE_INTERFACE); - } - - return ret; -} - -sal_Bool CorbaType::dump(CorbaOptions* pOptions, FileStream& o, TypeSet* allreadyDumped) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - ret = dumpConversionFunctions(o, allreadyDumped); - - return ret; -} - -sal_Bool CorbaType::dumpDependedTypes(CorbaOptions* pOptions, FileStream& o, TypeSet* allreadyDumped) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_True; - - TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName)); - - TypeUsingSet::const_iterator iter = usingSet.begin(); - OString typeName; - sal_uInt32 index = 0; - while (iter != usingSet.end()) - { - typeName = (*iter).m_type; - if ((index = typeName.lastIndexOf(']')) > 0) - typeName = typeName.copy(index + 1); - - if (getUnoBaseType(typeName).getLength() == 0) - { - if (!produceType(typeName, - m_typeMgr, - m_dependencies, - pOptions, - o, allreadyDumped, m_generatedConversions)) - { - fprintf(stderr, "%s ERROR: %s\n", - pOptions->getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - } - ++iter; - } - - return ret; -} - -sal_Bool CorbaType::dumpConversionFunctions(FileStream& o, TypeSet* allreadyDumped) - throw( CannotDumpException ) -{ - if (m_typeName.lastIndexOf(']') < 0) - { - dumpInclude(o, allreadyDumped, m_typeName, "hpp", sal_False); - dumpDepIncludes(o, allreadyDumped, m_typeName, "hpp"); - - dumpFunctions(o); - } - - return sal_True; -} - - -void CorbaType::dumpDefaultHxxIncludes(FileStream& o) -{ - o << "#ifndef _OSL_MUTEX_HXX_\n" - << "#include <osl/mutex.hxx>\n" - << "#endif\n\n"; - - o << "#ifndef _RTL_USTRING_HXX_\n" - << "#include <rtl/ustring.hxx>\n" - << "#endif\n\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_\n" - << "#include <com/sun/star/uno/Type.hxx>\n" - << "#endif\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_ANY_HXX_\n" - << "#include <com/sun/star/uno/Any.hxx>\n" - << "#endif\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_\n" - << "#include <com/sun/star/uno/Reference.hxx>\n" - << "#endif\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_\n" - << "#include <com/sun/star/uno/XInterface.hpp>\n" - << "#endif\n"; - - o << "#ifndef _BONOBO_NULLINTERFACE_HPP_\n" - << "#include <Bonobo/NullInterface.hpp>\n" - << "#endif\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_\n" - << "#include <com/sun/star/uno/Exception.hpp>\n" - << "#endif\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_\n" - << "#include <com/sun/star/uno/RuntimeException.hpp>\n" - << "#endif\n"; - - o << "#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_\n" - << "#include <com/sun/star/uno/Sequence.hxx>\n" - << "#endif\n"; -} - - -void CorbaType::dumpInclude(FileStream& o, TypeSet* allreadyDumped, const OString& typeName, sal_Char* prefix, sal_Bool bExtended, sal_Bool bCaseSensitive) -{ - OString realTypeName = checkRealBaseType( typeName ); - - if (!isNestedTypeByName(typeName) && - (BT_INVALID == isBaseType(realTypeName)) && - !realTypeName.equals("Bonobo/NullInterface") && - !realTypeName.equals("com/sun/star/uno/XInterface") && - !realTypeName.equals("com/sun/star/uno/TypeClass") && - !realTypeName.equals("com/sun/star/uno/Type") && - !realTypeName.equals("com/sun/star/uno/Exception") && - !realTypeName.equals("com/sun/star/uno/RuntimeException")) - { - TypeSet::const_iterator iter = allreadyDumped->find(realTypeName); - - if (iter == allreadyDumped->end()) - { - allreadyDumped->insert(realTypeName); - - sal_uInt32 length = 3+ m_typeName.getLength() + strlen(prefix); - - if (bExtended) - length += m_name.getLength() + 1; - - OStringBuffer tmpBuf(length); - - tmpBuf.append('_'); - tmpBuf.append(typeName); - tmpBuf.append('_'); - if (bExtended) - { - tmpBuf.append(m_name); - tmpBuf.append('_'); - } - tmpBuf.append(prefix); - tmpBuf.append('_'); - - OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toAsciiUpperCase()); - - length = 1 + typeName.getLength() + strlen(prefix); - if (bExtended) - length += m_name.getLength() + 1; - - tmpBuf.ensureCapacity(length); - tmpBuf.append(typeName); - if (bExtended) - { - tmpBuf.append('/'); - tmpBuf.append(m_name); - } - tmpBuf.append('.'); - tmpBuf.append(prefix); - - o << "#ifndef " << tmp << "\n#include <"; - if (bCaseSensitive) - { - o << tmpBuf.makeStringAndClear(); - } else - { - o << tmpBuf.makeStringAndClear(); - } - - o << ">\n"; - o << "#endif\n"; - - o << "namespace bonobobridge {\n\n"; - - std::list<OString> nestedTypes; - - do - { - if ((realTypeName.lastIndexOf(']') < 0) && - (BT_INVALID == isBaseType(realTypeName)) && - !realTypeName.equals("Bonobo/NullInterface") && - !realTypeName.equals("com/sun/star/uno/XInterface") && - !realTypeName.equals("com/sun/star/uno/TypeClass") && - !realTypeName.equals("com/sun/star/uno/Type") && - !realTypeName.equals("com/sun/star/uno/Exception") && - !realTypeName.equals("com/sun/star/uno/RuntimeException") && - !realTypeName.equals("com/sun/star/uno/TypeClass")) - { - o << "inline sal_Bool cpp_convert_b2u("; - dumpUnoType(o, realTypeName, sal_False, sal_True); - o << " u, "; - dumpCorbaType(o, realTypeName, sal_True, sal_True); - o << " b, const ::vos::ORef< ::bonobobridge::Bridge >& bridge);\n"; - o << "inline sal_Bool cpp_convert_u2b("; - dumpCorbaType(o, realTypeName, sal_False, sal_True); - o << " b, "; - dumpUnoType(o, realTypeName, sal_True, sal_True); - o << " u, const ::vos::ORef< ::bonobobridge::Bridge >& bridge);\n"; - } - - RegistryKey key = m_typeMgr.getTypeKey(realTypeName); - RegistryKeyNames nestedTypeNames; - key.getKeyNames(OUString(), nestedTypeNames); - for (sal_uInt32 i = 0; i < nestedTypeNames.getLength(); i++) - { - OString nTypeName(OUStringToOString(nestedTypeNames.getElement(i), RTL_TEXTENCODING_UTF8)); - - nTypeName = checkRealBaseType(nTypeName.copy(5)); - - if (BT_INVALID == isBaseType(nTypeName)) - { - allreadyDumped->insert(nTypeName); - nestedTypes.push_back(nTypeName); - } - } - - if (nestedTypes.size() > 0) - { - realTypeName = nestedTypes.front(); - nestedTypes.pop_front(); - } - else - { - realTypeName = ""; - } - } - while (realTypeName.getLength() > 0); - - o << "}; // namespace bonobobridge\n"; - } - } -} - -void CorbaType::dumpDepIncludes(FileStream& o, TypeSet* allreadyDumped, const OString& typeName, sal_Char* prefix) -{ - TypeUsingSet usingSet(m_dependencies.getDependencies(typeName)); - - TypeUsingSet::const_iterator iter = usingSet.begin(); - - OString sPrefix(OString(prefix).toAsciiUpperCase()); - sal_Bool bSequenceDumped = sal_False; - sal_Bool bInterfaceDumped = sal_False; - sal_uInt32 index = 0; - sal_uInt32 seqNum = 0; - OString relType; - while (iter != usingSet.end()) - { - index = (*iter).m_type.lastIndexOf(']'); - seqNum = (index > 0 ? ((index+1) / 2) : 0); - - relType = (*iter).m_type; - if (index > 0) - relType = relType.copy(index+1); - - if (!isNestedTypeByName(relType)) - { - OString defPrefix("HXX"); - if (sPrefix.equals("HDL")) - defPrefix = "H"; - - if (seqNum > 0 && !bSequenceDumped) - { - bSequenceDumped = sal_True; - } - - if (getUnoBaseType(relType).getLength() == 0 && - m_typeName != relType) - { - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE - && sPrefix.equals("HDL")) - { - if (!bInterfaceDumped) - { - bInterfaceDumped = sal_True; - } - - if (!((*iter).m_use & TYPEUSE_SUPER)) - { - o << "\n"; - dumpNameSpace(o, sal_True, sal_False, relType); - o << "\nclass " << scopedName(m_typeName, relType, sal_True) << ";\n"; - dumpNameSpace(o, sal_False, sal_False, relType); - o << "\n\n"; - } else - { - dumpInclude(o, allreadyDumped, relType, prefix); - } - } else - { - dumpInclude(o, allreadyDumped, relType, prefix); - } - } - } - ++iter; - } -} - -void CorbaType::dumpNameSpace(FileStream& o, sal_Bool bOpen, sal_Bool bFull, const OString& type) -{ - OString typeName(type); - sal_Bool bOneLine = sal_True; - if (typeName.getLength() == 0) - { - typeName = m_typeName; - bOneLine = sal_False; - } - - if (typeName == "/") - return; - - if (typeName.indexOf( '/' ) == -1 && !bFull) - return; - - if (!bFull) - typeName = typeName.copy( 0, typeName.lastIndexOf( '/' ) ); - - if (bOpen) - { - sal_Int32 nIndex = 0; - do - { - o << "namespace " << typeName.getToken(0, '/', nIndex); - if (bOneLine) - o << " { "; - else - o << "\n{\n"; - } while( nIndex != -1 ); - } else - { - sal_Int32 nPos = 0; - do - { - nPos = typeName.lastIndexOf( '/' ); - o << "}"; - if( bOneLine ) - o << " "; - else - o << " // " << typeName.copy( nPos+1 ) << "\n"; - if( nPos != -1 ) - typeName = typeName.copy( 0, nPos ); - } while( nPos != -1 ); - } -} - - -sal_uInt32 CorbaType::getMemberCount() -{ - sal_uInt32 count = m_reader.getMethodCount(); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - count++; - } - return count; -} - -sal_uInt32 CorbaType::checkInheritedMemberCount(const TypeReader* pReader) -{ - sal_Bool bSelfCheck = sal_True; - if (!pReader) - { - bSelfCheck = sal_False; - pReader = &m_reader; - } - - sal_uInt32 count = 0; - OString superType(pReader->getSuperTypeName()); - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - if ( aSuperReader.isValid() ) - { - count = checkInheritedMemberCount(&aSuperReader); - } - } - - if (bSelfCheck) - { - count += pReader->getMethodCount(); - sal_uInt32 fieldCount = pReader->getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = pReader->getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - count++; - } - } - - return count; -} - -sal_uInt32 CorbaType::getInheritedMemberCount() -{ - if (m_inheritedMemberCount == 0) - { - m_inheritedMemberCount = checkInheritedMemberCount(0); - } - - return m_inheritedMemberCount; -} - -OString CorbaType::getTypeClass(const OString& type, sal_Bool bCStyle) -{ - OString typeName = (type.getLength() > 0 ? type : m_typeName); - RTTypeClass rtTypeClass = RT_TYPE_INVALID; - - if (type.getLength() > 0) - { - typeName = type; - rtTypeClass = m_typeMgr.getTypeClass(typeName); - } else - { - typeName = m_typeName; - rtTypeClass = m_reader.getTypeClass(); - } - - if (typeName.lastIndexOf(']') > 0) - return bCStyle ? "typelib_TypeClass_SEQUENCE" : "::com::sun::star::uno::TypeClass_SEQUENCE"; - - switch (rtTypeClass) - { - case RT_TYPE_INTERFACE: - return bCStyle ? "typelib_TypeClass_INTERFACE" : "::com::sun::star::uno::TypeClass_INTERFACE"; - break; - case RT_TYPE_MODULE: - return bCStyle ? "typelib_TypeClass_MODULE" : "::com::sun::star::uno::TypeClass_MODULE"; - break; - case RT_TYPE_STRUCT: - return bCStyle ? "typelib_TypeClass_STRUCT" : "::com::sun::star::uno::TypeClass_STRUCT"; - break; - case RT_TYPE_ENUM: - return bCStyle ? "typelib_TypeClass_ENUM" : "::com::sun::star::uno::TypeClass_ENUM"; - break; - case RT_TYPE_EXCEPTION: - return bCStyle ? "typelib_TypeClass_EXCEPTION" : "::com::sun::star::uno::TypeClass_EXCEPTION"; - break; - case RT_TYPE_TYPEDEF: - { - OString realType = checkRealBaseType( typeName ); - return getTypeClass( realType, bCStyle ); - } -// return bCStyle ? "typelib_TypeClass_TYPEDEF" : "::com::sun::star::uno::TypeClass_TYPEDEF"; - break; - case RT_TYPE_SERVICE: - return bCStyle ? "typelib_TypeClass_SERVICE" : "::com::sun::star::uno::TypeClass_SERVICE"; - break; - case RT_TYPE_INVALID: - { - if (type.equals("long")) - return bCStyle ? "typelib_TypeClass_LONG" : "::com::sun::star::uno::TypeClass_LONG"; - if (type.equals("short")) - return bCStyle ? "typelib_TypeClass_SHORT" : "::com::sun::star::uno::TypeClass_SHORT"; - if (type.equals("hyper")) - return bCStyle ? "typelib_TypeClass_HYPER" : "::com::sun::star::uno::TypeClass_HYPER"; - if (type.equals("string")) - return bCStyle ? "typelib_TypeClass_STRING" : "::com::sun::star::uno::TypeClass_STRING"; - if (type.equals("boolean")) - return bCStyle ? "typelib_TypeClass_BOOLEAN" : "::com::sun::star::uno::TypeClass_BOOLEAN"; - if (type.equals("char")) - return bCStyle ? "typelib_TypeClass_CHAR" : "::com::sun::star::uno::TypeClass_CHAR"; - if (type.equals("byte")) - return bCStyle ? "typelib_TypeClass_BYTE" : "::com::sun::star::uno::TypeClass_BYTE"; - if (type.equals("any")) - return bCStyle ? "typelib_TypeClass_ANY" : "::com::sun::star::uno::TypeClass_ANY"; - if (type.equals("type")) - return bCStyle ? "typelib_TypeClass_TYPE" : "::com::sun::star::uno::TypeClass_TYPE"; - if (type.equals("float")) - return bCStyle ? "typelib_TypeClass_FLOAT" : "::com::sun::star::uno::TypeClass_FLOAT"; - if (type.equals("double")) - return bCStyle ? "typelib_TypeClass_DOUBLE" : "::com::sun::star::uno::TypeClass_DOUBLE"; - if (type.equals("void")) - return bCStyle ? "typelib_TypeClass_VOID" : "::com::sun::star::uno::TypeClass_VOID"; - if (type.equals("unsigned long")) - return bCStyle ? "typelib_TypeClass_UNSIGNED_LONG" : "::com::sun::star::uno::TypeClass_UNSIGNED_LONG"; - if (type.equals("unsigned short")) - return bCStyle ? "typelib_TypeClass_UNSIGNED_SHORT" : "::com::sun::star::uno::TypeClass_UNSIGNED_SHORT"; - if (type.equals("unsigned hyper")) - return bCStyle ? "typelib_TypeClass_UNSIGNED_HYPER" : "::com::sun::star::uno::TypeClass_UNSIGNED_HYPER"; - } - break; - } - - return bCStyle ? "typelib_TypeClass_UNKNOWN" : "::com::sun::star::uno::TypeClass_UNKNOWN"; -} - -OString CorbaType::printUnoType(const OString& type, sal_Bool bConst, sal_Bool bRef, sal_Bool bNative) - throw( CannotDumpException ) -{ - OStringBuffer ret(1024); - OString sType(checkRealBaseType(type, sal_True)); - sal_uInt32 index = sType.lastIndexOf(']'); - sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - RTTypeClass typeClass = m_typeMgr.getTypeClass(relType); - - if (bConst) ret.append("const "); - - sal_uInt32 i; - for (i=0; i < seqNum; i++) - { - ret.append("::com::sun::star::uno::Sequence< "); - } - - switch (typeClass) - { - case RT_TYPE_INTERFACE: - if (bNative) - ret.append(scopedName(m_typeName, relType)); - else - ret.append("::com::sun::star::uno::Reference< ").append(scopedName(m_typeName, relType)).append(" >"); - break; - case RT_TYPE_INVALID: - { - OString tmp(getUnoBaseType(relType)); - if (tmp.getLength() > 0) - { - ret.append(getUnoBaseType(relType)); - } else - throw CannotDumpException("Unknown type '" + relType + "', incomplete type library. ("+type+")"); - } - break; - case RT_TYPE_STRUCT: - case RT_TYPE_ENUM: - case RT_TYPE_TYPEDEF: - case RT_TYPE_EXCEPTION: - ret.append(scopedName(m_typeName, relType)); - break; - } - - for (i=0; i < seqNum; i++) - { - ret.append(" >"); - } - - if (bRef) ret.append("&"); - return ret.makeStringAndClear(); -} - -void CorbaType::dumpUnoType(FileStream& o, const OString& type, - sal_Bool bConst, sal_Bool bRef, sal_Bool bNative) - throw( CannotDumpException ) -{ - OString ret = printUnoType(type, bConst, bRef, bNative); - o << ret; -} - -OString CorbaType::printCorbaType(const OString& type, sal_Bool bConst, sal_Bool bRef) - throw( CannotDumpException ) -{ - OStringBuffer ret(1024); - - OString sType(type); - - sal_uInt32 index = sType.lastIndexOf(']'); - sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - RTTypeClass typeClass = m_typeMgr.getTypeClass(relType); - - if (relType.equals("com/sun/star/uno/XInterface")) - relType = "Bonobo/Unknown"; - - if (relType.equals("com/sun/star/uno/TypeClass")) - relType = "CORBA_TypeCode"; - - if (relType.equals("com/sun/star/uno/RuntimeException")) - relType = "CORBA_SystemException"; - - if (relType.equals("com/sun/star/uno/Exception")) - relType = "CORBA_any"; - - if (bConst) ret.append("const "); - - - sal_uInt32 i; - for (i=0; i < seqNum; i++) - { - ret.append("CORBA_sequence_"); - } - - switch (typeClass) - { - case RT_TYPE_INTERFACE: - ret.append(relType.replace('/', '_')); - break; - case RT_TYPE_INVALID: - { - OString tmp(getUnoBaseType(relType)); - if (tmp.getLength() > 0) - ret.append(getCorbaBaseType(relType)); - else - throw CannotDumpException("Unknown type '" + relType + "', incomplete type library. ("+type+")"); - } - break; - case RT_TYPE_STRUCT: - case RT_TYPE_ENUM: - case RT_TYPE_TYPEDEF: - case RT_TYPE_EXCEPTION: - ret.append(relType.replace('/', '_')); - break; - } - - if (bRef) ret.append("&"); - - return ret.makeStringAndClear(); -} - -sal_Bool CorbaType::isPassedAsPointer(const OString& type) -{ - sal_Bool ret = sal_False; - - OString sType(checkSpecialCorbaType(type)); - - sal_Int32 index = sType.lastIndexOf(']'); - sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - if (index > 0) - { - OString fakeTest; - - sal_Int32 j = type.lastIndexOf('/'); - if (j >= 0) - fakeTest = type.copy(0, j+1)+"_faked_array_"+type.copy(j+1); - else - fakeTest = "_faked_array_"+sType; - - TypeReader fakeTestReader = m_typeMgr.getTypeReader(fakeTest); - - if (fakeTestReader.isValid()) - ret = sal_False; - else - ret = sal_True; - } - else - { - RTTypeClass typeClass = m_typeMgr.getTypeClass(sType); - - switch (typeClass) - { - case RT_TYPE_STRUCT: - case RT_TYPE_EXCEPTION: - ret = sal_True; - break; - - case RT_TYPE_INTERFACE: - case RT_TYPE_ENUM: - case RT_TYPE_INVALID: - if (sType.equals("any")) - ret = sal_True; - else - ret = sal_False; - break; - } - } - - return ret; -} - -sal_Bool CorbaType::isDerivedFromUnknown(const ::rtl::OString& typeName) -{ - sal_Bool ret = sal_True; - if (typeName.getLength() == 0) - ret = sal_False; - else if (typeName.equals("Bonobo/NullInterface")) - ret = sal_False; - else if (typeName.equals("com/sun/star/uno/XInterface")) - ret = sal_True; - else - { - TypeReader reader(m_typeMgr.getTypeReader(typeName)); - if (reader.isValid()) - ret = isDerivedFromUnknown(reader.getSuperTypeName()); - else - ret = sal_False; - } - return ret; -} - - -sal_Bool CorbaType::isArray(const OString& type) -{ - sal_Bool ret = sal_False; - - OString sType(checkSpecialCorbaType(type)); - - sal_Int32 index = sType.lastIndexOf(']'); - sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - if (index > 0) - { - OString fakeTest; - - sal_Int32 j = type.lastIndexOf('/'); - if (j >= 0) - fakeTest = type.copy(0, j+1)+"_faked_array_"+type.copy(j+1); - else - fakeTest = "_faked_array_"+sType; - - TypeReader fakeTestReader = m_typeMgr.getTypeReader(fakeTest); - - if (fakeTestReader.isValid()) - ret = sal_True; - } - - return ret; -} - -OString CorbaType::printCorbaParameter(const OString& type, sal_Bool bOut) - throw( CannotDumpException ) -{ - OStringBuffer ret(1024); - - OString sType(type); - sal_Int32 index = sType.lastIndexOf(']'); - sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - RTTypeClass typeClass = m_typeMgr.getTypeClass(relType); - - if (relType.equals("Bonobo/NullInterface")) - relType = "CORBA_Object"; - - if (relType.equals("com/sun/star/uno/XInterface")) - relType = "Bonobo/Unknown"; - - if (relType.equals("com/sun/star/uno/TypeClass")) - relType = "CORBA_TypeCode"; - - if (relType.equals("com/sun/star/uno/RuntimeException")) - relType = "CORBA_SystemException"; - - if (relType.equals("com/sun/star/uno/Exception")) - relType = "CORBA_any"; - - int i; - for (i=0; i < seqNum; i++) - { - ret.append("CORBA_sequence_"); - } - - switch (typeClass) - { - case RT_TYPE_INTERFACE: - ret.append(relType.replace('/', '_')); - break; - case RT_TYPE_INVALID: - { - OString tmp(getUnoBaseType(relType)); - if (tmp.getLength() > 0) - { - ret.append(getCorbaBaseType(relType)); - } else - throw CannotDumpException("Unknown type '" + relType + "', incomplete type library. ("+type+")"); - } - break; - case RT_TYPE_STRUCT: - case RT_TYPE_EXCEPTION: - case RT_TYPE_ENUM: - case RT_TYPE_TYPEDEF: - ret.append(relType.replace('/', '_')); - break; - } - - return ret.makeStringAndClear(); -} - -void CorbaType::dumpCorbaType(FileStream& o, const OString& type, - sal_Bool bConst, sal_Bool bRef) - throw( CannotDumpException ) -{ - OString ret = printCorbaType(type, bConst, bRef); - o << ret; -} - -OString CorbaType::getUnoBaseType(const OString& type) -{ - if (type.equals("long")) - return "sal_Int32"; - if (type.equals("short")) - return "sal_Int16"; - if (type.equals("hyper")) - return "sal_Int64"; - if (type.equals("string")) - return "::rtl::OUString"; - if (type.equals("boolean")) - return "sal_Bool"; - if (type.equals("char")) - return "sal_Unicode"; - if (type.equals("byte")) - return "sal_Int8"; - if (type.equals("any")) - return "::com::sun::star::uno::Any"; - if (type.equals("type")) - return "::com::sun::star::uno::Type"; - if (type.equals("float")) - return "float"; - if (type.equals("double")) - return "double"; - if (type.equals("octet")) - return "sal_Int8"; - if (type.equals("void")) - return type; - if (type.equals("unsigned long")) - return "sal_uInt32"; - if (type.equals("unsigned short")) - return "sal_uInt16"; - if (type.equals("unsigned hyper")) - return "sal_uInt64"; - - return OString(); -} - -OString CorbaType::getCorbaBaseType(const OString& type) -{ - if (type.equals("long")) - return "CORBA_long"; - if (type.equals("short")) - return "CORBA_short"; - if (type.equals("hyper")) - return "CORBA_long_long"; - if (type.equals("string")) - return "CORBA_char*"; - if (type.equals("boolean")) - return "CORBA_boolean"; - if (type.equals("char")) - return "CORBA_char"; - if (type.equals("byte")) - return "CORBA_octet"; - if (type.equals("any")) - return "CORBA_any"; - if (type.equals("type")) - return "CORBA_TypeCode"; - if (type.equals("float")) - return "CORBA_float"; - if (type.equals("double")) - return "CORBA_double"; - if (type.equals("octet")) - return "CORBA_octet"; - if (type.equals("void")) - return type; - if (type.equals("unsigned long")) - return "CORBA_unsigned_long"; - if (type.equals("unsigned short")) - return "CORBA_unsigned_short"; - if (type.equals("unsigned hyper")) - return "CORBA_unsigned_long_long"; - - return OString(); -} - - -void CorbaType::dumpTypeInit(FileStream& o, const OString& typeName) -{ - OString type(checkSpecialCorbaType(typeName)); - - BASETYPE baseType = isBaseType(type); - - switch (baseType) - { - case BT_BOOLEAN: - o << "(sal_False)"; - return; - break; - case BT_ANY: - case BT_STRING: - o << "()"; - return; - break; - case BT_INVALID: - break; - default: - o << "(("; - dumpUnoType(o, type); - o << ")" << "0)"; - return; - } - - RTTypeClass typeClass = m_typeMgr.getTypeClass(type); - - if (typeClass == RT_TYPE_ENUM) - { - RegistryTypeReaderLoader aReaderLoader; - - if (aReaderLoader.isLoaded()) - { - TypeReader reader(m_typeMgr.getTypeReader(type)); - - if ( reader.isValid() ) - { - sal_Int32 nPos = type.lastIndexOf( '/' ); - o << "(" << shortScopedName("", type, sal_False) - << "::" << type.copy( nPos != -1 ? nPos+1 : 0 ) - << "_" << reader.getFieldName(0) << ")"; - return; - } - } - } - - o << "()"; -} - -BASETYPE CorbaType::isBaseType(const OString& type) -{ - if (type.equals("long")) - return BT_LONG; - if (type.equals("short")) - return BT_SHORT; - if (type.equals("hyper")) - return BT_HYPER; - if (type.equals("string")) - return BT_STRING; - if (type.equals("boolean")) - return BT_BOOLEAN; - if (type.equals("char")) - return BT_CHAR; - if (type.equals("byte")) - return BT_BYTE; - if (type.equals("any")) - return BT_ANY; - if (type.equals("float")) - return BT_FLOAT; - if (type.equals("double")) - return BT_DOUBLE; - if (type.equals("void")) - return BT_VOID; - if (type.equals("unsigned long")) - return BT_UNSIGNED_LONG; - if (type.equals("unsigned short")) - return BT_UNSIGNED_SHORT; - if (type.equals("unsigned hyper")) - return BT_UNSIGNED_HYPER; - - return BT_INVALID; -} - -OString CorbaType::typeToIdentifier(const OString& type) -{ - sal_uInt32 index = type.lastIndexOf(']'); - sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? ((OString)type).copy(index+1) : type); - OString sIdentifier; - - while( seqNum > 0 ) - { - sIdentifier += OString("seq"); - - if ( --seqNum == 0 ) - { - sIdentifier += OString("_"); - } - } - - if ( isBaseType(relType) ) - { - sIdentifier += relType.replace(' ', '_'); - } else - { - sIdentifier += relType.replace('/', '_'); - } - - - return sIdentifier; -} - -OString CorbaType::checkSpecialCorbaType(const OString& type) -{ - OString baseType(type); - - RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader(); - - RegistryKey key; - sal_uInt8* pBuffer=NULL; - RTTypeClass typeClass; - sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF); - TypeReader reader; - - while (isTypeDef) - { - reader = m_typeMgr.getTypeReader(baseType); - - if (reader.isValid()) - { - typeClass = reader.getTypeClass(); - - if (typeClass == RT_TYPE_TYPEDEF) - baseType = reader.getSuperTypeName(); - else - isTypeDef = sal_False; - } else - break; - } - - return baseType; -} - -OString CorbaType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOnly) -{ - sal_uInt32 index = type.lastIndexOf(']'); - OString baseType = (index > 0 ? ((OString)type).copy(index+1) : type); - OString seqPrefix = (index > 0 ? ((OString)type).copy(0, index+1) : OString()); - - RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader(); - - RegistryKey key; - sal_uInt8* pBuffer=NULL; - RTTypeClass typeClass; - sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF); - TypeReader reader; - - while (mustBeChecked) - { - reader = m_typeMgr.getTypeReader(baseType); - - if (reader.isValid()) - { - typeClass = reader.getTypeClass(); - - if (typeClass == RT_TYPE_TYPEDEF) - { - baseType = reader.getSuperTypeName(); - index = baseType.lastIndexOf(']'); - if (index > 0) - { - seqPrefix += baseType.copy(0, index+1); - baseType = baseType.copy(index+1); - } - } else - mustBeChecked = sal_False; - } else - break; - } - - if ( bResolveTypeOnly ) - baseType = seqPrefix + baseType; - - return baseType; -} - - -void CorbaType::inc(sal_uInt32 num) -{ - m_indentLength += num; -} - -void CorbaType::dec(sal_uInt32 num) -{ - if (m_indentLength - num < 0) - m_indentLength = 0; - else - m_indentLength -= num; -} - -OString CorbaType::indent() -{ - OStringBuffer tmp(m_indentLength); - - for (sal_uInt32 i=0; i < m_indentLength; i++) - { - tmp.append(' '); - } - return tmp.makeStringAndClear(); -} - -OString CorbaType::indent(sal_uInt32 num) -{ - OStringBuffer tmp(m_indentLength + num); - - for (sal_uInt32 i=0; i < m_indentLength + num; i++) - { - tmp.append(' '); - } - return tmp.makeStringAndClear(); -} - -//************************************************************************* -// InterfaceType -//************************************************************************* -InterfaceType::InterfaceType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : CorbaType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ - m_inheritedMemberCount = 0; - m_hasAttributes = sal_False; - m_hasMethods = sal_False; -} - -InterfaceType::~InterfaceType() -{ - -} - - -void InterfaceType::dumpUnoMethods(FileStream& o, sal_Bool bDeclOnly, sal_Bool bDelegateToSuper) -{ - OString superName(m_reader.getSuperTypeName()); - if (bDeclOnly && - !superName.equals("Bonobo/NullInterface") && - !superName.equals("com/sun/star/uno/XInterface")) - { - TypeReader reader(m_typeMgr.getTypeReader(superName)); - InterfaceType iType(reader, superName, m_typeMgr, TypeDependency(), m_generatedConversions); - iType.inc(); - iType.dumpUnoMethods(o, bDeclOnly, sal_True); - } - - sal_uInt32 methodCount = m_reader.getMethodCount(); - sal_Bool first=sal_True; - - OString methodName, returnType, paramType, paramName; - sal_uInt32 paramCount = 0; - sal_uInt32 excCount = 0; - RTMethodMode methodMode = RT_MODE_INVALID; - RTParamMode paramMode = RT_PARAM_INVALID; - - sal_Bool bRef = sal_False; - sal_Bool bConst = sal_False; - sal_Bool bWithRunTimeExcp = sal_True; - - for (sal_uInt16 i=0; i < methodCount; i++) - { - methodName = m_reader.getMethodName(i); - returnType = m_reader.getMethodReturnType(i); - paramCount = m_reader.getMethodParamCount(i); - excCount = m_reader.getMethodExcCount(i); - methodMode = m_reader.getMethodMode(i); - - if ( methodName.equals("acquire") || methodName.equals("release") ) - bWithRunTimeExcp = sal_False; - - if (first) - { - first = sal_False; - o << "\n" << indent() << "// Methods\n"; - } - - o << indent(); - if (bDeclOnly) - o << "virtual "; - dumpUnoType(o, returnType); - o << " SAL_CALL "; - if (!bDeclOnly) - { - o << "bonobobridge::BonoboWrapper_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "::"; - } - - o << methodName << "( "; - - sal_uInt16 j; - for (j=0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - paramType = m_reader.getMethodParamType(i, j); - paramMode = m_reader.getMethodParamMode(i, j); - - switch (paramMode) - { - case RT_PARAM_IN: - { - OString relType = checkSpecialCorbaType(paramType); - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_ENUM || - (isBaseType(relType) && !relType.equals("string") && !relType.equals("any"))) - { - bConst = sal_False; - bRef = sal_False; - } else - { - bConst = sal_True; - bRef = sal_True; - } - break; - } - case RT_PARAM_OUT: - case RT_PARAM_INOUT: - bConst = sal_False; - bRef = sal_True; - break; - } - - dumpUnoType(o, paramType, bConst, bRef); - o << " " << paramName; - - if (j+1 < paramCount) o << ", "; - } - o << " )"; - - o << " throw("; - OString excpName; - for (j=0; j < excCount; j++) - { - excpName = m_reader.getMethodExcType(i, j); - if (excpName != "com/sun/star/uno/RuntimeException") - o << scopedName(m_typeName, excpName); - if (bWithRunTimeExcp) - o << ", "; - } - - if ( bWithRunTimeExcp ) - { - o << " ::com::sun::star::uno::RuntimeException"; - } - - if (bDeclOnly && bDelegateToSuper) - { - o << " ) {\n"; - if (returnType.equals("void")) - o << indent() << " "; - else - o << indent() << " return "; - o << "BonoboWrapper_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "::" << methodName << "( "; - for (j = 0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - o << paramName; - if (j < (paramCount-1)) - o << ", "; - } - o << " );\n" - << indent() << "}\n"; - } - else if (!bDeclOnly) - { - o << " ) {\n"; - - OStringBuffer preBuffer(1024); - OStringBuffer callBuffer(1024); - OStringBuffer postBuffer(1024); - - callBuffer.append(" "); - - if (!returnType.equals("void")) - { - preBuffer.append(" "); - preBuffer.append(printCorbaParameter(returnType)); - if (isPassedAsPointer(returnType)) - preBuffer.append("*"); - preBuffer.append(" _b_ret;\n"); - preBuffer.append(" "); - preBuffer.append(printUnoType(returnType, sal_False, sal_False)); - preBuffer.append(" _u_ret;\n"); - - callBuffer.append("_b_ret = "); - } - - callBuffer.append(printCorbaType(m_typeName, sal_False, sal_False)); - callBuffer.append("_"); - if (methodName.indexOf("_reserved_identifier_") == 0) - callBuffer.append(methodName.copy(OString("_reserved_identifier_").getLength())); - else - callBuffer.append(methodName); - - callBuffer.append("( m_corbaObject"); - - for (j=0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - paramType = m_reader.getMethodParamType(i, j); - paramMode = m_reader.getMethodParamMode(i, j); - - preBuffer.append(" "); - preBuffer.append(printCorbaParameter(paramType)); - if (isPassedAsPointer(paramType) && (paramMode == RT_PARAM_OUT)) - { - preBuffer.append("* _b_"); - preBuffer.append(paramName); - preBuffer.append(";\n"); - } - else - { - preBuffer.append(" _b_"); - preBuffer.append(paramName); - preBuffer.append(";\n"); - } - - switch (paramMode) { - case RT_PARAM_IN: - - if (isArray(paramType)) - preBuffer.append(" // fix me: conversion of array types!\n"); - else - { - preBuffer.append(" cpp_convert_u2b("); - preBuffer.append("_b_"); - preBuffer.append(paramName); - preBuffer.append(", "); - preBuffer.append(paramName); - preBuffer.append(", m_bridge);\n"); - } - - if (isPassedAsPointer(paramType)) - callBuffer.append(", &_b_"); - else - callBuffer.append(", _b_"); - break; - case RT_PARAM_INOUT: - - if (isArray(paramType)) - preBuffer.append(" // fix me: conversion of array types!\n"); - else - { - preBuffer.append(" cpp_convert_u2b("); - if (isPassedAsPointer(paramType)) - preBuffer.append("_b_"); - else - preBuffer.append("_b_"); - preBuffer.append(paramName); - preBuffer.append(", "); - preBuffer.append(paramName); - preBuffer.append(", m_bridge);\n"); - } - - callBuffer.append(", &_b_"); - - if (isArray(paramType)) - postBuffer.append(" // fix me: conversion of array types!\n"); - else - { - postBuffer.append(" cpp_convert_b2u("); - postBuffer.append(paramName); - postBuffer.append(", _b_"); - postBuffer.append(paramName); - postBuffer.append(", m_bridge);\n"); - } - - break; - case RT_PARAM_OUT: - - callBuffer.append(", &_b_"); - - if (isArray(paramType)) - postBuffer.append(" // fix me: conversion of array types!\n"); - else - { - postBuffer.append(" cpp_convert_b2u("); - postBuffer.append(paramName); - if (isPassedAsPointer(paramType)) - postBuffer.append(", *_b_"); - else - postBuffer.append(", _b_"); - postBuffer.append(paramName); - postBuffer.append(", m_bridge);\n"); - } - - break; - } - - - callBuffer.append(paramName); - } - - callBuffer.append(", &_ev );\n"); - - if (!returnType.equals("void")) - { - if (isArray(returnType)) - { - postBuffer.append(" // fix me: conversion of array types!\n"); - } - else - { - if (isPassedAsPointer(returnType)) - postBuffer.append(" cpp_convert_b2u(_u_ret, *_b_ret, m_bridge);\n"); - else - postBuffer.append(" cpp_convert_b2u(_u_ret, _b_ret, m_bridge);\n"); - } - postBuffer.append(" return _u_ret;\n"); - } - - o << " ::osl::MutexGuard guard(m_bridge->getORBLock());\n" - << " CORBA_Environment _ev;\n" - << " CORBA_exception_init (&_ev);\n"; - - o << preBuffer; - o << callBuffer; - - o << " if (_ev._major != CORBA_NO_EXCEPTION) {\n" - << " ::com::sun::star::uno::RuntimeException _ex(::rtl::OUString::createFromAscii(\"exception raised in bonobobridge\"), NULL);\n" - << " CORBA_exception_free (&_ev);\n" - << " throw _ex;\n" - << " }\n" - << " CORBA_exception_free (&_ev);\n"; - - o << postBuffer; - - o << indent() << "}\n"; - } - else - o << " );\n"; - } -} - -void InterfaceType::dumpCorbaMethods(FileStream& o, sal_Bool bDeclOnly) -{ - OString superName(m_reader.getSuperTypeName()); - - sal_uInt32 methodCount = m_reader.getMethodCount(); - - OString methodName, returnType, paramType, paramName; - sal_uInt32 paramCount = 0; - sal_uInt32 excCount = 0; - RTMethodMode methodMode = RT_MODE_INVALID; - RTParamMode paramMode = RT_PARAM_INVALID; - - sal_Bool bRef = sal_False; - sal_Bool bConst = sal_False; - sal_Bool bWithRunTimeExcp = sal_True; - - for (sal_uInt16 i=0; i < methodCount; i++) - { - methodName = m_reader.getMethodName(i); - returnType = m_reader.getMethodReturnType(i); - paramCount = m_reader.getMethodParamCount(i); - excCount = m_reader.getMethodExcCount(i); - methodMode = m_reader.getMethodMode(i); - - o << indent() - << "extern \"C\" " - << printCorbaParameter(returnType); - - if (isPassedAsPointer(returnType)) - o << "*"; - - o << " bonobobridge_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "_" << methodName << "( PortableServer_Servant _servant, "; - - sal_uInt16 j; - for (j=0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - paramType = m_reader.getMethodParamType(i, j); - paramMode = m_reader.getMethodParamMode(i, j); - - if ((isPassedAsPointer(paramType) || paramType.equals("string") || isArray(paramType)) && - (paramMode == RT_PARAM_IN)) - o << "const "; - - o << printCorbaParameter(paramType); - - if (isPassedAsPointer(paramType)) - { - if (paramMode == RT_PARAM_OUT) - o << "**"; - else - o << "*"; - } - else - { - if (paramMode != RT_PARAM_IN) - o << "*"; - } - - - o << " " << paramName << ", "; - } - - o << "CORBA_Environment * _ev)"; - - if (bDeclOnly) - o << ";\n"; - else - { - o << " {\n"; - OStringBuffer preBuffer(1024); - OStringBuffer callBuffer(1024); - OStringBuffer postBuffer(1024); - - callBuffer.append(" "); - - preBuffer.append(" "); - preBuffer.append(printUnoType(m_typeName, sal_False, sal_False)); - preBuffer.append(" rThis(("); - preBuffer.append(printUnoType(m_typeName, sal_False, sal_False, sal_True)); - preBuffer.append(" *)((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getUnoObject());\n"); - - if (!returnType.equals("void")) - { - preBuffer.append(" "); - preBuffer.append(printCorbaParameter(returnType)); - if (isPassedAsPointer(returnType)) - { - preBuffer.append("* _b_ret = "); - preBuffer.append(printCorbaType(returnType, sal_False, sal_False)); - preBuffer.append("__alloc();\n"); - - } - else - { - preBuffer.append(" _b_ret;\n"); - } - preBuffer.append(" "); - preBuffer.append(printUnoType(returnType, sal_False, sal_False)); - preBuffer.append(" _u_ret;\n"); - - callBuffer.append("_u_ret = "); - } - - callBuffer.append("rThis->"); - callBuffer.append(methodName); - callBuffer.append("( "); - - for (j=0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - paramType = m_reader.getMethodParamType(i, j); - paramMode = m_reader.getMethodParamMode(i, j); - - preBuffer.append(" "); - preBuffer.append(printUnoType(paramType, sal_False, sal_False)); - preBuffer.append(" _u_"); - preBuffer.append(paramName); - preBuffer.append(";\n"); - - callBuffer.append("_u_"); - callBuffer.append(paramName); - - if (j < (paramCount-1)) - callBuffer.append(", "); - - switch (paramMode) { - case RT_PARAM_IN: - - if (isArray(paramType)) - preBuffer.append(" // fix me: conversion of array types!\n"); - else - { - preBuffer.append(" cpp_convert_b2u("); - preBuffer.append("_u_"); - preBuffer.append(paramName); - preBuffer.append(", "); - if (isPassedAsPointer(paramType)) - preBuffer.append("*"); - preBuffer.append(paramName); - preBuffer.append(", ((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getBridge());\n"); - } - break; - case RT_PARAM_INOUT: - - if (isArray(paramType)) - { - preBuffer.append(" // fix me: conversion of array types!\n"); - postBuffer.append(" // fix me: conversion of array types!\n"); - } - else - { - preBuffer.append(" cpp_convert_b2u("); - preBuffer.append("_u_"); - preBuffer.append(paramName); - preBuffer.append(", "); - if (isPassedAsPointer(paramType)) - preBuffer.append("*"); - preBuffer.append(paramName); - preBuffer.append(", ((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getBridge());\n"); - - postBuffer.append(" cpp_convert_u2b("); - if (isPassedAsPointer(paramType)) - postBuffer.append("*"); - postBuffer.append(paramName); - postBuffer.append(", _u_"); - postBuffer.append(paramName); - postBuffer.append(", ((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getBridge());\n"); - } - break; - case RT_PARAM_OUT: - - if (isArray(paramType)) - preBuffer.append(" // fix me: conversion of array types!\n"); - else - { - postBuffer.append(" cpp_convert_u2b("); - if (isPassedAsPointer(paramType)) - postBuffer.append("**"); - else - postBuffer.append("*"); - postBuffer.append(paramName); - postBuffer.append(", _u_"); - postBuffer.append(paramName); - postBuffer.append(", ((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getBridge());\n"); - } - break; - } - } - - callBuffer.append(" );\n"); - - if (!returnType.equals("void")) - { - if (isArray(returnType)) - postBuffer.append(" // fix me: conversion of array types!\n"); - else - { - if (isPassedAsPointer(returnType)) - postBuffer.append(" cpp_convert_u2b(*_b_ret, _u_ret, ((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getBridge());\n"); - else - postBuffer.append(" cpp_convert_u2b(_b_ret, _u_ret, ((bonobobridge::UNO_POA_com_sun_star_uno_XInterface*)_servant)->pThis->getBridge());\n"); - } - - postBuffer.append(" return _b_ret;\n"); - } - - o << preBuffer; - o << callBuffer; - o << postBuffer; - - o << "}\n"; - } - } -} - -void InterfaceType::dumpFunctions(FileStream& o) -{ - if (m_typeName.equals("com/sun/star/uno/XInterface") || - m_typeName.equals("Bonobo/NullInterface")) - return; - - m_generatedConversions->insert(m_typeName); - - o << "namespace bonobobridge {\n\n"; - - /* bonobo implementation class */ - o << "class BonoboWrapper_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - - OString superName(m_reader.getSuperTypeName()); - o << " : public BonoboWrapper< BonoboWrapper_"; - dumpCorbaType(o, superName, sal_False, sal_False); - o << ", "; - dumpUnoType(o, m_typeName, sal_False, sal_False, sal_True); - o << " > {\n"; - - o << "public: \n" - << " BonoboWrapper_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "("; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << " corbaObject," - << "const vos::ORef<bonobobridge::Bridge>& bridge)\n"; - - o << " : BonoboWrapper< " - << "BonoboWrapper_"; - dumpCorbaType(o, superName, sal_False, sal_False); - o << ", "; - dumpUnoType(o, m_typeName, sal_False, sal_False, sal_True); - o << " >(corbaObject, bridge) {\n"; - - if (isDerivedFromUnknown(m_typeName)) - { - o << " m_bridge->registerObjectWrapper(::getCppuType(("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*)NULL), m_corbaObject, ("; - dumpUnoType(o, m_typeName, sal_False, sal_False, sal_True); - o << "*)this);\n"; - } - - o << " }\n"; - - o << " virtual ~BonoboWrapper_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "() {\n"; - if (isDerivedFromUnknown(m_typeName)) - { - o << " m_bridge->unregisterObjectWrapper(::getCppuType(("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*)NULL), m_corbaObject, ("; - dumpUnoType(o, m_typeName, sal_False, sal_False, sal_True); - o << "*)this);\n"; - } - o << " }\n"; - inc(); - dumpUnoMethods(o, sal_True, sal_False); - dec(); - - o << "};\n\n"; - - o << "}; // namespace bonobobridge\n"; - - dumpUnoMethods(o, sal_False, sal_False); - - /* convert function bonobo to uno */ - o << "static sal_Bool convert_b2u_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " sal_Bool ret = sal_True;\n "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "& _u = *("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pOut;\n const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "& _b = *(const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n\n" - << " _u = new bonobobridge::BonoboWrapper_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "(_b, bridge);\n" - << " return ret;\n"; - - o << "}\n\n"; - - /* POA implementation class */ - dumpCorbaMethods(o, sal_True); - o << "static POA_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "__epv bonobobridge_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "_epv = {\n"; - sal_uInt32 methodCount = m_reader.getMethodCount(); - OString methodName; - - o << " NULL,\n"; - - for (sal_uInt16 i=0; i < methodCount; i++) - { - methodName = m_reader.getMethodName(i); - o << " bonobobridge_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "_" << methodName; - - if (i < (methodCount-1)) - o << ",\n"; - else - o << "\n};\n"; - } - - OStringBuffer initBuffer(1024); - - initBuffer.insert(0, OString("&bonobobridge_") + printCorbaType(m_typeName, sal_False, sal_False) + OString("_epv")); - - while(superName.getLength() != 0) - { - if (superName.equals("Bonobo/NullInterface")) - { - superName = ""; - } - else - { - if (superName.equals("com/sun/star/uno/XInterface")) - { - initBuffer.insert(0, OString("&bonobobridge_com_sun_star_uno_XInterface_epv, ")); - } - else - { - initBuffer.insert(0, OString("&bonobobridge_") + printCorbaType(superName, sal_False, sal_False) + OString("_epv, ")); - } - TypeReader reader(m_typeMgr.getTypeReader(superName)); - superName = reader.getSuperTypeName(); - } - } - - initBuffer.insert(0, OString("NULL, ")); - - o << "static POA_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "__vepv bonobobridge_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "__vepv = {"; - o << initBuffer.makeStringAndClear(); - o << " };\n"; - - superName = m_reader.getSuperTypeName(); - - o << "namespace bonobobridge {\n\n"; - - o << "class UnoServant_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << " : public UnoServant_com_sun_star_uno_XInterface {\n"; - - o << "public:\n" - << " UnoServant_"; - - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "("; - dumpUnoType(o, m_typeName, sal_False, sal_False, sal_True); - o << "* unoObject," - << " const ::vos::ORef<bonobobridge::Bridge>& bridge," - << " CORBA_Environment *ev," - << " sal_Bool bInitPoa)\n" - << " : UnoServant_com_sun_star_uno_XInterface(unoObject, bridge, ev, sal_False) {\n" - << " if (bInitPoa) {\n" - << " memset(&m_POAUnknown, 0, sizeof(m_POAUnknown));\n" - << " POA_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "__init((PortableServer_Servant) &(m_POAUnknown.poa), ev);\n" - << " m_POAUnknown.pThis = (UnoServant_com_sun_star_uno_XInterface*)this;\n" - << " m_POAUnknown.poa.vepv = (POA_Bonobo_Unknown__vepv*)&bonobobridge_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "__vepv;\n" - << " }\n" - << " }\n" - << "};\n" - << "}; // namespace bonobobridge\n"; - - dumpCorbaMethods(o, sal_False); - - /* convert function uno to bonobo */ - o << "static sal_Bool convert_u2b_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n"; - o << " sal_Bool ret = sal_True;\n const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "& _u = *(const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "& _b = *("; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pOut;\n\n" - << " if (_u.is()) {\n" - << " bonobobridge::UnoServant_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << " *uno_servant;\n" - << " POA_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << " *poa;\n" - << " CORBA_Environment ev;\n" - << " CORBA_exception_init (&ev);\n" - << " uno_servant = new bonobobridge::UnoServant_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "(_u.get(), bridge, &ev, sal_True);\n" - << " poa = (POA_"; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*)uno_servant->getPOA();\n" - << " if (ev._major != CORBA_NO_EXCEPTION) {\n" - << " delete uno_servant;\n" - << " CORBA_exception_free (&ev);\n" - << " _b = CORBA_OBJECT_NIL;\n" - << " ret = sal_False;\n" - << " }\n" - << " else {\n" - << " CORBA_free(PortableServer_POA_activate_object(bridge->getPOA(), poa, &ev));\n" - << " _b = PortableServer_POA_servant_to_reference (bridge->getPOA(), poa, &ev);\n" - << " uno_servant->corbaObjectRegistered(_b, getCppuType(("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*)NULL)"; - - if (!isDerivedFromUnknown(m_typeName)) - o << ", sal_False"; - - o << ");\n" - << " }\n" - << " CORBA_exception_free (&ev);\n" - << " }\n" - << " return ret;\n" - << "}\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_b2u("; - dumpUnoType(o, m_typeName, sal_False, sal_True); - o << " u, "; - dumpCorbaType(o, m_typeName, sal_True, sal_True); - o << " b, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return bridge->convertB2U(&u, &b, ::getCppuType(&u));\n" - << "};\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_u2b("; - dumpCorbaType(o, m_typeName, sal_False, sal_True); - o << " b, "; - dumpUnoType(o, m_typeName, sal_True, sal_True); - o << " u, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return bridge->convertU2B(&b, &u, ::getCppuType(&u));\n" - << "};\n\n"; - - return; -} - - - - -sal_uInt32 InterfaceType::getMemberCount() -{ - sal_uInt32 count = m_reader.getMethodCount(); - - if (count) - m_hasMethods = sal_True; - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - m_hasAttributes = sal_True; - count++; - } - } - return count; -} - -sal_uInt32 InterfaceType::checkInheritedMemberCount(const TypeReader* pReader) -{ - sal_uInt32 cout = 0; - sal_Bool bSelfCheck = sal_True; - if (!pReader) - { - bSelfCheck = sal_False; - pReader = &m_reader; - } - - sal_uInt32 count = 0; - OString superType(pReader->getSuperTypeName()); - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - if (aSuperReader.isValid()) - { - count = checkInheritedMemberCount(&aSuperReader); - } - } - - if (bSelfCheck) - { - count += pReader->getMethodCount(); - sal_uInt32 fieldCount = pReader->getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = pReader->getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - count++; - } - } - - return count; -} - -sal_uInt32 InterfaceType::getInheritedMemberCount() -{ - if (m_inheritedMemberCount == 0) - { - m_inheritedMemberCount = checkInheritedMemberCount(0); - } - - return m_inheritedMemberCount; -} - - - - -//************************************************************************* -// ModuleType -//************************************************************************* -ModuleType::ModuleType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : CorbaType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ -} - -ModuleType::~ModuleType() -{ - -} - - -sal_Bool ModuleType::hasConstants() -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST) - return sal_True; - } - - return sal_False; -} - -void ModuleType::dumpFunctions(FileStream& o) -{ -}; - -sal_Bool ModuleType::dumpConversionFunctions(FileStream& o, TypeSet* allreadyDumped) - throw( CannotDumpException ) -{ - sal_Bool bSpecialDefine = sal_True; - - if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS) - { - bSpecialDefine = sal_False; - } - - dumpInclude(o, allreadyDumped, m_typeName, "hpp", bSpecialDefine); - - return sal_True; -} - -//************************************************************************* -// ConstantsType -//************************************************************************* -ConstantsType::ConstantsType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : ModuleType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ -} - -ConstantsType::~ConstantsType() -{ - -} - -void ConstantsType::dumpFunctions(FileStream& o) -{ -}; - -//************************************************************************* -// StructureType -//************************************************************************* -StructureType::StructureType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : CorbaType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ -} - -StructureType::~StructureType() -{ - -} - -void StructureType::dumpFunctions(FileStream& o) -{ - m_generatedConversions->insert(m_typeName); - - OString superType(m_reader.getSuperTypeName()); - - o << "static sal_Bool convert_b2u_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " sal_Bool ret = sal_True;\n "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "& _u = *("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pOut;\n const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "& _b = *(const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n\n"; - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - OString fieldName; - OString fieldType; - sal_uInt16 i=0; - sal_Int32 cIndex; - OString corbaFieldName; - - sal_Bool bIsUnion = sal_False; - - for (i=0; !bIsUnion && (i < fieldCount); i++) - bIsUnion = OString("_union_fake_tag").equals(m_reader.getFieldName(i)); - - if (bIsUnion) - { - o << " // fix me: union !!!!\n ret = sal_False;\n"; - } - else - { - if (superType.getLength() > 0) - { - o << " ret = bonobobridge::cpp_convert_b2u(("; - dumpUnoType(o, superType, sal_False, sal_False); - o << "&) _u, (const "; - dumpCorbaType(o, superType, sal_False, sal_False); - o << "&) _b, bridge);\n"; - } - - for (i=0; i < fieldCount; i++) - { - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - cIndex = fieldName.indexOf("_reserved_identifier_"); - - if (cIndex == 0) - corbaFieldName = fieldName.copy(OString("_reserved_identifier_").getLength()); - else - corbaFieldName = fieldName; - - if (isArray(fieldType)) - o << " // fix me: no conversion of array types!\n"; - else - o << " if (ret)\n" - << " ret = bonobobridge::cpp_convert_b2u(" - << "_u." << fieldName.getStr() - << " , _b." << corbaFieldName.getStr() - << ", bridge);\n"; - } - } - o << " return ret;\n" - << "}\n\n" - << "static sal_Bool convert_u2b_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " sal_Bool ret = sal_True;\n const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "& _u = *(const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "& _b = *("; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pOut;\n\n"; - - if (bIsUnion) - o << " // fix me: union !!!!\n ret = sal_False;\n"; - else - { - if (superType.getLength() > 0) - { - o << " ret = bonobobridge::cpp_convert_u2b(("; - dumpCorbaType(o, superType, sal_False, sal_False); - o << "&) _u, (const "; - dumpUnoType(o, superType, sal_False, sal_False); - o << "&) _b, bridge);\n"; - } - - for (i=0; i < fieldCount; i++) - { - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - cIndex = fieldName.indexOf("_reserved_identifier_"); - - if (cIndex == 0) - corbaFieldName = fieldName.copy(OString("_reserved_identifier_").getLength()); - else - corbaFieldName = fieldName; - - if (isArray(fieldType)) - o << " // fix me: no conversion of array types!\n"; - else - o << " if (ret)\n" - << " ret = bonobobridge::cpp_convert_u2b(" - << "_b." << corbaFieldName.getStr() - << ", _u." << fieldName.getStr() - << ", bridge);\n"; - } - } - - o << " return ret;\n" - << "}\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_b2u("; - dumpUnoType(o, m_typeName, sal_False, sal_True); - o << " u , "; - dumpCorbaType(o, m_typeName, sal_True, sal_True); - o << " b, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return convert_b2u_" << m_typeName.replace('/', '_') - << "(&u, &b, ::getCppuType(&u), bridge);\n" - << "};\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_u2b("; - dumpCorbaType(o, m_typeName, sal_False, sal_True); - o << " b, "; - dumpUnoType(o, m_typeName, sal_True, sal_True); - o << " u, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return convert_u2b_" << m_typeName.replace('/', '_') - << "(&b, &u, ::getCppuType(&u), bridge);\n" - << "};\n\n"; -} - -sal_Bool StructureType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType) -{ - sal_Bool hasMember = sal_False; - - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - - if (aSuperReader.isValid()) - { - hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType); - - sal_uInt32 fieldCount = aSuperReader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = aSuperReader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = aSuperReader.getFieldName(i); - fieldType = aSuperReader.getFieldType(i); - - if (hasMember) - { - o << ", "; - } else - { - hasMember = (fieldCount > 0); - } - - if (bWithType) - { - dumpUnoType(o, fieldType, sal_True, sal_True); - o << " "; - } - o << "__" << fieldName; - } - } - } - - return hasMember; -} - -//************************************************************************* -// ExceptionType -//************************************************************************* -ExceptionType::ExceptionType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : CorbaType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ -} - -ExceptionType::~ExceptionType() -{ - -} - -void ExceptionType::dumpFunctions(FileStream& o) -{ - if (m_typeName.equals("com/sun/star/uno/Exception")) - return; - - if (m_typeName.equals("com/sun/star/uno/RuntimeException")) - return; - - m_generatedConversions->insert(m_typeName); - - OString superType(m_reader.getSuperTypeName()); - - o << "static sal_Bool convert_b2u_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " sal_Bool ret = sal_True;\n"; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "& _u = *("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pOut;\n const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "& _b = *(const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n\n"; - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - OString fieldName; - OString fieldType; - sal_uInt16 i=0; - sal_Int32 cIndex; - OString corbaFieldName; - - if (superType.getLength() > 0) - { - o << " ret = bonobobridge::cpp_convert_b2u(("; - dumpUnoType(o, superType, sal_False, sal_False); - o << "&) _u, (const "; - dumpCorbaType(o, superType, sal_False, sal_False); - o << "&) _b, bridge);\n"; - } - - for (i=0; i < fieldCount; i++) - { - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - cIndex = fieldName.indexOf("_reserved_identifier_"); - - if (cIndex == 0) - corbaFieldName = fieldName.copy(OString("_reserved_identifier_").getLength()); - else - corbaFieldName = fieldName; - - if (isArray(fieldType)) - o << " // fix me: no conversion of array types!\n"; - else - o << " if (ret)\n" - << " ret = bonobobridge::cpp_convert_b2u(" - << "_u." << fieldName.getStr() - << ", _b." << corbaFieldName.getStr() - << ", bridge);\n"; - } - o << " return ret;\n" - << "}\n\n"; - - - o << "static sal_Bool convert_u2b_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " sal_Bool ret = sal_True;\n const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "& _u = *(const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "& _b = *("; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pOut;\n\n"; - - if (superType.getLength() > 0) - { - o << " ret = bonobobridge::cpp_convert_u2b(("; - dumpCorbaType(o, superType, sal_False, sal_False); - o << "&) _u, (const "; - dumpUnoType(o, superType, sal_False, sal_False); - o << "&) _b, bridge);\n"; - } - - for (i=0; i < fieldCount; i++) - { - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - cIndex = fieldName.indexOf("_reserved_identifier_"); - - if (cIndex == 0) - corbaFieldName = fieldName.copy(OString("_reserved_identifier_").getLength()); - else - corbaFieldName = fieldName; - - if (isArray(fieldType)) - o << " // fix me: no conversion of array types!\n"; - else - o << " if (ret)\n" - << " ret = bonobobridge::cpp_convert_u2b(" - << "_b." << corbaFieldName.getStr() - << ", _u." << fieldName.getStr() - << ", bridge);\n"; - } - - o << " return ret;\n" - << "}\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_b2u("; - dumpUnoType(o, m_typeName, sal_False, sal_True); - o << " u , "; - dumpCorbaType(o, m_typeName, sal_True, sal_True); - o << " b, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return convert_b2u_" << m_typeName.replace('/', '_') - << "(&u, &b, ::getCppuType(&u), bridge);\n" - << "};\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_u2b("; - dumpCorbaType(o, m_typeName, sal_False, sal_True); - o << " b, "; - dumpUnoType(o, m_typeName, sal_True, sal_True); - o << " u, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return convert_u2b_" << m_typeName.replace('/', '_') - << "(&b, &u, ::getCppuType(&u), bridge);\n" - << "};\n\n"; -} - - - -sal_Bool ExceptionType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType) -{ - sal_Bool hasMember = sal_False; - - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - - if (aSuperReader.isValid()) - { - hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType); - - sal_uInt32 fieldCount = aSuperReader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = aSuperReader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = aSuperReader.getFieldName(i); - fieldType = aSuperReader.getFieldType(i); - - if (hasMember) - { - o << ", "; - } else - { - hasMember = (fieldCount > 0); - } - - if (bWithType) - { - dumpUnoType(o, fieldType, sal_True, sal_True); - o << " "; - } - o << "__" << fieldName; - } - } - } - - return hasMember; -} - -//************************************************************************* -// EnumType -//************************************************************************* -EnumType::EnumType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : CorbaType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ -} - -EnumType::~EnumType() -{ - -} - -void EnumType::dumpFunctions(FileStream& o) -{ - if (m_typeName.equals("com/sun/star/uno/TypeClass")) - return; - - m_generatedConversions->insert(m_typeName); - - o << "static sal_Bool convert_b2u_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " *("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pOut = ("; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << ") *(const "; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n\n" - << " return sal_True;\n" - << "}\n\n"; - - o << "static sal_Bool convert_u2b_" << m_typeName.replace('/', '_') - << "(void* pOut, const void* pIn, const ::com::sun::star::uno::Type& type, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " *("; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << "*) pOut = ("; - dumpCorbaType(o, m_typeName, sal_False, sal_False); - o << ") *(const "; - dumpUnoType(o, m_typeName, sal_False, sal_False); - o << "*) pIn;\n\n" - << " return sal_True;\n" - << "}\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_b2u("; - dumpUnoType(o, m_typeName, sal_False, sal_True); - o << " u , "; - dumpCorbaType(o, m_typeName, sal_True, sal_True); - o << " b, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return convert_b2u_" << m_typeName.replace('/', '_') - << "(&u, &b, ::getCppuType(&u), bridge);\n" - << "};\n\n"; - - o << "inline sal_Bool bonobobridge::cpp_convert_u2b("; - dumpCorbaType(o, m_typeName, sal_False, sal_True); - o << " b, "; - dumpUnoType(o, m_typeName, sal_True, sal_True); - o << " u, const ::vos::ORef< ::bonobobridge::Bridge >& bridge) {\n" - << " return convert_u2b_" << m_typeName.replace('/', '_') - << "(&b, &u, ::getCppuType(&u), bridge);\n" - << "};\n\n"; - - return; -} - - -//************************************************************************* -// TypeDefType -//************************************************************************* -TypeDefType::TypeDefType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions) - : CorbaType(typeReader, typeName, typeMgr, typeDependencies, generatedConversions) -{ -} - -TypeDefType::~TypeDefType() -{ - -} - -void TypeDefType::dumpFunctions(FileStream& o) -{ -} - - - -//************************************************************************* -// produceType -//************************************************************************* -sal_Bool produceType(const OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - CorbaOptions* pOptions, - FileStream& o, TypeSet* allreadyDumped, - TypeSet* generatedConversions) - throw( CannotDumpException ) -{ - sal_Bool bNewTypeSet = (allreadyDumped == NULL); - sal_Bool ret = sal_True; - - if (bNewTypeSet) - allreadyDumped = new TypeSet(); - - - if (!typeDependencies.isGenerated(typeName)) - { - TypeReader reader(typeMgr.getTypeReader(typeName)); - - if (!reader.isValid() && !typeName.equals("/")) - ret = sal_False; - - if( ret && !checkTypeDependencies(typeMgr, typeDependencies, typeName)) - ret = sal_False; - - if (ret) - { - RTTypeClass typeClass = reader.getTypeClass(); - - switch (typeClass) - { - case RT_TYPE_INTERFACE: - { - InterfaceType iType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - ret = iType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - ret = iType.dumpDependedTypes(pOptions, o, allreadyDumped); - } - break; - case RT_TYPE_MODULE: - { - ModuleType mType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - if (mType.hasConstants()) - { - ret = mType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - } else - { - typeDependencies.setGenerated(typeName); - ret = sal_True; - } - } - break; - case RT_TYPE_STRUCT: - { - StructureType sType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - ret = sType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - ret = sType.dumpDependedTypes(pOptions, o, allreadyDumped); - } - break; - case RT_TYPE_ENUM: - { - EnumType enType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - ret = enType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - ret = enType.dumpDependedTypes(pOptions, o, allreadyDumped); - } - break; - case RT_TYPE_EXCEPTION: - { - ExceptionType eType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - ret = eType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - ret = eType.dumpDependedTypes(pOptions, o, allreadyDumped); - } - break; - case RT_TYPE_TYPEDEF: - { - TypeDefType tdType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - ret = tdType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - ret = tdType.dumpDependedTypes(pOptions, o, allreadyDumped); - } - break; - case RT_TYPE_CONSTANTS: - { - ConstantsType cType(reader, typeName, typeMgr, typeDependencies, generatedConversions); - if (cType.hasConstants()) - { - ret = cType.dump(pOptions, o, allreadyDumped); - if (ret) typeDependencies.setGenerated(typeName); - } else - { - typeDependencies.setGenerated(typeName); - ret = sal_True; - } - } - break; - case RT_TYPE_SERVICE: - case RT_TYPE_OBJECT: - ret = sal_True; - break; - } - } - } - - if (bNewTypeSet) - delete allreadyDumped; - - return ret; -} - -//************************************************************************* -// scopedName -//************************************************************************* -OString scopedName(const OString& scope, const OString& type, - sal_Bool bNoNameSpace) -{ - sal_Int32 nPos = type.lastIndexOf( '/' ); - if (nPos == -1) - return type; - - if (bNoNameSpace) - return type.copy(nPos+1); - - OStringBuffer tmpBuf(type.getLength()*2); - nPos = 0; - do - { - tmpBuf.append("::"); - tmpBuf.append(type.getToken(0, '/', nPos)); - } while( nPos != -1 ); - - return tmpBuf.makeStringAndClear(); -} - -//************************************************************************* -// shortScopedName -//************************************************************************* -OString shortScopedName(const OString& scope, const OString& type, - sal_Bool bNoNameSpace) -{ - sal_Int32 nPos = type.lastIndexOf( '/' ); - if( nPos == -1 ) - return OString(); - - if (bNoNameSpace) - return OString(); - - // scoped name only if the namespace is not equal - if (scope.lastIndexOf('/') > 0) - { - OString tmpScp(scope.copy(0, scope.lastIndexOf('/'))); - OString tmpScp2(type.copy(0, nPos)); - - if (tmpScp == tmpScp2) - return OString(); - } - - OString aScope( type.copy( 0, nPos ) ); - OStringBuffer tmpBuf(aScope.getLength()*2); - - nPos = 0; - do - { - tmpBuf.append("::"); - tmpBuf.append(aScope.getToken(0, '/', nPos)); - } while( nPos != -1 ); - - return tmpBuf.makeStringAndClear(); -} - - diff --git a/codemaker/source/bonobowrappermaker/corbatype.hxx b/codemaker/source/bonobowrappermaker/corbatype.hxx deleted file mode 100644 index 439aba86e68e..000000000000 --- a/codemaker/source/bonobowrappermaker/corbatype.hxx +++ /dev/null @@ -1,310 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _CORBAMAKER_CPPUTYPE_HXX_ -#define _CORBAMAKER_CPPUTYPE_HXX_ - -#include <codemaker/typemanager.hxx> -#include <codemaker/dependency.hxx> - -#include <hash_set> - -enum BASETYPE -{ - BT_INVALID, - BT_VOID, - BT_ANY, - BT_TYPE, - BT_BOOLEAN, - BT_CHAR, - BT_STRING, - BT_FLOAT, - BT_DOUBLE, - BT_OCTET, - BT_BYTE, - BT_SHORT, - BT_LONG, - BT_HYPER, - BT_UNSIGNED_SHORT, - BT_UNSIGNED_LONG, - BT_UNSIGNED_HYPER -}; - - -class CorbaOptions; -class FileStream; - -struct OStringEqual -{ - sal_Bool operator() (const ::rtl::OString& lhs, const ::rtl::OString& rhs) const - { return lhs.equals( rhs );} -}; - -struct OStringHash : public std::unary_function< const ::rtl::OString &, size_t > -{ - size_t operator()( const ::rtl::OString & rStr ) const - { return rStr.hashCode(); } -}; - -typedef std::hash_set< ::rtl::OString, OStringHash, OStringEqual > TypeSet; - -class CorbaType -{ -public: - CorbaType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~CorbaType(); - - virtual sal_Bool dump(CorbaOptions* pOptions, FileStream& o, TypeSet* allreadyDumped) throw( CannotDumpException ); - virtual sal_Bool dumpDependedTypes(CorbaOptions* pOptions, FileStream& o, TypeSet* allreadyDumped) throw( CannotDumpException ); - virtual sal_Bool dumpConversionFunctions(FileStream& o, TypeSet* allreadyDumped) throw( CannotDumpException ); - - static void dumpDefaultHxxIncludes(FileStream& o); - - virtual void dumpInclude(FileStream& o, TypeSet* allreadyDumped, const ::rtl::OString& typeName, sal_Char* prefix, sal_Bool bExtended=sal_False, sal_Bool bCaseSensitive=sal_False); - virtual void dumpDepIncludes(FileStream& o, TypeSet* allreadyDumped, const ::rtl::OString& typeName, sal_Char* prefix); - - virtual void dumpNameSpace(FileStream& o, sal_Bool bOpen = sal_True, sal_Bool bFull = sal_False, const ::rtl::OString& type=""); - virtual void dumpFunctions(FileStream& o) = 0; - - virtual ::rtl::OString printUnoType( const ::rtl::OString& type, - sal_Bool bConst=sal_False, - sal_Bool bRef=sal_False, - sal_Bool bNative=sal_False) - throw( CannotDumpException ); - - virtual void dumpUnoType(FileStream& o, - const ::rtl::OString& type, - sal_Bool bConst=sal_False, - sal_Bool bRef=sal_False, - sal_Bool bNative=sal_False) - throw( CannotDumpException ); - - virtual ::rtl::OString printCorbaType(const ::rtl::OString& type, - sal_Bool bConst, - sal_Bool bRef) - throw( CannotDumpException ); - - virtual void dumpCorbaType(FileStream& o, - const ::rtl::OString& type, - sal_Bool bConst=sal_False, - sal_Bool bRef=sal_False) - throw( CannotDumpException ); - - sal_Bool isPassedAsPointer(const ::rtl::OString& type); - sal_Bool isArray(const ::rtl::OString& type); - - sal_Bool isDerivedFromUnknown(const ::rtl::OString& typeName); - - - ::rtl::OString printCorbaParameter(const ::rtl::OString& type, - sal_Bool bOut = sal_False) - throw( CannotDumpException ); - - ::rtl::OString getTypeClass(const ::rtl::OString& type="", - sal_Bool bCStyle=sal_False); - ::rtl::OString getUnoBaseType(const ::rtl::OString& type); - ::rtl::OString getCorbaBaseType(const ::rtl::OString& type); - - void dumpTypeInit(FileStream& o, const ::rtl::OString& type); - BASETYPE isBaseType(const ::rtl::OString& type); - - ::rtl::OString typeToIdentifier(const ::rtl::OString& type); - - virtual sal_uInt32 getMemberCount(); - virtual sal_uInt32 getInheritedMemberCount(); - - sal_Bool isNestedTypeByName(const ::rtl::OString& type); - - void inc(sal_uInt32 num=4); - void dec(sal_uInt32 num=4); - ::rtl::OString indent(); - ::rtl::OString indent(sal_uInt32 num); -protected: - virtual sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); - - ::rtl::OString checkSpecialCorbaType(const ::rtl::OString& type); - ::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False); - -protected: - sal_uInt32 m_inheritedMemberCount; - sal_uInt32 m_indentLength; - ::rtl::OString m_typeName; - ::rtl::OString m_name; - TypeReader m_reader; - TypeManager& m_typeMgr; - TypeDependency m_dependencies; - TypeSet* m_generatedConversions; -}; - -class InterfaceType : public CorbaType -{ -public: - InterfaceType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~InterfaceType(); - - void dumpFunctions(FileStream& o); - - void dumpUnoMethods(FileStream& o, sal_Bool bDeclOnly, sal_Bool bDelegateToSuper); - void dumpCorbaMethods(FileStream& o, sal_Bool bDeclOnly); - - sal_uInt32 getMemberCount(); - sal_uInt32 getInheritedMemberCount(); - -protected: - sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); - -protected: - sal_uInt32 m_inheritedMemberCount; - sal_Bool m_hasAttributes; - sal_Bool m_hasMethods; -}; - -class ModuleType : public CorbaType -{ -public: - ModuleType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~ModuleType(); - - sal_Bool dumpConversionFunctions(FileStream& o, TypeSet* allreadyDumped) throw( CannotDumpException ); - void dumpFunctions(FileStream& o); - sal_Bool hasConstants(); -}; - -class ConstantsType : public ModuleType -{ -public: - ConstantsType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~ConstantsType(); - - void dumpFunctions(FileStream& o); -}; - -class StructureType : public CorbaType -{ -public: - StructureType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~StructureType(); - - void dumpFunctions(FileStream& o); - - sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType); -}; - -class ExceptionType : public CorbaType -{ -public: - ExceptionType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversions); - - virtual ~ExceptionType(); - - void dumpFunctions(FileStream& o); - - sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType); -}; - -class EnumType : public CorbaType -{ -public: - EnumType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~EnumType(); - - void dumpFunctions(FileStream& o); -}; - -class TypeDefType : public CorbaType -{ -public: - TypeDefType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies, - TypeSet* generatedConversion); - - virtual ~TypeDefType(); - - void dumpFunctions(FileStream& o); -}; - - -sal_Bool produceType(const ::rtl::OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - CorbaOptions* pOptions, - FileStream& o, TypeSet* allreadyDumped, - TypeSet* generatedConversions) - throw( CannotDumpException ); - -/** - * This function returns a C++ scoped name, represents the namespace - * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of - * the type is equal scope, the relativ name will be used. - */ -::rtl::OString scopedName(const ::rtl::OString& scope, - const ::rtl::OString& type, - sal_Bool bNoNameSpace=sal_False); - -::rtl::OString shortScopedName(const ::rtl::OString& scope, - const ::rtl::OString& type, - sal_Bool bNoNameSpace=sal_False); - - -#endif // _CORBAMAKER_CPPUTYPE_HXX_ - diff --git a/codemaker/source/bonobowrappermaker/makefile.mk b/codemaker/source/bonobowrappermaker/makefile.mk deleted file mode 100644 index 36889e96400f..000000000000 --- a/codemaker/source/bonobowrappermaker/makefile.mk +++ /dev/null @@ -1,62 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=codemaker -TARGET=bonobowrappermaker -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - - -CXXFILES= corbamaker.cxx \ - corbaoptions.cxx \ - corbatype.cxx - - -APP1TARGET= $(TARGET) - -APP1OBJS= $(OBJ)$/corbamaker.obj \ - $(OBJ)$/corbaoptions.obj \ - $(OBJ)$/corbatype.obj - -APP1STDLIBS= \ - $(SALLIB) \ - $(SALHELPERLIB) \ - $(REGLIB) - -APP1LIBS= \ - $(LB)$/codemaker.lib - -.INCLUDE : target.mk diff --git a/codemaker/source/codemaker/codemaker.cxx b/codemaker/source/codemaker/codemaker.cxx index d31b4762f235..8ce02ab0a1d5 100644 --- a/codemaker/source/codemaker/codemaker.cxx +++ b/codemaker/source/codemaker/codemaker.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -186,3 +187,5 @@ codemaker::UnoType::Sort decomposeAndResolve( } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/codemaker/dependencies.cxx b/codemaker/source/codemaker/dependencies.cxx index a005c07ec4fe..da8d33e1f88e 100644 --- a/codemaker/source/codemaker/dependencies.cxx +++ b/codemaker/source/codemaker/dependencies.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -279,3 +280,5 @@ void Dependencies::insert(rtl::OString const & type, bool base) { break; } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/codemaker/exceptiontree.cxx b/codemaker/source/codemaker/exceptiontree.cxx index 3fd581651ba3..e54483d39561 100644 --- a/codemaker/source/codemaker/exceptiontree.cxx +++ b/codemaker/source/codemaker/exceptiontree.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -104,3 +105,5 @@ void ExceptionTree::add(rtl::OString const & name, TypeManager const & manager) } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx index a83116635afc..7d3faa98121a 100644 --- a/codemaker/source/codemaker/global.cxx +++ b/codemaker/source/codemaker/global.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,7 +35,7 @@ #include "osl/file.hxx" #include <string.h> -#if defined(SAL_W32) || defined(SAL_OS2) +#if defined(SAL_W32) #include <io.h> #include <direct.h> @@ -151,7 +152,7 @@ OString createFileNameFromType( const OString& destination, continue; } -#if defined(SAL_UNX) || defined(SAL_OS2) +#if defined(SAL_UNX) if (mkdir((char*)nameBuffer.getStr(), 0777) == -1) #else if (mkdir((char*)nameBuffer.getStr()) == -1) @@ -447,3 +448,5 @@ FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s) { o.m_file, s.getStr(), s.getLength() * sizeof(sal_Char), &writtenBytes); return o; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/codemaker/makefile.mk b/codemaker/source/codemaker/makefile.mk index 515d3657969e..fb458fb6f61c 100644 --- a/codemaker/source/codemaker/makefile.mk +++ b/codemaker/source/codemaker/makefile.mk @@ -43,9 +43,7 @@ SLOFILES = \ $(SLO)$/codemaker.obj LIB1TARGET=$(LB)$/$(TARGET).lib -.IF "$(GUI)" != "OS2" LIB1ARCHIV=$(LB)$/lib$(TARGET).a -.ENDIF LIB1OBJFILES=$(SLOFILES) .INCLUDE: target.mk diff --git a/codemaker/source/codemaker/options.cxx b/codemaker/source/codemaker/options.cxx index 7bbc67056e75..8748db53c2c8 100644 --- a/codemaker/source/codemaker/options.cxx +++ b/codemaker/source/codemaker/options.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,7 @@ #include "codemaker/options.hxx" -using namespace rtl; +using ::rtl::OString; Options::Options() { @@ -97,3 +98,4 @@ OString Options::getExtraInputFile(sal_uInt16 index) const } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx index b1edde7f26c4..2e46ef713af8 100644 --- a/codemaker/source/codemaker/typemanager.cxx +++ b/codemaker/source/codemaker/typemanager.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,7 +34,10 @@ #include "registry/reader.hxx" #include "registry/version.h" -using namespace rtl; +using ::rtl::OUString; +using ::rtl::OString; +using ::rtl::OStringToOUString; +using ::rtl::OUStringToOString; TypeManager::TypeManager() { @@ -58,7 +62,7 @@ sal_Int32 TypeManager::release() { delete m_pImpl; } - return refCount;; + return refCount; } sal_Bool TypeManager::isBaseType(const ::rtl::OString& name) @@ -401,3 +405,5 @@ RegistryKeyList RegistryTypeManager::getTypeKeys(const ::rtl::OString& name_) co return keyList; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/codemaker/unotype.cxx b/codemaker/source/codemaker/unotype.cxx index c1b00dcb9b3d..cd3ce6d83752 100644 --- a/codemaker/source/codemaker/unotype.cxx +++ b/codemaker/source/codemaker/unotype.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -101,3 +102,5 @@ rtl::OString codemaker::UnoType::decompose( OSL_ASSERT(k == len - 1 && type[k] == '>'); return type.copy(i, j - i); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx index 4744af6df023..c8da1873846d 100644 --- a/codemaker/source/commoncpp/commoncpp.cxx +++ b/codemaker/source/commoncpp/commoncpp.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -353,3 +354,5 @@ rtl::OString translateUnoToCppIdentifier( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/commonjava/commonjava.cxx b/codemaker/source/commonjava/commonjava.cxx index 8ae254cbde84..fe2fad09eb43 100644 --- a/codemaker/source/commonjava/commonjava.cxx +++ b/codemaker/source/commonjava/commonjava.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -165,3 +166,5 @@ rtl::OString translateUnoToJavaIdentifier( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/cppumaker.cxx b/codemaker/source/cppumaker/cppumaker.cxx index e6d5679409e8..ae24f4291d8e 100644 --- a/codemaker/source/cppumaker/cppumaker.cxx +++ b/codemaker/source/cppumaker/cppumaker.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,7 +39,8 @@ #include "cppuoptions.hxx" #include "cpputype.hxx" -using namespace rtl; +using ::rtl::OString; +using ::rtl::OUString; namespace { @@ -242,3 +244,4 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/cppuoptions.cxx b/codemaker/source/cppumaker/cppuoptions.cxx index da8ce2089c6e..37b843b6544c 100644 --- a/codemaker/source/cppumaker/cppuoptions.cxx +++ b/codemaker/source/cppumaker/cppuoptions.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,14 +35,16 @@ #include "osl/thread.h" #include "osl/process.h" +using ::rtl::OUString; +using ::rtl::OUStringToOString; +using ::rtl::OString; + #ifdef SAL_UNX #define SEPARATOR '/' #else #define SEPARATOR '\\' #endif -using namespace rtl; - sal_Bool CppuOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) throw( IllegalArgument ) { @@ -360,3 +363,5 @@ OString CppuOptions::prepareVersion() } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/cppuoptions.hxx b/codemaker/source/cppumaker/cppuoptions.hxx index b291eb548e73..567372e91c5d 100644 --- a/codemaker/source/cppumaker/cppuoptions.hxx +++ b/codemaker/source/cppumaker/cppuoptions.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,3 +50,5 @@ protected: }; #endif // INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_CPPUOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index a08e0be518be..51a01f6d8059 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -50,9 +51,12 @@ #include "dumputils.hxx" #include "includes.hxx" -using namespace rtl; using namespace codemaker::cpp; +using ::rtl::OUString; +using ::rtl::OString; +using ::rtl::OStringBuffer; + namespace { rtl::OString translateSimpleUnoType(rtl::OString const & unoType, bool cppuUnoType=false) { @@ -359,6 +363,7 @@ void CppuType::addDefaultHxxIncludes(codemaker::cppumaker::Includes & includes) const { //TODO: Only include what is really needed + includes.addRtlInstanceHxx(); includes.addOslMutexHxx(); includes.addType(); if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE) { @@ -589,16 +594,21 @@ void CppuType::dumpNormalGetCppuType(FileStream& o) void CppuType::dumpComprehensiveGetCppuType(FileStream& o) { - dumpGetCppuTypePreamble(o); - - o << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n"; + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false); + else + o << "namespace cppu { "; + o << " namespace detail {\n\n"; - o << indent() << "if (the_pType == 0)\n" << indent() << "{\n"; + OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1); + OString sStaticTypeClass = "the" + sType + "Type"; + o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n"; + o << indent() << "{\n"; inc(); - o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n"; - - o << indent() << "if (the_pType == 0)\n" << indent() << "{\n"; + o << indent() << "::com::sun::star::uno::Type operator()() const\n"; + o << indent() << "{\n"; inc(); + o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\"" << m_typeName.replace('/', '.') << "\") );\n\n"; @@ -675,8 +685,8 @@ void CppuType::dumpComprehensiveGetCppuType(FileStream& o) } else { o << indent() << count << ",\n" << indent() << "0 );\n\n"; } - dec(); + o << indent() << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD" " );\n\n"); @@ -684,15 +694,24 @@ void CppuType::dumpComprehensiveGetCppuType(FileStream& o) o << indent() << "typelib_typedescription_release( pTD );\n" << indent() << "// End inline typedescription generation\n\n"; - o << indent() << "static ::com::sun::star::uno::Type the_staticType( " + o << indent() << "::com::sun::star::uno::Type the_staticType( " << getTypeClass(m_typeName) << ", sTypeName );\n"; - o << indent() << "the_pType = &the_staticType;\n"; + o << indent() << "return the_staticType;\n"; dec(); o << indent() << "}\n"; dec(); - o << indent() << "}\n\n"; - o << indent() << "return *the_pType;\n"; + o << indent() << "};\n\n"; + + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false); + else + o << " }"; + + o << " }\n\n"; + + dumpGetCppuTypePreamble(o); + o << indent() << "return detail::" << sStaticTypeClass << "::get();\n"; dumpGetCppuTypePostamble(o); } @@ -1200,7 +1219,7 @@ void CppuType::dumpConstantValue(FileStream& o, sal_uInt16 index) { ::rtl::OUString aUStr(constValue.m_value.aString); ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US); - o << "::rtl::OUString::createFromAscii(\"" << aStr.getStr() << "\")"; + o << "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"" << aStr.getStr() << "\"))"; } break; } @@ -1515,15 +1534,20 @@ void InterfaceType::dumpNormalGetCppuType(FileStream& o) void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o) { - dumpGetCppuTypePreamble(o); - - o << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n"; + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false); + else + o << "namespace cppu { "; + o << " namespace detail {\n\n"; - o << indent() << "if (the_pType == 0)\n" << indent() << "{\n"; + OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1); + OString sStaticTypeClass = "the" + sType + "Type"; + o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n"; + o << indent() << "{\n"; inc(); - o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n"; + o << indent() << "::com::sun::star::uno::Type operator()() const\n"; + o << indent() << "{\n"; - o << indent() << "if (the_pType == 0)\n" << indent() << "{\n"; inc(); o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\"" << m_typeName.replace('/', '.') << "\") );\n\n"; @@ -1595,9 +1619,38 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o) << ("typelib_typedescription_release( (typelib_TypeDescription*)pTD" " );\n\n"); - o << indent() << "static ::com::sun::star::uno::Type the_staticType( " + o << indent() << "::com::sun::star::uno::Type the_staticType( " << getTypeClass(m_typeName) << ", sTypeName );\n"; - o << indent() << "the_pType = &the_staticType;\n"; + + o << indent() << "return the_staticType;\n"; + + dec(); + + o << indent() << "}\n"; + dec(); + o << indent() << "};\n\n"; + + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false); + else + o << " }"; + o << " }\n\n"; + + dumpGetCppuTypePreamble(o); + o << indent() << "const ::com::sun::star::uno::Type &rRet = detail::" << sStaticTypeClass << "::get();\n"; + + o << indent() << "// End inline typedescription generation\n"; + + o << indent() << "static bool bInitStarted = false;\n"; + o << indent() << "if (!bInitStarted)\n"; + o << indent() << "{\n"; + inc(); + o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n"; + o << indent() << "if (!bInitStarted)\n"; + o << indent() << "{\n"; + inc(); + o << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n"; + o << indent() << "bInitStarted = true;\n"; StringSet aTypes; // type for RuntimeException is always needed @@ -1615,14 +1668,18 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o) dumpCppuMethods(o, index); } - o << indent() << "// End inline typedescription generation\n"; - dec(); - o << indent() << "}\n"; + o << indent() << "}\n"; + dec(); + o << indent() << "}\n"; + o << indent() << "else\n"; + o << indent() << "{\n"; + inc(); + o << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n"; dec(); - o << indent() << "}\n\n" - << indent() << "return *the_pType;\n"; + o << indent() << "}\n"; + o << indent() << "return rRet;\n"; dumpGetCppuTypePostamble(o); } @@ -1831,6 +1888,10 @@ void InterfaceType::dumpCppuAttributes(FileStream& o, sal_uInt32& index) inc(); o << indent() << "::rtl::OUString sAttributeType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\"" << fieldType.replace('/', '.') << "\") );\n"; + + o << indent() << "::rtl::OUString sAttributeName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\"" + << scope.replace('/', '.') << "::" << fieldName << "\") );\n"; + sal_Int32 getExceptions = dumpAttributeExceptionTypeNames( o, "get", name, RT_MODE_ATTRIBUTE_GET); sal_Int32 setExceptions = dumpAttributeExceptionTypeNames( @@ -1873,6 +1934,7 @@ void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index) if (m_hasMethods) { o << "\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n"; + OString scope = m_typeName.replace('/', '.'); for (sal_uInt16 i=0; i < methodCount; i++) { @@ -1942,6 +2004,9 @@ void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index) o << indent() << "::rtl::OUString sReturnType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\"" << returnType.replace('/', '.') << "\") );\n"; + o << indent() << "::rtl::OUString sMethodName" << i << + "( RTL_CONSTASCII_USTRINGPARAM(\"" + << scope.replace('/', '.') << "::" << methodName << "\") );\n"; o << indent() << "typelib_typedescription_newInterfaceMethod( &pMethod,\n"; inc(); o << indent() << absoluteIndex++ << ", "; @@ -1949,6 +2014,7 @@ void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index) o << "sal_True,\n"; else o << "sal_False,\n"; + o << indent() << "sMethodName" << i << ".pData,\n"; o << indent() << "(typelib_TypeClass)" << getTypeClass(returnType) << ", sReturnType" << i << ".pData,\n"; @@ -2366,8 +2432,6 @@ sal_Bool StructureType::dumpDeclaration(FileStream& o) { o << "\n#ifdef SAL_W32\n" << "# pragma pack(push, 8)\n" - << "#elif defined(SAL_OS2)\n" - << "# pragma pack(8)\n" << "#endif\n\n"; OSL_ASSERT(!isPolymorphic() || m_reader.getSuperTypeCount() == 0); //TODO @@ -2444,8 +2508,6 @@ sal_Bool StructureType::dumpDeclaration(FileStream& o) o << "#ifdef SAL_W32\n" << "# pragma pack(pop)\n" - << "#elif defined(SAL_OS2)\n" - << "# pragma pack()\n" << "#endif\n\n"; return sal_True; @@ -2781,14 +2843,30 @@ void StructureType::dumpNormalGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void StructureType::dumpComprehensiveGetCppuType(FileStream & out) { - dumpGetCppuTypePreamble(out); - out << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n" - << indent() << "if (the_pType == 0) {\n"; +void StructureType::dumpComprehensiveGetCppuType(FileStream & out) +{ + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false); + else + out << "namespace cppu { "; + out << " namespace detail {\n\n"; + + OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1); + OString sStaticTypeClass = "the" + sType + "Type"; + out << indent(); + if (isPolymorphic()) + dumpTemplateHead(out); + out << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, "; + out << sStaticTypeClass; + if (isPolymorphic()) + dumpTemplateParameters(out); + out << " >\n"; + + out << indent() << "{\n"; inc(); - out << indent() - << "::osl::MutexGuard the_guard(::osl::Mutex::getGlobalMutex());\n" - << indent() << "if (the_pType == 0) {\n"; + out << indent() << "::com::sun::star::uno::Type operator()() const\n"; + out << indent() << "{\n"; + inc(); if (isPolymorphic()) { out << indent() << "::rtl::OUStringBuffer the_buffer;\n" << indent() @@ -2912,18 +2990,26 @@ void StructureType::dumpComprehensiveGetCppuType(FileStream & out) { out << ", " << fields << ", the_members);\n"; out << indent() << "::typelib_typedescription_register(&the_newType);\n"; out << indent() << "::typelib_typedescription_release(the_newType);\n"; - out << indent() << "static ::com::sun::star::uno::Type the_staticType(" + + out << indent() << "::com::sun::star::uno::Type the_staticType(" << getTypeClass(m_typeName) << ", the_name);\n"; - out << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n"; - out << indent() << "the_pType = &the_staticType;\n"; + out << indent() << "return the_staticType;\n"; dec(); out << indent() << "}\n"; dec(); - out << indent() << "} else {\n"; - inc(); - out << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n"; - dec(); - out << indent() << "}\n" << indent() << "return *the_pType;\n"; + out << indent() << "};\n"; + + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false); + else + out << " }"; + out << " }\n\n"; + + dumpGetCppuTypePreamble(out); + out << indent() << "return detail::" << sStaticTypeClass; + if (isPolymorphic()) + dumpTemplateParameters(out); + out << "::get();\n"; dumpGetCppuTypePostamble(out); } @@ -3017,7 +3103,7 @@ void StructureType::addComprehensiveGetCppuTypeIncludes( { includes.addType(); includes.addCppuUnotypeHxx(); - includes.addOslDoublecheckedlockingH(); + includes.addRtlInstanceHxx(); includes.addOslMutexHxx(); includes.addRtlUstringH(); includes.addRtlUstringHxx(); @@ -3584,15 +3670,20 @@ void EnumType::dumpNormalGetCppuType(FileStream& o) void EnumType::dumpComprehensiveGetCppuType(FileStream& o) { - dumpGetCppuTypePreamble(o); - - o << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n"; + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false); + else + o << "namespace cppu { "; + o << " namespace detail {\n\n"; - o << indent() << "if (the_pType == 0)\n" << indent() << "{\n"; + OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1); + OString sStaticTypeClass = "the" + sType + "Type"; + o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n"; + o << indent() << "{\n"; inc(); - o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n"; + o << indent() << "::com::sun::star::uno::Type operator()() const\n"; + o << indent() << "{\n"; - o << indent() << "if (the_pType == 0)\n" << indent() << "{\n"; inc(); o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\"" << m_typeName.replace('/', '.') << "\") );\n\n"; @@ -3644,16 +3735,23 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o) o << indent() << "typelib_typedescription_release( pTD );\n" << indent() << "// End inline typedescription generation\n\n"; - o << indent() << "static ::com::sun::star::uno::Type the_staticType( " + o << indent() << "::com::sun::star::uno::Type the_staticType( " << getTypeClass(m_typeName) << ", sTypeName );\n"; - o << indent() << "the_pType = &the_staticType;\n"; + o << indent() << "return the_staticType;\n"; dec(); o << indent() << "}\n"; dec(); - o << indent() << "}\n\n" - << indent() << "return *the_pType;\n"; + o << indent() << "};\n\n"; + if (!isPolymorphic()) + codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false); + else + o << " }"; + o << " }\n\n"; + + dumpGetCppuTypePreamble(o); + o << indent() << "return detail::" << sStaticTypeClass << "::get();\n"; dumpGetCppuTypePostamble(o); } @@ -4502,3 +4600,5 @@ OString scopedName(const OString& scope, const OString& type, return tmpBuf.makeStringAndClear(); } */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/cpputype.hxx b/codemaker/source/cppumaker/cpputype.hxx index 55b74ff60f94..2823e9c30159 100644 --- a/codemaker/source/cppumaker/cpputype.hxx +++ b/codemaker/source/cppumaker/cpputype.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -404,3 +405,4 @@ bool produceType(RegistryKey& typeName, bool bIsExtraType, #endif // INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_CPPUTYPE_HXX +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/dumputils.cxx b/codemaker/source/cppumaker/dumputils.cxx index b19a98af9f0f..05f178eed2fe 100644 --- a/codemaker/source/cppumaker/dumputils.cxx +++ b/codemaker/source/cppumaker/dumputils.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -89,3 +90,5 @@ void dumpTypeIdentifier(FileStream & out, rtl::OString const & registryType) { } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/dumputils.hxx b/codemaker/source/cppumaker/dumputils.hxx index 1f8f1e831c12..265110dedbea 100644 --- a/codemaker/source/cppumaker/dumputils.hxx +++ b/codemaker/source/cppumaker/dumputils.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,3 +45,5 @@ void dumpTypeIdentifier(FileStream & out, rtl::OString const & registryType); } } #endif // INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_DUMPUTILS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx index e1e3f43360fb..96e8313906d3 100644 --- a/codemaker/source/cppumaker/includes.cxx +++ b/codemaker/source/cppumaker/includes.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -59,6 +60,7 @@ Includes::Includes( m_includeRtlTextencH(false), m_includeRtlUstrbufHxx(false), m_includeRtlUstringH(false), m_includeRtlUstringHxx(dependencies.hasStringDependency()), + m_includeRtlInstanceHxx(false), m_includeSalTypesH( dependencies.hasBooleanDependency() || dependencies.hasByteDependency() || dependencies.hasShortDependency() @@ -249,6 +251,10 @@ void Includes::dump(FileStream & out, rtl::OString const * companionHdl) { dumpEmptyLineBeforeFirst(out, &first); out << ("#include \"rtl/ustring.hxx\"\n"); } + if (m_includeRtlInstanceHxx) { + dumpEmptyLineBeforeFirst(out, &first); + out << "#include \"rtl/instance.hxx\"\n"; + } if (m_includeSalTypesH) { dumpEmptyLineBeforeFirst(out, &first); out << "#include \"sal/types.h\"\n"; @@ -278,3 +284,5 @@ void Includes::dumpInclude( bool Includes::isInterfaceType(rtl::OString const & registryType) const { return m_manager.getTypeClass(registryType) == RT_TYPE_INTERFACE; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx index afa2b41f09f3..c8477a19e10a 100644 --- a/codemaker/source/cppumaker/includes.hxx +++ b/codemaker/source/cppumaker/includes.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,43 +46,26 @@ public: ~Includes(); void add(rtl::OString const & registryType); - void addAny() { m_includeAny = true; } - void addReference() { m_includeReference = true; } - void addSequence() { m_includeSequence = true; } - void addType() { m_includeType = true; } - void addCppuMacrosHxx() { m_includeCppuMacrosHxx = true; } - void addCppuUnotypeHxx() { m_includeCppuUnotypeHxx = true; } - void addOslDoublecheckedlockingH() - { m_includeOslDoublecheckedlockingH = true; } - + { m_includeOslDoublecheckedlockingH = true; } void addOslMutexHxx() { m_includeOslMutexHxx = true; } - void addRtlStrbufHxx() { m_includeRtlStrbufHxx = true; } - void addRtlStringH() { m_includeRtlStringH = true; } - void addRtlTextencH() { m_includeRtlTextencH = true; } - void addRtlUstrbufHxx() { m_includeRtlUstrbufHxx = true; } - void addRtlUstringH() { m_includeRtlUstringH = true; } - void addRtlUstringHxx() { m_includeRtlUstringHxx = true; } - + void addRtlInstanceHxx() { m_includeRtlInstanceHxx = true; } void addSalTypesH() { m_includeSalTypesH = true; } - void addTypelibTypeclassH() { m_includeTypelibTypeclassH = true; } - void addTypelibTypedescriptionH() - { m_includeTypelibTypedescriptionH = true; } - + { m_includeTypelibTypedescriptionH = true; } void dump(FileStream & out, rtl::OString const * companionHdl); static void dumpInclude( @@ -111,6 +95,7 @@ private: bool m_includeRtlUstrbufHxx; bool m_includeRtlUstringH; bool m_includeRtlUstringHxx; + bool m_includeRtlInstanceHxx; bool m_includeSalTypesH; bool m_includeTypelibTypeclassH; bool m_includeTypelibTypedescriptionH; @@ -119,3 +104,5 @@ private: } } #endif // INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_INCLUDES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/cppumaker/makefile.mk b/codemaker/source/cppumaker/makefile.mk index a3ff38c4c07a..c05773e416f3 100644 --- a/codemaker/source/cppumaker/makefile.mk +++ b/codemaker/source/cppumaker/makefile.mk @@ -36,6 +36,12 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk + +.IF "$(OS)" == "IOS" +all: + @echo No build-time tools for this platform +.ENDIF + .INCLUDE : $(PRJ)$/codemaker.pmk # --- Files -------------------------------------------------------- diff --git a/codemaker/source/cunomaker/cunomaker.cxx b/codemaker/source/cunomaker/cunomaker.cxx deleted file mode 100644 index 56f20b0968c1..000000000000 --- a/codemaker/source/cunomaker/cunomaker.cxx +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" - -#include <stdio.h> - -#include "sal/main.h" - -#include <codemaker/typemanager.hxx> -#include <codemaker/dependency.hxx> - -#include "cunooptions.hxx" -#include "cunotype.hxx" - -using namespace rtl; - -sal_Bool produceAllTypes(const OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - CunoOptions* pOptions, - sal_Bool bFullScope) - throw( CannotDumpException ) -{ - if (!produceType(typeName, typeMgr, typeDependencies, pOptions)) - { - fprintf(stderr, "%s ERROR: %s\n", - pOptions->getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - - RegistryKey typeKey = typeMgr.getTypeKey(typeName); - RegistryKeyNames subKeys; - - if (typeKey.getKeyNames(OUString(), subKeys)) - return sal_False; - - OString tmpName; - for (sal_uInt32 i=0; i < subKeys.getLength(); i++) - { - tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8); - - if (pOptions->isValid("-B")) - tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1); - else - tmpName = tmpName.copy(1); - - if (bFullScope) - { - if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True)) - return sal_False; - } else - { - if (!produceType(tmpName, typeMgr, typeDependencies, pOptions)) - return sal_False; - } - } - - return sal_True; -} - -SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) -{ - CunoOptions options; - - try - { - if (!options.initOptions(argc, argv)) - { - exit(1); - } - } - catch( IllegalArgument& e) - { - fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr()); - exit(99); - } - - RegistryTypeManager typeMgr; - TypeDependency typeDependencies; - - if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles())) - { - fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr()); - exit(99); - } - - if (options.isValid("-B")) - { - typeMgr.setBase(options.getOption("-B")); - } - - try - { - if (options.isValid("-T")) - { - OString tOption(options.getOption("-T")); - - OString typeName, tmpName; - sal_Bool ret = sal_False; - sal_Int32 nIndex = 0; - do - { - typeName = tOption.getToken(0, ';', nIndex); - - sal_Int32 nPos = typeName.lastIndexOf( '.' ); - tmpName = typeName.copy( nPos != -1 ? nPos+1 : 0 ); - if (tmpName == "*") - { - // produce this type and his scope, but the scope is not recursively generated. - if (typeName.equals("*")) - { - tmpName = "/"; - } else - { - tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/'); - if (tmpName.getLength() == 0) - tmpName = "/"; - else - tmpName.replace('.', '/'); - } - ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False); - } else - { - // produce only this type - ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options); - } - - if (!ret) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - } while( nIndex != -1 ); - } else - { - // produce all types - if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True)) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - "an error occurs while dumping all types."); - exit(99); - } - } - } - catch( CannotDumpException& e) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - e.m_message.getStr()); - exit(99); - } - - return 0; -} - - diff --git a/codemaker/source/cunomaker/cunooptions.cxx b/codemaker/source/cunomaker/cunooptions.cxx deleted file mode 100644 index 909ab3edc8dd..000000000000 --- a/codemaker/source/cunomaker/cunooptions.cxx +++ /dev/null @@ -1,329 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" -#include <stdio.h> - -#include "cunooptions.hxx" - -using namespace rtl; - -sal_Bool CunoOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) - throw( IllegalArgument ) -{ - sal_Bool ret = sal_True; - sal_uInt16 i=0; - - if (!bCmdFile) - { - bCmdFile = sal_True; - - m_program = av[0]; - - if (ac < 2) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - ret = sal_False; - } - - i = 1; - } else - { - i = 0; - } - - char *s=NULL; - for (i; i < ac; i++) - { - if (av[i][0] == '-') - { - switch (av[i][1]) - { - case 'O': - if (av[i][2] == 'C') - { - if (av[i][3] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-OC', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 3; - } - - m_options["-OC"] = OString(s); - break; - } else - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-O', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-O"] = OString(s); - break; - case 'B': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-B', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-B"] = OString(s); - break; - case 'T': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-T', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - if (m_options.count("-T") > 0) - { - OString tmp(m_options["-T"]); - tmp = tmp + ";" + s; - m_options["-T"] = tmp; - } else - { - m_options["-T"] = OString(s); - } - break; - case 'U': - if (av[i][2] != '\0') - { - OString tmp("'-U', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - m_options["-U"] = OString(""); - break; -/* - case 'L': - if (av[i][2] != '\0') - { - OString tmp("'-L', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - if (isValid("-C") || isValid("-CS")) - { - OString tmp("'-L' could not be combined with '-C' or '-CS' option"); - throw IllegalArgument(tmp); - } - m_options["-L"] = OString(""); - break; -*/ - case 'C': - if (av[i][2] != '\0') - { - OString tmp("'-C', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - if (isValid("-L") || isValid("-CS")) - { - OString tmp("'-C' could not be combined with '-L' or '-CS' option"); - throw IllegalArgument(tmp); - } - m_options["-C"] = OString(""); - break; - case 'G': - if (av[i][2] == 'c') - { - if (av[i][3] != '\0') - { - OString tmp("'-Gc', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - m_options["-Gc"] = OString(""); - break; - } else - if (av[i][2] != '\0') - { - OString tmp("'-G', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - m_options["-G"] = OString(""); - break; - default: - throw IllegalArgument("the option is unknown" + OString(av[i])); - break; - } - } else - { - if (av[i][0] == '@') - { - FILE* cmdFile = fopen(av[i]+1, "r"); - if( cmdFile == NULL ) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - ret = sal_False; - } else - { - int rargc=0; - char* rargv[512]; - char buffer[512]; - - while ( fscanf(cmdFile, "%s", buffer) != EOF ) - { - rargv[rargc]= strdup(buffer); - rargc++; - } - fclose(cmdFile); - - ret = initOptions(rargc, rargv, bCmdFile); - - for (long i=0; i < rargc; i++) - { - free(rargv[i]); - } - } - } else - { - m_inputFiles.push_back(av[i]); - } - } - } - - return ret; -} - -OString CunoOptions::prepareHelp() -{ - OString help("\nusing: "); - help += m_program + " [-options] file_1 ... file_n\nOptions:\n"; - help += " -O<path> = path describes the root directory for the generated output.\n"; - help += " The output directory tree is generated under this directory.\n"; - help += " -T<name> = name specifies a type or a list of types. The output for this\n"; - help += " [t1;...] type is generated. If no '-T' option is specified,\n"; - help += " then output for all types is generated.\n"; - help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n"; - help += " -B<name> = name specifies the base node. All types are searched under this\n"; - help += " node. Default is the root '/' of the registry files.\n"; - help += " -U = activate the generating of a getCppuType_<name> function.\n"; -// help += " -L = getCppuType function with a known leak.\n"; - help += " -C = getCppuType_<name> function keeps comprehensive type information.\n"; - help += " -G = generate only target files which does not exists.\n"; - help += " -Gc = generate only target files which content will be changed.\n"; - help += prepareVersion(); - - return help; -} - -OString CunoOptions::prepareVersion() -{ - OString version(m_program); - version += " Version 1.0\n\n"; - return version; -} - - diff --git a/codemaker/source/cunomaker/cunooptions.hxx b/codemaker/source/cunomaker/cunooptions.hxx deleted file mode 100644 index ba47d6bcf1b9..000000000000 --- a/codemaker/source/cunomaker/cunooptions.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOOPTIONS_HXX -#define INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOOPTIONS_HXX - -#include <codemaker/options.hxx> - -class CunoOptions : public Options -{ -public: - CunoOptions() - : Options() {} - - ~CunoOptions() {} - - sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) - throw( IllegalArgument ); - - ::rtl::OString prepareHelp(); - - ::rtl::OString prepareVersion(); - -protected: -}; - -#endif // INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOOPTIONS_HXX diff --git a/codemaker/source/cunomaker/cunotype.cxx b/codemaker/source/cunomaker/cunotype.cxx deleted file mode 100644 index 56e87300eebe..000000000000 --- a/codemaker/source/cunomaker/cunotype.cxx +++ /dev/null @@ -1,3533 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" - -#include <stdio.h> -#include <rtl/alloc.h> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> - -#include "cunotype.hxx" -#include "cunooptions.hxx" - -using namespace rtl; - -//************************************************************************* -// CunoType -//************************************************************************* -CunoType::CunoType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : m_inheritedMemberCount(0) - , m_cunoTypeLib(sal_False) - , m_cunoTypeLeak(sal_False) - , m_cunoTypeDynamic(sal_True) - , m_indentLength(0) - , m_typeName(typeName) -// , m_name(typeName.getToken(typeName.getTokenCount('/') - 1, '/')) - , m_name(typeName.replace('/', '_')) - , m_reader(typeReader) - , m_typeMgr((TypeManager&)typeMgr) - , m_dependencies(typeDependencies) - , m_bIsNestedType(sal_False) -{ - // check if this type is nested - sal_Int32 i = typeName.lastIndexOf('/'); - - if (i >= 0) - { - OString outerTypeName(typeName.copy(0, i)); - m_bIsNestedType = (m_typeMgr.getTypeClass(outerTypeName) == RT_TYPE_INTERFACE); - } - - // check if this type has nested types - RegistryKey key = m_typeMgr.getTypeKey(typeName); - - key.getKeyNames(OUString(), m_nestedTypeNames); -} - -CunoType::~CunoType() -{ - -} - -sal_Bool CunoType::isNestedTypeByName(const ::rtl::OString& type) -{ - sal_Bool ret = sal_False; - - sal_Int32 i = type.lastIndexOf('/'); - - if (i >= 0) - { - OString outerTypeName(type.copy(0, i)); - ret = (m_typeMgr.getTypeClass(outerTypeName) == RT_TYPE_INTERFACE); - } - - return ret; -} - -sal_Bool CunoType::hasNestedType(const ::rtl::OString& type) -{ - sal_Bool ret = sal_False; - - if (m_nestedTypeNames.getLength() > 0) - { - OUString typeName(OStringToOUString(type, RTL_TEXTENCODING_UTF8)); - - for (sal_uInt32 i = 0; !ret && (i < m_nestedTypeNames.getLength()); i++) - ret = typeName.equals(m_nestedTypeNames.getElement(i).copy(5)); - } - - return ret; -} - -sal_Bool CunoType::dump(CunoOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - if (isNestedType()) - return sal_True; - - if (pOptions->isValid("-U")) - m_cunoTypeLib = sal_True; - if (pOptions->isValid("-L")) - m_cunoTypeLeak = sal_True; - if (pOptions->isValid("-C")) - m_cunoTypeDynamic = sal_False; - - OString outPath; - if (pOptions->isValid("-O")) - outPath = pOptions->getOption("-O"); - - OString tmpFileName; - OString hFileName = createFileNameFromType(outPath, m_typeName, ".h"); - - sal_Bool bFileExists = sal_False; - sal_Bool bFileCheck = sal_False; - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( hFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmh"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream hFile; - - if ( bFileCheck ) - hFile.open(tmpFileName); - else - hFile.open(hFileName); - - if(!hFile.isValid()) - { - OString message("cannot open "); - message += hFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpHFile(hFile); - - hFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(hFileName, tmpFileName); - } - } - - if ( m_cunoTypeLib ) - { - bFileExists = sal_False; - bFileCheck = sal_False; - - if (pOptions->isValid("-OC")) - outPath = pOptions->getOption("-OC"); - else - outPath = OString(); - - OString cFileName = createFileNameFromType(outPath, m_typeName, ".c"); - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( cFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmc"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream cFile; - - if ( bFileCheck ) - cFile.open(tmpFileName); - else - cFile.open(cFileName); - - if(!cFile.isValid()) - { - OString message("cannot open "); - message += cFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpCFile(cFile); - - cFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(cFileName, tmpFileName); - } - } - } - return ret; -} -sal_Bool CunoType::dumpDependedTypes(CunoOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_True; - - TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName)); - - TypeUsingSet::const_iterator iter = usingSet.begin(); - OString typeName; - sal_uInt32 index = 0; - while (iter != usingSet.end()) - { - typeName = (*iter).m_type; - if ((index = typeName.lastIndexOf(']')) > 0) - typeName = typeName.copy(index + 1); - - if (getBaseType(typeName).getLength() == 0) - { - if (!produceType(typeName, - m_typeMgr, - m_dependencies, - pOptions)) - { - fprintf(stderr, "%s ERROR: %s\n", - pOptions->getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - } - ++iter; - } - - return ret; -} - -OString CunoType::dumpHeaderDefine(FileStream& o, sal_Char* prefix, sal_Bool bExtended) -{ - if (m_typeName.equals("/")) - { - bExtended = sal_False; - m_typeName = "global"; - } - - sal_uInt32 length = 3 + m_typeName.getLength() + strlen(prefix); - - if (bExtended) - length += m_name.getLength() + 1; - - OStringBuffer tmpBuf(length); - - tmpBuf.append('_'); - tmpBuf.append(m_typeName); - tmpBuf.append('_'); - if (bExtended) - { - tmpBuf.append(m_name); - tmpBuf.append('_'); - } - tmpBuf.append(prefix); - tmpBuf.append('_'); - - OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toAsciiUpperCase()); - - o << "#ifndef " << tmp << "\n#define " << tmp << "\n"; - - return tmp; -} - -void CunoType::dumpDefaultHIncludes(FileStream& o) -{ - o << "#ifndef _UNO_CUNO_H_\n" - << "#include <uno/cuno.h>\n" - << "#endif\n"; -/* - if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE && - !m_typeName.equals("com/sun/star/uno/XInterface") ) - { - o << "#ifndef _COM_SUN_STAR_UNO_XINTERFACE_H_\n" - << "#include <com/sun/star/uno/XInterface.h>\n" - << "#endif\n"; - } -*/ -} - -void CunoType::dumpDefaultCIncludes(FileStream& o) -{ - o << "#ifndef _OSL_MUTEX_H_\n" - << "#include <osl/mutex.h>\n" - << "#endif\n\n"; -} - -void CunoType::dumpInclude(FileStream& o, const OString& typeName, sal_Char* prefix, sal_Bool bExtended, sal_Bool bCaseSensitive) -{ - sal_uInt32 length = 3+ m_typeName.getLength() + strlen(prefix); - - if (bExtended) - length += m_name.getLength() + 1; - - OStringBuffer tmpBuf(length); - - tmpBuf.append('_'); - tmpBuf.append(typeName); - tmpBuf.append('_'); - if (bExtended) - { - tmpBuf.append(m_name); - tmpBuf.append('_'); - } - tmpBuf.append(prefix); - tmpBuf.append('_'); - - OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toAsciiUpperCase()); - - length = 1 + typeName.getLength() + strlen(prefix); - if (bExtended) - length += m_name.getLength() + 1; - - tmpBuf.ensureCapacity(length); - tmpBuf.append(typeName); - if (bExtended) - { - tmpBuf.append('/'); - tmpBuf.append(m_name); - } - tmpBuf.append('.'); - tmpBuf.append(prefix); - - o << "#ifndef " << tmp << "\n#include <"; - if (bCaseSensitive) - { - o << tmpBuf.makeStringAndClear(); - } else - { - o << tmpBuf.makeStringAndClear(); - } - o << ">\n#endif\n"; -} - -void CunoType::dumpDepIncludes(FileStream& o, const OString& typeName, sal_Char* prefix) -{ - TypeUsingSet usingSet(m_dependencies.getDependencies(typeName)); - - TypeUsingSet::const_iterator iter = usingSet.begin(); - - OString sPrefix(OString(prefix).toAsciiUpperCase()); - sal_Bool bSequenceDumped = sal_False; - sal_uInt32 index = 0; - sal_uInt32 seqNum = 0; - OString relType; - while (iter != usingSet.end()) - { - sal_Bool bDumpThisType = sal_True; - index = (*iter).m_type.lastIndexOf(']'); - seqNum = (index > 0 ? ((index+1) / 2) : 0); - - relType = (*iter).m_type; - if (index > 0) - relType = relType.copy(index+1); - - if (isNestedTypeByName(relType) && hasNestedType(relType)) - bDumpThisType = sal_False; - - if (bDumpThisType) - { - OString defPrefix("H"); - if (sPrefix.equals("H")) - defPrefix = "H"; - - if (seqNum > 0 && !bSequenceDumped) - { - bSequenceDumped = sal_True; - o << "#ifndef _UNO_SEQUENCE2_" << defPrefix - << "_\n#include <uno/sequence2." << defPrefix.toAsciiLowerCase() - << ">\n#endif\n"; - } - - if (getBaseType(relType).getLength() == 0 && - m_typeName != relType) - { - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE - && sPrefix.equals("H")) - { - if (!((*iter).m_use & TYPEUSE_SUPER)) - { - if (isNestedTypeByName(relType)) - { - sal_Int32 iLastS = relType.lastIndexOf('/'); - - OString outerNamespace(relType.copy(0,iLastS)); - OString innerClass(relType.copy(iLastS+1)); - - iLastS = outerNamespace.lastIndexOf('/'); - OString outerClass(outerNamespace.copy(iLastS+1)); - -// o << "\n"; -// dumpNameSpace(o, sal_True, sal_False, outerNamespace); -// o << "\nclass " << outerClass << "::" << innerClass << ";\n"; -// dumpNameSpace(o, sal_False, sal_False, outerNamespace); -// o << "\n\n"; - } - else - { -// dumpInclude(o, relType, prefix); - OString type(relType.replace('/', '_')); - o << "\n#ifndef " << type.toAsciiUpperCase() << "\n"; - o << "#define " << type.toAsciiUpperCase() << "\n"; - o << "struct _" << type << ";\n" - << "typedef struct _" << type << "_ftab * " << type << ";\n"; - o << "#endif\n\n"; - } - } else - { - if (isNestedTypeByName(relType)) - { - sal_Int32 iLastS = relType.lastIndexOf('/'); - - OString outerNamespace(relType.copy(0,iLastS)); - - dumpInclude(o, outerNamespace, prefix); - } - else - dumpInclude(o, relType, prefix); - } - } else - { - if (isNestedTypeByName(relType)) - { - sal_Int32 iLastS = relType.lastIndexOf('/'); - - OString outerNamespace(relType.copy(0,iLastS)); - - dumpInclude(o, outerNamespace, prefix); - } - else - dumpInclude(o, relType, prefix); - } - } else - if (relType == "any") - { - o << "#ifndef _UNO_ANY2_H_\n" - << "#include <uno/any2.h>\n" - << "#endif\n"; - } else - if (relType == "type") - { - o << "#ifndef _TYPELIB_TYPEDESCRIPTION_H_\n" - << "#include <typelib/typedescription.h>\n" - << "#endif\n"; - } else - if (relType == "string" && sPrefix.equals("H")) - { - o << "#ifndef _RTL_USTRING_H_\n" - << "#include <rtl/ustring.h>\n" - << "#endif\n"; - } - } - ++iter; - } - if (m_typeName.equals(typeName) && (getNestedTypeNames().getLength() > 0)) - { - o << "// includes for nested types\n\n"; - - for (sal_uInt32 i = 0; i < getNestedTypeNames().getLength(); i++) - { - OUString s(getNestedTypeNames().getElement(i)); - - OString nestedName(s.getStr(), s.getLength(), RTL_TEXTENCODING_UTF8); - - dumpDepIncludes(o, nestedName, prefix); - } - } -} - -void CunoType::dumpOpenExternC(FileStream& o) -{ - o << "#ifdef __cplusplus\n" - << "extern \"C\" {\n" - << "#endif\n\n"; -} - -void CunoType::dumpCloseExternC(FileStream& o) -{ - o << "#ifdef __cplusplus\n" - << "}\n" - << "#endif\n\n"; -} - -void CunoType::dumpLGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - if (m_reader.getTypeClass() == RT_TYPE_TYPEDEF) - { - o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( ) SAL_THROW( () )\n{\n"; - } else - { - o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCunoType( "; - dumpType(o, m_typeName, sal_True, sal_False); - o << "* ) SAL_THROW( () )\n{\n"; - } - inc(); - - o << indent() << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << indent() << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "typelib_static_type_init( &s_pType_" << typeName << ", " - << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\" );\n"; - dec(); - o << indent() << "}\n"; - o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_" - << typeName <<" );\n"; - dec(); - o << indent() << "}\n"; - - return; -} - -void CunoType::dumpGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - if ( m_cunoTypeLeak ) - { - dumpLGetCunoType(o); - return; - } - if ( !m_cunoTypeDynamic ) - { - dumpCGetCunoType(o); - return; - } - - dumpOpenExternC(o); - - if ( !m_typeName.equals("com/sun/star/uno/Exception") ) - { - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - } - - o << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () )\n{\n"; - inc(); - - if ( m_typeName.equals("com/sun/star/uno/Exception") ) - { - o << indent() << "return typelib_static_type_getByTypeClass( typelib_TypeClass_EXCEPTION );\n"; - } else - { - o << indent() << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << indent() << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - - OString superType(m_reader.getSuperTypeName()); - sal_Bool bIsBaseException = sal_False; - if (superType.getLength() > 0) - { - if ( superType.equals("com/sun/star/uno/Exception") ) - { - bIsBaseException = sal_True; - } else - { - o << indent() << "typelib_TypeDescriptionReference * pBaseType = 0;\n"; - } - } - - sal_uInt32 count = getMemberCount(); - if (count) - { - o << indent() << "typelib_TypeDescriptionReference * aMemberRefs[" << count << "];\n"; - } - - if ( !bIsBaseException ) - { - o << indent() << "typelib_typedescriptionreference_newByAsciiName(&pBaseType, typelib_TypeClass_INTERFACE, \"" - << superType.replace('/', '.') << "\" );\n"; - } - - if (count) - { - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldType, fieldName; - OString scope = m_typeName.replace('/', '.'); - sal_Bool bWithScope = sal_True; - OString modFieldType; - StringSet generatedTypeSet; - StringSet::iterator findIter; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True); - -// modFieldType = typeToIdentifier(fieldType); - - findIter = generatedTypeSet.find(fieldType); - if ( findIter == generatedTypeSet.end() ) - { - generatedTypeSet.insert(fieldType); - o << indent() << "typelib_typedescriptionreference_newByAsciiName(&aMemberRefs[" - << i << "], " << getTypeClass(fieldType, sal_True); - o << " , \"" << fieldType.replace('/', '.') << "\" );\n"; - } - } - o << "\n"; - } - - o << indent() << "typelib_static_compound_type_init( &s_pType_" << typeName << ", " - << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\", "; - if ( superType.getLength() > 0 || bIsBaseException ) - { - if ( bIsBaseException ) - { - o << "* typelib_static_type_getByTypeClass( typelib_TypeClass_EXCEPTION ), " - << count << ", "; - } else - { - o << "pBaseType, " << count << ", "; - } - } else - { - o << "0, " << count << ", "; - } - - if (count) - { - o << " aMemberRefs );\n"; - } else - { - o << " 0 );\n"; - } - dec(); - o << indent() << "}\n" - << indent() << "typelib_typedescriptionreference_acquire( s_pType_" << typeName << " );\n" - << indent() << "return &_pType_" << typeName <<" );\n"; - } - dec(); - o << indent() << "}\n"; - - dumpCloseExternC(o); -} - -void CunoType::dumpCGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - dumpOpenExternC(o); - - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () )\n{\n"; - inc(); - - o << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "oslMutex * pMutex = osl_getGlobalMutex();\n" - << indent() << "osl_acquireMutex( pMutex );\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "rtl_uString * pTypeName = 0;\n" - << indent() << "typelib_TypeDescription * pTD = 0;\n"; - - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - o << indent() << "typelib_TypeDescriptionReference * pSuperType = 0;\n"; - - sal_uInt32 count = getMemberCount(); - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - if (count) - { - o << indent() << "typelib_CompoundMember_Init aMembers[" - << count << "];\n"; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - o << indent() << "rtl_uString * pMemberName" << i << " = 0;\n" - << indent() << "rtl_uString * pMemberType" << i << " = 0;\n"; - } - } - - o << indent() << "rtl_uString_newFromAscii( &pTypeName, \"" << m_typeName.replace('/', '.') << "\" );\n"; - - if (superType.getLength() > 0) - { - o << indent() << "typelib_typedescriptionreference_newByAsciiName(&pSuperType, typelib_TypeClass_INTERFACE, \"" - << superType.replace('/', '.') << "\" );\n"; - } - - dumpCppuGetTypeMemberDecl(o, CUNOTYPEDECL_ALLTYPES); - - if (count) - { - OString fieldType, fieldName; - OString scope = m_typeName.replace('/', '.'); - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True); - - o << indent() << "rtl_uString_newFromAscii( &pMemberType" << i << ", \"" - << fieldType.replace('/', '.') << "\") );\n"; - o << indent() << "rtl_uString_newFromAscii( &pMemberName" << i << ", \""; - o << fieldName << "\") );\n"; - o << indent() << "aMembers[" << i << "].eTypeClass = " - << getTypeClass(fieldType, sal_True) << ";\n" - << indent() << "aMembers[" << i << "].pTypeName = pMemberType" << i << ";\n" - << indent() << "aMembers[" << i << "].pMemberName = pMemberName" << i << ";\n"; - } - - o << "\n" << indent() << "typelib_typedescription_new(\n"; - inc(); - o << indent() << "&pTD,\n" << indent() - << getTypeClass(OString(), sal_True) << ", pTypeName,\n"; - - if (superType.getLength() > 0) - o << indent() << "pSuperType,\n"; - else - o << indent() << "0,\n"; - - if ( count ) - { - o << indent() << count << ",\n" << indent() << "aMembers );\n\n"; - } else - { - o << indent() << count << ",\n" << indent() << "0 );\n\n"; - } - - dec(); - o << indent() << "typelib_typedescription_register( &pTD );\n\n"; - - o << indent() << "typelib_typedescriptionreference_new( &s_pType_ " << typeName - << getTypeClass(OString(), sal_True) << ", pTD);\n\n"; - - o << indent() << "typelib_typedescription_release( pTD );\n" - << indent() << "typelib_typedescriptionreference_release( pSuperType );\n" - << indent() << "rtl_uString_release( pTypeName );\n"; - - for (i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - o << indent() << "rtl_uString_release( pMemberName" << i << " );\n" - << indent() << "rtl_uString_release( pMemberType" << i << " );\n"; - } - } - - dec(); - o << indent() << "}\n"; - o << indent() << "osl_releaseMutex( pMutex );\n"; - dec(); - o << indent() << "}\n" - << indent() << "typelib_typedescriptionreference_acquire( s_pType_" << typeName << " );\n" - << indent() << "return &s_pType_" << typeName <<" );\n"; - dec(); - o << "}\n"; - - dumpCloseExternC(o); -} - -void CunoType::dumpCppuGetTypeMemberDecl(FileStream& o, CunoTypeDecl eDeclFlag) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - - if ( fieldCount ) - { - o << indent() << "{\n" << indent() << "typelib_TypeDescriptionReference ** ppTypeRef = 0;\n"; - - StringSet aFinishedTypes; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - if (aFinishedTypes.count(m_reader.getFieldType(i)) == 0) - { - aFinishedTypes.insert(m_reader.getFieldType(i)); - dumpCppuGetType(o, m_reader.getFieldType(i), sal_True, eDeclFlag); - } - } - o << indent() << "}\n"; - } -} - -sal_uInt32 CunoType::getMemberCount() -{ - sal_uInt32 count = m_reader.getMethodCount(); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - count++; - } - return count; -} - -sal_uInt32 CunoType::checkInheritedMemberCount(const TypeReader* pReader) -{ - sal_Bool bSelfCheck = sal_True; - if (!pReader) - { - bSelfCheck = sal_False; - pReader = &m_reader; - } - - sal_uInt32 count = 0; - OString superType(pReader->getSuperTypeName()); - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - if ( aSuperReader.isValid() ) - { - count = checkInheritedMemberCount(&aSuperReader); - } - } - - if (bSelfCheck) - { - count += pReader->getMethodCount(); - sal_uInt32 fieldCount = pReader->getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = pReader->getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - count++; - } - } - } - - return count; -} - -sal_uInt32 CunoType::getInheritedMemberCount() -{ - if (m_inheritedMemberCount == 0) - { - m_inheritedMemberCount = checkInheritedMemberCount(0); - } - - return m_inheritedMemberCount; -} - -void CunoType::dumpInheritedMembers(FileStream& o, rtl::OString& superType) -{ - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - - OString baseType(aSuperReader.getSuperTypeName()); - if (baseType.getLength() > 0) - { - dumpInheritedMembers(o, baseType); - } - - sal_uInt32 fieldCount = aSuperReader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = aSuperReader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - fieldName = aSuperReader.getFieldName(i); - fieldType = aSuperReader.getFieldType(i); - - o << indent(); - dumpType(o, fieldType); - o << " " << fieldName << ";\n"; - } - } -} - -OString CunoType::getTypeClass(const OString& type, sal_Bool bCStyle) -{ - OString typeName = (type.getLength() > 0 ? type : m_typeName); - RTTypeClass rtTypeClass = RT_TYPE_INVALID; - - if (type.getLength() > 0) - { - typeName = type; - rtTypeClass = m_typeMgr.getTypeClass(typeName); - } else - { - typeName = m_typeName; - rtTypeClass = m_reader.getTypeClass(); - } - - if (typeName.lastIndexOf(']') > 0) - return bCStyle ? "typelib_TypeClass_SEQUENCE" : "::com::sun::star::uno::TypeClass_SEQUENCE"; - - switch (rtTypeClass) - { - case RT_TYPE_INTERFACE: - return bCStyle ? "typelib_TypeClass_INTERFACE" : "::com::sun::star::uno::TypeClass_INTERFACE"; - break; - case RT_TYPE_MODULE: - return bCStyle ? "typelib_TypeClass_MODULE" : "::com::sun::star::uno::TypeClass_MODULE"; - break; - case RT_TYPE_STRUCT: - return bCStyle ? "typelib_TypeClass_STRUCT" : "::com::sun::star::uno::TypeClass_STRUCT"; - break; - case RT_TYPE_ENUM: - return bCStyle ? "typelib_TypeClass_ENUM" : "::com::sun::star::uno::TypeClass_ENUM"; - break; - case RT_TYPE_EXCEPTION: - return bCStyle ? "typelib_TypeClass_EXCEPTION" : "::com::sun::star::uno::TypeClass_EXCEPTION"; - break; - case RT_TYPE_TYPEDEF: - { - OString realType = checkRealBaseType( typeName ); - return getTypeClass( realType, bCStyle ); - } -// return bCStyle ? "typelib_TypeClass_TYPEDEF" : "::com::sun::star::uno::TypeClass_TYPEDEF"; - break; - case RT_TYPE_SERVICE: - return bCStyle ? "typelib_TypeClass_SERVICE" : "::com::sun::star::uno::TypeClass_SERVICE"; - break; - case RT_TYPE_INVALID: - { - if (type.equals("long")) - return bCStyle ? "typelib_TypeClass_LONG" : "::com::sun::star::uno::TypeClass_LONG"; - if (type.equals("short")) - return bCStyle ? "typelib_TypeClass_SHORT" : "::com::sun::star::uno::TypeClass_SHORT"; - if (type.equals("hyper")) - return bCStyle ? "typelib_TypeClass_HYPER" : "::com::sun::star::uno::TypeClass_HYPER"; - if (type.equals("string")) - return bCStyle ? "typelib_TypeClass_STRING" : "::com::sun::star::uno::TypeClass_STRING"; - if (type.equals("boolean")) - return bCStyle ? "typelib_TypeClass_BOOLEAN" : "::com::sun::star::uno::TypeClass_BOOLEAN"; - if (type.equals("char")) - return bCStyle ? "typelib_TypeClass_CHAR" : "::com::sun::star::uno::TypeClass_CHAR"; - if (type.equals("byte")) - return bCStyle ? "typelib_TypeClass_BYTE" : "::com::sun::star::uno::TypeClass_BYTE"; - if (type.equals("any")) - return bCStyle ? "typelib_TypeClass_ANY" : "::com::sun::star::uno::TypeClass_ANY"; - if (type.equals("type")) - return bCStyle ? "typelib_TypeClass_TYPE" : "::com::sun::star::uno::TypeClass_TYPE"; - if (type.equals("float")) - return bCStyle ? "typelib_TypeClass_FLOAT" : "::com::sun::star::uno::TypeClass_FLOAT"; - if (type.equals("double")) - return bCStyle ? "typelib_TypeClass_DOUBLE" : "::com::sun::star::uno::TypeClass_DOUBLE"; - if (type.equals("void")) - return bCStyle ? "typelib_TypeClass_VOID" : "::com::sun::star::uno::TypeClass_VOID"; - if (type.equals("unsigned long")) - return bCStyle ? "typelib_TypeClass_UNSIGNED_LONG" : "::com::sun::star::uno::TypeClass_UNSIGNED_LONG"; - if (type.equals("unsigned short")) - return bCStyle ? "typelib_TypeClass_UNSIGNED_SHORT" : "::com::sun::star::uno::TypeClass_UNSIGNED_SHORT"; - if (type.equals("unsigned hyper")) - return bCStyle ? "typelib_TypeClass_UNSIGNED_HYPER" : "::com::sun::star::uno::TypeClass_UNSIGNED_HYPER"; - } - break; - } - - return bCStyle ? "typelib_TypeClass_UNKNOWN" : "::com::sun::star::uno::TypeClass_UNKNOWN"; -} - -void CunoType::dumpType(FileStream& o, const OString& type, - sal_Bool bConst, sal_Bool bPointer, sal_Bool bParam) - throw( CannotDumpException ) -{ - OString sType(checkRealBaseType(type, sal_True)); - sal_uInt32 index = sType.lastIndexOf(']'); - sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - RTTypeClass typeClass = m_typeMgr.getTypeClass(relType); - -// if (bConst) o << "const "; - - if ( seqNum ) - { - o << "/*"; - sal_uInt32 i; - for (i=0; i < seqNum; i++) - { - o << "sequence< "; - } - o << relType.replace( '/', '.'); - for (i=0; i < seqNum; i++) - { - o << " >"; - } - o << "*/ uno_Sequence *"; - if (bPointer) o << "*"; - return; - } - switch (typeClass) - { - case RT_TYPE_INTERFACE: - o << relType.replace('/', '_') << " *"; - break; - case RT_TYPE_INVALID: - { - OString tmp(getBaseType(relType)); - if (tmp.getLength() > 0) - { - o << tmp.getStr(); - if ( bParam && !bPointer && relType.equals("any") ) - o << " *"; - } else - throw CannotDumpException("Unknown type '" + relType + "', incomplete type library."); - } - break; - case RT_TYPE_STRUCT: - case RT_TYPE_EXCEPTION: - o << relType.replace('/', '_'); - if ( bParam && !bPointer ) o << " *"; - break; - case RT_TYPE_ENUM: - case RT_TYPE_TYPEDEF: - o << relType.replace('/', '_'); - break; - } - - if (bPointer) o << "*"; -} - -OString CunoType::getBaseType(const OString& type) -{ - if (type.equals("long")) - return "sal_Int32"; - if (type.equals("short")) - return "sal_Int16"; - if (type.equals("hyper")) - return "sal_Int64"; - if (type.equals("string")) - return "rtl_uString *"; - if (type.equals("boolean")) - return "sal_Bool"; - if (type.equals("char")) - return "sal_Unicode"; - if (type.equals("byte")) - return "sal_Int8"; - if (type.equals("any")) - return "uno_Any"; - if (type.equals("type")) - return "typelib_TypeDescriptionReference *"; - if (type.equals("float")) - return "float"; - if (type.equals("double")) - return "double"; - if (type.equals("octet")) - return "sal_Int8"; - if (type.equals("void")) - return type; - if (type.equals("unsigned long")) - return "sal_uInt32"; - if (type.equals("unsigned short")) - return "sal_uInt16"; - if (type.equals("unsigned hyper")) - return "sal_uInt64"; - - return OString(); -} - -void CunoType::dumpCppuGetType(FileStream& o, const OString& type, sal_Bool bDecl, CunoTypeDecl eDeclFlag) -{ - OString sType( checkRealBaseType(type, sal_True) ); - sal_uInt32 index = sType.lastIndexOf(']'); - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - if (eDeclFlag == CUNOTYPEDECL_ONLYINTERFACES) - { - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE) - { - if (bDecl) - o << indent() << "ppTypeRef = "; - else - o << indent(); - - o << "getCUnoType_" << type.replace('/', '_') << "()"; - - if (bDecl) - o << ";\n" << indent() << "typelib_typedescriptionreference_release( *ppTypeRef );\n"; - } - } else - { - if (isBaseType(type)) - { - return; - } else - { - if (eDeclFlag == CUNOTYPEDECL_NOINTERFACES && - m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE) - return; - - if ( type.equals("type") ) - return; - - if (bDecl) - o << indent() << "ppTypeRef = "; - else - o << indent(); - - o << indent() << "getCUnoType_" << type.replace('/', '_') << "()"; - } - if (bDecl) - o << ";\n" << indent() << "typelib_typedescriptionreference_release( *ppTypeRef );\n"; - } -} - -void CunoType::dumpTypeInit(FileStream& o, const OString& typeName) -{ - OString type(checkSpecialCunoType(typeName)); - - BASETYPE baseType = isBaseType(type); - - switch (baseType) - { - case BT_BOOLEAN: - o << "(sal_False)"; - return; - break; - case BT_ANY: - case BT_STRING: - o << "()"; - return; - break; - case BT_INVALID: - break; - default: - o << "(("; - dumpType(o, type); - o << ")" << "0)"; - return; - } - - RTTypeClass typeClass = m_typeMgr.getTypeClass(type); - - if (typeClass == RT_TYPE_ENUM) - { - RegistryTypeReaderLoader aReaderLoader; - - if (aReaderLoader.isLoaded()) - { - TypeReader reader(m_typeMgr.getTypeReader(type)); - - if ( reader.isValid() ) - { - sal_Int32 i = type.lastIndexOf('/'); - o << "(" << shortScopedName("", type, sal_False) - << "::" << type.copy( i != -1 ? i+1 :0 ) - << "_" << reader.getFieldName(0) << ")"; - return; - } - } - } - - o << "()"; -} - -BASETYPE CunoType::isBaseType(const OString& type) -{ - if (type.equals("long")) - return BT_LONG; - if (type.equals("short")) - return BT_SHORT; - if (type.equals("hyper")) - return BT_HYPER; - if (type.equals("string")) - return BT_STRING; - if (type.equals("boolean")) - return BT_BOOLEAN; - if (type.equals("char")) - return BT_CHAR; - if (type.equals("byte")) - return BT_BYTE; - if (type.equals("any")) - return BT_ANY; - if (type.equals("float")) - return BT_FLOAT; - if (type.equals("double")) - return BT_DOUBLE; - if (type.equals("void")) - return BT_VOID; - if (type.equals("unsigned long")) - return BT_UNSIGNED_LONG; - if (type.equals("unsigned short")) - return BT_UNSIGNED_SHORT; - if (type.equals("unsigned hyper")) - return BT_UNSIGNED_HYPER; - - return BT_INVALID; -} - -OString CunoType::typeToIdentifier(const OString& type) -{ - sal_uInt32 index = type.lastIndexOf(']'); - sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? ((OString)type).copy(index+1) : type); - OString sIdentifier; - - while( seqNum > 0 ) - { - sIdentifier += OString("seq"); - - if ( --seqNum == 0 ) - { - sIdentifier += OString("_"); - } - } - - if ( isBaseType(relType) ) - { - sIdentifier += relType.replace(' ', '_'); - } else - { - sIdentifier += relType.replace('/', '_'); - } - - - return sIdentifier; -} - -OString CunoType::checkSpecialCunoType(const OString& type) -{ - OString baseType(type); - - RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader(); - - RegistryKey key; - sal_uInt8* pBuffer=NULL; - RTTypeClass typeClass; - sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF); - TypeReader reader; - - while (isTypeDef) - { - reader = m_typeMgr.getTypeReader(baseType); - - if (reader.isValid()) - { - typeClass = reader.getTypeClass(); - - if (typeClass == RT_TYPE_TYPEDEF) - baseType = reader.getSuperTypeName(); - else - isTypeDef = sal_False; - } else - { - break; - } - } - - return baseType; -} - -sal_Bool CunoType::isSeqType(const OString& type, OString& baseType, OString& seqPrefix) -{ - if ( type.getStr()[0] == '[' ) - { - sal_uInt32 index = type.lastIndexOf(']'); - baseType = ((OString)type).copy(index+1); - seqPrefix = ((OString)type).copy(0, index+1); - return sal_True; - } else - { - baseType = type; - seqPrefix = OString(); - } - return sal_False; -} - -sal_Bool CunoType::isArrayType(const OString& type, OString& baseType, OString& arrayPrefix) -{ - if ( type.getStr()[type.getLength()-1] == ']' ) - { - sal_uInt32 index = type.indexOf('['); - baseType = ((OString)type).copy(0, index-1); - arrayPrefix = ((OString)type).copy(index); - return sal_True; - } else - { - baseType = type; - arrayPrefix = OString(); - } - return sal_False; -} - -OString CunoType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOnly) -{ - OString realType; - OString baseType; - OString completePrefix; - OString prefix; - sal_Bool bSeqType = sal_True; - - if ( !isSeqType(type, baseType, completePrefix) ) - isArrayType(type, baseType, completePrefix); - - RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader(); - - RegistryKey key; - sal_uInt8* pBuffer=NULL; - RTTypeClass typeClass; - sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF); - TypeReader reader; - while (mustBeChecked) - { - reader = m_typeMgr.getTypeReader(baseType); - - if (reader.isValid()) - { - typeClass = reader.getTypeClass(); - - if (typeClass == RT_TYPE_TYPEDEF) - { - realType = reader.getSuperTypeName(); - if ( isSeqType(realType, baseType, prefix) || - isArrayType(realType, baseType, prefix) ) - { - completePrefix += prefix; - } - } else - mustBeChecked = sal_False; - } else - { - break; - } - } - - if ( bResolveTypeOnly ) - { - if ( completePrefix.getLength() > 0 ) - { - baseType = bSeqType ? (completePrefix + baseType) : ( baseType + completePrefix); - } - } - return baseType; -} - -void CunoType::dumpConstantValue(FileStream& o, sal_uInt16 index) -{ - RTConstValue constValue = m_reader.getFieldConstValue(index); - - switch (constValue.m_type) - { - case RT_TYPE_BOOL: - if (constValue.m_value.aBool) - o << "sal_True"; - else - o << "sal_False"; - break; - case RT_TYPE_BYTE: - { - char tmp[16]; - snprintf(tmp, sizeof(tmp), "0x%x", (sal_Int8)constValue.m_value.aByte); - o << "(sal_Int8)" << tmp; - } - break; - case RT_TYPE_INT16: - o << "(sal_Int16)" << constValue.m_value.aShort; - break; - case RT_TYPE_UINT16: - o << "(sal_uInt16)" << constValue.m_value.aUShort; - break; - case RT_TYPE_INT32: - o << "(sal_Int32)" << constValue.m_value.aLong; - break; - case RT_TYPE_UINT32: - o << "(sal_uInt32)" << constValue.m_value.aULong; - break; - case RT_TYPE_INT64: - { - ::rtl::OString tmp( OString::valueOf(constValue.m_value.aHyper) ); - o << "(sal_Int64)" << tmp.getStr() << "L"; - } - break; - case RT_TYPE_UINT64: - { - ::rtl::OString tmp( OString::valueOf((sal_Int64)constValue.m_value.aUHyper) ); - o << "(sal_uInt64)" << tmp.getStr() << "L"; - } - break; - case RT_TYPE_FLOAT: - { - ::rtl::OString tmp( OString::valueOf(constValue.m_value.aFloat) ); - o << "(float)" << tmp.getStr(); - } - break; - case RT_TYPE_DOUBLE: - { - ::rtl::OString tmp( OString::valueOf(constValue.m_value.aDouble) ); - o << "(double)" << tmp.getStr(); - } - break; - case RT_TYPE_STRING: - { - ::rtl::OUString aUStr(constValue.m_value.aString); - ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US); - o << "::rtl::OUString::createFromAscii(\"" << aStr.getStr() << "\")"; - } - break; - } -} - -void CunoType::inc(sal_uInt32 num) -{ - m_indentLength += num; -} - -void CunoType::dec(sal_uInt32 num) -{ - if (m_indentLength - num < 0) - m_indentLength = 0; - else - m_indentLength -= num; -} - -OString CunoType::indent() -{ - OStringBuffer tmp(m_indentLength); - - for (sal_uInt32 i=0; i < m_indentLength; i++) - { - tmp.append(' '); - } - return tmp.makeStringAndClear(); -} - -OString CunoType::indent(sal_uInt32 num) -{ - OStringBuffer tmp(m_indentLength + num); - - for (sal_uInt32 i=0; i < m_indentLength + num; i++) - { - tmp.append(' '); - } - return tmp.makeStringAndClear(); -} - -//************************************************************************* -// InterfaceType -//************************************************************************* -InterfaceType::InterfaceType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : CunoType(typeReader, typeName, typeMgr, typeDependencies) -{ - m_inheritedMemberCount = 0; - m_hasAttributes = sal_False; - m_hasMethods = sal_False; -} - -InterfaceType::~InterfaceType() -{ - -} - -sal_Bool InterfaceType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "H")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - dumpOpenExternC(o); - - o << "#ifndef " << m_name.toAsciiUpperCase() << "\n"; - o << "#define " << m_name.toAsciiUpperCase() << "\n"; - o << "struct _" << m_name << "_ftab;\n" - << "typedef struct _" << m_name << "_ftab * " << m_name << ";\n"; - o << "#endif\n\n"; - - dumpDeclaration(o); - - if ( m_cunoTypeLib ) - { - o << "#ifdef CUNO_TYPELIB\n" - << "typelib_TypeDescriptionReference * SAL_CALL getCUnoType_" << m_name << "() SAL_THROW( () );\n" - << "#endif\n\n"; - } - -/* - if (getNestedTypeNames().getLength() > 0) - { - o << indent() << "// nested types\n\n"; - for (sal_uInt32 i = 0; i < getNestedTypeNames().getLength(); i++) - { - OUString s(getNestedTypeNames().getElement(i)); - - OString nestedName(s.getStr(), s.getLength(), RTL_TEXTENCODING_UTF8); - - nestedName = checkRealBaseType(nestedName.copy(5)); - - if (nestedName.lastIndexOf(']') < 0) - { - o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCunoType( "; - dumpType(o, nestedName, sal_True, sal_False); - o << "* ) SAL_THROW( () );\n\n"; - } - } - } -*/ - dumpCloseExternC(o); - - o << "#endif /* "<< headerDefine << " */\n"; - return sal_True; -} - -void InterfaceType::dumpInheritedFunctions(FileStream& o, rtl::OString& superType) -{ - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - - OString baseType(aSuperReader.getSuperTypeName()); - if (baseType.getLength() > 0) - { - dumpInheritedFunctions(o, baseType); - } - - dumpAttributes(o, superType.replace('/', '_'), aSuperReader); - dumpMethods(o, superType.replace('/', '_'), aSuperReader); -} - -sal_Bool InterfaceType::dumpDeclaration(FileStream& o) - throw( CannotDumpException ) -{ - o << "typedef struct _" << m_name << "_ftab\n" << indent() << "{"; - inc(); - - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - dumpInheritedFunctions(o, superType); -/* - if (getNestedTypeNames().getLength() > 0) - { - inc(); - o << indent() << "// nested types\n\n"; - for (sal_uInt32 i = 0; i < getNestedTypeNames().getLength(); i++) - { - OUString s(getNestedTypeNames().getElement(i)); - - OString nestedName(s.getStr(), s.getLength(), RTL_TEXTENCODING_UTF8); - - nestedName = nestedName.copy(5); - - o << indent() << "// " << nestedName.getStr() << "\n"; - - TypeReader reader(m_typeMgr.getTypeReader(nestedName)); - - if (reader.isValid()) - { - RTTypeClass typeClass = reader.getTypeClass(); - switch (typeClass) { - case RT_TYPE_INTERFACE: - { - InterfaceType iType(reader, nestedName, m_typeMgr, m_dependencies); - iType.dumpDeclaration(o); - } - break; - case RT_TYPE_STRUCT: - { - StructureType sType(reader, nestedName, m_typeMgr, m_dependencies); - sType.dumpDeclaration(o); - } - break; - case RT_TYPE_ENUM: - { - EnumType enType(reader, nestedName, m_typeMgr, m_dependencies); - enType.dumpDeclaration(o); - } - break; - case RT_TYPE_EXCEPTION: - { - ExceptionType eType(reader, nestedName, m_typeMgr, m_dependencies); - eType.dumpDeclaration(o); - } - break; - case RT_TYPE_TYPEDEF: - { - TypeDefType tdType(reader, nestedName, m_typeMgr, m_dependencies); - tdType.dumpDeclaration(o); - } - break; - default: - break; - } - } - } - dec(); - } -*/ - dumpAttributes(o, m_name, m_reader); - dumpMethods(o, m_name, m_reader); - - dec(); - o << "} " << m_name << "_ftab;\n\n"; - - return sal_True; -} - -sal_Bool InterfaceType::dumpCFile(FileStream& o) - throw( CannotDumpException ) -{ - dumpInclude(o, m_typeName, "h"); - o << "\n"; - dumpDefaultCIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - dumpGetCunoType(o); -/* - if (getNestedTypeNames().getLength() > 0) - { - o << indent() << "// nested types\n\n"; - for (sal_uInt32 i = 0; i < getNestedTypeNames().getLength(); i++) - { - OUString s(getNestedTypeNames().getElement(i)); - - OString nestedName(s.getStr(), s.getLength(), RTL_TEXTENCODING_UTF8); - - nestedName = nestedName.copy(5); - - o << indent() << "// " << nestedName.getStr() << "\n"; - - TypeReader reader(m_typeMgr.getTypeReader(nestedName)); - - if (reader.isValid()) - { - RTTypeClass typeClass = reader.getTypeClass(); - switch (typeClass) { - case RT_TYPE_INTERFACE: - { - InterfaceType iType(reader, nestedName, m_typeMgr, m_dependencies); - iType.dumpGetCunoType(o); - } - break; - case RT_TYPE_STRUCT: - { - StructureType sType(reader, nestedName, m_typeMgr, m_dependencies); - sType.dumpGetCunoType(o); - } - break; - case RT_TYPE_ENUM: - { - EnumType enType(reader, nestedName, m_typeMgr, m_dependencies); - enType.dumpGetCunoType(o); - } - break; - case RT_TYPE_EXCEPTION: - { - ExceptionType eType(reader, nestedName, m_typeMgr, m_dependencies); - eType.dumpGetCunoType(o); - } - break; - case RT_TYPE_TYPEDEF: - { - TypeDefType tdType(reader, nestedName, m_typeMgr, m_dependencies); - tdType.dumpGetCunoType(o); - } - break; - default: - break; - } - } - } - } -*/ - return sal_True; -} - -void InterfaceType::dumpAttributes(FileStream& o, const OString& interfaceType, TypeReader& reader ) -{ - sal_uInt32 fieldCount = reader.getFieldCount(); - sal_Bool first=sal_True; - - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = reader.getFieldName(i); - fieldType = reader.getFieldType(i); - - if (first) - { - first = sal_False; - o << "\n" << indent() << "/* Attributes of " << interfaceType << " */\n"; - } - - o << indent() << "cuno_ErrorCode (SAL_CALL *get" << fieldName << ")( " - << interfaceType << " *, uno_Any *, "; - dumpType(o, fieldType, sal_False, sal_True); - o << " );\n"; - - if (access != RT_ACCESS_READONLY) - { - OString relType = checkSpecialCunoType(fieldType); - sal_Bool bParam = sal_False; - - if ( m_typeMgr.getTypeClass(relType) == RT_TYPE_STRUCT || - m_typeMgr.getTypeClass(relType) == RT_TYPE_EXCEPTION || - (isBaseType(relType) && relType.equals("any"))) - { - bParam = sal_True; - } else - { - bParam = sal_False; - } - - o << indent() << "cuno_ErrorCode (SAL_CALL *set" << fieldName << ")( " - << interfaceType << " *, uno_Any *, "; - dumpType(o, fieldType, sal_False, sal_False, bParam); - o << " );\n"; - } - } -} - -void InterfaceType::dumpMethods(FileStream& o, const OString& interfaceType, TypeReader& reader ) -{ - sal_uInt32 methodCount = reader.getMethodCount(); - sal_Bool first=sal_True; - - OString methodName, returnType, paramType, paramName; - sal_uInt32 paramCount = 0; - sal_uInt32 excCount = 0; - RTMethodMode methodMode = RT_MODE_INVALID; - RTParamMode paramMode = RT_PARAM_INVALID; - - sal_Bool bPointer = sal_False; - sal_Bool bParam = sal_False; - sal_Bool bWithRunTimeExcp = sal_True; - - for (sal_uInt16 i=0; i < methodCount; i++) - { - methodName = reader.getMethodName(i); - returnType = reader.getMethodReturnType(i); - paramCount = reader.getMethodParamCount(i); - excCount = reader.getMethodExcCount(i); - methodMode = reader.getMethodMode(i); - - if ( methodName.equals("queryInterface") ) - { - first = sal_False; - o << "\n" << indent() << "/* Methods of " << interfaceType << " */\n"; - o << indent() << "cuno_ErrorCode (SAL_CALL *queryInterface)( com_sun_star_uno_XInterface *, " - << "uno_Any *, com_sun_star_uno_XInterface **, typelib_TypeDescriptionReference * );\n"; - continue; - } - - if ( methodName.equals("acquire") || methodName.equals("release") ) - { - bWithRunTimeExcp = sal_False; - } - - if (first) - { - first = sal_False; - o << "\n" << indent() << "/* Methods of " << interfaceType << " */\n"; - } - - o << indent() << "cuno_ErrorCode (SAL_CALL *" << methodName << ")( " - << interfaceType << " *"; - if ( excCount || bWithRunTimeExcp ) - { - o << ", uno_Any *"; - } - if ( !isVoid(returnType) ) - { - o << ", "; - dumpType(o, returnType, sal_False, sal_True); - } - - sal_uInt16 j; - for (j=0; j < paramCount; j++) - { - paramName = reader.getMethodParamName(i, j); - paramType = reader.getMethodParamType(i, j); - paramMode = reader.getMethodParamMode(i, j); - - if (j < (sal_uInt16)paramCount) o << ", "; - - switch (paramMode) - { - case RT_PARAM_IN: - { - OString relType = checkSpecialCunoType(paramType); - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_STRUCT || - m_typeMgr.getTypeClass(relType) == RT_TYPE_EXCEPTION || - (isBaseType(relType) && relType.equals("any"))) - { - bParam = sal_True; - } else - { - bParam = sal_False; - } - break; - } - case RT_PARAM_OUT: - case RT_PARAM_INOUT: - bPointer = sal_True; - break; - } - - dumpType(o, paramType, sal_False, bPointer, bParam); - } - o << " );\n"; - } -} - -void InterfaceType::dumpGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - if ( m_cunoTypeLeak ) - { - dumpLGetCunoType(o); - return; - } - if ( !m_cunoTypeDynamic ) - { - dumpCGetCunoType(o); - return; - } - - dumpOpenExternC(o); - - if ( !m_typeName.equals("com/sun/star/uno/XInterface") ) - { - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - } - - o << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () )\n{\n"; - inc(); - - if ( m_typeName.equals("com/sun/star/uno/XInterface") ) - { - o << indent() << "return typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE );\n"; - } else - { - o << indent() << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << indent() << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - OString superType(m_reader.getSuperTypeName()); - sal_Bool bWithBase = sal_False; - if (superType.getLength() > 0 && !superType.equals("com/sun/star/uno/XInterface")) - { - bWithBase = sal_True; - o << indent() << "typelib_TypeDescriptionReference * pSuperType = 0;\n" - << indent() << "typelib_typedescriptionreference_newByAsciiName(&pSuperType, typelib_TypeClass_INTERFACE, \"" - << superType.replace('/', '.') << "\" );\n"; - } - - o << indent() << "typelib_static_interface_type_init( &s_pType_" << typeName - << ", \"" << m_typeName.replace('/', '.') << "\", "; - - if ( bWithBase ) - { - o << "pSuperType );\n"; - } else - { - o << "0 );\n"; - } - - dec(); - o << indent() << "}\n" - << indent() << "typelib_typedescriptionreference_acquire( s_pType_" << typeName << " );\n" - << indent() << "return &s_pType_" << typeName <<" );\n"; - } - dec(); - o << indent() << "}\n"; - - dumpCloseExternC(o); -} - -void InterfaceType::dumpCGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - dumpOpenExternC(o); - - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () )\n{\n"; - inc(); - - o << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "oslMutex * pMutex = osl_getGlobalMutex();\n" - << indent() << "osl_acquireMutex( pMutex );\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "rtl_uString * pTypeName = 0;\n" - << indent() << "typelib_InterfaceTypeDescription * pTD = 0;\n"; - - OString superType(m_reader.getSuperTypeName()); - sal_uInt32 count = getMemberCount(); - - if (superType.getLength() > 0) - o << indent() << "typelib_TypeDescriptionReference * pSuperType = 0;\n"; - - if (count) - { - o << indent() << "typelib_TypeDescriptionReference * pMembers[" << count << "] = { "; - for (sal_uInt32 i = 0; i < count; i++) - { - o << "0"; - if (i+1 < count) - o << ","; - else - o << " };\n"; - } - - dumpCUnoAttributeTypeNames(o); - dumpCUnoMethodTypeNames(o); - } - - o << indent() << "rtl_uString_newFromAscii( &pTypeName, \"" << m_typeName.replace('/', '.') << "\" );\n"; - - if (superType.getLength() > 0) - { - o << indent() << "typelib_typedescriptionreference_newByAsciiName(&pSuperType, typelib_TypeClass_INTERFACE, \"" - << superType.replace('/', '.') << "\" );\n"; - } - - if (count) - { - sal_uInt32 index = 0; - dumpCUnoAttributeRefs(o, index); - dumpCUnoMethodRefs(o, index); - } - - o << "\n" << indent() << "typelib_typedescription_newInterface(\n"; - inc(); - o << indent() << "&pTD,\n" - << indent() << "pTypeName, "; - - RTUik uik; - m_reader.getUik(uik); - sal_Char buffer[53]; - snprintf(buffer, sizeof(buffer), "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n", - uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5); - o << buffer; - - if (superType.getLength() > 0) - o << indent() << "pSuperType,\n"; - else - o << indent() << "0,\n"; - - if ( count ) - { - o << indent() << count << ",\n" << indent() << "pMembers );\n\n"; - } else - { - o << indent() << count << ",\n" << indent() << "0 );\n\n"; - } - dec(); - - o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n"; - if ( count ) - { - for (sal_uInt16 i=0; i < count; i++) - { - o << indent() << "typelib_typedescriptionreference_release( pMembers[" - << i << "] );\n"; - } - } - o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pTD );\n"; - - if (superType.getLength() > 0) - o << indent() << "typelib_typedescription_release( pSuperType );\n\n"; - else - o << "\n"; - - o << indent() << "typelib_typedescriptionreference_new( &s_pType_ " << typeName - << "typelib_TypeClass_INTERFACE, (typelib_TypeDescription*)pTD);\n\n"; - - o << indent() << "typelib_TypeDescriptionReference ** ppTypeRef = 0;\n"; - StringSet aTypes; - // type for RuntimeException is always needed - OString sRunTimeExceptionType("com/sun/star/uno/RuntimeException"); - aTypes.insert(sRunTimeExceptionType); - dumpCppuGetType(o, sRunTimeExceptionType, sal_True, CUNOTYPEDECL_ALLTYPES); - - dumpAttributesCppuDecl(o, &aTypes, CUNOTYPEDECL_ALLTYPES); - dumpMethodsCppuDecl(o, &aTypes, CUNOTYPEDECL_ALLTYPES); - - if (count) - { - sal_uInt32 index = getInheritedMemberCount(); - dumpCUnoAttributes(o, index); - dumpCUnoMethods(o, index); - } - - // release strings for names - dumpCUnoAttributeTypeNames(o, sal_True); - dumpCUnoMethodTypeNames(o, sal_True); - - dec(); - o << indent() << "}\n"; - o << indent() << "osl_releaseMutex( pMutex );\n"; - dec(); - o << indent() << "}\n\n" - << indent() << "typelib_typedescriptionreference_acquire( s_pType_" << typeName << " );\n" - << indent() << "return &s_pType_" << typeName << ";\n"; - - dec(); - o << "}\n"; - - dumpCloseExternC(o); -} - -void InterfaceType::dumpCUnoAttributeTypeNames(FileStream&o, sal_Bool bRelease) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - if ( bRelease ) - { - o << indent() << "rtl_uString_release( pAttributeName" << i << " );\n"; - } else - { - o << indent() << "rtl_uString * pAttributeName" << i << " = 0;\n"; - } - } -} - -void InterfaceType::dumpCUnoMethodTypeNames(FileStream&o, sal_Bool bRelease) -{ - sal_uInt32 methodCount = m_reader.getMethodCount(); - - for (sal_uInt16 i = 0; i < methodCount; i++) - { - if ( bRelease ) - { - o << indent() << "rtl_uString_release( pMethodName" << i << " );\n"; - } else - { - o << indent() << "rtl_uString * pMethodName" << i << " = 0;\n"; - } - } -} - -void InterfaceType::dumpCUnoAttributeRefs(FileStream& o, sal_uInt32& index) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString scope = m_typeName.replace('/', '.'); - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - fieldName = m_reader.getFieldName(i); - - o << indent() << "rtl_uString_newFromAscii( &pAttributeName" << i << ", \"" - << scope << "::" << fieldName << "\" );\n"; - o << indent() << "typelib_typedescriptionreference_new( &pMembers[" - << index << "],\n"; - inc(38); - o << indent() << "typelib_TypeClass_INTERFACE_ATTRIBUTE,\n" - << indent() << "pAttributeName" << i << " );\n"; - dec(38); - index++; - } -} - -void InterfaceType::dumpCUnoMethodRefs(FileStream& o, sal_uInt32& index) -{ - sal_uInt32 methodCount = m_reader.getMethodCount(); - OString methodName; //, returnType, paramType, paramName; - OString scope = m_typeName.replace('/', '.'); - - for (sal_uInt16 i = 0; i < methodCount; i++) - { - methodName = m_reader.getMethodName(i); - - o << indent() << "rtl_uString_newFromAscii( &pMethodName" << i << ", \"" - << scope.replace('/', '.') << "::" << methodName << "\" );\n"; - o << indent() << "typelib_typedescriptionreference_new( &pMembers[" - << index << "],\n"; - inc(38); - o << indent() << "typelib_TypeClass_INTERFACE_METHOD,\n" - << indent() << "pMethodName" << i << " );\n"; - dec(38); - index++; - } -} - -sal_uInt32 InterfaceType::getMemberCount() -{ - sal_uInt32 count = m_reader.getMethodCount(); - - if (count) - m_hasMethods = sal_True; - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - m_hasAttributes = sal_True; - count++; - } - } - return count; -} - -sal_uInt32 InterfaceType::checkInheritedMemberCount(const TypeReader* pReader) -{ - sal_uInt32 cout = 0; - sal_Bool bSelfCheck = sal_True; - if (!pReader) - { - bSelfCheck = sal_False; - pReader = &m_reader; - } - - sal_uInt32 count = 0; - OString superType(pReader->getSuperTypeName()); - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - if (aSuperReader.isValid()) - { - count = checkInheritedMemberCount(&aSuperReader); - } - } - - if (bSelfCheck) - { - count += pReader->getMethodCount(); - sal_uInt32 fieldCount = pReader->getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = pReader->getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - count++; - } - } - } - - return count; -} - -sal_uInt32 InterfaceType::getInheritedMemberCount() -{ - if (m_inheritedMemberCount == 0) - { - m_inheritedMemberCount = checkInheritedMemberCount(0); - } - - return m_inheritedMemberCount; -} - -void InterfaceType::dumpCUnoAttributes(FileStream& o, sal_uInt32& index) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldType; - - sal_uInt32 absoluteIndex = index; - - if (m_hasAttributes) - { - o << "\n" << indent() << "{\n" << indent() << "typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n"; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True); - o << indent() << "{\n"; - o << indent() << "rtl_uString * pAttributeType" << i << " = 0;\n"; - o << indent() << "rtl_uString_newFromAscii( &pAttributeType" << i << ", \"" - << fieldType.replace('/', '.') << "\" );\n"; - o << indent() << "typelib_typedescription_newInterfaceAttribute( &pAttribute,\n"; - inc(); - o << indent() << absoluteIndex++ << ", pAttributeName" << i << ",\n"; - o << indent() << getTypeClass(fieldType, sal_True) << ", pAttributeType" << i << ",\n"; - if (access == RT_ACCESS_READONLY) - o << indent() << "sal_True );\n"; - else - o << indent() << "sal_False );\n"; - dec(); - o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pAttribute );\n\n"; - o << indent() << "}\n"; - } - o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pAttribute );\n"; - o << indent() << "}\n"; - index = absoluteIndex; - } -} - -void InterfaceType::dumpCUnoMethods(FileStream& o, sal_uInt32& index) -{ - sal_uInt32 methodCount = m_reader.getMethodCount(); - OString methodName, returnType, paramType, paramName; - sal_uInt32 paramCount = 0; - sal_uInt32 excCount = 0; - RTMethodMode methodMode = RT_MODE_INVALID; - RTParamMode paramMode = RT_PARAM_INVALID; - sal_Bool bWithRuntimeException = sal_True; - - sal_uInt32 absoluteIndex = index; - - if (m_hasMethods) - { - o << "\n" << indent() << "{\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n"; - - for (sal_uInt16 i=0; i < methodCount; i++) - { - methodName = m_reader.getMethodName(i); - returnType = checkRealBaseType(m_reader.getMethodReturnType(i), sal_True); - paramCount = m_reader.getMethodParamCount(i); - excCount = m_reader.getMethodExcCount(i); - methodMode = m_reader.getMethodMode(i); - - if ( methodName.equals("acquire") || methodName.equals("release") ) - { - bWithRuntimeException = sal_False; - } - o << indent() << "{\n"; - inc(); - - if (paramCount) - { - o << indent() << "typelib_Parameter_Init pParameters[" << paramCount << "];\n"; - } - if ( excCount || bWithRuntimeException ) - { - o << indent() << "rtl_uString * pExceptions[" << excCount + 1 << "];\n"; - } - o << indent() << "rtl_uString * pReturnType" << i << " = 0;\n"; - - sal_uInt16 j; - for (j=0; j < paramCount; j++) - { - o << indent() << "rtl_uString * pParamName" << j << " = 0;\n" - << indent() << "rtl_uString * pParamType" << j << " = 0;\n"; - } - - for (j=0; j < excCount; j++) - { - o << indent() << "rtl_uString * pExceptionName" << j << " = 0;\n"; - } - if ( excCount || bWithRuntimeException ) - { - o << indent() << "rtl_uString * pExceptionName" << excCount << " = 0;\n"; - } - for (j=0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - paramType = checkRealBaseType(m_reader.getMethodParamType(i, j), sal_True); - paramMode = m_reader.getMethodParamMode(i, j); - o << indent() << "rtl_uString_newFromAscii( &pParamName" << j << ", \"" - << paramName << "\" );\n"; - o << indent() << "rtl_uString_newFromAscii( &pParamType" << j << ", \"" - << paramType.replace('/', '.') << "\" );\n"; - o << indent() << "pParameters[" << j << "].pParamName = pParamName" << j << ";\n"; - o << indent() << "pParameters[" << j << "].eTypeClass = " - << getTypeClass(paramType, sal_True) << ";\n"; - o << indent() << "pParameters[" << j << "].pTypeName = sParamType" << j << ";\n"; - - if (paramMode == RT_PARAM_IN || paramMode == RT_PARAM_INOUT) - o << indent() << "pParameters[" << j << "].bIn = sal_True;\n"; - else - o << indent() << "pParameters[" << j << "].bIn = sal_False;\n"; - - if (paramMode == RT_PARAM_OUT || paramMode == RT_PARAM_INOUT) - o << indent() << "pParameters[" << j << "].bOut = sal_True;\n"; - else - o << indent() << "pParameters[" << j << "].bOut = sal_False;\n"; - } - - for (j=0; j < excCount; j++) - { - if (!m_reader.getMethodExcType(i, j).equals("com/sun/star/uno/RuntimeException")) - { - o << indent() << "rtl_uString_newFromAscii( & pExceptionName" << j << ", \"" - << OString(m_reader.getMethodExcType(i, j)).replace('/', '.') << "\" );\n"; - o << indent() << "pExceptions[" << j << "] = pExceptionName" << j << ";\n"; - } - } - if ( excCount || bWithRuntimeException ) - { - o << indent() << "rtl_uString_newFromAscii( & pExceptionName" << excCount - << ", \"com.sun.star.uno.RuntimeException\") );\n"; - o << indent() << "pExceptions[" << excCount << "] = pExceptionName" << excCount << ";\n"; - } - o << indent() << "rtl_uString_newFromAscii( &pReturnType" << i << ", \"" - << returnType.replace('/', '.') << "\" );\n"; - o << indent() << "typelib_typedescription_newInterfaceMethod( &pMethod,\n"; - inc(); - o << indent() << absoluteIndex++ << ", "; - if (methodMode == RT_MODE_ONEWAY || methodMode == RT_MODE_ONEWAY_CONST) - o << "sal_True,\n"; - else - o << "sal_False,\n"; - o << indent() << "pMethodName" << i << ",\n"; - o << indent() << getTypeClass(returnType, sal_True) << ", pReturnType" << i << ",\n"; - if (paramCount) - o << indent() << paramCount << ", pParameters,\n"; - else - o << indent() << "0, 0,\n"; - - if ( excCount || bWithRuntimeException ) - { - o << indent() << excCount + 1 << ", pExceptions );\n"; - } else - { - o << indent() << "0, 0 );\n"; - } - - dec(); - o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );\n"; - - o << indent() << "rtl_uString_release( pReturnType );\n"; - for (j=0; j < paramCount; j++) - { - o << indent() << "rtl_uString_release( pParamName" << j << " );\n" - << indent() << "rtl_uString_release( pParamType" << j << " );\n"; - } - - for (j=0; j < excCount; j++) - { - o << indent() << "rtl_uString_release( pExceptionName" << j << " );\n"; - } - if ( excCount || bWithRuntimeException ) - { - o << indent() << "rtl_uString_release( pExceptionName" << excCount << " );\n"; - } - dec(); - o << indent() << "}\n"; - } - o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pMethod );\n"; - - o << indent() << "}\n"; - index = absoluteIndex; - } -} - -void InterfaceType::dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CunoTypeDecl eDeclFlag) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - if (pFinishedTypes->count(fieldType) == 0) - { - pFinishedTypes->insert(fieldType); - dumpCppuGetType(o, fieldType, sal_True, eDeclFlag); - } - } -} - -void InterfaceType::dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CunoTypeDecl eDeclFlag) -{ - sal_uInt32 methodCount = m_reader.getMethodCount(); - OString returnType, paramType, excType; - sal_uInt32 paramCount = 0; - sal_uInt32 excCount = 0; - - for (sal_uInt16 i=0; i < methodCount; i++) - { - returnType = m_reader.getMethodReturnType(i); - paramCount = m_reader.getMethodParamCount(i); - excCount = m_reader.getMethodExcCount(i); - - if (pFinishedTypes->count(returnType) == 0) - { - pFinishedTypes->insert(returnType); - dumpCppuGetType(o, returnType, sal_True, eDeclFlag); - } - sal_uInt16 j; - for (j=0; j < paramCount; j++) - { - paramType = m_reader.getMethodParamType(i, j); - - if (pFinishedTypes->count(paramType) == 0) - { - pFinishedTypes->insert(paramType); - dumpCppuGetType(o, paramType, sal_True, eDeclFlag); - } - } - - for (j=0; j < excCount; j++) - { - excType = m_reader.getMethodExcType(i, j); - if (pFinishedTypes->count(excType) == 0) - { - pFinishedTypes->insert(excType); - dumpCppuGetType(o, excType, sal_True, eDeclFlag); - } - } - } -} - -//************************************************************************* -// ModuleType -//************************************************************************* -ModuleType::ModuleType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : CunoType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -ModuleType::~ModuleType() -{ - -} - -sal_Bool ModuleType::dump(CunoOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - if (pOptions->isValid("-U")) - m_cunoTypeDynamic = sal_True; - - OString outPath; - if (pOptions->isValid("-O")) - outPath = pOptions->getOption("-O"); - - OString tmpName(m_typeName); - - if (tmpName.equals("/")) - tmpName = "global"; - else -// tmpName += "/" + m_typeName.getToken(m_typeName.getTokenCount('/') - 1, '/'); - tmpName += "/" + m_name; - - OString tmpFileName; - OString hFileName = createFileNameFromType(outPath, tmpName, ".hdl"); - - sal_Bool bFileExists = sal_False; - sal_Bool bFileCheck = sal_False; - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( hFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream hFile; - - if ( bFileCheck ) - hFile.open(tmpFileName); - else - hFile.open(hFileName); - - if(!hFile.isValid()) - { - OString message("cannot open "); - message += hFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpHFile(hFile); - - hFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(hFileName, tmpFileName); - } - } -/* - bFileExists = sal_False; - bFileCheck = sal_False; - OString cFileName = createFileNameFromType(outPath, tmpName, ".c"); - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( cFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmc"); - bFileCheck = sal_True; - } - - - if ( !bFileExists || bFileCheck ) - { - FileStream hxxFile; - - if ( bFileCheck ) - cFile.open(tmpFileName); - else - cFile.open(cFileName); - - if(!cFile.isValid()) - { - OString message("cannot open "); - message += cFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpCFile(cFile); - - cFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(cFileName, tmpFileName); - } - } -*/ - return ret; -} - -sal_Bool ModuleType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - sal_Bool bSpecialDefine = sal_True; - - if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS) - { - bSpecialDefine = sal_False; - } - - OString headerDefine(dumpHeaderDefine(o, "H", bSpecialDefine)); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - - dumpOpenExternC(o); - dumpDeclaration(o); - o << "\n"; - dumpCloseExternC(o); - - o << "\n#endif /* "<< headerDefine << " */\n"; - - return sal_True; -} - -sal_Bool ModuleType::dumpDeclaration(FileStream& o) - throw( CannotDumpException ) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST) - { - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - o << "static const "; - dumpType(o, fieldType); - o << " " << m_name << "_" << fieldName << " = "; - dumpConstantValue(o, i); - o << ";\n"; - } - } - - return sal_True; -} - -sal_Bool ModuleType::hasConstants() -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST) - return sal_True; - } - - return sal_False; -} - -sal_Bool ModuleType::dumpCFile(FileStream& o) - throw( CannotDumpException ) -{ - return sal_True; -} - -//************************************************************************* -// ConstantsType -//************************************************************************* -ConstantsType::ConstantsType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : ModuleType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -ConstantsType::~ConstantsType() -{ - -} - -sal_Bool ConstantsType::dump(CunoOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - if (pOptions->isValid("-U")) - m_cunoTypeDynamic = sal_True; - - OString outPath; - if (pOptions->isValid("-O")) - outPath = pOptions->getOption("-O"); - - OString tmpFileName; - OString hFileName = createFileNameFromType(outPath, m_typeName, ".h"); - - sal_Bool bFileExists = sal_False; - sal_Bool bFileCheck = sal_False; - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( hFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmh"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream hFile; - - if ( bFileCheck ) - hFile.open(tmpFileName); - else - hFile.open(hFileName); - - if(!hFile.isValid()) - { - OString message("cannot open "); - message += hFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpHFile(hFile); - - hFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(hFileName, tmpFileName); - } - } -/* - bFileExists = sal_False; - bFileCheck = sal_False; - OString cFileName = createFileNameFromType(outPath, m_typeName, ".c"); - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( cFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmc"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream cFile; - - if ( bFileCheck ) - cFile.open(tmpFileName); - else - cFile.open(cFileName); - - if(!cFile.isValid()) - { - OString message("cannot open "); - message += cFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpCFile(cFile); - - cFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(cFileName, tmpFileName); - } - } -*/ - return ret; -} - -//************************************************************************* -// StructureType -//************************************************************************* -StructureType::StructureType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : CunoType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -StructureType::~StructureType() -{ - -} - -sal_Bool StructureType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "H")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - - dumpOpenExternC(o); - - dumpDeclaration(o); - - if ( m_cunoTypeLib ) - { - o << "#ifdef CUNO_TYPELIB\n" - << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () );\n" - << "#endif\n\n"; - } - - dumpCloseExternC(o); - - o << "#endif /* "<< headerDefine << " */\n"; - - return sal_True; -} - -sal_Bool StructureType::dumpDeclaration(FileStream& o) - throw( CannotDumpException ) -{ - o << "#ifdef SAL_W32\n" - << "# pragma pack(push, 8)\n" - << "#elif defined(SAL_OS2)\n" - << "# pragma pack(8)\n" - << "#endif\n\n"; - - o << "typedef struct _" << m_name << "\n{\n"; - inc(); - - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - o << indent() << superType.replace('/', '_').getStr() << " _Base;\n"; - //dumpInheritedMembers(o, superType); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - sal_uInt16 i=0; - - for (i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - o << indent(); - dumpType(o, fieldType); - o << " " << fieldName << ";\n"; - } - - dec(); - o << "} " << m_name << ";\n\n"; - - o << "#ifdef SAL_W32\n" - << "# pragma pack(pop)\n" - << "#elif defined(SAL_OS2)\n" - << "# pragma pack()\n" - << "#endif\n\n"; - - return sal_True; -} - -sal_Bool StructureType::dumpCFile(FileStream& o) - throw( CannotDumpException ) -{ - dumpInclude(o, m_typeName, "h"); - o << "\n"; - dumpDefaultCIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - - dumpGetCunoType(o); - - return sal_True; -} - -//************************************************************************* -// ExceptionType -//************************************************************************* -ExceptionType::ExceptionType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : CunoType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -ExceptionType::~ExceptionType() -{ - -} - -sal_Bool ExceptionType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "H")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - - dumpOpenExternC(o); - - dumpDeclaration(o); - - if ( m_cunoTypeLib ) - { - o << "#ifdef CUNO_TYPELIB\n" - << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () );\n" - << "#endif\n\n"; - } - - dumpCloseExternC(o); - - o << "#endif /* "<< headerDefine << " */\n"; - - return sal_True; -} - -sal_Bool ExceptionType::dumpDeclaration(FileStream& o) - throw( CannotDumpException ) -{ - o << "#ifdef SAL_W32\n" - << "# pragma pack(push, 8)\n" - << "#elif defined(SAL_OS2)\n" - << "# pragma pack(8)\n" - << "#endif\n\n"; - - o << "\n/* Exception type */\ntypedef struct _" << m_name << "\n{\n"; - inc(); - - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - o << indent() << superType.replace('/', '_').getStr() << " _Base;\n"; - //dumpInheritedMembers(o, superType); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - sal_uInt16 i = 0; - - for (i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - o << indent(); - dumpType(o, fieldType); - o << " " << fieldName << ";\n"; - } - - dec(); - o << "} " << m_name << ";\n\n"; - - o << "#ifdef SAL_W32\n" - << "# pragma pack(pop)\n" - << "#elif defined(SAL_OS2)\n" - << "# pragma pack()\n" - << "#endif\n\n"; - - return sal_True; -} - -sal_Bool ExceptionType::dumpCFile(FileStream& o) - throw( CannotDumpException ) -{ - dumpInclude(o, m_typeName, "h"); - o << "\n"; - dumpDefaultCIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - - dumpGetCunoType(o); - - return sal_True; -} - - -//************************************************************************* -// EnumType -//************************************************************************* -EnumType::EnumType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : CunoType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -EnumType::~EnumType() -{ - -} - -sal_Bool EnumType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "H")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpOpenExternC(o); - - dumpDeclaration(o); - - if ( m_cunoTypeLib ) - { - o << "#ifdef CUNO_TYPELIB\n" - << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () );\n" - << "#endif\n\n"; - } - - dumpCloseExternC(o); - - o << "#endif /* "<< headerDefine << " */\n"; - - return sal_True; -} - -sal_Bool EnumType::dumpDeclaration(FileStream& o) - throw( CannotDumpException ) -{ - o << "\ntypedef enum _" << m_name << "\n{\n"; - inc(); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - RTConstValue constValue; - OString fieldName; - sal_Int32 value=0; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST) - continue; - - fieldName = m_reader.getFieldName(i); - constValue = m_reader.getFieldConstValue(i); - - if (constValue.m_type == RT_TYPE_INT32) - value = constValue.m_value.aLong; - else - value++; - - o << indent() << m_name << "_" << fieldName << " = " << value << ",\n"; - } - - o << indent() << m_name << "_MAKE_FIXED_SIZE = SAL_MAX_ENUM\n"; - - dec(); - o << "} " << m_name << ";\n\n"; - - return sal_True; -} - -sal_Bool EnumType::dumpCFile(FileStream& o) - throw( CannotDumpException ) -{ - dumpInclude(o, m_typeName, "h"); - o << "\n"; - dumpDefaultCIncludes(o); - o << "\n"; - dumpGetCunoType(o); - return sal_True; -} - -void EnumType::dumpGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - if ( m_cunoTypeLeak ) - { - dumpLGetCunoType(o); - return; - } - if ( !m_cunoTypeDynamic ) - { - dumpCGetCunoType(o); - return; - } - - dumpOpenExternC(o); - - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () )\n{\n"; - inc(); - - o << indent() << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << indent() << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - - o << indent() << "typelib_static_enum_type_init( &s_pType_" << typeName << ",\n"; - inc(31); - o << indent() << "\"" << m_typeName.replace('/', '.') << "\",\n" - << indent() << m_name << "_" << m_reader.getFieldName(0) << " );\n"; - dec(31); - dec(); - o << indent() << "}\n" - << indent() << "typelib_typedescriptionreference_acquire( s_pType_" << typeName <<" );\n" - << indent() << "return &s_pType_" << typeName <<" );\n"; - dec(); - o << indent() << "}\n"; - - dumpCloseExternC(o); -} - -void EnumType::dumpCGetCunoType(FileStream& o) -{ - OString typeName(m_typeName.replace('/', '_')); - - dumpOpenExternC(o); - - o << "#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () )\n{\n"; - inc(); - - o << "#if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))\n" - << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n" - << "#endif\n\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "oslMutex * pMutex = osl_getGlobalMutex();\n" - << indent() << "osl_acquireMutex( pMutex );\n"; - - o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n"; - inc(); - o << indent() << "rtl_uString * pTypeName = 0;\n" - << indent() << "_typelib_TypeDescription * pTD = 0;\n"; - - sal_uInt32 count = m_reader.getFieldCount(); - o << indent() << "rtl_uString* enumValueNames[" << count << "];\n" - << indent() << "sal_Int32 enumValues[" << count << "];\n"; - sal_uInt32 i; - for (i = 0; i < count; i++) - { - o << indent() << "rtl_uString * pEnumValue" << i << " = 0;\n"; - } - - o << indent() << "rtl_uString_newFromAscii( &pTypeName, \"" - << m_typeName.replace('/', '.') << "\") );\n\n"; - - for (i = 0; i < count; i++) - { - o << indent() << "rtl_uString_newFromAscii( &pEnumValue" << i << ", \"" - << m_reader.getFieldName((sal_uInt16)i) << "\" );\n"; - o << indent() << "enumValueNames[" << i << "] = pEnumValue" << i << ";\n"; - } - - RTConstValue constValue; - sal_Int32 value=0; - for (i = 0; i < count; i++) - { - o << indent() << "enumValues[" << i << "] = "; - constValue = m_reader.getFieldConstValue((sal_uInt16)i); - if (constValue.m_type == RT_TYPE_INT32) - value = constValue.m_value.aLong; - else - value++; - o << value << ";\n"; - } - - o << "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n"; - inc(); - o << indent() << "pTypeName,\n" - << indent() << "(sal_Int32)" << m_name << "_" << m_reader.getFieldName(0) << ",\n" - << indent() << count << ", enumValueNames, enumValues );\n\n"; - dec(); - - o << indent() << "typelib_typedescription_register( &pTD );\n"; - - o << indent() << "typelib_typedescriptionreference_new( &s_pType_ " << typeName - << getTypeClass(OString(), sal_True) << ", pTD);\n\n"; - - o << indent() << "typelib_typedescription_release( pTD );\n" - << indent() << "rtl_uString_release( pTypeName );\n"; - for (i = 0; i < count; i++) - { - o << indent() << "rtl_uString_release( pEnumValue" << i << " );\n"; - } - - dec(); - o << indent() << "}\n"; - o << indent() << "osl_releaseMutex( pMutex );\n"; - dec(); - o << indent() << "}\n\n" - << indent() << "typelib_typedescriptionreference_acquire( s_pType_" << typeName <<" );\n" - << indent() << "return &s_pType_" << typeName <<" );\n"; - - dec(); - o << "}\n"; - - dumpCloseExternC(o); -} - -//************************************************************************* -// TypeDefType -//************************************************************************* -TypeDefType::TypeDefType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : CunoType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -TypeDefType::~TypeDefType() -{ - -} - -sal_Bool TypeDefType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "H")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - - dumpOpenExternC(o); - - dumpDeclaration(o); - - if ( m_cunoTypeLib ) - { - o << "#ifdef CUNO_TYPELIB\n" - << "typelib_TypeDescriptionReference ** SAL_CALL getCUnoType_" << m_name << "() SAL_THROW_EXTERN_C( () );\n" - << "#endif\n\n"; - } - - dumpCloseExternC(o); - - o << "#endif /* "<< headerDefine << " */\n"; - - return sal_True; -} - -sal_Bool TypeDefType::dumpDeclaration(FileStream& o) - throw( CannotDumpException ) -{ - o << "\ntypedef "; - dumpType(o, m_reader.getSuperTypeName()); - o << " " << m_name << ";\n\n"; - - return sal_True; -} - -sal_Bool TypeDefType::dumpCFile(FileStream& o) - throw( CannotDumpException ) -{ - dumpInclude(o, m_typeName, "h"); - o << "\n"; - dumpDefaultCIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "h"); - o << "\n"; - dumpGetCunoType(o); - return sal_True; -} - -void TypeDefType::dumpGetCunoType(FileStream& o) -{ - if ( m_cunoTypeLeak ) - { - dumpLGetCunoType(o); - return; - } - if ( !m_cunoTypeDynamic ) - { - dumpCGetCunoType(o); - return; - } -} - -void TypeDefType::dumpCGetCunoType(FileStream& o) -{ -} - -void TypeDefType::dumpLGetCunoType(FileStream& o) -{ -} - -//************************************************************************* -// produceType -//************************************************************************* -sal_Bool produceType(const OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - CunoOptions* pOptions) - throw( CannotDumpException ) -{ - if (typeDependencies.isGenerated(typeName)) - return sal_True; - - TypeReader reader(typeMgr.getTypeReader(typeName)); - - if (!reader.isValid()) - { - if (typeName.equals("/")) - return sal_True; - else - return sal_False; - } - - if( !checkTypeDependencies(typeMgr, typeDependencies, typeName)) - return sal_False; - - RTTypeClass typeClass = reader.getTypeClass(); - sal_Bool ret = sal_False; - switch (typeClass) - { - case RT_TYPE_INTERFACE: - { - InterfaceType iType(reader, typeName, typeMgr, typeDependencies); - ret = iType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = iType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_MODULE: - { - ModuleType mType(reader, typeName, typeMgr, typeDependencies); - if (mType.hasConstants()) - { - ret = mType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); -// ret = mType.dumpDependedTypes(pOptions); - } else - { - typeDependencies.setGenerated(typeName); - ret = sal_True; - } - } - break; - case RT_TYPE_STRUCT: - { - StructureType sType(reader, typeName, typeMgr, typeDependencies); - ret = sType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = sType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_ENUM: - { - EnumType enType(reader, typeName, typeMgr, typeDependencies); - ret = enType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = enType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_EXCEPTION: - { - ExceptionType eType(reader, typeName, typeMgr, typeDependencies); - ret = eType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = eType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_TYPEDEF: - { - TypeDefType tdType(reader, typeName, typeMgr, typeDependencies); - ret = tdType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = tdType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_CONSTANTS: - { - ConstantsType cType(reader, typeName, typeMgr, typeDependencies); - if (cType.hasConstants()) - { - ret = cType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); -// ret = cType.dumpDependedTypes(pOptions); - } else - { - typeDependencies.setGenerated(typeName); - ret = sal_True; - } - } - break; - case RT_TYPE_SERVICE: - case RT_TYPE_OBJECT: - ret = sal_True; - break; - } - - return ret; -} - -//************************************************************************* -// scopedName -//************************************************************************* -OString scopedName(const OString& scope, const OString& type, - sal_Bool bNoNameSpace) -{ - sal_Int32 nPos = type.lastIndexOf( '/' ); - if (nPos == -1) - return type; - - if (bNoNameSpace) - return type.copy(nPos+1); - - OStringBuffer tmpBuf(type.getLength()*2); - nPos = 0; - do - { - tmpBuf.append("::"); - tmpBuf.append(type.getToken(0, '/', nPos)); - } while( nPos != -1 ); - - return tmpBuf.makeStringAndClear(); -} - -//************************************************************************* -// shortScopedName -//************************************************************************* -OString shortScopedName(const OString& scope, const OString& type, - sal_Bool bNoNameSpace) -{ - sal_Int32 nPos = type.lastIndexOf( '/' ); - if( nPos == -1 ) - return OString(); - - if (bNoNameSpace) - return OString(); - - // scoped name only if the namespace is not equal - if (scope.lastIndexOf('/') > 0) - { - OString tmpScp(scope.copy(0, scope.lastIndexOf('/'))); - OString tmpScp2(type.copy(0, nPos)); - - if (tmpScp == tmpScp2) - return OString(); - } - - OString aScope( type.copy( 0, nPos ) ); - OStringBuffer tmpBuf(aScope.getLength()*2); - - nPos = 0; - do - { - tmpBuf.append("::"); - tmpBuf.append(aScope.getToken(0, '/', nPos)); - } while( nPos != -1 ); - - return tmpBuf.makeStringAndClear(); -} - - diff --git a/codemaker/source/cunomaker/cunotype.hxx b/codemaker/source/cunomaker/cunotype.hxx deleted file mode 100644 index 81d55270833a..000000000000 --- a/codemaker/source/cunomaker/cunotype.hxx +++ /dev/null @@ -1,309 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOTYPE_HXX_ -#define INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOTYPE_HXX - -#include <codemaker/typemanager.hxx> -#include <codemaker/dependency.hxx> - -enum BASETYPE -{ - BT_INVALID, - BT_VOID, - BT_ANY, - BT_TYPE, - BT_BOOLEAN, - BT_CHAR, - BT_STRING, - BT_FLOAT, - BT_DOUBLE, - BT_OCTET, - BT_BYTE, - BT_SHORT, - BT_LONG, - BT_HYPER, - BT_UNSIGNED_SHORT, - BT_UNSIGNED_LONG, - BT_UNSIGNED_HYPER -}; - - -enum CunoTypeDecl -{ - CUNOTYPEDECL_ALLTYPES, - CUNOTYPEDECL_NOINTERFACES, - CUNOTYPEDECL_ONLYINTERFACES -}; - -class CunoOptions; -class FileStream; - -class CunoType -{ -public: - CunoType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~CunoType(); - - virtual sal_Bool dump(CunoOptions* pOptions) throw( CannotDumpException ); - virtual sal_Bool dumpDependedTypes(CunoOptions* pOptions) throw( CannotDumpException ); - virtual sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ) = 0; - virtual sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ) = 0; - - virtual ::rtl::OString dumpHeaderDefine(FileStream& o, sal_Char* prefix, sal_Bool bExtended=sal_False); - virtual void dumpDefaultHIncludes(FileStream& o); - virtual void dumpDefaultCIncludes(FileStream& o); - virtual void dumpInclude(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix, sal_Bool bExtended=sal_False, sal_Bool bCaseSensitive=sal_False); - virtual void dumpDepIncludes(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix); - - virtual void dumpOpenExternC(FileStream& o); - virtual void dumpCloseExternC(FileStream& o); - - virtual void dumpGetCunoType(FileStream& o); - virtual void dumpCGetCunoType(FileStream& o); - virtual void dumpLGetCunoType(FileStream& o); - - virtual void dumpType(FileStream& o, const ::rtl::OString& type, sal_Bool bConst=sal_False, - sal_Bool bPointer=sal_False, sal_Bool bParam=sal_False) - throw( CannotDumpException ); - ::rtl::OString getTypeClass(const ::rtl::OString& type="", sal_Bool bCStyle=sal_False); - ::rtl::OString getBaseType(const ::rtl::OString& type); - void dumpCppuGetType(FileStream& o, const ::rtl::OString& type, sal_Bool bDecl=sal_False, CunoTypeDecl eDeclFlag=CUNOTYPEDECL_ALLTYPES); - void dumpTypeInit(FileStream& o, const ::rtl::OString& type); - BASETYPE isBaseType(const ::rtl::OString& type); - - ::rtl::OString typeToIdentifier(const ::rtl::OString& type); - - void dumpConstantValue(FileStream& o, sal_uInt16 index); - - virtual sal_uInt32 getMemberCount(); - virtual sal_uInt32 getInheritedMemberCount(); - void dumpInheritedMembers(FileStream& o, rtl::OString& superType); - - sal_Bool isSeqType(const ::rtl::OString& type, ::rtl::OString& baseType, ::rtl::OString& seqPrefix); - sal_Bool isArrayType(const ::rtl::OString& type, ::rtl::OString& baseType, ::rtl::OString& arrayPrefix); - sal_Bool isVoid(const ::rtl::OString& type) - { return type.equals("void"); } - void inc(sal_uInt32 num=4); - void dec(sal_uInt32 num=4); - ::rtl::OString indent(); - ::rtl::OString indent(sal_uInt32 num); -protected: - virtual sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); - - ::rtl::OString checkSpecialCunoType(const ::rtl::OString& type); - ::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False); - void dumpCppuGetTypeMemberDecl(FileStream& o, CunoTypeDecl eDeclFlag); - - sal_Bool isNestedType() - { return m_bIsNestedType; }; - - RegistryKeyNames& getNestedTypeNames() - { return m_nestedTypeNames; }; - - sal_Bool isNestedTypeByName(const ::rtl::OString& type); - sal_Bool hasNestedType(const ::rtl::OString& type); - -protected: - sal_uInt32 m_inheritedMemberCount; - - sal_Bool m_cunoTypeLib; - sal_Bool m_cunoTypeLeak; - sal_Bool m_cunoTypeDynamic; - sal_uInt32 m_indentLength; - ::rtl::OString m_typeName; - ::rtl::OString m_name; - TypeReader m_reader; - TypeManager& m_typeMgr; - TypeDependency m_dependencies; - sal_Bool m_bIsNestedType; - RegistryKeyNames m_nestedTypeNames; -}; - -class InterfaceType : public CunoType -{ -public: - InterfaceType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~InterfaceType(); - - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ); - - void dumpInheritedFunctions(FileStream& o, rtl::OString& superType); - void dumpAttributes(FileStream& o, const ::rtl::OString& interfaceType, TypeReader& reader ); - void dumpMethods(FileStream& o, const ::rtl::OString& interfaceType, TypeReader& reader ); - void dumpGetCunoType(FileStream& o); - void dumpCGetCunoType(FileStream& o); - void dumpCUnoAttributeTypeNames(FileStream& o, sal_Bool bRelease=sal_False); - void dumpCUnoMethodTypeNames(FileStream& o, sal_Bool bRelease=sal_False); - void dumpCUnoAttributeRefs(FileStream& o, sal_uInt32& index); - void dumpCUnoMethodRefs(FileStream& o, sal_uInt32& index); - void dumpCUnoAttributes(FileStream& o, sal_uInt32& index); - void dumpCUnoMethods(FileStream& o, sal_uInt32& index); - void dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CunoTypeDecl eDeclFlag); - void dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CunoTypeDecl eDeclFlag ); - - sal_uInt32 getMemberCount(); - sal_uInt32 getInheritedMemberCount(); - -protected: - sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); - -protected: - sal_uInt32 m_inheritedMemberCount; - sal_Bool m_hasAttributes; - sal_Bool m_hasMethods; -}; - -class ModuleType : public CunoType -{ -public: - ModuleType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~ModuleType(); - - virtual sal_Bool dump(CunoOptions* pOptions) throw( CannotDumpException ); - - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ); - sal_Bool hasConstants(); -}; - -class ConstantsType : public ModuleType -{ -public: - ConstantsType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~ConstantsType(); - - virtual sal_Bool dump(CunoOptions* pOptions) throw( CannotDumpException ); -}; - -class StructureType : public CunoType -{ -public: - StructureType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~StructureType(); - - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ); -}; - -class ExceptionType : public CunoType -{ -public: - ExceptionType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~ExceptionType(); - - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ); -}; - -class EnumType : public CunoType -{ -public: - EnumType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~EnumType(); - - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ); - - void dumpGetCunoType(FileStream& o); - void dumpCGetCunoType(FileStream& o); -}; - -class TypeDefType : public CunoType -{ -public: - TypeDefType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~TypeDefType(); - - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool dumpCFile(FileStream& o) throw( CannotDumpException ); - - void dumpGetCunoType(FileStream& o); - void dumpLGetCunoType(FileStream& o); - void dumpCGetCunoType(FileStream& o); -}; - - -sal_Bool produceType(const ::rtl::OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - CunoOptions* pOptions) - throw( CannotDumpException ); - -/** - * This function returns a C++ scoped name, represents the namespace - * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of - * the type is equal scope, the relativ name will be used. - */ -::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type, - sal_Bool bNoNameSpace=sal_False); - -::rtl::OString shortScopedName(const ::rtl::OString& scope, const ::rtl::OString& type, - sal_Bool bNoNameSpace=sal_False); - - -#endif // INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOTYPE_HXX - diff --git a/codemaker/source/cunomaker/makefile.mk b/codemaker/source/cunomaker/makefile.mk deleted file mode 100644 index 5cc3bc99db8f..000000000000 --- a/codemaker/source/cunomaker/makefile.mk +++ /dev/null @@ -1,61 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=codemaker -TARGET=cunomaker -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -CXXFILES= cunomaker.cxx \ - cunooptions.cxx \ - cunotype.cxx - - -APP1TARGET= $(TARGET) - -APP1OBJS= $(OBJ)$/cunomaker.obj \ - $(OBJ)$/cunooptions.obj \ - $(OBJ)$/cunotype.obj - -APP1STDLIBS= \ - $(SALLIB) \ - $(SALHELPERLIB) \ - $(REGLIB) \ - -APP1LIBS= \ - $(LB)$/codemaker.lib - -.INCLUDE : target.mk diff --git a/codemaker/source/idlmaker/idlmaker.cxx b/codemaker/source/idlmaker/idlmaker.cxx deleted file mode 100644 index 278bac63e4bd..000000000000 --- a/codemaker/source/idlmaker/idlmaker.cxx +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" - -#include <stdio.h> - -#include "sal/main.h" - -#include <codemaker/typemanager.hxx> -#include <codemaker/dependency.hxx> - -#include "idloptions.hxx" -#include "idltype.hxx" - -using namespace rtl; - -sal_Bool produceAllTypes(const OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - IdlOptions* pOptions, - sal_Bool bFullScope) - throw( CannotDumpException ) -{ - if (!produceType(typeName, typeMgr, typeDependencies, pOptions)) - { - fprintf(stderr, "%s ERROR: %s\n", - pOptions->getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - - RegistryKey typeKey = typeMgr.getTypeKey(typeName); - RegistryKeyNames subKeys; - - if (typeKey.getKeyNames(OUString(), subKeys)) - return sal_False; - - OString tmpName; - for (sal_uInt32 i=0; i < subKeys.getLength(); i++) - { - tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8); - - if (pOptions->isValid("-B")) - tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1); - else - tmpName = tmpName.copy(1); - - if (bFullScope) - { - if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True)) - return sal_False; - } else - { - if (!produceType(tmpName, typeMgr, typeDependencies, pOptions)) - return sal_False; - } - } - - return sal_True; -} - -SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) -{ - IdlOptions options; - - try - { - if (!options.initOptions(argc, argv)) - { - exit(1); - } - } - catch( IllegalArgument& e) - { - fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr()); - exit(99); - } - - RegistryTypeManager typeMgr; - TypeDependency typeDependencies; - - if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles())) - { - fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr()); - exit(99); - } - - if (options.isValid("-B")) - { - typeMgr.setBase(options.getOption("-B")); - } - - try - { - if (options.isValid("-T")) - { - OString tOption(options.getOption("-T")); - - OString typeName, tmpName; - sal_Bool ret = sal_False; - sal_Int32 nIndex = 0; - do - { - typeName = tOption.getToken(0, ';', nIndex); - - sal_Int32 nPos = typeName.lastIndexOf( '.' ); - tmpName = typeName.copy( nPos != -1 ? nPos+1 : 0 ); - if (tmpName == "*") - { - // produce this type and his scope, but the scope is not recursively generated. - if (typeName.equals("*")) - { - tmpName = "/"; - } else - { - tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/'); - if (tmpName.getLength() == 0) - tmpName = "/"; - else - tmpName.replace('.', '/'); - } - ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False); - } else - { - // produce only this type - ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options); - } - - if (!ret) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - } while( nIndex != -1 ); - } else - { - // produce all types - if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True)) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - "an error occurs while dumping all types."); - exit(99); - } - } - } - catch( CannotDumpException& e) - { - fprintf(stderr, "%s ERROR: %s\n", - options.getProgramName().getStr(), - e.m_message.getStr()); - exit(99); - } - - return 0; -} - - diff --git a/codemaker/source/idlmaker/idloptions.cxx b/codemaker/source/idlmaker/idloptions.cxx deleted file mode 100644 index e495f555e5cb..000000000000 --- a/codemaker/source/idlmaker/idloptions.cxx +++ /dev/null @@ -1,250 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" -#include <stdio.h> - -#include "idloptions.hxx" - -using namespace rtl; - -sal_Bool IdlOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) - throw( IllegalArgument ) -{ - sal_Bool ret = sal_True; - sal_uInt16 i=0; - - if (!bCmdFile) - { - bCmdFile = sal_True; - - m_program = av[0]; - - if (ac < 2) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - ret = sal_False; - } - - i = 1; - } else - { - i = 0; - } - - char *s=NULL; - for (i; i < ac; i++) - { - if (av[i][0] == '-') - { - switch (av[i][1]) - { - case 'O': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-O', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-O"] = OString(s); - break; - case 'B': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-B', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - m_options["-B"] = OString(s); - break; - case 'T': - if (av[i][2] == '\0') - { - if (i < ac - 1 && av[i+1][0] != '-') - { - i++; - s = av[i]; - } else - { - OString tmp("'-T', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i+1]) + "'"; - } - - throw IllegalArgument(tmp); - } - } else - { - s = av[i] + 2; - } - - if (m_options.count("-T") > 0) - { - OString tmp(m_options["-T"]); - tmp = tmp + ";" + s; - m_options["-T"] = tmp; - } else - { - m_options["-T"] = OString(s); - } - break; - case 'G': - if (av[i][2] == 'c') - { - if (av[i][3] != '\0') - { - OString tmp("'-Gc', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - m_options["-Gc"] = OString(""); - break; - } else - if (av[i][2] != '\0') - { - OString tmp("'-G', please check"); - if (i <= ac - 1) - { - tmp += " your input '" + OString(av[i]) + "'"; - } - - throw IllegalArgument(tmp); - } - - m_options["-G"] = OString(""); - break; - default: - throw IllegalArgument("the option is unknown" + OString(av[i])); - break; - } - } else - { - if (av[i][0] == '@') - { - FILE* cmdFile = fopen(av[i]+1, "r"); - if( cmdFile == NULL ) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - ret = sal_False; - } else - { - int rargc=0; - char* rargv[512]; - char buffer[512]; - - while ( fscanf(cmdFile, "%s", buffer) != EOF ) - { - rargv[rargc]= strdup(buffer); - rargc++; - } - fclose(cmdFile); - - ret = initOptions(rargc, rargv, bCmdFile); - - for (long i=0; i < rargc; i++) - { - free(rargv[i]); - } - } - } else - { - m_inputFiles.push_back(av[i]); - } - } - } - - return ret; -} - -OString IdlOptions::prepareHelp() -{ - OString help("\nusing: "); - help += m_program + " [-options] file_1 ... file_n\nOptions:\n"; - help += " -O<path> = path describes the root directory for the generated output.\n"; - help += " The output directory tree is generated under this directory.\n"; - help += " -T<name> = name specifies a type or a list of types. The output for this\n"; - help += " [t1;...] type is generated. If no '-T' option is specified,\n"; - help += " then output for all types is generated.\n"; - help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n"; - help += " -B<name> = name specifies the base node. All types are searched under this\n"; - help += " node. Default is the root '/' of the registry files.\n"; - help += " -G = generate only target files which does not exists.\n"; - help += " -Gc = generate only target files which content will be changed.\n"; - help += "IMPORTANT: You lose enum values and struct, exception inheritance!\n"; - help += " Parameter name Object is translated to _Object!\n"; - help += " The type type is translated to CORBA::TypeCode!\n"; - help += " Sequences are expanded to a typedef name Sequence_..._\"name\"!\n"; - help += prepareVersion(); - - return help; -} - -OString IdlOptions::prepareVersion() -{ - OString version(m_program); - version += " Version 2.0\n\n"; - return version; -} - - diff --git a/codemaker/source/idlmaker/idloptions.hxx b/codemaker/source/idlmaker/idloptions.hxx deleted file mode 100644 index 6ad5e47daa4d..000000000000 --- a/codemaker/source/idlmaker/idloptions.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLOPTIONS_HXX -#define INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLOPTIONS_HXX - -#include <codemaker/options.hxx> - -class IdlOptions : public Options -{ -public: - IdlOptions() - : Options() {} - - ~IdlOptions() {} - - sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) - throw( IllegalArgument ); - - ::rtl::OString prepareHelp(); - - ::rtl::OString prepareVersion(); - -protected: -}; - -#endif // INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLOPTIONS_HXX diff --git a/codemaker/source/idlmaker/idltype.cxx b/codemaker/source/idlmaker/idltype.cxx deleted file mode 100644 index 8ffa32543100..000000000000 --- a/codemaker/source/idlmaker/idltype.cxx +++ /dev/null @@ -1,1752 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_codemaker.hxx" - -#include <stdio.h> -#include <rtl/alloc.h> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> - -#include "idltype.hxx" -#include "idloptions.hxx" - -using namespace rtl; - -//************************************************************************* -// IdlType -//************************************************************************* -IdlType::IdlType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : m_inheritedMemberCount(0) - , m_indentLength(0) - , m_typeName(typeName) - , m_reader(typeReader) - , m_typeMgr((TypeManager&)typeMgr) - , m_dependencies(typeDependencies) -{ - sal_Int32 i = typeName.lastIndexOf('/'); - m_name = typeName.copy( i != -1 ? i+1 : 0 ); -} - -IdlType::~IdlType() -{ - -} - -sal_Bool IdlType::dump(IdlOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - OString outPath; - if (pOptions->isValid("-O")) - outPath = pOptions->getOption("-O"); - - OString tmpFileName; - OString hFileName = createFileNameFromType(outPath, m_typeName, ".idl"); - - sal_Bool bFileExists = sal_False; - sal_Bool bFileCheck = sal_False; - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( hFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream hFile; - - if ( bFileCheck ) - hFile.open(tmpFileName); - else - hFile.open(hFileName); - - if(!hFile.isValid()) - { - OString message("cannot open "); - message += hFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpHFile(hFile); - - hFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(hFileName, tmpFileName); - } - } - - return ret; -} -sal_Bool IdlType::dumpDependedTypes(IdlOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_True; - - TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName)); - - TypeUsingSet::const_iterator iter = usingSet.begin(); - OString typeName; - sal_uInt32 index = 0; - while (iter != usingSet.end()) - { - typeName = (*iter).m_type; - if ((index = typeName.lastIndexOf(']')) > 0) - typeName = typeName.copy(index + 1); - - if (getBaseType(typeName).getLength() == 0) - { - if (!produceType(typeName, - m_typeMgr, - m_dependencies, - pOptions)) - { - fprintf(stderr, "%s ERROR: %s\n", - pOptions->getProgramName().getStr(), - OString("cannot dump Type '" + typeName + "'").getStr()); - exit(99); - } - } - ++iter; - } - - return ret; -} - -OString IdlType::dumpHeaderDefine(FileStream& o, sal_Char* prefix ) -{ - if (m_typeName.equals("/")) - { - m_typeName = "global"; - } - - sal_uInt32 length = 3 + m_typeName.getLength() + strlen(prefix); - - OStringBuffer tmpBuf(length); - - tmpBuf.append('_'); - tmpBuf.append(m_typeName); - tmpBuf.append('_'); - tmpBuf.append(prefix); - tmpBuf.append('_'); - - OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toAsciiUpperCase()); - - o << "#ifndef " << tmp << "\n#define " << tmp << "\n"; - - return tmp; -} - -void IdlType::dumpDefaultHIncludes(FileStream& o) -{ -} - -void IdlType::dumpInclude(FileStream& o, const OString& genTypeName, const OString& typeName, sal_Char* prefix ) -{ - sal_uInt32 length = 3+ m_typeName.getLength() + strlen(prefix); - - OStringBuffer tmpBuf(length); - - tmpBuf.append('_'); - tmpBuf.append(typeName); - tmpBuf.append('_'); - tmpBuf.append(prefix); - tmpBuf.append('_'); - - OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toAsciiUpperCase()); - - length = 1 + typeName.getLength() + strlen(prefix); - - tmpBuf.ensureCapacity(length); - tmpBuf.append(typeName); - tmpBuf.append('.'); - tmpBuf.append(prefix); - - o << "#ifndef " << tmp << "\n#include <"; - tmp = tmpBuf.makeStringAndClear(); - - sal_Int32 nIndex = 0; - do - { - genTypeName.getToken(0, '/', nIndex); - o << "../"; - } while( nIndex != -1 ); - -// sal_Int32 nSlashes = genTypeName.getTokenCount( '/'); -// for( sal_Int32 i = 1; i < nSlashes; i++ ) -// o << "../"; - o << tmp; - o << ">\n#endif\n"; -} - -void IdlType::dumpDepIncludes(FileStream& o, const OString& typeName, sal_Char* prefix) -{ - TypeUsingSet usingSet(m_dependencies.getDependencies(typeName)); - - TypeUsingSet::const_iterator iter = usingSet.begin(); - - OString sPrefix(OString(prefix).toAsciiUpperCase()); - sal_uInt32 index = 0; - sal_uInt32 seqNum = 0; - OString relType; - while (iter != usingSet.end()) - { - index = (*iter).m_type.lastIndexOf(']'); - seqNum = (index > 0 ? ((index+1) / 2) : 0); - - relType = (*iter).m_type; - if (index > 0) - relType = relType.copy(index+1); - - - OString defPrefix("IDL"); - - if (getBaseType(relType).getLength() == 0 && - m_typeName != relType) - { - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE) - { - if (!((*iter).m_use & TYPEUSE_SUPER)) - { - o << "\n"; - dumpNameSpace(o, sal_True, sal_False, relType); - o << "\ninterface " << scopedName(m_typeName, relType, sal_True) << ";\n"; - dumpNameSpace(o, sal_False, sal_False, relType); - o << "\n\n"; - } - } - dumpInclude(o, typeName, relType, prefix); - } - else if (relType == "type") - { - o << "module CORBA {\n" - << "\tinterface TypeCode;\n" - << "};\n\n"; - } - - if( seqNum != 0 ) - { - // write typedef for sequences to support Rational Rose 2000 import - OString aST = relType; - OString aScope; - dumpNameSpace( o, sal_True, sal_False, relType ); - for( sal_uInt32 i = 0; i < seqNum; i++ ) - { - o << "typedef sequence< " << scopedName("", aST) << " > "; - - if( i == 0 ) - { - aST = aST.replace( '/', '_' ); - aST = aST.replace( ' ', '_' ); - } - aST = aST + "_Sequence" ; - o << aST << ";\n"; - } - dumpNameSpace( o, sal_False, sal_False, relType ); - } - ++iter; - } -} - -void IdlType::dumpNameSpace(FileStream& o, sal_Bool bOpen, sal_Bool bFull, const OString& type) -{ - OString typeName(type); - sal_Bool bOneLine = sal_True; - if (typeName.getLength() == 0) - { - typeName = m_typeName; - bOneLine = sal_False; - } - - if (typeName == "/") - return; - - if (typeName.indexOf( '/' ) == -1 && !bFull) - return; - - if (!bFull) - typeName = typeName.copy( 0, typeName.lastIndexOf( '/' ) ); - - if (bOpen) - { - sal_Int32 nIndex = 0; - do - { - o << "module " << typeName.getToken(0, '/', nIndex); - if (bOneLine) - o << " { "; - else - o << "\n{\n"; - } while( nIndex != -1 ); - } else - { - sal_Int32 nPos = 0; - do - { - nPos = typeName.lastIndexOf( '/' ); - o << "};"; - if( bOneLine ) - o << " "; - else - o << " /* " << typeName.copy( nPos+1 ) << " */\n"; - if( nPos != -1 ) - typeName = typeName.copy( 0, nPos ); - } while( nPos != -1 ); - } -} - - -sal_uInt32 IdlType::getMemberCount() -{ - sal_uInt32 count = m_reader.getMethodCount(); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - count++; - } - return count; -} - -sal_uInt32 IdlType::checkInheritedMemberCount(const TypeReader* pReader) -{ - sal_Bool bSelfCheck = sal_True; - if (!pReader) - { - bSelfCheck = sal_False; - pReader = &m_reader; - } - - sal_uInt32 count = 0; - OString superType(pReader->getSuperTypeName()); - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - if ( aSuperReader.isValid() ) - { - count = checkInheritedMemberCount(&aSuperReader); - } - } - - if (bSelfCheck) - { - count += pReader->getMethodCount(); - sal_uInt32 fieldCount = pReader->getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = pReader->getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - count++; - } - } - } - - return count; -} - -sal_uInt32 IdlType::getInheritedMemberCount() -{ - if (m_inheritedMemberCount == 0) - { - m_inheritedMemberCount = checkInheritedMemberCount(0); - } - - return m_inheritedMemberCount; -} - - -void IdlType::dumpType(FileStream& o, const OString& type ) - throw( CannotDumpException ) -{ - OString sType(checkRealBaseType(type, sal_True)); - sal_uInt32 index = sType.lastIndexOf(']'); - sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0); - - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - RTTypeClass typeClass = m_typeMgr.getTypeClass(relType); - - sal_uInt32 i; -/* - for (i=0; i < seqNum; i++) - { - //o << "sequence< "; - } -*/ - switch (typeClass) - { - case RT_TYPE_INVALID: - { - OString tmp(getBaseType(relType)); - if (tmp.getLength() > 0) - { - tmp = tmp.replace( ' ', '_' ); - o << tmp; - } else - throw CannotDumpException("Unknown type '" + relType + "', incomplete type library."); - } - break; - case RT_TYPE_INTERFACE: - case RT_TYPE_STRUCT: - case RT_TYPE_ENUM: - case RT_TYPE_TYPEDEF: - case RT_TYPE_EXCEPTION: - if( seqNum ) - { - OString aST = relType.replace( '/', '_' ); - aST = aST.replace( ' ', '_' ); - o << aST; - } - else - o << scopedName(m_typeName, relType); - break; - } - - for (i=0; i < seqNum; i++) - { - //o << " >"; - // use typedef for sequences to support Rational Rose 2000 import - o << "_Sequence"; - } -} - -OString IdlType::getBaseType(const OString& type) -{ - if (type.equals("long")) - return type; - if (type.equals("short")) - return type; - if (type.equals("hyper")) - return "long long"; - if (type.equals("string")) - return "string"; - if (type.equals("boolean")) - return type; - if (type.equals("char")) - return "char"; - if (type.equals("byte")) - return "byte"; - if (type.equals("any")) - return type; - if (type.equals("type")) - return "CORBA::TypeCode"; - if (type.equals("float")) - return type; - if (type.equals("double")) - return type; - if (type.equals("octet")) - return type; - if (type.equals("void")) - return type; - if (type.equals("unsigned long")) - return type; - if (type.equals("unsigned short")) - return type; - if (type.equals("unsigned hyper")) - return "unsigned long long"; - - return OString(); -} - -void IdlType::dumpIdlGetType(FileStream& o, const OString& type, sal_Bool bDecl, IdlTypeDecl eDeclFlag) -{ - OString sType( checkRealBaseType(type, sal_True) ); - sal_uInt32 index = sType.lastIndexOf(']'); - OString relType = (index > 0 ? (sType).copy(index+1) : type); - - if (eDeclFlag == CPPUTYPEDECL_ONLYINTERFACES) - { - if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE) - { - o << indent() << "getIdlType( ("; - dumpType(o, type); - o << "*)0 )"; - - if (bDecl) - o << ";\n"; - } - } else - { - if (isBaseType(type)) - { - return; - } else - { - if (eDeclFlag == CPPUTYPEDECL_NOINTERFACES && - m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE) - return; - -// if (m_typeMgr.getTypeClass(type) == RT_TYPE_TYPEDEF) -// { -// o << indent() << "get_" << type.replace('/', '_') << "_Type()"; -// } else -// { - o << indent() << "getIdlType( ("; - dumpType(o, type); - o << "*)0 )"; -// } - } - if (bDecl) - o << ";\n"; - } -} - -BASETYPE IdlType::isBaseType(const OString& type) -{ - if (type.equals("long")) - return BT_LONG; - if (type.equals("short")) - return BT_SHORT; - if (type.equals("hyper")) - return BT_HYPER; - if (type.equals("string")) - return BT_STRING; - if (type.equals("boolean")) - return BT_BOOLEAN; - if (type.equals("char")) - return BT_CHAR; - if (type.equals("byte")) - return BT_BYTE; - if (type.equals("any")) - return BT_ANY; - if (type.equals("float")) - return BT_FLOAT; - if (type.equals("double")) - return BT_DOUBLE; - if (type.equals("void")) - return BT_VOID; - if (type.equals("unsigned long")) - return BT_UNSIGNED_LONG; - if (type.equals("unsigned short")) - return BT_UNSIGNED_SHORT; - if (type.equals("unsigned hyper")) - return BT_UNSIGNED_HYPER; - - return BT_INVALID; -} - -OString IdlType::checkSpecialIdlType(const OString& type) -{ - OString baseType(type); - - RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader(); - - RegistryKey key; - sal_uInt8* pBuffer=NULL; - RTTypeClass typeClass; - sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF); - TypeReader reader; - - while (isTypeDef) - { - reader = m_typeMgr.getTypeReader(baseType); - - if (reader.isValid()) - { - typeClass = reader.getTypeClass(); - - if (typeClass == RT_TYPE_TYPEDEF) - baseType = reader.getSuperTypeName(); - else - isTypeDef = sal_False; - } else - { - break; - } - } - - return baseType; -} - -OString IdlType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOnly) -{ - sal_uInt32 index = type.lastIndexOf(']'); - OString baseType = (index > 0 ? ((OString)type).copy(index+1) : type); - OString seqPrefix = (index > 0 ? ((OString)type).copy(0, index+1) : OString()); - - RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader(); - - RegistryKey key; - sal_uInt8* pBuffer=NULL; - RTTypeClass typeClass; - sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF); - TypeReader reader; - - while (mustBeChecked) - { - reader = m_typeMgr.getTypeReader(baseType); - - if (reader.isValid()) - { - typeClass = reader.getTypeClass(); - - if (typeClass == RT_TYPE_TYPEDEF) - { - baseType = reader.getSuperTypeName(); - index = baseType.lastIndexOf(']'); - if (index > 0) - { - seqPrefix += baseType.copy(0, index+1); - baseType = baseType.copy(index+1); - } - } else - mustBeChecked = sal_False; - } else - { - break; - } - } - - if ( bResolveTypeOnly ) - baseType = seqPrefix + baseType; - - return baseType; -} - -void IdlType::dumpConstantValue(FileStream& o, sal_uInt16 index) -{ - RTConstValue constValue = m_reader.getFieldConstValue(index); - - switch (constValue.m_type) - { - case RT_TYPE_BOOL: - if (constValue.m_value.aBool) - o << "true"; - else - o << "false"; - break; - case RT_TYPE_BYTE: - { - char tmp[16]; - snprintf(tmp, sizeof(tmp), "0x%x", (sal_Int8)constValue.m_value.aByte); - o << tmp; - } - break; - case RT_TYPE_INT16: - o << constValue.m_value.aShort; - break; - case RT_TYPE_UINT16: - o << constValue.m_value.aUShort; - break; - case RT_TYPE_INT32: - o << constValue.m_value.aLong; - break; - case RT_TYPE_UINT32: - o << constValue.m_value.aULong; - break; - case RT_TYPE_INT64: - { - ::rtl::OString tmp( OString::valueOf(constValue.m_value.aHyper) ); - o << tmp.getStr(); - } - break; - case RT_TYPE_UINT64: - { - ::rtl::OString tmp( OString::valueOf((sal_Int64)constValue.m_value.aUHyper) ); - o << tmp.getStr(); - } - break; - case RT_TYPE_FLOAT: - { - ::rtl::OString tmp( OString::valueOf(constValue.m_value.aFloat) ); - o << tmp.getStr(); - } - break; - case RT_TYPE_DOUBLE: - { - ::rtl::OString tmp( OString::valueOf(constValue.m_value.aDouble) ); - o << tmp.getStr(); - } - break; - case RT_TYPE_STRING: - { - ::rtl::OUString aUStr(constValue.m_value.aString); - ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US); - o << "\"" << aStr.getStr() << "\")"; - } - break; - } -} - -void IdlType::inc(sal_uInt32 num) -{ - m_indentLength += num; -} - -void IdlType::dec(sal_uInt32 num) -{ - if (m_indentLength - num < 0) - m_indentLength = 0; - else - m_indentLength -= num; -} - -OString IdlType::indent() -{ - OStringBuffer tmp(m_indentLength); - - for (sal_uInt32 i=0; i < m_indentLength; i++) - { - tmp.append(' '); - } - return tmp.makeStringAndClear(); -} - -OString IdlType::indent(sal_uInt32 num) -{ - OStringBuffer tmp(m_indentLength + num); - - for (sal_uInt32 i=0; i < m_indentLength + num; i++) - { - tmp.append(' '); - } - return tmp.makeStringAndClear(); -} - -//************************************************************************* -// InterfaceType -//************************************************************************* -InterfaceType::InterfaceType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : IdlType(typeReader, typeName, typeMgr, typeDependencies) -{ - m_inheritedMemberCount = 0; - m_hasAttributes = sal_False; - m_hasMethods = sal_False; -} - -InterfaceType::~InterfaceType() -{ - -} - -sal_Bool InterfaceType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "IDL")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "idl"); - o << "\n"; - dumpNameSpace(o); - - // write documentation - OString aDoc = m_reader.getDoku(); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - o << "\ninterface " << m_name; - - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - o << " : " << scopedName(m_typeName, superType); - - o << "\n{\n"; - inc(); - - dumpAttributes(o); - dumpMethods(o); - - dec(); - o << "};\n\n"; - - dumpNameSpace(o, sal_False); - -// o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n" -// << "class Type;\n} } } }\n\n"; - - o << "#endif /* "<< headerDefine << "*/" << "\n"; - return sal_True; -} - -void InterfaceType::dumpAttributes(FileStream& o) -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - sal_Bool first=sal_True; - - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - if (first) - { - first = sal_False; - o << "\n"; - } - - // write documentation - OString aDoc = m_reader.getFieldDoku(i); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/\n"; - - if (access == RT_ACCESS_READONLY) - o << indent() << "readonly attribute "; - else - o << indent() << "attribute "; - dumpType(o, fieldType); - o << " " << fieldName << ";\n"; - } -} - -void InterfaceType::dumpMethods(FileStream& o) -{ - sal_uInt32 methodCount = m_reader.getMethodCount(); - - OString methodName, returnType, paramType, paramName; - sal_uInt32 paramCount = 0; - sal_uInt32 excCount = 0; - RTMethodMode methodMode = RT_MODE_INVALID; - RTParamMode paramMode = RT_PARAM_INVALID; - - sal_Bool bRef = sal_False; - sal_Bool bConst = sal_False; - sal_Bool bWithRunTimeExcp = sal_True; - - for (sal_Int16 i=0; i < methodCount; i++) - { - methodName = m_reader.getMethodName(i); - returnType = m_reader.getMethodReturnType(i); - paramCount = m_reader.getMethodParamCount(i); - excCount = m_reader.getMethodExcCount(i); - methodMode = m_reader.getMethodMode(i); - - if ( methodName.equals("acquire") || methodName.equals("release") ) - { - bWithRunTimeExcp = sal_False; - } - - // write documentation - OString aDoc = m_reader.getMethodDoku(i); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/\n"; - - o << indent(); - dumpType(o, returnType); - o << " " << methodName << "( "; - sal_uInt16 j; - for (j=0; j < paramCount; j++) - { - paramName = m_reader.getMethodParamName(i, j); - paramType = m_reader.getMethodParamType(i, j); - paramMode = m_reader.getMethodParamMode(i, j); - - switch (paramMode) - { - case RT_PARAM_IN: - o << "in "; - break; - case RT_PARAM_OUT: - o << "out "; - break; - case RT_PARAM_INOUT: - o << "inout "; - break; - break; - } - - dumpType(o, paramType); - if( paramName == "Object" ) - o << " _Object"; - else - o << " " << paramName; - - if (j+1 < paramCount) o << ", "; - } - o << " )"; - - if( excCount ) - { - o << " raises("; - OString excpName; - sal_Bool bWriteComma = sal_False; - sal_Bool bRTExceptionWritten = sal_False; - for (j=0; j < excCount; j++) - { - excpName = m_reader.getMethodExcType(i, j); - if( bWriteComma ) - o << ", "; - o << scopedName(m_typeName, excpName); - bWriteComma = sal_True; - - if(excpName == "com/sun/star/uno/RuntimeException") - bRTExceptionWritten = sal_True; - } - - if ( bWithRunTimeExcp && !bRTExceptionWritten ) - { - if( bWriteComma ) - o << ", "; - o << "::com::sun::star::uno::RuntimeException"; - } - - o << ");\n"; - } - else if ( bWithRunTimeExcp ) - { - o << "raises( ::com::sun::star::uno::RuntimeException );\n"; - } - else - { - o << ";\n"; - } - } -} - - -sal_uInt32 InterfaceType::getMemberCount() -{ - sal_uInt32 count = m_reader.getMethodCount(); - - if (count) - m_hasMethods = sal_True; - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - m_hasAttributes = sal_True; - count++; - } - } - return count; -} - -sal_uInt32 InterfaceType::checkInheritedMemberCount(const TypeReader* pReader) -{ - sal_uInt32 cout = 0; - sal_Bool bSelfCheck = sal_True; - if (!pReader) - { - bSelfCheck = sal_False; - pReader = &m_reader; - } - - sal_uInt32 count = 0; - OString superType(pReader->getSuperTypeName()); - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - if (aSuperReader.isValid()) - { - count = checkInheritedMemberCount(&aSuperReader); - } - } - - if (bSelfCheck) - { - count += pReader->getMethodCount(); - sal_uInt32 fieldCount = pReader->getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = pReader->getFieldAccess(i); - - if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID) - { - count++; - } - } - } - - return count; -} - -sal_uInt32 InterfaceType::getInheritedMemberCount() -{ - if (m_inheritedMemberCount == 0) - { - m_inheritedMemberCount = checkInheritedMemberCount(0); - } - - return m_inheritedMemberCount; -} - - - -//************************************************************************* -// ModuleType -//************************************************************************* -ModuleType::ModuleType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : IdlType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -ModuleType::~ModuleType() -{ - -} - -sal_Bool ModuleType::dump(IdlOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - OString outPath; - if (pOptions->isValid("-O")) - outPath = pOptions->getOption("-O"); - - OString tmpName(m_typeName); - - if (tmpName.equals("/")) - tmpName = "global"; - else -// tmpName += "/" + m_typeName.getToken(m_typeName.getTokenCount('/') - 1, '/'); - tmpName += "/" + m_name; - - OString tmpFileName; - OString hFileName = createFileNameFromType(outPath, tmpName, ".idl"); - - sal_Bool bFileExists = sal_False; - sal_Bool bFileCheck = sal_False; - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( hFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream hFile; - - if ( bFileCheck ) - hFile.open(tmpFileName); - else - hFile.open(hFileName); - - if(!hFile.isValid()) - { - OString message("cannot open "); - message += hFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpHFile(hFile); - - hFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(hFileName, tmpFileName); - } - } - - return ret; -} - -sal_Bool ModuleType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "IDL")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "idl"); - o << "\n"; - - dumpNameSpace(o, sal_True, sal_True); - o << "\n"; - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST) - { - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - o << "const "; - dumpType(o, fieldType); - o << " " << fieldName << " = "; - dumpConstantValue(o, i); - o << ";\n"; - } - } - - o << "\n"; - dumpNameSpace(o, sal_False, sal_True); - o << "\n#endif /* "<< headerDefine << "*/" << "\n"; - - return sal_True; -} - -sal_Bool ModuleType::hasConstants() -{ - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST) - return sal_True; - } - - return sal_False; -} - -//************************************************************************* -// ConstantsType -//************************************************************************* -ConstantsType::ConstantsType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : ModuleType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -ConstantsType::~ConstantsType() -{ - -} - -sal_Bool ConstantsType::dump(IdlOptions* pOptions) - throw( CannotDumpException ) -{ - sal_Bool ret = sal_False; - - OString outPath; - if (pOptions->isValid("-O")) - outPath = pOptions->getOption("-O"); - - OString tmpFileName; - OString hFileName = createFileNameFromType(outPath, m_typeName, ".idl"); - - sal_Bool bFileExists = sal_False; - sal_Bool bFileCheck = sal_False; - - if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") ) - { - bFileExists = fileExists( hFileName ); - ret = sal_True; - } - - if ( bFileExists && pOptions->isValid("-Gc") ) - { - tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml"); - bFileCheck = sal_True; - } - - if ( !bFileExists || bFileCheck ) - { - FileStream hFile; - - if ( bFileCheck ) - hFile.open(tmpFileName); - else - hFile.open(hFileName); - - if(!hFile.isValid()) - { - OString message("cannot open "); - message += hFileName + " for writing"; - throw CannotDumpException(message); - } - - ret = dumpHFile(hFile); - - hFile.close(); - if (ret && bFileCheck) - { - ret = checkFileContent(hFileName, tmpFileName); - } - } - - return ret; -} - -//************************************************************************* -// StructureType -//************************************************************************* -StructureType::StructureType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : IdlType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -StructureType::~StructureType() -{ - -} - -sal_Bool StructureType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "IDL")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "idl"); - o << "\n"; - - dumpNameSpace(o); - - // write documentation - OString aDoc = m_reader.getDoku(); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << "\nstruct " << m_name; - o << "\n{\n"; - inc(); - - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - dumpSuperMember(o, superType); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - sal_uInt16 i=0; - - for (i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - // write documentation - OString aDoc = m_reader.getFieldDoku(i); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << indent(); - dumpType(o, fieldType); - o << " " << fieldName << ";\n"; - } - - dec(); - o << "};\n\n"; - - dumpNameSpace(o, sal_False); - - o << "#endif /* "<< headerDefine << "*/" << "\n"; - - return sal_True; -} - -void StructureType::dumpSuperMember(FileStream& o, const OString& superType) -{ - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - - if (aSuperReader.isValid()) - { - dumpSuperMember(o, aSuperReader.getSuperTypeName()); - - sal_uInt32 fieldCount = aSuperReader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = aSuperReader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = aSuperReader.getFieldName(i); - fieldType = aSuperReader.getFieldType(i); - - // write documentation - OString aDoc = aSuperReader.getFieldDoku(i); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << indent(); - dumpType(o, fieldType); - o << " "; - o << fieldName << ";\n"; - } - } - } -} - -//************************************************************************* -// ExceptionType -//************************************************************************* -ExceptionType::ExceptionType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : IdlType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -ExceptionType::~ExceptionType() -{ - -} - -sal_Bool ExceptionType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "IDL")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "idl"); - o << "\n"; - - dumpNameSpace(o); - - // write documentation - OString aDoc = m_reader.getDoku(); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << "\nexception " << m_name; - o << "\n{\n"; - inc(); - - // Write extra member for derived exceptions - o << indent() << "/*extra member to hold a derived exception */\n"; - o << indent() << "any _derivedException;\n"; - OString superType(m_reader.getSuperTypeName()); - if (superType.getLength() > 0) - dumpSuperMember(o, superType); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - sal_uInt16 i = 0; - - for (i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = m_reader.getFieldName(i); - fieldType = m_reader.getFieldType(i); - - // write documentation - OString aDoc = m_reader.getFieldDoku(i); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << indent(); - dumpType(o, fieldType); - o << " " << fieldName << ";\n"; - } - - - dec(); - o << "};\n\n"; - - dumpNameSpace(o, sal_False); - - o << "#endif /* "<< headerDefine << "*/" << "\n"; - - return sal_True; -} - -void ExceptionType::dumpSuperMember(FileStream& o, const OString& superType) -{ - if (superType.getLength() > 0) - { - TypeReader aSuperReader(m_typeMgr.getTypeReader(superType)); - - if (aSuperReader.isValid()) - { - dumpSuperMember(o, aSuperReader.getSuperTypeName()); - - sal_uInt32 fieldCount = aSuperReader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - OString fieldName; - OString fieldType; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = aSuperReader.getFieldAccess(i); - - if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID) - continue; - - fieldName = aSuperReader.getFieldName(i); - fieldType = aSuperReader.getFieldType(i); - - // write documentation - OString aDoc = aSuperReader.getFieldDoku(i); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << indent(); - dumpType(o, fieldType); - o << " "; - o << fieldName << ";\n"; - } - } - } -} - -//************************************************************************* -// EnumType -//************************************************************************* -EnumType::EnumType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : IdlType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -EnumType::~EnumType() -{ - -} - -sal_Bool EnumType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "IDL")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - - dumpNameSpace(o); - - // write documentation - OString aDoc = m_reader.getDoku(); - if( aDoc.getLength() ) - o << "/**\n" << aDoc << "\n*/"; - - o << "\nenum " << m_name << "\n{\n"; - inc(); - - sal_uInt32 fieldCount = m_reader.getFieldCount(); - RTFieldAccess access = RT_ACCESS_INVALID; - RTConstValue constValue; - OString fieldName; - sal_uInt32 value=0; - for (sal_uInt16 i=0; i < fieldCount; i++) - { - access = m_reader.getFieldAccess(i); - - if (access != RT_ACCESS_CONST) - continue; - - fieldName = m_reader.getFieldName(i); - constValue = m_reader.getFieldConstValue(i); - - if (constValue.m_type == RT_TYPE_INT32) - value = constValue.m_value.aLong; - else - value++; - - /* doesn't work with rational rose 2000 - // write documentation - OString aDoc = m_reader.getFieldDoku(i); - if( aDoc.getLength() ) - */ - // o << "/**\n" << aDoc << "\n*/\n"; - o << indent() << fieldName; - if( i +1 < fieldCount ) - o << ",\n"; - } - - dec(); - o << "\n};\n\n"; - - dumpNameSpace(o, sal_False); - - o << "#endif /* "<< headerDefine << "*/" << "\n"; - - return sal_True; -} - - -//************************************************************************* -// TypeDefType -//************************************************************************* -TypeDefType::TypeDefType(TypeReader& typeReader, - const OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies) - : IdlType(typeReader, typeName, typeMgr, typeDependencies) -{ -} - -TypeDefType::~TypeDefType() -{ - -} - -sal_Bool TypeDefType::dumpHFile(FileStream& o) - throw( CannotDumpException ) -{ - OString headerDefine(dumpHeaderDefine(o, "IDL")); - o << "\n"; - - dumpDefaultHIncludes(o); - o << "\n"; - dumpDepIncludes(o, m_typeName, "idl"); - o << "\n"; - - dumpNameSpace(o); - - o << "\ntypedef "; - dumpType(o, m_reader.getSuperTypeName()); - o << " " << m_name << ";\n\n"; - - dumpNameSpace(o, sal_False); - - o << "#endif /* "<< headerDefine << "*/" << "\n"; - - return sal_True; -} - - -//************************************************************************* -// produceType -//************************************************************************* -sal_Bool produceType(const OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - IdlOptions* pOptions) - throw( CannotDumpException ) -{ - if (typeDependencies.isGenerated(typeName)) - return sal_True; - - TypeReader reader(typeMgr.getTypeReader(typeName)); - - if (!reader.isValid()) - { - if (typeName.equals("/")) - return sal_True; - else - return sal_False; - } - - if( !checkTypeDependencies(typeMgr, typeDependencies, typeName)) - return sal_False; - - RTTypeClass typeClass = reader.getTypeClass(); - sal_Bool ret = sal_False; - switch (typeClass) - { - case RT_TYPE_INTERFACE: - { - InterfaceType iType(reader, typeName, typeMgr, typeDependencies); - ret = iType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = iType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_MODULE: - { - ModuleType mType(reader, typeName, typeMgr, typeDependencies); - if (mType.hasConstants()) - { - ret = mType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); -// ret = mType.dumpDependedTypes(pOptions); - } else - { - typeDependencies.setGenerated(typeName); - ret = sal_True; - } - } - break; - case RT_TYPE_STRUCT: - { - StructureType sType(reader, typeName, typeMgr, typeDependencies); - ret = sType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = sType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_ENUM: - { - EnumType enType(reader, typeName, typeMgr, typeDependencies); - ret = enType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = enType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_EXCEPTION: - { - ExceptionType eType(reader, typeName, typeMgr, typeDependencies); - ret = eType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = eType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_TYPEDEF: - { - TypeDefType tdType(reader, typeName, typeMgr, typeDependencies); - ret = tdType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); - ret = tdType.dumpDependedTypes(pOptions); - } - break; - case RT_TYPE_CONSTANTS: - { - ConstantsType cType(reader, typeName, typeMgr, typeDependencies); - if (cType.hasConstants()) - { - ret = cType.dump(pOptions); - if (ret) typeDependencies.setGenerated(typeName); -// ret = cType.dumpDependedTypes(pOptions); - } else - { - typeDependencies.setGenerated(typeName); - ret = sal_True; - } - } - break; - case RT_TYPE_SERVICE: - case RT_TYPE_OBJECT: - ret = sal_True; - break; - } - - return ret; -} - -//************************************************************************* -// scopedName -//************************************************************************* -OString scopedName(const OString& scope, const OString& type, - sal_Bool bNoNameSpace) -{ - sal_Int32 nPos = type.lastIndexOf( '/' ); - if (nPos == -1) - return type; - - if (bNoNameSpace) - return type.copy(nPos+1); - - OStringBuffer tmpBuf(type.getLength()*2); - nPos = 0; - do - { - tmpBuf.append("::"); - tmpBuf.append(type.getToken(0, '/', nPos)); - } while( nPos != -1 ); - - return tmpBuf.makeStringAndClear(); -} - -//************************************************************************* -// shortScopedName -//************************************************************************* -OString scope(const OString& scope, const OString& type ) -{ - sal_Int32 nPos = type.lastIndexOf( '/' ); - if( nPos == -1 ) - return OString(); - - // scoped name only if the namespace is not equal - if (scope.lastIndexOf('/') > 0) - { - OString tmpScp(scope.copy(0, scope.lastIndexOf('/'))); - OString tmpScp2(type.copy(0, nPos)); - - if (tmpScp == tmpScp2) - return OString(); - } - - OString aScope( type.copy( 0, nPos ) ); - OStringBuffer tmpBuf(aScope.getLength()*2); - - nPos = 0; - do - { - tmpBuf.append("::"); - tmpBuf.append(aScope.getToken(0, '/', nPos)); - } while( nPos != -1 ); - - return tmpBuf.makeStringAndClear(); -} - - diff --git a/codemaker/source/idlmaker/idltype.hxx b/codemaker/source/idlmaker/idltype.hxx deleted file mode 100644 index 307ea4290edb..000000000000 --- a/codemaker/source/idlmaker/idltype.hxx +++ /dev/null @@ -1,249 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLTYPE_HXX -#define INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLTYPE_HXX - -#include <codemaker/typemanager.hxx> -#include <codemaker/dependency.hxx> - -enum BASETYPE -{ - BT_INVALID, - BT_VOID, - BT_ANY, - BT_TYPE, - BT_BOOLEAN, - BT_CHAR, - BT_STRING, - BT_FLOAT, - BT_DOUBLE, - BT_OCTET, - BT_BYTE, - BT_SHORT, - BT_LONG, - BT_HYPER, - BT_UNSIGNED_SHORT, - BT_UNSIGNED_LONG, - BT_UNSIGNED_HYPER -}; - - -enum IdlTypeDecl -{ - CPPUTYPEDECL_ALLTYPES, - CPPUTYPEDECL_NOINTERFACES, - CPPUTYPEDECL_ONLYINTERFACES -}; - -class IdlOptions; -class FileStream; - -class IdlType -{ -public: - IdlType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~IdlType(); - - virtual sal_Bool dump(IdlOptions* pOptions) throw( CannotDumpException ); - virtual sal_Bool dumpDependedTypes(IdlOptions* pOptions) throw( CannotDumpException ); - virtual sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ) = 0; - - virtual ::rtl::OString dumpHeaderDefine(FileStream& o, sal_Char* prefix ); - virtual void dumpDefaultHIncludes(FileStream& o); - virtual void dumpInclude(FileStream& o, const ::rtl::OString& genTypeName, const ::rtl::OString& typeName, sal_Char* prefix ); - - virtual void dumpDepIncludes(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix); - - virtual void dumpNameSpace(FileStream& o, sal_Bool bOpen = sal_True, sal_Bool bFull = sal_False, const ::rtl::OString& type=""); - - virtual void dumpType(FileStream& o, const ::rtl::OString& type) - throw( CannotDumpException ); - ::rtl::OString getBaseType(const ::rtl::OString& type); - void dumpIdlGetType(FileStream& o, const ::rtl::OString& type, sal_Bool bDecl=sal_False, IdlTypeDecl eDeclFlag=CPPUTYPEDECL_ALLTYPES); - BASETYPE isBaseType(const ::rtl::OString& type); - - void dumpConstantValue(FileStream& o, sal_uInt16 index); - - virtual sal_uInt32 getMemberCount(); - virtual sal_uInt32 getInheritedMemberCount(); - - void inc(sal_uInt32 num=4); - void dec(sal_uInt32 num=4); - ::rtl::OString indent(); - ::rtl::OString indent(sal_uInt32 num); -protected: - virtual sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); - - ::rtl::OString checkSpecialIdlType(const ::rtl::OString& type); - ::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False); - -protected: - sal_uInt32 m_inheritedMemberCount; - - sal_uInt32 m_indentLength; - ::rtl::OString m_typeName; - ::rtl::OString m_name; - TypeReader m_reader; - TypeManager& m_typeMgr; - TypeDependency m_dependencies; -}; - -class InterfaceType : public IdlType -{ -public: - InterfaceType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~InterfaceType(); - - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - - void dumpAttributes(FileStream& o); - void dumpMethods(FileStream& o); - - sal_uInt32 getMemberCount(); - sal_uInt32 getInheritedMemberCount(); - -protected: - sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); - -protected: - sal_uInt32 m_inheritedMemberCount; - sal_Bool m_hasAttributes; - sal_Bool m_hasMethods; -}; - -class ModuleType : public IdlType -{ -public: - ModuleType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~ModuleType(); - - virtual sal_Bool dump(IdlOptions* pOptions) throw( CannotDumpException ); - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - sal_Bool hasConstants(); -}; - -class ConstantsType : public ModuleType -{ -public: - ConstantsType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~ConstantsType(); - - virtual sal_Bool dump(IdlOptions* pOptions) throw( CannotDumpException ); -}; - -class StructureType : public IdlType -{ -public: - StructureType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~StructureType(); - - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - - void dumpSuperMember(FileStream& o, const ::rtl::OString& super); -}; - -class ExceptionType : public IdlType -{ -public: - ExceptionType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~ExceptionType(); - - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); - - void dumpSuperMember(FileStream& o, const ::rtl::OString& super); -}; - -class EnumType : public IdlType -{ -public: - EnumType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~EnumType(); - - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); -}; - -class TypeDefType : public IdlType -{ -public: - TypeDefType(TypeReader& typeReader, - const ::rtl::OString& typeName, - const TypeManager& typeMgr, - const TypeDependency& typeDependencies); - - virtual ~TypeDefType(); - - sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ); -}; - - -sal_Bool produceType(const ::rtl::OString& typeName, - TypeManager& typeMgr, - TypeDependency& typeDependencies, - IdlOptions* pOptions) - throw( CannotDumpException ); - -/** - * This function returns a C++ scoped name, represents the namespace - * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of - * the type is equal scope, the relativ name will be used. - */ -::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type, sal_Bool bNoNameSpace = sal_False ); - -::rtl::OString scope(const ::rtl::OString& scope, const ::rtl::OString& type ); - - -#endif // INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLTYPE_HXX - diff --git a/codemaker/source/idlmaker/makefile.mk b/codemaker/source/idlmaker/makefile.mk deleted file mode 100644 index cd447262e24d..000000000000 --- a/codemaker/source/idlmaker/makefile.mk +++ /dev/null @@ -1,62 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=codemaker -TARGET=idlmaker -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -CXXFILES= idlmaker.cxx \ - idloptions.cxx \ - idltype.cxx - - -APP1TARGET= $(TARGET) - -APP1OBJS= $(OBJ)$/idlmaker.obj \ - $(OBJ)$/idloptions.obj \ - $(OBJ)$/idltype.obj - -APP1STDLIBS= \ - $(SALLIB) \ - $(SALHELPERLIB) \ - $(REGLIB) \ - $(STDLIBCPP) - -APP1LIBS= \ - $(LB)$/codemaker.lib - -.INCLUDE : target.mk diff --git a/codemaker/source/javamaker/classfile.cxx b/codemaker/source/javamaker/classfile.cxx index 05c473256738..9ab2e4296228 100644 --- a/codemaker/source/javamaker/classfile.cxx +++ b/codemaker/source/javamaker/classfile.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -901,3 +902,5 @@ void ClassFile::appendSignatureAttribute( appendU2(stream, addUtf8Info(signature)); } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/classfile.hxx b/codemaker/source/javamaker/classfile.hxx index 6a0018ac38d0..974a827b0c81 100644 --- a/codemaker/source/javamaker/classfile.hxx +++ b/codemaker/source/javamaker/classfile.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -63,17 +64,11 @@ public: ~Code(); void instrAastore(); - void instrAconstNull(); - void instrAnewarray(rtl::OString const & type); - void instrAreturn(); - void instrAthrow(); - void instrCheckcast(rtl::OString const & type); - void instrDup(); void instrGetstatic( @@ -81,9 +76,7 @@ public: rtl::OString const & descriptor); Branch instrIfAcmpne(); - Branch instrIfeq(); - Branch instrIfnull(); void instrInstanceof(rtl::OString const & type); @@ -109,9 +102,7 @@ public: std::list< std::pair< sal_Int32, Code * > > const & blocks); void instrNew(rtl::OString const & type); - void instrNewarray(codemaker::UnoType::Sort sort); - void instrPop(); void instrPutfield( @@ -123,7 +114,6 @@ public: rtl::OString const & descriptor); void instrReturn(); - void instrSwap(); void instrTableswitch( @@ -131,21 +121,13 @@ public: std::list< Code * > const & blocks); void loadIntegerConstant(sal_Int32 value); - void loadStringConstant(rtl::OString const & value); - void loadLocalInteger(sal_uInt16 index); - void loadLocalLong(sal_uInt16 index); - void loadLocalFloat(sal_uInt16 index); - void loadLocalDouble(sal_uInt16 index); - void loadLocalReference(sal_uInt16 index); - void storeLocalReference(sal_uInt16 index); - void branchHere(Branch branch); void addException( @@ -187,11 +169,8 @@ public: Code * newCode(); sal_uInt16 addIntegerInfo(sal_Int32 value); - sal_uInt16 addFloatInfo(float value); - sal_uInt16 addLongInfo(sal_Int64 value); - sal_uInt16 addDoubleInfo(double value); void addInterface(rtl::OString const & interface); @@ -216,11 +195,8 @@ private: void operator =(ClassFile); // not implemented sal_uInt16 nextConstantPoolIndex(sal_uInt16 width); - sal_uInt16 addUtf8Info(rtl::OString const & value); - sal_uInt16 addClassInfo(rtl::OString const & type); - sal_uInt16 addStringInfo(rtl::OString const & value); sal_uInt16 addFieldrefInfo( @@ -272,3 +248,5 @@ private: } } #endif // INCLUDED_CODEMAKER_SOURCE_JAVAMAKER_CLASSFILE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/javamaker.cxx b/codemaker/source/javamaker/javamaker.cxx index b4e612d55823..4deeb727a4c0 100644 --- a/codemaker/source/javamaker/javamaker.cxx +++ b/codemaker/source/javamaker/javamaker.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -37,8 +38,8 @@ #include "javaoptions.hxx" #include "javatype.hxx" -using namespace rtl; - +using ::rtl::OUString; +using ::rtl::OString; sal_Bool produceAllTypes(RegistryKey& rTypeKey, sal_Bool bIsExtraType, TypeManager const & typeMgr, codemaker::GeneratedTypeSet & generated, @@ -245,3 +246,4 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/javaoptions.cxx b/codemaker/source/javamaker/javaoptions.cxx index 58235bd32616..e29280b211d2 100644 --- a/codemaker/source/javamaker/javaoptions.cxx +++ b/codemaker/source/javamaker/javaoptions.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,14 +34,16 @@ #include "osl/process.h" #include "osl/thread.h" +using ::rtl::OUString; +using ::rtl::OString; +using ::rtl::OUStringToOString; + #ifdef SAL_UNX #define SEPARATOR '/' #else #define SEPARATOR '\\' #endif -using namespace rtl; - sal_Bool JavaOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) throw( IllegalArgument ) { @@ -304,3 +307,5 @@ OString JavaOptions::prepareVersion() } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/javaoptions.hxx b/codemaker/source/javamaker/javaoptions.hxx index 8bcc04150370..e7f2f48b3960 100644 --- a/codemaker/source/javamaker/javaoptions.hxx +++ b/codemaker/source/javamaker/javaoptions.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,3 +50,5 @@ protected: }; #endif // INCLUDED_CODEMAKER_SOURCE_JAVAMAKER_JAVAOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx index 7820a419a205..4b99ef9f116b 100644 --- a/codemaker/source/javamaker/javatype.cxx +++ b/codemaker/source/javamaker/javatype.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -3372,3 +3373,5 @@ bool produceType( } return true; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/javatype.hxx b/codemaker/source/javamaker/javatype.hxx index fd08ee286fb6..e294aa6ab94f 100644 --- a/codemaker/source/javamaker/javatype.hxx +++ b/codemaker/source/javamaker/javatype.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,3 +44,5 @@ bool produceType(RegistryKey& typeName, bool bIsExtraType, TypeManager const & t JavaOptions* pOptions); #endif // INCLUDED_CODEMAKER_SOURCE_JAVAMAKER_JAVATYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/codemaker/source/javamaker/makefile.mk b/codemaker/source/javamaker/makefile.mk index 297f35bd0329..cf8a29858f53 100644 --- a/codemaker/source/javamaker/makefile.mk +++ b/codemaker/source/javamaker/makefile.mk @@ -37,6 +37,12 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk + +.IF "$(OS)" == "IOS" +all: + @echo No build-time tools for this platform +.ENDIF + .INCLUDE : $(PRJ)$/codemaker.pmk # --- Files -------------------------------------------------------- |