From 73d9da9960f1fd6ebe7b940a35f0e3749f632098 Mon Sep 17 00:00:00 2001 From: Daniel Boelzle Date: Wed, 31 Jul 2002 11:46:45 +0000 Subject: [PATCH] #101918# supporting -X option now --- codemaker/inc/codemaker/options.hxx | 10 +- codemaker/inc/codemaker/typemanager.hxx | 37 +++---- codemaker/source/codemaker/options.cxx | 18 +++- codemaker/source/codemaker/typemanager.cxx | 116 ++++++++------------- codemaker/source/cppumaker/cppumaker.cxx | 6 +- codemaker/source/cppumaker/cppuoptions.cxx | 33 +++++- codemaker/source/cppumaker/cpputype.cxx | 12 ++- codemaker/source/javamaker/javamaker.cxx | 6 +- codemaker/source/javamaker/javaoptions.cxx | 35 ++++++- codemaker/source/javamaker/javatype.cxx | 34 +++++- 10 files changed, 194 insertions(+), 113 deletions(-) diff --git a/codemaker/inc/codemaker/options.hxx b/codemaker/inc/codemaker/options.hxx index a8e7b1580a8f..d9fe4802832b 100644 --- a/codemaker/inc/codemaker/options.hxx +++ b/codemaker/inc/codemaker/options.hxx @@ -2,9 +2,9 @@ * * $RCSfile: options.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jsc $ $Date: 2001-03-13 12:04:21 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -131,9 +131,15 @@ public: const StringVector& getInputFiles(); + ::rtl::OString getExtraInputFile(sal_uInt16 index) const throw( IllegalArgument ); + inline sal_uInt16 getNumberOfExtraInputFiles() const + { return (sal_uInt16)m_extra_input_files.size(); } + inline const StringVector& getExtraInputFiles() const + { return m_extra_input_files; } protected: ::rtl::OString m_program; StringVector m_inputFiles; + StringVector m_extra_input_files; OptionMap m_options; }; diff --git a/codemaker/inc/codemaker/typemanager.hxx b/codemaker/inc/codemaker/typemanager.hxx index 481541dbd800..bd1c81615f56 100644 --- a/codemaker/inc/codemaker/typemanager.hxx +++ b/codemaker/inc/codemaker/typemanager.hxx @@ -2,9 +2,9 @@ * * $RCSfile: typemanager.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jsc $ $Date: 2001-03-13 12:04:21 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -121,17 +121,14 @@ public: return *this; } - virtual sal_Bool init(sal_Bool bMerge, const StringVector& regFiles) - { return sal_False; } - virtual sal_Bool init(const ::rtl::OString& registryName) - { return sal_False; } - virtual sal_Bool isValidType(const ::rtl::OString& name) { return sal_False; } - virtual RegistryKey getTypeKey(const ::rtl::OString& name) + virtual RegistryKey getTypeKey( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) { return RegistryKey(); } - virtual TypeReader getTypeReader(const ::rtl::OString& name) + virtual TypeReader getTypeReader( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) { return TypeReader(); } virtual RTTypeClass getTypeClass(const ::rtl::OString& name) { return RT_TYPE_INVALID; } @@ -153,16 +150,13 @@ protected: struct RegistryTypeManagerImpl { RegistryTypeManagerImpl() - : m_pMergedRegistry(NULL) - , m_isMerged(sal_False) - , m_base("/") + : m_base("/") {} T2TypeClassMap m_t2TypeClass; RegistryList m_registries; - Registry* m_pMergedRegistry; + RegistryList m_extra_registries; ::rtl::OString m_base; - sal_Bool m_isMerged; }; class RegistryTypeManager : public TypeManager @@ -186,13 +180,15 @@ public: return *this; } */ - sal_Bool init(sal_Bool bMerge, const StringVector& regFiles); + sal_Bool init(const StringVector& regFiles, const StringVector& extraFiles = StringVector() ); sal_Bool isValidType(const ::rtl::OString& name) - { return searchTypeKey(name).isValid(); } - RegistryKey getTypeKey(const ::rtl::OString& name) - { return searchTypeKey(name); } - TypeReader getTypeReader(const ::rtl::OString& name); + { return searchTypeKey(name, 0).isValid(); } + RegistryKey getTypeKey( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) + { return searchTypeKey(name, pIsExtraType); } + TypeReader getTypeReader( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ); RTTypeClass getTypeClass(const ::rtl::OString& name); void setBase(const ::rtl::OString& base); @@ -200,7 +196,8 @@ public: sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); } protected: - RegistryKey searchTypeKey(const ::rtl::OString& name); + RegistryKey searchTypeKey( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ); void freeRegistries(); void acquire(); diff --git a/codemaker/source/codemaker/options.cxx b/codemaker/source/codemaker/options.cxx index 0ef959c45e71..3633646e33f8 100644 --- a/codemaker/source/codemaker/options.cxx +++ b/codemaker/source/codemaker/options.cxx @@ -2,9 +2,9 @@ * * $RCSfile: options.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -136,3 +136,17 @@ const StringVector& Options::getInputFiles() return m_inputFiles; } +OString Options::getExtraInputFile(sal_uInt16 index) const + throw( IllegalArgument ) +{ + if (index < m_extra_input_files.size()) + { + return m_extra_input_files[index]; + } else + { + throw IllegalArgument("index is out of bound."); + } + + return OString(); +} + diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx index 353845a9255b..b3bbb70174d6 100644 --- a/codemaker/source/codemaker/typemanager.cxx +++ b/codemaker/source/codemaker/typemanager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: typemanager.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jsc $ $Date: 2001-08-17 13:15:48 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -157,29 +157,16 @@ void RegistryTypeManager::release() { if (0 == TypeManager::release()) { - if (m_pImpl->m_pMergedRegistry) - { - if (m_pImpl->m_pMergedRegistry->isValid()) - { - m_pImpl->m_pMergedRegistry->destroy(OUString()); - } - - delete m_pImpl->m_pMergedRegistry; - } - - if (m_pImpl->m_registries.size() > 0) - { - freeRegistries(); - } + freeRegistries(); delete m_pImpl; } } -sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFiles) +sal_Bool RegistryTypeManager::init( + const StringVector& regFiles, + StringVector const & extraFiles ) { - m_pImpl->m_isMerged = bMerged && (regFiles.size() > 1); - if (regFiles.empty()) return sal_False; @@ -198,53 +185,27 @@ sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFile } ++iter; } - - if (m_pImpl->m_isMerged) + iter = extraFiles.begin(); + while (iter != extraFiles.end()) { - Registry *pTmpReg = new Registry(loader); - OString tmpName(makeTempName(NULL)); - - if (!pTmpReg->create( convertToFileUrl(tmpName) ) ) + if (!tmpReg.open( convertToFileUrl(*iter), REG_READONLY)) + m_pImpl->m_extra_registries.push_back(new Registry(tmpReg)); + else { - RegistryKey rootKey; - RegError ret = REG_NO_ERROR; - OUString aRoot( RTL_CONSTASCII_USTRINGPARAM("/") ); - iter = regFiles.begin(); - pTmpReg->openRootKey(rootKey); - - while (iter != regFiles.end()) - { - if ( ret = pTmpReg->mergeKey(rootKey, aRoot, convertToFileUrl( *iter )) ) - { - if (ret != REG_MERGE_CONFLICT) - { - freeRegistries(); - rootKey.closeKey(); - pTmpReg->destroy( OUString() ); - delete pTmpReg; - return sal_False; - } - } - iter++; - } - - m_pImpl->m_pMergedRegistry = pTmpReg; - freeRegistries(); - } else - { - delete pTmpReg; freeRegistries(); return sal_False; } + ++iter; } return sal_True; } -TypeReader RegistryTypeManager::getTypeReader(const OString& name) +TypeReader RegistryTypeManager::getTypeReader( + const OString& name, sal_Bool * pIsExtraType ) { TypeReader reader; - RegistryKey key(searchTypeKey(name)); + RegistryKey key(searchTypeKey(name, pIsExtraType)); if (key.isValid()) { @@ -317,38 +278,51 @@ void RegistryTypeManager::setBase(const OString& base) void RegistryTypeManager::freeRegistries() { RegistryList::const_iterator iter = m_pImpl->m_registries.begin(); - while (iter != m_pImpl->m_registries.end()) { delete *iter; ++iter; } - + iter = m_pImpl->m_extra_registries.begin(); + while (iter != m_pImpl->m_extra_registries.end()) + { + delete *iter; + ++iter; + } } -RegistryKey RegistryTypeManager::searchTypeKey(const OString& name) +RegistryKey RegistryTypeManager::searchTypeKey(const OString& name_, sal_Bool * pIsExtraType ) { + OUString name( OStringToOUString(m_pImpl->m_base + name_, RTL_TEXTENCODING_UTF8) ); RegistryKey key, rootKey; - if (m_pImpl->m_isMerged) + RegistryList::const_iterator iter = m_pImpl->m_registries.begin(); + while (iter != m_pImpl->m_registries.end()) { - if (!m_pImpl->m_pMergedRegistry->openRootKey(rootKey)) + if (!(*iter)->openRootKey(rootKey)) { - rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key); - } - } else - { - RegistryList::const_iterator iter = m_pImpl->m_registries.begin(); - - while (iter != m_pImpl->m_registries.end()) - { - if (!(*iter)->openRootKey(rootKey)) + if (!rootKey.openKey(name, key)) { - if (!rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key)) - break; + if (pIsExtraType) + *pIsExtraType = sal_False; + return key; } - ++iter; } + ++iter; + } + iter = m_pImpl->m_extra_registries.begin(); + while (iter != m_pImpl->m_extra_registries.end()) + { + if (!(*iter)->openRootKey(rootKey)) + { + if (!rootKey.openKey(name, key)) + { + if (pIsExtraType) + *pIsExtraType = sal_True; + break; + } + } + ++iter; } return key; diff --git a/codemaker/source/cppumaker/cppumaker.cxx b/codemaker/source/cppumaker/cppumaker.cxx index be8365d9a150..111feb8356b6 100644 --- a/codemaker/source/cppumaker/cppumaker.cxx +++ b/codemaker/source/cppumaker/cppumaker.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cppumaker.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pl $ $Date: 2001-05-10 14:16:40 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -142,7 +142,7 @@ int _cdecl main( int argc, char * argv[] ) RegistryTypeManager typeMgr; TypeDependency typeDependencies; - if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles())) + if (!typeMgr.init(options.getInputFiles(), options.getExtraInputFiles())) { fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr()); exit(99); diff --git a/codemaker/source/cppumaker/cppuoptions.cxx b/codemaker/source/cppumaker/cppuoptions.cxx index 481c48805349..ec9ab831306d 100644 --- a/codemaker/source/cppumaker/cppuoptions.cxx +++ b/codemaker/source/cppumaker/cppuoptions.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cppuoptions.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: hr $ $Date: 2002-02-21 11:35:11 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -265,6 +265,34 @@ sal_Bool CppuOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) m_options["-G"] = OString(""); break; + + case 'X': // support for eXtra type rdbs + { + if (av[i][2] == '\0') + { + if (i < ac - 1 && av[i+1][0] != '-') + { + i++; + s = av[i]; + } else + { + OString tmp("'-X', please check"); + if (i <= ac - 1) + { + tmp += " your input '" + OString(av[i+1]) + "'"; + } + + throw IllegalArgument(tmp); + } + } else + { + s = av[i] + 2; + } + + m_extra_input_files.push_back( s ); + break; + } + default: throw IllegalArgument("the option is unknown" + OString(av[i])); break; @@ -324,6 +352,7 @@ OString CppuOptions::prepareHelp() help += " -C = getCppuType 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 += " -X = extra types which will not be taken into account for generation.\n"; help += prepareVersion(); return help; diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index 73b18a471eea..084be04eaad0 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cpputype.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: jsc $ $Date: 2002-06-18 17:26:56 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -3972,7 +3972,13 @@ sal_Bool produceType(const OString& typeName, if (typeDependencies.isGenerated(typeName)) return sal_True; - TypeReader reader(typeMgr.getTypeReader(typeName)); + sal_Bool bIsExtraType = sal_False; + TypeReader reader(typeMgr.getTypeReader(typeName, &bIsExtraType)); + if (bIsExtraType) + { + typeDependencies.setGenerated(typeName); + return sal_True; + } if (!reader.isValid()) { diff --git a/codemaker/source/javamaker/javamaker.cxx b/codemaker/source/javamaker/javamaker.cxx index 73f03d1c25bc..0e83402e50ca 100644 --- a/codemaker/source/javamaker/javamaker.cxx +++ b/codemaker/source/javamaker/javamaker.cxx @@ -2,9 +2,9 @@ * * $RCSfile: javamaker.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pl $ $Date: 2001-05-10 14:16:41 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -142,7 +142,7 @@ int _cdecl main( int argc, char * argv[] ) RegistryTypeManager typeMgr; TypeDependency typeDependencies; - if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles())) + if (!typeMgr.init(options.getInputFiles(), options.getExtraInputFiles())) { fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr()); exit(99); diff --git a/codemaker/source/javamaker/javaoptions.cxx b/codemaker/source/javamaker/javaoptions.cxx index b0b6b92a482a..0f045b88136d 100644 --- a/codemaker/source/javamaker/javaoptions.cxx +++ b/codemaker/source/javamaker/javaoptions.cxx @@ -2,9 +2,9 @@ * * $RCSfile: javaoptions.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2002-02-21 11:41:39 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -186,6 +186,34 @@ sal_Bool JavaOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) m_options["-T"] = OString(s); } break; + + case 'X': // support for eXtra type rdbs + { + if (av[i][2] == '\0') + { + if (i < ac - 1 && av[i+1][0] != '-') + { + i++; + s = av[i]; + } else + { + OString tmp("'-X', please check"); + if (i <= ac - 1) + { + tmp += " your input '" + OString(av[i+1]) + "'"; + } + + throw IllegalArgument(tmp); + } + } else + { + s = av[i] + 2; + } + + m_extra_input_files.push_back( s ); + break; + } + default: throw IllegalArgument("the option is unknown" + OString(av[i])); break; @@ -232,7 +260,7 @@ sal_Bool JavaOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile) OString JavaOptions::prepareHelp() { OString help("\nusing: "); - help += m_program + " [-options] file_1 ... file_n\nOptions:\n"; + help += m_program + " [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2\nOptions:\n"; help += " -O = path describes the root directory for the generated output.\n"; help += " The output directory tree is generated under this directory.\n"; help += " -T = name specifies a type or a list of types. The output for this\n"; @@ -242,6 +270,7 @@ OString JavaOptions::prepareHelp() help += " -B = name specifies the base node. All types are searched under this\n"; help += " node. Default is the root '/' of the registry files.\n"; help += " -nD = no dependent types are generated.\n"; + help += " -X = extra types which will not be taken into account for generation.\n"; help += prepareVersion(); return help; diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx index 4457eb6cf20c..ae98ec3e85cc 100644 --- a/codemaker/source/javamaker/javatype.cxx +++ b/codemaker/source/javamaker/javatype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: javatype.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: jsc $ $Date: 2002-06-25 08:56:49 $ + * last change: $Author: dbo $ $Date: 2002-07-31 12:46:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1895,7 +1895,33 @@ sal_Bool produceType(const OString& typeName, if (typeDependencies.isGenerated(typeName)) return sal_True; - RegistryKey typeKey = typeMgr.getTypeKey(typeName); + sal_Bool bIsExtraType = sal_False; + TypeReader reader(typeMgr.getTypeReader(typeName, &bIsExtraType)); + if (bIsExtraType) + { + typeDependencies.setGenerated(typeName); + return sal_True; + } + + if (!reader.isValid()) + { + if (typeName.equals("/")) + return sal_True; + else + return sal_False; + } + + if( !checkTypeDependencies(typeMgr, typeDependencies, typeName)) + return sal_False; + +/* + sal_Bool bIsExtraType = sal_False; + RegistryKey typeKey = typeMgr.getTypeKey(typeName, &bIsExtraType); + if (bIsExtraType) + { + typeDependencies.setGenerated(typeName); + return sal_True; + } if (!typeKey.isValid()) return sal_False; @@ -1926,7 +1952,7 @@ sal_Bool produceType(const OString& typeName, TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_True); rtl_freeMemory(pBuffer); - +*/ RTTypeClass typeClass = reader.getTypeClass(); sal_Bool ret = sal_False; switch (typeClass)