diff options
Diffstat (limited to 'codemaker/inc/codemaker')
-rw-r--r-- | codemaker/inc/codemaker/codemaker.hxx | 56 | ||||
-rw-r--r-- | codemaker/inc/codemaker/commoncpp.hxx | 57 | ||||
-rw-r--r-- | codemaker/inc/codemaker/commonjava.hxx | 44 | ||||
-rw-r--r-- | codemaker/inc/codemaker/dependencies.hxx | 149 | ||||
-rw-r--r-- | codemaker/inc/codemaker/exceptiontree.hxx | 124 | ||||
-rw-r--r-- | codemaker/inc/codemaker/generatedtypeset.hxx | 79 | ||||
-rw-r--r-- | codemaker/inc/codemaker/global.hxx | 151 | ||||
-rw-r--r-- | codemaker/inc/codemaker/options.hxx | 98 | ||||
-rw-r--r-- | codemaker/inc/codemaker/typemanager.hxx | 182 | ||||
-rw-r--r-- | codemaker/inc/codemaker/unotype.hxx | 110 |
10 files changed, 1050 insertions, 0 deletions
diff --git a/codemaker/inc/codemaker/codemaker.hxx b/codemaker/inc/codemaker/codemaker.hxx new file mode 100644 index 000000000000..fee56c307b11 --- /dev/null +++ b/codemaker/inc/codemaker/codemaker.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * + * 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_CODEMAKER_HXX +#define INCLUDED_CODEMAKER_CODEMAKER_HXX + +#include "sal/config.h" +#include "codemaker/unotype.hxx" +#include "registry/types.h" +#include "sal/types.h" + +#include <vector> + +namespace rtl { + class OString; + class OUString; +} +class TypeManager; + +namespace codemaker { + +rtl::OString convertString(rtl::OUString const & string); + +codemaker::UnoType::Sort decomposeAndResolve( + TypeManager const & manager, rtl::OString const & type, + bool resolveTypedefs, bool allowVoid, bool allowExtraEntities, + RTTypeClass * typeClass, rtl::OString * name, sal_Int32 * rank, + std::vector< rtl::OString > * arguments); + +} + +#endif // INCLUDED_CODEMAKER_CODEMAKER_HXX diff --git a/codemaker/inc/codemaker/commoncpp.hxx b/codemaker/inc/codemaker/commoncpp.hxx new file mode 100644 index 000000000000..241336775d2b --- /dev/null +++ b/codemaker/inc/codemaker/commoncpp.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * 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_COMMONCPP_HXX +#define INCLUDED_CODEMAKER_COMMONCPP_HXX + +#include "codemaker/codemaker.hxx" + +namespace codemaker { namespace cpp { + +rtl::OString typeToPrefix(TypeManager const & manager, rtl::OString const & type); + +rtl::OString scopedCppName(rtl::OString const & type, bool bNoNameSpace=false, + bool shortname=false); + +rtl::OString translateUnoToCppType( + codemaker::UnoType::Sort sort, RTTypeClass typeClass, + rtl::OString const & nucleus, bool shortname); + +enum IdentifierTranslationMode { + ITM_GLOBAL, + ITM_NONGLOBAL, + ITM_KEYWORDSONLY +}; + +rtl::OString translateUnoToCppIdentifier( + rtl::OString const & identifier, rtl::OString const & prefix, + IdentifierTranslationMode transmode = ITM_GLOBAL, + rtl::OString const * forbidden = 0); + +} } + +#endif // INCLUDED_CODEMAKER_COMMONCPP_HXX diff --git a/codemaker/inc/codemaker/commonjava.hxx b/codemaker/inc/codemaker/commonjava.hxx new file mode 100644 index 000000000000..ae5c8b18fc3b --- /dev/null +++ b/codemaker/inc/codemaker/commonjava.hxx @@ -0,0 +1,44 @@ +/************************************************************************* + * + * 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_COMMONJAVA_HXX +#define INCLUDED_CODEMAKER_COMMONJAVA_HXX + +#include "codemaker/codemaker.hxx" + +namespace codemaker { namespace java { + +rtl::OString translateUnoToJavaType( + codemaker::UnoType::Sort sort, RTTypeClass typeClass, + rtl::OString const & nucleus, bool referenceType); + +rtl::OString translateUnoToJavaIdentifier( + rtl::OString const & identifier, rtl::OString const & prefix); + +} } + +#endif // INCLUDED_CODEMAKER_COMMONJAVA_HXX diff --git a/codemaker/inc/codemaker/dependencies.hxx b/codemaker/inc/codemaker/dependencies.hxx new file mode 100644 index 000000000000..66aad808a130 --- /dev/null +++ b/codemaker/inc/codemaker/dependencies.hxx @@ -0,0 +1,149 @@ +/************************************************************************* + * + * 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_DEPENDENCIES_HXX +#define INCLUDED_CODEMAKER_DEPENDENCIES_HXX + +#include "rtl/string.hxx" + +#include <hash_map> + +namespace rtl { class OUString; } +class TypeManager; + +/// @HTML + +namespace codemaker { + +/** + A simple class to track which other types a given type depends on. + + <p>This class is not multi-thread–safe.</p> + */ +class Dependencies { +public: + /** + Flags to distinguish whether or not one type depends on another type + because the second is a direct base of the first. + */ + enum Kind { KIND_NO_BASE, KIND_BASE }; + + typedef std::hash_map< rtl::OString, Kind, rtl::OStringHash > Map; + + /** + Constructs the dependencies for a given type. + + <p>If the given type is not successfully available at the given type + manager, <code>isValid()</code> will return <code>false</code>.</p> + + @param manager a type manager, to obtain information about the given type + + @param type the UNO type registry name of an enum type, plain struct + type, polymorphic struct type template, exception type, interface type, + typedef, module, constant group, service, or singleton + */ + Dependencies(TypeManager const & manager, rtl::OString const & type); + + ~Dependencies(); + + /** + Add a special dependency (which is not obvious from the type's data + available at the type manager). + + @param type a UNO type registry name + */ + void add(rtl::OString const & type) { insert(type, false); } + + bool isValid() const { return m_valid; } + + Map const & getMap() const { return m_map; } + + bool hasVoidDependency() const { return m_voidDependency; } + + bool hasBooleanDependency() const { return m_booleanDependency; } + + bool hasByteDependency() const { return m_byteDependency; } + + bool hasShortDependency() const { return m_shortDependency; } + + bool hasUnsignedShortDependency() const + { return m_unsignedShortDependency; } + + bool hasLongDependency() const { return m_longDependency; } + + bool hasUnsignedLongDependency() const { return m_unsignedLongDependency; } + + bool hasHyperDependency() const { return m_hyperDependency; } + + bool hasUnsignedHyperDependency() const + { return m_unsignedHyperDependency; } + + bool hasFloatDependency() const { return m_floatDependency; } + + bool hasDoubleDependency() const { return m_doubleDependency; } + + bool hasCharDependency() const { return m_charDependency; } + + bool hasStringDependency() const { return m_stringDependency; } + + bool hasTypeDependency() const { return m_typeDependency; } + + bool hasAnyDependency() const { return m_anyDependency; } + + bool hasSequenceDependency() const { return m_sequenceDependency; } + +private: + Dependencies(Dependencies &); // not implemented + void operator =(Dependencies); // not implemented + + void insert(rtl::OUString const & type, bool base); + + void insert(rtl::OString const & type, bool base); + + Map m_map; + bool m_valid; + bool m_voidDependency; + bool m_booleanDependency; + bool m_byteDependency; + bool m_shortDependency; + bool m_unsignedShortDependency; + bool m_longDependency; + bool m_unsignedLongDependency; + bool m_hyperDependency; + bool m_unsignedHyperDependency; + bool m_floatDependency; + bool m_doubleDependency; + bool m_charDependency; + bool m_stringDependency; + bool m_typeDependency; + bool m_anyDependency; + bool m_sequenceDependency; +}; + +} + +#endif // INCLUDED_CODEMAKER_DEPENDENCIES_HXX diff --git a/codemaker/inc/codemaker/exceptiontree.hxx b/codemaker/inc/codemaker/exceptiontree.hxx new file mode 100644 index 000000000000..7a8e1bb837c2 --- /dev/null +++ b/codemaker/inc/codemaker/exceptiontree.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * 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_EXCEPTIONTREE_HXX +#define INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX + +#include "codemaker/global.hxx" +#include "rtl/string.hxx" + +#include <vector> + +class TypeManager; + +namespace codemaker { + +/** + Represents a node of the hierarchy from the ExceptionTree class. + */ +struct ExceptionTreeNode { + typedef std::vector< ExceptionTreeNode * > Children; + + // Internally used by ExceptionTree: + ExceptionTreeNode(rtl::OString const & theName): + name(theName), present(false) {} + + // Internally used by ExceptionTree: + ~ExceptionTreeNode() { clearChildren(); } + + // Internally used by ExceptionTree: + void setPresent() { present = true; clearChildren(); } + + // Internally used by ExceptionTree: + ExceptionTreeNode * add(rtl::OString const & theName); + + rtl::OString name; + bool present; + Children children; + +private: + ExceptionTreeNode(ExceptionTreeNode &); // not implemented + void operator =(ExceptionTreeNode); // not implemented + + void clearChildren(); +}; + +/** + Represents the hierarchy formed by a set of UNO exception types. + + The hierarchy is rooted at com.sun.star.uno.Exception. For each exception E + from the given set S, the hierarchy from com.sun.star.uno.Exception to the + first supertype E' of E which is itself a member of S is represented (i.e., + subtypes that are hidden by supertypes are pruned from the hierarchy). The + exception com.sun.star.uno.RuntimeException and its subtypes are pruned + completely from the hierarchy. Each node of the hierarchy is represented by + an instance of ExceptionTreeNode, where name gives the slashified name of + the UNO exception type, present is true iff the given exception type is a + member of the set S, and children contains all the relevant direct subtypes + of the given exception type, in no particular order (for nodes other than the + root node it holds that children is non-empty iff present is false). + */ +class ExceptionTree { +public: + ExceptionTree(): m_root("com/sun/star/uno/Exception") {} + + ~ExceptionTree() {} + + /** + Builds the exception hierarchy, by adding one exception type at a time. + + This function can be called more than once for the same exception name. + + @param name the name of a UNO exception type, in slashified form; it is + an error if the given name does not represent a UNO exception type + + @param manager a type manager, used to resolve type names; it is an error + if different calls to this member function use different, incompatible + type managers + */ + void add(rtl::OString const & name, TypeManager const & manager) + throw( CannotDumpException ); + + /** + Gives access to the resultant exception hierarchy. + + @return a non-null pointer to the root of the exception hierarchy, as + formed by all previous calls to add; it is an error if any calls to add + follow the first call to getRoot + */ + ExceptionTreeNode const * getRoot() const { return &m_root; } + +private: + ExceptionTree(ExceptionTree &); // not implemented + void operator =(ExceptionTree); // not implemented + + ExceptionTreeNode m_root; +}; + +} + +#endif diff --git a/codemaker/inc/codemaker/generatedtypeset.hxx b/codemaker/inc/codemaker/generatedtypeset.hxx new file mode 100644 index 000000000000..c5a481893b14 --- /dev/null +++ b/codemaker/inc/codemaker/generatedtypeset.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * 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_GENERATEDTYPESET_HXX +#define INCLUDED_CODEMAKER_GENERATEDTYPESET_HXX + +#include "rtl/string.hxx" + +#include <hash_set> + +/// @HTML + +namespace codemaker { + +/** + A simple class to track which types have already been processed by a code + maker. + + <p>This class is not multi-thread–safe.</p> + */ +class GeneratedTypeSet { +public: + GeneratedTypeSet() {} + + ~GeneratedTypeSet() {} + + /** + Add a type to the set of generated types. + + <p>If the type was already present, nothing happens.</p> + + @param type a UNO type registry name + */ + void add(rtl::OString const & type) { m_set.insert(type); } + + /** + Checks whether a given type has already been generated. + + @param type a UNO type registry name + + @return true iff the given type has already been generated + */ + bool contains(rtl::OString const & type) const + { return m_set.find(type) != m_set.end(); } + +private: + GeneratedTypeSet(GeneratedTypeSet &); // not implemented + void operator =(GeneratedTypeSet); // not implemented + + std::hash_set< rtl::OString, rtl::OStringHash > m_set; +}; + +} + +#endif // INCLUDED_CODEMAKER_GENERATEDTYPESET_HXX diff --git a/codemaker/inc/codemaker/global.hxx b/codemaker/inc/codemaker/global.hxx new file mode 100644 index 000000000000..b1919d041daf --- /dev/null +++ b/codemaker/inc/codemaker/global.hxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * 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_GLOBAL_HXX +#define INCLUDED_CODEMAKER_GLOBAL_HXX + +#include <list> +#include <vector> +#include <set> + +#include <stdio.h> + +#include "osl/file.hxx" +#include "rtl/ustring.hxx" +#include "rtl/strbuf.hxx" + +struct EqualString +{ + sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const + { + return (str1 == str2); + } +}; + +struct HashString +{ + size_t operator()(const ::rtl::OString& str) const + { + return str.hashCode(); + } +}; + +struct LessString +{ + sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const + { + return (str1 < str2); + } +}; + +#if defined(_MSC_VER) && _MSC_VER < 1200 +typedef ::std::new_alloc NewAlloc; +#endif + + +typedef ::std::list< ::rtl::OString > StringList; +typedef ::std::vector< ::rtl::OString > StringVector; +typedef ::std::set< ::rtl::OString, LessString > StringSet; + +//************************************************************************* +// FileStream +//************************************************************************* +enum FileAccessMode +{ + FAM_READ, // "r" + FAM_WRITE, // "w" + FAM_READWRITE_EXIST, // "r+" + FAM_READWRITE // "w+" +}; + +class FileStream +{ +public: + FileStream(); + FileStream(const ::rtl::OString& name, FileAccessMode nMode = FAM_READWRITE); + virtual ~FileStream(); + + sal_Bool isValid(); + + void open(const ::rtl::OString& name, FileAccessMode nMode = FAM_READWRITE); + void createTempFile(const ::rtl::OString& sPath); + void close(); + + ::rtl::OString getName() { return m_name; } + + bool write(void const * buffer, sal_uInt64 size); + + // friend functions + friend FileStream &operator<<(FileStream& o, sal_uInt32 i); + friend FileStream &operator<<(FileStream& o, char const * s); + friend FileStream &operator<<(FileStream& o, ::rtl::OString* s); + friend FileStream &operator<<(FileStream& o, const ::rtl::OString& s); + friend FileStream &operator<<(FileStream& o, ::rtl::OStringBuffer* s); + friend FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s); + +private: + sal_uInt32 checkAccessMode(FileAccessMode mode); + + oslFileHandle m_file; + ::rtl::OString m_name; +}; + + +//************************************************************************* +// Helper functions +//************************************************************************* +::rtl::OString getTempDir(const ::rtl::OString& sFileName); + +::rtl::OString createFileNameFromType(const ::rtl::OString& destination, + const ::rtl::OString type, + const ::rtl::OString postfix, + sal_Bool bLowerCase=sal_False, + const ::rtl::OString prefix=""); + +sal_Bool fileExists(const ::rtl::OString& fileName); +sal_Bool makeValidTypeFile(const ::rtl::OString& targetFileName, + const ::rtl::OString& tmpFileName, + sal_Bool bFileCheck); +sal_Bool removeTypeFile(const ::rtl::OString& fileName); + +::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName); + +//************************************************************************* +// Global exception to signal problems when a type cannot be dumped +//************************************************************************* +class CannotDumpException +{ +public: + CannotDumpException(const ::rtl::OString& msg) + : m_message(msg) {} + + ::rtl::OString m_message; +}; + + +#endif // INCLUDED_CODEMAKER_GLOBAL_HXX + diff --git a/codemaker/inc/codemaker/options.hxx b/codemaker/inc/codemaker/options.hxx new file mode 100644 index 000000000000..5f440744cc2a --- /dev/null +++ b/codemaker/inc/codemaker/options.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * 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_OPTIONS_HXX +#define INCLUDED_CODEMAKER_OPTIONS_HXX + +#include <hash_map> + +#include <codemaker/global.hxx> + +#if defined( _MSC_VER ) && ( _MSC_VER < 1200 ) +typedef ::std::__hash_map__ +< + ::rtl::OString, + ::rtl::OString, + HashString, + EqualString, + NewAlloc +> OptionMap; +#else +typedef ::std::hash_map +< + ::rtl::OString, + ::rtl::OString, + HashString, + EqualString +> OptionMap; +#endif + +class IllegalArgument +{ +public: + IllegalArgument(const ::rtl::OString& msg) + : m_message(msg) {} + + ::rtl::OString m_message; +}; + +class Options +{ +public: + Options(); + virtual ~Options(); + + virtual sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) + throw( IllegalArgument ) = 0; + + virtual ::rtl::OString prepareHelp() = 0; + + const ::rtl::OString& getProgramName() const; + sal_Bool isValid(const ::rtl::OString& option); + const ::rtl::OString getOption(const ::rtl::OString& option) + throw( IllegalArgument ); + const OptionMap& getOptions(); + + const ::rtl::OString getInputFile(sal_uInt16 index) + throw( IllegalArgument ); + + 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; +}; + +#endif // INCLUDED_CODEMAKER_OPTIONS_HXX + diff --git a/codemaker/inc/codemaker/typemanager.hxx b/codemaker/inc/codemaker/typemanager.hxx new file mode 100644 index 000000000000..dacb97b1214b --- /dev/null +++ b/codemaker/inc/codemaker/typemanager.hxx @@ -0,0 +1,182 @@ +/************************************************************************* + * + * 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_TYPEMANAGER_HXX +#define INCLUDED_CODEMAKER_TYPEMANAGER_HXX + +#include "codemaker/global.hxx" +#include "registry/registry.hxx" +#include "registry/types.h" + +#include <hash_map> +#include <list> + +namespace typereg { class Reader; } + +//typedef ::std::list< Registry* > RegistryList; +typedef ::std::vector< Registry* > RegistryList; +typedef ::std::pair< RegistryKey, sal_Bool > KeyPair; +typedef ::std::vector< KeyPair > RegistryKeyList; + +#if defined( _MSC_VER ) && ( _MSC_VER < 1200 ) +typedef ::std::__hash_map__ +< + ::rtl::OString, // Typename + RTTypeClass, // TypeClass + HashString, + EqualString, + NewAlloc +> T2TypeClassMap; +#else +typedef ::std::hash_map +< + ::rtl::OString, // Typename + RTTypeClass, // TypeClass + HashString, + EqualString +> T2TypeClassMap; +#endif + +struct TypeManagerImpl +{ + TypeManagerImpl() + : m_refCount(0) + {} + + sal_Int32 m_refCount; +}; + +class TypeManager +{ +public: + TypeManager(); + virtual ~TypeManager(); + + TypeManager( const TypeManager& value ) + : m_pImpl( value.m_pImpl ) + { + acquire(); + } + + TypeManager& operator = ( const TypeManager& value ) + { + release(); + m_pImpl = value.m_pImpl; + acquire(); + return *this; + } + + virtual sal_Bool isValidType(const ::rtl::OString&) const + { return sal_False; } + + virtual ::rtl::OString getTypeName(RegistryKey&) const + { return ::rtl::OString(); } + + virtual RegistryKey getTypeKey(const ::rtl::OString&, sal_Bool * = 0 ) const + { return RegistryKey(); } + virtual RegistryKeyList getTypeKeys(const ::rtl::OString&) const + { return RegistryKeyList(); } + virtual typereg::Reader getTypeReader( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) const = 0; + virtual typereg::Reader getTypeReader(RegistryKey& rTypeKey) const = 0; + virtual RTTypeClass getTypeClass(const ::rtl::OString&) const + { return RT_TYPE_INVALID; } + virtual RTTypeClass getTypeClass(RegistryKey&) const + { return RT_TYPE_INVALID; } + + virtual void setBase(const ::rtl::OString&) {} + virtual ::rtl::OString getBase() const { return ::rtl::OString(); } + + virtual sal_Int32 getSize() const { return 0; } + + static sal_Bool isBaseType(const ::rtl::OString& name); +protected: + sal_Int32 acquire(); + sal_Int32 release(); + +protected: + TypeManagerImpl* m_pImpl; +}; + +struct RegistryTypeManagerImpl +{ + RegistryTypeManagerImpl() + : m_base("/") + {} + + T2TypeClassMap m_t2TypeClass; + RegistryList m_registries; + RegistryList m_extra_registries; + ::rtl::OString m_base; +}; + +class RegistryTypeManager : public TypeManager +{ +public: + RegistryTypeManager(); + virtual ~RegistryTypeManager(); + + RegistryTypeManager( const RegistryTypeManager& value ) + : TypeManager(value) + , m_pImpl( value.m_pImpl ) + { + acquire(); + } + + sal_Bool init(const StringVector& regFiles, const StringVector& extraFiles = StringVector() ); + + ::rtl::OString getTypeName(RegistryKey& rTypeKey) const; + + sal_Bool isValidType(const ::rtl::OString& name) const + { return searchTypeKey(name, 0).isValid(); } + RegistryKey getTypeKey( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) const + { return searchTypeKey(name, pIsExtraType); } + RegistryKeyList getTypeKeys(const ::rtl::OString& name) const; + typereg::Reader getTypeReader( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) const; + typereg::Reader getTypeReader(RegistryKey& rTypeKey) const; + RTTypeClass getTypeClass(const ::rtl::OString& name) const; + RTTypeClass getTypeClass(RegistryKey& rTypeKey) const; + + void setBase(const ::rtl::OString& base); + ::rtl::OString getBase() const { return m_pImpl->m_base; } + + sal_Int32 getSize() const { return m_pImpl->m_t2TypeClass.size(); } +protected: + RegistryKey searchTypeKey( + const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) const; + void freeRegistries(); + + void acquire(); + void release(); + +protected: + RegistryTypeManagerImpl* m_pImpl; +}; + +#endif // INCLUDED_CODEMAKER_TYPEMANAGER_HXX diff --git a/codemaker/inc/codemaker/unotype.hxx b/codemaker/inc/codemaker/unotype.hxx new file mode 100644 index 000000000000..24a3d7adcba1 --- /dev/null +++ b/codemaker/inc/codemaker/unotype.hxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * 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_UNOTYPE_HXX +#define INCLUDED_CODEMAKER_UNOTYPE_HXX + +#include "sal/types.h" + +#include <vector> + +namespace rtl { class OString; } + +namespace codemaker { + +namespace UnoType { + /** + An enumeration of all the sorts of UNO types. + + All complex UNO types are subsumed under SORT_COMPLEX. + */ + enum Sort { + SORT_VOID, + SORT_BOOLEAN, + SORT_BYTE, + SORT_SHORT, + SORT_UNSIGNED_SHORT, + SORT_LONG, + SORT_UNSIGNED_LONG, + SORT_HYPER, + SORT_UNSIGNED_HYPER, + SORT_FLOAT, + SORT_DOUBLE, + SORT_CHAR, + SORT_STRING, + SORT_TYPE, + SORT_ANY, + SORT_COMPLEX + }; + + /** + Maps from a binary UNO type name or UNO type registry name to its type + sort. + + @param type a binary UNO type name or UNO type registry name + + @return the sort of the UNO type denoted by the given type; the detection + of the correct sort is purely syntactical (especially, if the given input + is a UNO type registry name that denotes something other than a UNO type, + SORT_COMPLEX is returned) + */ + Sort getSort(rtl::OString const & type); + + /** + Determines whether a UNO type name or UNO type registry name denotes a + UNO sequence type. + + @param type a binary UNO type name or UNO type registry name + + @return true iff the given type denotes a UNO sequence type; the + detection is purely syntactical + */ + bool isSequenceType(rtl::OString const & type); + + /** + Decomposes a UNO type name or UNO type registry name. + + @param type a binary UNO type name or UNO type registry name + + @param rank if non-null, returns the rank of the denoted UNO type (which + is zero for any given type that does not denote a UNO sequence type) + + @param arguments if non-null, the type arguments are stripped from an + instantiated polymorphic struct type and returned via this parameter (in + the correct order); if null, type arguments are not stripped from + instantiated polymorphic struct types + + @return the base part of the given type + */ + rtl::OString decompose( + rtl::OString const & type, sal_Int32 * rank = 0, + std::vector< rtl::OString > * arguments = 0); +} + +} + +#endif |