diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-04-08 08:45:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-04-09 09:44:33 +0200 |
commit | 02a8e8acd1f0cbb512868fd9849363f9d069db95 (patch) | |
tree | ce8a68631b45d663d583646c89d3aaaeb2a4e402 /codemaker/source/cppumaker/includes.cxx | |
parent | 209d6a0fcca942a0168eb10ca3ab8f5f0d2ba9be (diff) |
[API CHANGE] WIP: Experimental new binary type.rdb format
Make cppumaker work on top of unoidl/ instead of registry/, as a first step to
change all the various codemakers.
* API CHANGE: cppumaker no longer supports the -B switch, as that is meaningless
with the new format. When reading from an old-format .rdb file, /UCR is
hard-coded as the prefix now.
* TODO: The new format does not yet support deprecation annotations, so the
generated .hdl/.hpp files lack any SAL_DEPRECATED_INTERNALs for now.
* codemaker/typemanager.hxx is extended with access to unoidl/ functionality, so
the various codemakers can use registry/ and unoidl/ in parallel for now.
The access to registry/ functionality will be removed. (Added small throwaway
helper functions u2b/b2u to easily map between OString and OUString at the
remaining seams for now.)
* Includes a selective revert of ba044b1e9613ed30906a9a540b7da8392923e4e3
"remove needless forward rtl::OUString declarations" in those parts of
codemaker, unodevtools, unoidl that were covered by this local
work-in-progress patch; I would otherwise have hard a hard time re-applying
it.
* The generated .hdl/.hpp files are mostly unchanged, except for a few minor
things:
** Any SAL_DEPRECATED_INTERNALs are missing (see above).
** In comprehensive getCppuType definitions, some members were erroneously
classified as TypeCalss_UNKNOWN.
** In comprehensive getCppuType definitions, some unnecessary calls like
::cppu::UnoType< ::sal_Int32 >::get();
can be removed.
** For typedef sequence<X>, the .hdl file need not include X.hdl, but only needs
to forward-declare it.
** Unnecessary includes for optional bases of interfaces can be removed.
** Some numbering of local variable names (sMethodName1, ...) has changed.
Change-Id: Icad98f248ac15177337f1b4ab709a755a8af6238
Diffstat (limited to 'codemaker/source/cppumaker/includes.cxx')
-rwxr-xr-x[-rw-r--r--] | codemaker/source/cppumaker/includes.cxx | 100 |
1 files changed, 44 insertions, 56 deletions
diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx index 34f23e954bf1..c6516745a5d2 100644..100755 --- a/codemaker/source/cppumaker/includes.cxx +++ b/codemaker/source/cppumaker/includes.cxx @@ -20,9 +20,9 @@ #include "includes.hxx" +#include "dependencies.hxx" #include "dumputils.hxx" -#include "codemaker/dependencies.hxx" #include "codemaker/global.hxx" #include "codemaker/typemanager.hxx" #include "codemaker/unotype.hxx" @@ -39,7 +39,7 @@ using codemaker::cppumaker::Includes; Includes::Includes( rtl::Reference< TypeManager > const & manager, - codemaker::Dependencies const & dependencies, bool hpp): + codemaker::cppumaker::Dependencies const & dependencies, bool hpp): m_manager(manager), m_map(dependencies.getMap()), m_hpp(hpp), m_includeCassert(false), m_includeAny(dependencies.hasAnyDependency()), m_includeReference(false), @@ -68,20 +68,14 @@ Includes::Includes( Includes::~Includes() {} -void Includes::add(OString const & registryType) { - sal_Int32 rank; +void Includes::add(OString const & entityName) { + sal_Int32 k; std::vector< OString > args; - OString type( - codemaker::UnoType::decompose(registryType, &rank, &args)); - if (rank > 0) { + OUString n(b2u(codemaker::UnoType::decompose(entityName, &k, &args))); + if (k != 0) { m_includeSequence = true; } - switch (codemaker::UnoType::getSort(type)) { - case codemaker::UnoType::SORT_VOID: - OSL_ASSERT(args.empty()); - OSL_ASSERT(false); - break; - + switch (m_manager->getSort(n)) { case codemaker::UnoType::SORT_BOOLEAN: case codemaker::UnoType::SORT_BYTE: case codemaker::UnoType::SORT_SHORT: @@ -91,44 +85,40 @@ void Includes::add(OString const & registryType) { case codemaker::UnoType::SORT_HYPER: case codemaker::UnoType::SORT_UNSIGNED_HYPER: case codemaker::UnoType::SORT_CHAR: - OSL_ASSERT(args.empty()); m_includeSalTypesH = true; break; - case codemaker::UnoType::SORT_FLOAT: case codemaker::UnoType::SORT_DOUBLE: - OSL_ASSERT(args.empty()); break; - case codemaker::UnoType::SORT_STRING: - OSL_ASSERT(args.empty()); m_includeRtlUstringHxx = true; break; - case codemaker::UnoType::SORT_TYPE: - OSL_ASSERT(args.empty()); m_includeType = true; break; - case codemaker::UnoType::SORT_ANY: - OSL_ASSERT(args.empty()); m_includeAny = true; break; - - case codemaker::UnoType::SORT_COMPLEX: - m_map.insert( - codemaker::Dependencies::Map::value_type( - type, codemaker::Dependencies::KIND_NO_BASE)); - for (std::vector< OString >::iterator i(args.begin()); - i != args.end(); ++i) + case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE: + for (std::vector< OString >::iterator i(args.begin()); i != args.end(); + ++i) { add(*i); } + // fall through + case codemaker::UnoType::SORT_SEQUENCE_TYPE: + case codemaker::UnoType::SORT_ENUM_TYPE: + case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE: + case codemaker::UnoType::SORT_EXCEPTION_TYPE: + case codemaker::UnoType::SORT_INTERFACE_TYPE: + case codemaker::UnoType::SORT_TYPEDEF: + m_map.insert( + Dependencies::Map::value_type(n, Dependencies::KIND_NO_BASE)); break; - default: - OSL_ASSERT(false); - break; + throw CannotDumpException( + "unexpected type \"" + b2u(entityName) + + "\" in call to codemaker::cppumaker::Includes::add"); } } @@ -144,13 +134,13 @@ void dumpEmptyLineBeforeFirst(FileStream & out, bool * first) { } -void Includes::dump(FileStream & out, OString const * companionHdl) { +void Includes::dump(FileStream & out, OUString const * companionHdl) { OSL_ASSERT(companionHdl == 0 || m_hpp); if (!m_includeReference) { - for (codemaker::Dependencies::Map::iterator i(m_map.begin()); - i != m_map.end(); ++i) + for (Dependencies::Map::iterator i(m_map.begin()); i != m_map.end(); + ++i) { - if (isInterfaceType(i->first)) { + if (isInterfaceType(u2b(i->first))) { m_includeReference = true; break; } @@ -162,17 +152,16 @@ void Includes::dump(FileStream & out, OString const * companionHdl) { } if (companionHdl) { out << "\n"; - dumpInclude(out, *companionHdl, false); + dumpInclude(out, u2b(*companionHdl), false); } bool first = true; - for (codemaker::Dependencies::Map::iterator i(m_map.begin()); - i != m_map.end(); ++i) + for (Dependencies::Map::iterator i(m_map.begin()); i != m_map.end(); ++i) { dumpEmptyLineBeforeFirst(out, &first); - if (m_hpp || i->second == codemaker::Dependencies::KIND_BASE - || !isInterfaceType(i->first)) + if (m_hpp || i->second == Dependencies::KIND_BASE + || !isInterfaceType(u2b(i->first))) { - dumpInclude(out, i->first, m_hpp); + dumpInclude(out, u2b(i->first), m_hpp); } else { bool ns = dumpNamespaceOpen(out, i->first, false); if (ns) { @@ -191,19 +180,23 @@ void Includes::dump(FileStream & out, OString const * companionHdl) { static char const * hxxExtension[2] = { "h", "hxx" }; if (m_includeAny) { dumpEmptyLineBeforeFirst(out, &first); - out << "#include \"com/sun/star/uno/Any." << hxxExtension[m_hpp] << "\"\n"; + out << "#include \"com/sun/star/uno/Any." << hxxExtension[m_hpp] + << "\"\n"; } if (m_includeReference) { dumpEmptyLineBeforeFirst(out, &first); - out << "#include \"com/sun/star/uno/Reference." << hxxExtension[m_hpp] << "\"\n"; + out << "#include \"com/sun/star/uno/Reference." << hxxExtension[m_hpp] + << "\"\n"; } if (m_includeSequence) { dumpEmptyLineBeforeFirst(out, &first); - out << "#include \"com/sun/star/uno/Sequence." << hxxExtension[m_hpp] << "\"\n"; + out << "#include \"com/sun/star/uno/Sequence." << hxxExtension[m_hpp] + << "\"\n"; } if (m_includeType) { dumpEmptyLineBeforeFirst(out, &first); - out << "#include \"com/sun/star/uno/Type." << hxxExtension[m_hpp] << "\"\n"; + out << "#include \"com/sun/star/uno/Type." << hxxExtension[m_hpp] + << "\"\n"; } if (m_includeCppuMacrosHxx) { dumpEmptyLineBeforeFirst(out, &first); @@ -264,19 +257,14 @@ void Includes::dump(FileStream & out, OString const * companionHdl) { } void Includes::dumpInclude( - FileStream & out, OString const & registryType, bool hpp, - OString const & suffix) + FileStream & out, OString const & entityName, bool hpp) { - static char const * extension[2] = { "hdl", "hpp" }; - out << "#include \"" << registryType; - if (!suffix.isEmpty()) { - out << "/" << suffix; - } - out << "." << extension[hpp] << "\"\n"; + out << "#include \"" << entityName.replace('.', '/') << "." + << (hpp ? "hpp" : "hdl") << "\"\n"; } -bool Includes::isInterfaceType(OString const & registryType) const { - return m_manager->getTypeClass(registryType) == RT_TYPE_INTERFACE; +bool Includes::isInterfaceType(OString const & entityName) const { + return m_manager->getSort(b2u(entityName)) == UnoType::SORT_INTERFACE_TYPE; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |