diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-22 16:39:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-04 06:38:03 +0000 |
commit | 5676ced82539d9e40bde6196d2aa3b2e4c7b3fdb (patch) | |
tree | db860b2365f8cb0e2fab4772e80e4e38d4d89b37 /codemaker/source | |
parent | 1a1d1a86e9129ec3885610b641179b30f9bf5e79 (diff) |
make UNO enums scoped for internal LO code
this modifies codemaker so that, for an UNO enum, we generate code
that effectively looks like:
#ifdef LIBO_INTERNAL_ONLY && HAVE_CX11_CONSTEXPR
enum class XXX {
ONE = 1
};
constexpr auto ONE = XXX_ONE;
#else
...the old normal way..
#endif
which means that for LO internal code, the enums are scoped.
The "constexpr auto" trick acts like an alias so we don't have to
use scoped naming everywhere.
Change-Id: I3054ecb230e8666ce98b4a9cb87b384df5f64fb4
Reviewed-on: https://gerrit.libreoffice.org/34546
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'codemaker/source')
-rw-r--r-- | codemaker/source/commoncpp/commoncpp.cxx | 1 | ||||
-rw-r--r-- | codemaker/source/cppumaker/cpputype.cxx | 958 |
2 files changed, 482 insertions, 477 deletions
diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx index 4f1840c54e43..a4279e3a98dd 100644 --- a/codemaker/source/commoncpp/commoncpp.cxx +++ b/codemaker/source/commoncpp/commoncpp.cxx @@ -63,7 +63,6 @@ OString scopedCppName(OString const & type, bool ns_alias) return s; } - OString translateUnoToCppType( codemaker::UnoType::Sort sort, OUString const & nucleus) { diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index 659061a8fd34..a657389d6a4d 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -46,9 +46,11 @@ #include "dumputils.hxx" #include "includes.hxx" -namespace { +namespace +{ -bool isBootstrapType(OUString const & name) { +bool isBootstrapType(OUString const & name) +{ static char const * const names[] = { "com.sun.star.beans.Property", "com.sun.star.beans.PropertyAttribute", @@ -136,8 +138,9 @@ bool isBootstrapType(OUString const & name) { "com.sun.star.uno.XReference", "com.sun.star.uno.XUnloadingPreference", "com.sun.star.uno.XWeak", - "com.sun.star.util.XMacroExpander" }; - // cf. cppuhelper/unotypes/Makefile UNOTYPES (plus missing dependencies) + "com.sun.star.util.XMacroExpander" + }; + // cf. cppuhelper/unotypes/Makefile UNOTYPES (plus missing dependencies) for (std::size_t i = 0; i < SAL_N_ELEMENTS(names); ++i) { if (name.equalsAscii(names[i])) { return true; @@ -146,7 +149,8 @@ bool isBootstrapType(OUString const & name) { return false; } -class CppuType { +class CppuType +{ public: CppuType( OUString const & name, rtl::Reference< TypeManager > const & typeMgr); @@ -166,8 +170,9 @@ public: codemaker::GeneratedTypeSet & generated, CppuOptions const & options); virtual void dumpHdlFile( - FileStream & out, codemaker::cppumaker::Includes & includes) - { dumpHFileContent(out, includes); } + FileStream & out, codemaker::cppumaker::Includes & includes) { + dumpHFileContent(out, includes); + } virtual void dumpHppFile(FileStream& o, codemaker::cppumaker::Includes & includes) = 0; @@ -177,16 +182,18 @@ public: virtual void dumpLightGetCppuType(FileStream & out); - virtual void dumpNormalGetCppuType(FileStream &) - { assert(false); } // this cannot happen + virtual void dumpNormalGetCppuType(FileStream &) { + assert(false); // this cannot happen + } - virtual void dumpComprehensiveGetCppuType(FileStream &) - { assert(false); } // this cannot happen + virtual void dumpComprehensiveGetCppuType(FileStream &) { + assert(false); // this cannot happen + } void dumpType( FileStream & out, OUString const & name, bool isConst = false, bool isRef = false, bool native = false, bool cppuUnoType = false) - const; + const; OUString getTypeClass(OUString const & name, bool cStyle = false); @@ -199,8 +206,10 @@ public: void dec(sal_Int32 num=4); OUString indent() const; protected: - virtual sal_uInt32 checkInheritedMemberCount() const - { assert(false); return 0; } // this cannot happen + virtual sal_uInt32 checkInheritedMemberCount() const { + assert(false); // this cannot happen + return 0; + } bool passByReference(OUString const & name) const; @@ -213,8 +222,9 @@ protected: codemaker::cpp::IdentifierTranslationMode isGlobal() const; - virtual void dumpDeclaration(FileStream &) - { assert(false); } // this cannot happen + virtual void dumpDeclaration(FileStream &) { + assert(false); // this cannot happen + } virtual void dumpFiles(OUString const & uri, CppuOptions const & options); @@ -259,7 +269,7 @@ protected: private: void addGetCppuTypeIncludes(codemaker::cppumaker::Includes & includes) - const; + const; }; CppuType::CppuType( @@ -275,11 +285,10 @@ CppuType::CppuType( {} void CppuType::addGetCppuTypeIncludes(codemaker::cppumaker::Includes & includes) - const +const { if (name_ == "com.sun.star.uno.XInterface" - || name_ == "com.sun.star.uno.Exception") - { + || name_ == "com.sun.star.uno.Exception") { includes.addType(); includes.addCppuUnotypeHxx(); includes.addSalTypesH(); @@ -294,7 +303,8 @@ void CppuType::addGetCppuTypeIncludes(codemaker::cppumaker::Includes & includes) } } -void CppuType::dumpFiles(OUString const & uri, CppuOptions const & options) { +void CppuType::dumpFiles(OUString const & uri, CppuOptions const & options) +{ dumpFile(uri, name_, false, options); dumpFile(uri, name_, true, options); } @@ -323,9 +333,13 @@ void CppuType::addComprehensiveGetCppuTypeIncludes( includes.addCppuUnotypeHxx(); } -bool CppuType::isPolymorphic() const { return false; } +bool CppuType::isPolymorphic() const +{ + return false; +} -void CppuType::dumpGetCppuTypePreamble(FileStream & out) { +void CppuType::dumpGetCppuTypePreamble(FileStream & out) +{ if (isPolymorphic()) { out << "namespace cppu {\n\n"; dumpTemplateHead(out); @@ -348,7 +362,8 @@ void CppuType::dumpGetCppuTypePreamble(FileStream & out) { inc(); } -void CppuType::dumpGetCppuTypePostamble(FileStream & out) { +void CppuType::dumpGetCppuTypePostamble(FileStream & out) +{ dec(); if (isPolymorphic()) { out << indent() << "}\n\nprivate:\n" @@ -377,7 +392,8 @@ void CppuType::dumpGetCppuTypePostamble(FileStream & out) { out << indent() << "}\n"; } -void CppuType::dump(CppuOptions const & options) { +void CppuType::dump(CppuOptions const & options) +{ if (isBootstrapType(name_)) { m_cppuTypeDynamic = false; } else { @@ -434,7 +450,7 @@ bool CppuType::dumpFile( } out.close(); return makeValidTypeFile( - u2b(fileUri), u2b(tmpUri), exists && options.isValid("-Gc")); + u2b(fileUri), u2b(tmpUri), exists && options.isValid("-Gc")); } void CppuType::dumpDependedTypes( @@ -443,8 +459,7 @@ void CppuType::dumpDependedTypes( if (!options.isValid("-nD")) { codemaker::cppumaker::Dependencies::Map const & map = m_dependencies.getMap(); - for (const auto& entry : map) - { + for (const auto& entry : map) { produce(entry.first, m_typeMgr, generated, options); } } @@ -461,25 +476,23 @@ OUString CppuType::dumpHeaderDefine( } void CppuType::addDefaultHIncludes(codemaker::cppumaker::Includes & includes) - const +const { //TODO: Only include what is really needed includes.addCppuMacrosHxx(); if (m_typeMgr->getSort(name_) - == codemaker::UnoType::Sort::Interface) - { + == codemaker::UnoType::Sort::Interface) { includes.addReference(); } } void CppuType::addDefaultHxxIncludes(codemaker::cppumaker::Includes & includes) - const +const { //TODO: Only include what is really needed includes.addType(); if (m_typeMgr->getSort(name_) - == codemaker::UnoType::Sort::Interface) - { + == codemaker::UnoType::Sort::Interface) { includes.addReference(); } } @@ -517,6 +530,7 @@ void CppuType::dumpInitializer( << (dynamic_cast< unoidl::EnumTypeEntity * >(ent.get())-> getMembers()[0].name); break; + break; case codemaker::UnoType::Sort::String: case codemaker::UnoType::Sort::Type: case codemaker::UnoType::Sort::Any: @@ -541,8 +555,8 @@ void CppuType::dumpHFileContent( dumpHeaderDefine(out, "HDL"); out << "\n"; includes.dump(out, nullptr, false); - // 'exceptions = false' would be wrong for services/singletons, but - // those don't dump .hdl files anyway + // 'exceptions = false' would be wrong for services/singletons, but + // those don't dump .hdl files anyway out << ("\nnamespace com { namespace sun { namespace star { namespace uno" " { class Type; } } } }\n\n"); if (codemaker::cppumaker::dumpNamespaceOpen(out, name_, false)) { @@ -551,8 +565,7 @@ void CppuType::dumpHFileContent( dumpDeclaration(out); if (!(name_ == "com.sun.star.uno.XInterface" || name_ == "com.sun.star.uno.Exception" - || isPolymorphic())) - { + || isPolymorphic())) { out << "\n" << indent() << ("inline ::css::uno::Type const &" " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER "); @@ -570,7 +583,8 @@ void CppuType::dumpHFileContent( out << " *);\n\n#endif\n"; } -void CppuType::dumpGetCppuType(FileStream & out) { +void CppuType::dumpGetCppuType(FileStream & out) +{ if (name_ == "com.sun.star.uno.XInterface") { out << indent() << ("SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL" @@ -604,7 +618,8 @@ void CppuType::dumpGetCppuType(FileStream & out) { } } -void CppuType::dumpLightGetCppuType(FileStream & out) { +void CppuType::dumpLightGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << "static typelib_TypeDescriptionReference * the_type = 0;\n" @@ -619,112 +634,115 @@ void CppuType::dumpLightGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -codemaker::cpp::IdentifierTranslationMode CppuType::isGlobal() const { +codemaker::cpp::IdentifierTranslationMode CppuType::isGlobal() const +{ return name_.indexOf('.') == -1 - ? codemaker::cpp::IdentifierTranslationMode::Global : codemaker::cpp::IdentifierTranslationMode::NonGlobal; + ? codemaker::cpp::IdentifierTranslationMode::Global : codemaker::cpp::IdentifierTranslationMode::NonGlobal; } sal_uInt32 CppuType::getInheritedMemberCount() { - if (m_inheritedMemberCount == 0) - { + if (m_inheritedMemberCount == 0) { m_inheritedMemberCount = checkInheritedMemberCount(); } return m_inheritedMemberCount; } -OUString CppuType::getTypeClass(OUString const & name, bool cStyle) { +OUString CppuType::getTypeClass(OUString const & name, bool cStyle) +{ rtl::Reference< unoidl::Entity > ent; switch (m_typeMgr->getSort(name, &ent)) { case codemaker::UnoType::Sort::Void: return cStyle - ? OUString("typelib_TypeClass_VOID") - : OUString("::css::uno::TypeClass_VOID"); + ? OUString("typelib_TypeClass_VOID") + : OUString("::css::uno::TypeClass_VOID"); case codemaker::UnoType::Sort::Boolean: return cStyle - ? OUString("typelib_TypeClass_BOOLEAN") - : OUString("::css::uno::TypeClass_BOOLEAN"); + ? OUString("typelib_TypeClass_BOOLEAN") + : OUString("::css::uno::TypeClass_BOOLEAN"); case codemaker::UnoType::Sort::Byte: return cStyle - ? OUString("typelib_TypeClass_BYTE") - : OUString("::css::uno::TypeClass_BYTE"); + ? OUString("typelib_TypeClass_BYTE") + : OUString("::css::uno::TypeClass_BYTE"); case codemaker::UnoType::Sort::Short: return cStyle - ? OUString("typelib_TypeClass_SHORT") - : OUString("::css::uno::TypeClass_SHORT"); + ? OUString("typelib_TypeClass_SHORT") + : OUString("::css::uno::TypeClass_SHORT"); case codemaker::UnoType::Sort::UnsignedShort: return cStyle - ? OUString("typelib_TypeClass_UNSIGNED_SHORT") - : OUString("::css::uno::TypeClass_UNSIGNED_SHORT"); + ? OUString("typelib_TypeClass_UNSIGNED_SHORT") + : OUString("::css::uno::TypeClass_UNSIGNED_SHORT"); case codemaker::UnoType::Sort::Long: return cStyle - ? OUString("typelib_TypeClass_LONG") - : OUString("::css::uno::TypeClass_LONG"); + ? OUString("typelib_TypeClass_LONG") + : OUString("::css::uno::TypeClass_LONG"); case codemaker::UnoType::Sort::UnsignedLong: return cStyle - ? OUString("typelib_TypeClass_UNSIGNED_LONG") - : OUString("::css::uno::TypeClass_UNSIGNED_LONG"); + ? OUString("typelib_TypeClass_UNSIGNED_LONG") + : OUString("::css::uno::TypeClass_UNSIGNED_LONG"); case codemaker::UnoType::Sort::Hyper: return cStyle - ? OUString("typelib_TypeClass_HYPER") - : OUString("::css::uno::TypeClass_HYPER"); + ? OUString("typelib_TypeClass_HYPER") + : OUString("::css::uno::TypeClass_HYPER"); case codemaker::UnoType::Sort::UnsignedHyper: return cStyle - ? OUString("typelib_TypeClass_UNSIGNED_HYPER") - : OUString("::css::uno::TypeClass_UNSIGNED_HYPER"); + ? OUString("typelib_TypeClass_UNSIGNED_HYPER") + : OUString("::css::uno::TypeClass_UNSIGNED_HYPER"); case codemaker::UnoType::Sort::Float: return cStyle - ? OUString("typelib_TypeClass_FLOAT") - : OUString("::css::uno::TypeClass_FLOAT"); + ? OUString("typelib_TypeClass_FLOAT") + : OUString("::css::uno::TypeClass_FLOAT"); case codemaker::UnoType::Sort::Double: return cStyle - ? OUString("typelib_TypeClass_DOUBLE") - : OUString("::css::uno::TypeClass_DOUBLE"); + ? OUString("typelib_TypeClass_DOUBLE") + : OUString("::css::uno::TypeClass_DOUBLE"); case codemaker::UnoType::Sort::Char: return cStyle - ? OUString("typelib_TypeClass_CHAR") - : OUString("::css::uno::TypeClass_CHAR"); + ? OUString("typelib_TypeClass_CHAR") + : OUString("::css::uno::TypeClass_CHAR"); case codemaker::UnoType::Sort::String: return cStyle - ? OUString("typelib_TypeClass_STRING") - : OUString("::css::uno::TypeClass_STRING"); + ? OUString("typelib_TypeClass_STRING") + : OUString("::css::uno::TypeClass_STRING"); case codemaker::UnoType::Sort::Type: return cStyle - ? OUString("typelib_TypeClass_TYPE") - : OUString("::css::uno::TypeClass_TYPE"); + ? OUString("typelib_TypeClass_TYPE") + : OUString("::css::uno::TypeClass_TYPE"); case codemaker::UnoType::Sort::Any: return cStyle - ? OUString("typelib_TypeClass_ANY") - : OUString("::css::uno::TypeClass_ANY"); + ? OUString("typelib_TypeClass_ANY") + : OUString("::css::uno::TypeClass_ANY"); case codemaker::UnoType::Sort::Sequence: return cStyle - ? OUString("typelib_TypeClass_SEQUENCE") - : OUString("::css::uno::TypeClass_SEQUENCE"); + ? OUString("typelib_TypeClass_SEQUENCE") + : OUString("::css::uno::TypeClass_SEQUENCE"); case codemaker::UnoType::Sort::Enum: return cStyle - ? OUString("typelib_TypeClass_ENUM") - : OUString("::css::uno::TypeClass_ENUM"); + ? OUString("typelib_TypeClass_ENUM") + : OUString("::css::uno::TypeClass_ENUM"); case codemaker::UnoType::Sort::PlainStruct: case codemaker::UnoType::Sort::PolymorphicStructTemplate: case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct: return cStyle - ? OUString("typelib_TypeClass_STRUCT") - : OUString("::css::uno::TypeClass_STRUCT"); + ? OUString("typelib_TypeClass_STRUCT") + : OUString("::css::uno::TypeClass_STRUCT"); case codemaker::UnoType::Sort::Exception: return cStyle - ? OUString("typelib_TypeClass_EXCEPTION") - : OUString("::css::uno::TypeClass_EXCEPTION"); + ? OUString("typelib_TypeClass_EXCEPTION") + : OUString("::css::uno::TypeClass_EXCEPTION"); case codemaker::UnoType::Sort::Interface: return cStyle - ? OUString("typelib_TypeClass_INTERFACE") - : OUString("::css::uno::TypeClass_INTERFACE"); + ? OUString("typelib_TypeClass_INTERFACE") + : OUString("::css::uno::TypeClass_INTERFACE"); case codemaker::UnoType::Sort::Typedef: return getTypeClass( - dynamic_cast<unoidl::TypedefEntity&>(*ent.get()).getType(), - cStyle); + dynamic_cast<unoidl::TypedefEntity&>(*ent.get()).getType(), + cStyle); default: - for (;;) { std::abort(); } + for (;;) { + std::abort(); + } } } @@ -801,8 +819,7 @@ void CppuType::dumpType( if (!args.empty()) { out << "< "; for (std::vector< OString >::iterator i(args.begin()); - i != args.end(); ++i) - { + i != args.end(); ++i) { if (i != args.begin()) { out << ", "; } @@ -839,7 +856,7 @@ void CppuType::dumpCppuGetType( OUString nucleus; sal_Int32 rank; codemaker::UnoType::Sort sort = m_typeMgr->decompose( - name, true, &nucleus, &rank, nullptr, nullptr); + name, true, &nucleus, &rank, nullptr, nullptr); switch (rank == 0 ? sort : codemaker::UnoType::Sort::Sequence) { case codemaker::UnoType::Sort::Void: case codemaker::UnoType::Sort::Boolean: @@ -879,7 +896,8 @@ void CppuType::dumpCppuGetType( } } -bool CppuType::passByReference(OUString const & name) const { +bool CppuType::passByReference(OUString const & name) const +{ switch (m_typeMgr->getSort(resolveOuterTypedefs(name))) { case codemaker::UnoType::Sort::Boolean: case codemaker::UnoType::Sort::Byte: @@ -909,10 +927,12 @@ bool CppuType::passByReference(OUString const & name) const { } } -bool CppuType::canBeWarnUnused(OUString const & name) const { +bool CppuType::canBeWarnUnused(OUString const & name) const +{ return canBeWarnUnused(name, 0); } -bool CppuType::canBeWarnUnused(OUString const & name, int depth) const { +bool CppuType::canBeWarnUnused(OUString const & name, int depth) const +{ // prevent infinite recursion and blowing the stack if (depth > 10) return false; @@ -933,23 +953,20 @@ bool CppuType::canBeWarnUnused(OUString const & name, int depth) const { case codemaker::UnoType::Sort::String: case codemaker::UnoType::Sort::Type: return true; - case codemaker::UnoType::Sort::PlainStruct: - { + case codemaker::UnoType::Sort::PlainStruct: { rtl::Reference< unoidl::Entity > ent; m_typeMgr->getSort(aResolvedName, &ent); rtl::Reference< unoidl::PlainStructTypeEntity > ent2( dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get())); if (!ent2->getDirectBase().isEmpty() && !canBeWarnUnused(ent2->getDirectBase(), depth+1)) return false; - for ( const unoidl::PlainStructTypeEntity::Member& rMember : ent2->getDirectMembers()) - { + for ( const unoidl::PlainStructTypeEntity::Member& rMember : ent2->getDirectMembers()) { if (!canBeWarnUnused(rMember.type, depth+1)) return false; } return true; } - case codemaker::UnoType::Sort::Sequence: - { + case codemaker::UnoType::Sort::Sequence: { OUString aInnerType = aResolvedName.copy(2); return canBeWarnUnused(aInnerType, depth+1); } @@ -964,7 +981,8 @@ bool CppuType::canBeWarnUnused(OUString const & name, int depth) const { } } -OUString CppuType::resolveOuterTypedefs(OUString const & name) const { +OUString CppuType::resolveOuterTypedefs(OUString const & name) const +{ for (OUString n(name);;) { rtl::Reference< unoidl::Entity > ent; if (m_typeMgr->getSort(n, &ent) != codemaker::UnoType::Sort::Typedef) { @@ -974,7 +992,8 @@ OUString CppuType::resolveOuterTypedefs(OUString const & name) const { } } -OUString CppuType::resolveAllTypedefs(OUString const & name) const { +OUString CppuType::resolveAllTypedefs(OUString const & name) const +{ sal_Int32 k1; OUString n(b2u(codemaker::UnoType::decompose(u2b(name), &k1))); for (;;) { @@ -984,10 +1003,10 @@ OUString CppuType::resolveAllTypedefs(OUString const & name) const { } sal_Int32 k2; n = b2u( - codemaker::UnoType::decompose( - u2b(dynamic_cast<unoidl::TypedefEntity&>(*ent.get()). - getType()), - &k2)); + codemaker::UnoType::decompose( + u2b(dynamic_cast<unoidl::TypedefEntity&>(*ent.get()). + getType()), + &k2)); k1 += k2; //TODO: overflow } OUStringBuffer b; @@ -1008,7 +1027,8 @@ void CppuType::dec(sal_Int32 num) m_indentLength = std::max< sal_Int32 >(m_indentLength - num, 0); } -OUString CppuType::indent() const { +OUString CppuType::indent() const +{ OUStringBuffer buf(m_indentLength); for (sal_Int32 i = 0; i != m_indentLength; ++i) { buf.append(' '); @@ -1016,9 +1036,9 @@ OUString CppuType::indent() const { return buf.makeStringAndClear(); } -bool isDeprecated(std::vector< OUString > const & annotations) { - for (const OUString& r : annotations) - { +bool isDeprecated(std::vector< OUString > const & annotations) +{ + for (const OUString& r : annotations) { if (r == "deprecated") { return true; } @@ -1026,22 +1046,28 @@ bool isDeprecated(std::vector< OUString > const & annotations) { return false; } -void dumpDeprecation(FileStream & out, bool deprecated) { +void dumpDeprecation(FileStream & out, bool deprecated) +{ if (deprecated) { out << "SAL_DEPRECATED_INTERNAL(\"marked @deprecated in UNOIDL\") "; } } -class BaseOffset { +class BaseOffset +{ public: BaseOffset( rtl::Reference< TypeManager > const & manager, rtl::Reference< unoidl::InterfaceTypeEntity > const & entity): - manager_(manager), offset_(0) { calculateBases(entity); } + manager_(manager), offset_(0) { + calculateBases(entity); + } BaseOffset(const BaseOffset&) = delete; const BaseOffset& operator=(const BaseOffset&) = delete; - sal_Int32 get() const { return offset_; } + sal_Int32 get() const { + return offset_; + } private: void calculateBases( @@ -1056,8 +1082,7 @@ void BaseOffset::calculateBases( rtl::Reference< unoidl::InterfaceTypeEntity > const & entity) { assert(entity.is()); - for (const unoidl::AnnotatedReference& ar : entity->getDirectMandatoryBases()) - { + for (const unoidl::AnnotatedReference& ar : entity->getDirectMandatoryBases()) { if (set_.insert(ar.name).second) { rtl::Reference< unoidl::Entity > ent; codemaker::UnoType::Sort sort = manager_->getSort(ar.name, &ent); @@ -1071,12 +1096,13 @@ void BaseOffset::calculateBases( assert(ent2.is()); calculateBases(ent2); offset_ += ent2->getDirectAttributes().size() - + ent2->getDirectMethods().size(); //TODO: overflow + + ent2->getDirectMethods().size(); //TODO: overflow } } } -class InterfaceType: public CppuType { +class InterfaceType: public CppuType +{ public: InterfaceType( rtl::Reference< unoidl::InterfaceTypeEntity > const & entity, @@ -1100,8 +1126,9 @@ private: virtual void addComprehensiveGetCppuTypeIncludes( codemaker::cppumaker::Includes & includes) const override; - virtual sal_uInt32 checkInheritedMemberCount() const override - { return BaseOffset(m_typeMgr, entity_).get(); } + virtual sal_uInt32 checkInheritedMemberCount() const override { + return BaseOffset(m_typeMgr, entity_).get(); + } void dumpExceptionTypeName( FileStream & out, OUString const & prefix, sal_uInt32 index, @@ -1124,12 +1151,12 @@ InterfaceType::InterfaceType( assert(entity.is()); } -void InterfaceType::dumpDeclaration(FileStream & out) { +void InterfaceType::dumpDeclaration(FileStream & out) +{ out << "\nclass SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI " << id_; for (std::vector< unoidl::AnnotatedReference >::const_iterator i( entity_->getDirectMandatoryBases().begin()); - i != entity_->getDirectMandatoryBases().end(); ++i) - { + i != entity_->getDirectMandatoryBases().end(); ++i) { out << (i == entity_->getDirectMandatoryBases().begin() ? " :" : ",") << " public " << codemaker::cpp::scopedCppName(u2b(i->name)); } @@ -1170,12 +1197,12 @@ void InterfaceType::dumpHppFile( out << "}\n\n#endif // "<< headerDefine << "\n"; } -void InterfaceType::dumpAttributes(FileStream & out) { +void InterfaceType::dumpAttributes(FileStream & out) +{ if (!entity_->getDirectAttributes().empty()) { out << "\n" << indent() << "// Attributes\n"; } - for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) - { + for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) { bool depr = m_isDeprecated || isDeprecated(attr.annotations); out << indent(); dumpDeprecation(out, depr); @@ -1193,12 +1220,12 @@ void InterfaceType::dumpAttributes(FileStream & out) { } } -void InterfaceType::dumpMethods(FileStream & out) { +void InterfaceType::dumpMethods(FileStream & out) +{ if (!entity_->getDirectMethods().empty()) { out << "\n" << indent() << "// Methods\n"; } - for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) - { + for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) { out << indent(); dumpDeprecation(out, m_isDeprecated || isDeprecated(method.annotations)); out << "virtual "; @@ -1207,15 +1234,13 @@ void InterfaceType::dumpMethods(FileStream & out) { if (!method.parameters.empty()) { out << " "; for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >:: - const_iterator j(method.parameters.begin()); - j != method.parameters.end();) - { + const_iterator j(method.parameters.begin()); + j != method.parameters.end();) { bool isConst; bool isRef; if (j->direction == (unoidl::InterfaceTypeEntity::Method::Parameter:: - DIRECTION_IN)) - { + DIRECTION_IN)) { isConst = passByReference(j->type); isRef = isConst; } else { @@ -1235,7 +1260,8 @@ void InterfaceType::dumpMethods(FileStream & out) { } } -void InterfaceType::dumpNormalGetCppuType(FileStream & out) { +void InterfaceType::dumpNormalGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << "static typelib_TypeDescriptionReference * the_type = 0;\n" @@ -1245,16 +1271,14 @@ void InterfaceType::dumpNormalGetCppuType(FileStream & out) { entity_->getDirectMandatoryBases().size()); if (bases == 1 && (entity_->getDirectMandatoryBases()[0].name - == "com.sun.star.uno.XInterface")) - { + == "com.sun.star.uno.XInterface")) { bases = 0; } if (bases != 0) { out << indent() << "typelib_TypeDescriptionReference * aSuperTypes[" << entity_->getDirectMandatoryBases().size() << "];\n"; std::vector< unoidl::AnnotatedReference >::size_type n = 0; - for (const unoidl::AnnotatedReference& ar : entity_->getDirectMandatoryBases()) - { + for (const unoidl::AnnotatedReference& ar : entity_->getDirectMandatoryBases()) { out << indent() << "aSuperTypes[" << n++ << "] = ::cppu::UnoType< "; dumpType(out, ar.name, true, false, false, true); out << " >::get().getTypeLibType();\n"; @@ -1270,7 +1294,8 @@ void InterfaceType::dumpNormalGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void InterfaceType::dumpComprehensiveGetCppuType(FileStream & out) { +void InterfaceType::dumpComprehensiveGetCppuType(FileStream & out) +{ codemaker::cppumaker::dumpNamespaceOpen(out, name_, false); OUString staticTypeClass("the" + id_ + "Type"); out << " namespace detail {\n\n" << indent() << "struct " << staticTypeClass @@ -1286,14 +1311,13 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream & out) { out << indent() << "typelib_TypeDescriptionReference * aSuperTypes[" << entity_->getDirectMandatoryBases().size() << "];\n"; std::vector< unoidl::AnnotatedReference >::size_type n = 0; - for (const unoidl::AnnotatedReference& ar : entity_->getDirectMandatoryBases()) - { + for (const unoidl::AnnotatedReference& ar : entity_->getDirectMandatoryBases()) { out << indent() << "aSuperTypes[" << n++ << "] = ::cppu::UnoType< "; dumpType(out, ar.name, false, false, false, true); out << " >::get().getTypeLibType();\n"; } std::size_t count = entity_->getDirectAttributes().size() - + entity_->getDirectMethods().size(); //TODO: overflow + + entity_->getDirectMethods().size(); //TODO: overflow if (count != 0) { out << indent() << "typelib_TypeDescriptionReference * pMembers[" << count << "] = { "; @@ -1318,7 +1342,7 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream & out) { dec(); out << indent() << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD" - " );\n"); + " );\n"); for (std::size_t i = 0; i != count; ++i) { out << indent() << "typelib_typedescriptionreference_release( pMembers[" << i << "] );\n"; @@ -1372,8 +1396,7 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream & out) { void InterfaceType::dumpCppuAttributeRefs(FileStream & out, sal_uInt32 & index) { std::vector< unoidl::InterfaceTypeEntity::Attribute >::size_type n = 0; - for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) - { + for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) { out << indent() << "::rtl::OUString sAttributeName" << n << "( \"" << name_ << "::" << attr.name << "\" );\n" << indent() << "typelib_typedescriptionreference_new( &pMembers[" << index++ @@ -1387,10 +1410,10 @@ void InterfaceType::dumpCppuAttributeRefs(FileStream & out, sal_uInt32 & index) } } -void InterfaceType::dumpCppuMethodRefs(FileStream & out, sal_uInt32 & index) { +void InterfaceType::dumpCppuMethodRefs(FileStream & out, sal_uInt32 & index) +{ std::vector< unoidl::InterfaceTypeEntity::Method >::size_type n = 0; - for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) - { + for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) { out << indent() << "::rtl::OUString sMethodName" << n << "( \"" << name_ << "::" << method.name << "\" );\n" << indent() << "typelib_typedescriptionreference_new( &pMembers[" << index++ @@ -1415,13 +1438,13 @@ void InterfaceType::addComprehensiveGetCppuTypeIncludes( includes.add("com.sun.star.uno.RuntimeException"); } -void InterfaceType::dumpCppuAttributes(FileStream & out, sal_uInt32 & index) { +void InterfaceType::dumpCppuAttributes(FileStream & out, sal_uInt32 & index) +{ if (!entity_->getDirectAttributes().empty()) { out << "\n" << indent() << "typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n"; std::vector< unoidl::InterfaceTypeEntity::Attribute >::size_type n = 0; - for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) - { + for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) { OUString type(resolveAllTypedefs(attr.type)); out << indent() << "{\n"; inc(); @@ -1430,9 +1453,9 @@ void InterfaceType::dumpCppuAttributes(FileStream & out, sal_uInt32 & index) { << "::rtl::OUString sAttributeName" << n << "( \"" << name_ << "::" << attr.name << "\" );\n"; sal_Int32 getExcn = dumpExceptionTypeNames( - out, "get", attr.getExceptions, false); + out, "get", attr.getExceptions, false); sal_Int32 setExcn = dumpExceptionTypeNames( - out, "set", attr.setExceptions, false); + out, "set", attr.setExceptions, false); out << indent() << ("typelib_typedescription_newExtendedInterfaceAttribute(" " &pAttribute,\n"); @@ -1459,13 +1482,13 @@ void InterfaceType::dumpCppuAttributes(FileStream & out, sal_uInt32 & index) { } } -void InterfaceType::dumpCppuMethods(FileStream & out, sal_uInt32 & index) { +void InterfaceType::dumpCppuMethods(FileStream & out, sal_uInt32 & index) +{ if (!entity_->getDirectMethods().empty()) { out << "\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n"; std::vector< unoidl::InterfaceTypeEntity::Method >::size_type n = 0; - for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) - { + for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) { OUString returnType(resolveAllTypedefs(method.returnType)); out << indent() << "{\n"; inc(); @@ -1474,9 +1497,8 @@ void InterfaceType::dumpCppuMethods(FileStream & out, sal_uInt32 & index) { << method.parameters.size() << "];\n"; } std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >:: - size_type m = 0; - for (const unoidl::InterfaceTypeEntity::Method::Parameter& param : method.parameters) - { + size_type m = 0; + for (const unoidl::InterfaceTypeEntity::Method::Parameter& param : method.parameters) { OUString type(resolveAllTypedefs(param.type)); out << indent() << "::rtl::OUString sParamName" << m << "( \"" << param.name << "\" );\n" << indent() @@ -1501,8 +1523,8 @@ void InterfaceType::dumpCppuMethods(FileStream & out, sal_uInt32 & index) { ++m; } sal_Int32 excn = dumpExceptionTypeNames( - out, "", method.exceptions, - method.name != "acquire" && method.name != "release"); + out, "", method.exceptions, + method.name != "acquire" && method.name != "release"); out << indent() << "::rtl::OUString sReturnType" << n << "( \"" << returnType << "\" );\n" << indent() << "::rtl::OUString sMethodName" << n << "( \"" << name_ << "::" @@ -1535,19 +1557,16 @@ void InterfaceType::dumpAttributesCppuDecl( FileStream & out, std::set< OUString > * seen) { assert(seen != nullptr); - for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) - { + for (const unoidl::InterfaceTypeEntity::Attribute& attr : entity_->getDirectAttributes()) { if (seen->insert(attr.type).second) { dumpCppuGetType(out, attr.type); } - for (const OUString& exc : attr.getExceptions) - { + for (const OUString& exc : attr.getExceptions) { if (seen->insert(exc).second) { dumpCppuGetType(out, exc); } } - for (const OUString& exc : attr.setExceptions) - { + for (const OUString& exc : attr.setExceptions) { if (seen->insert(exc).second) { dumpCppuGetType(out, exc); } @@ -1559,10 +1578,8 @@ void InterfaceType::dumpMethodsCppuDecl( FileStream & out, std::set< OUString > * seen) { assert(seen != nullptr); - for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) - { - for (const OUString& ex : method.exceptions) - { + for (const unoidl::InterfaceTypeEntity::Method& method : entity_->getDirectMethods()) { + for (const OUString& ex : method.exceptions) { if (seen->insert(ex).second) { dumpCppuGetType(out, ex); } @@ -1583,8 +1600,7 @@ sal_Int32 InterfaceType::dumpExceptionTypeNames( std::vector< OUString > const & exceptions, bool runtimeException) { sal_Int32 count = 0; - for (const OUString& ex : exceptions) - { + for (const OUString& ex : exceptions) { if (ex != "com.sun.star.uno.RuntimeException") { dumpExceptionTypeName(out, prefix, count++, ex); } @@ -1604,15 +1620,19 @@ sal_Int32 InterfaceType::dumpExceptionTypeNames( return count; } -class ConstantGroup: public CppuType { +class ConstantGroup: public CppuType +{ public: ConstantGroup( rtl::Reference< unoidl::ConstantGroupEntity > const & entity, OUString const & name, rtl::Reference< TypeManager > const & typeMgr): - CppuType(name, typeMgr), entity_(entity) - { assert(entity.is()); } + CppuType(name, typeMgr), entity_(entity) { + assert(entity.is()); + } - bool hasConstants() const { return !entity_->getMembers().empty(); } + bool hasConstants() const { + return !entity_->getMembers().empty(); + } private: virtual void dumpHdlFile( @@ -1655,9 +1675,9 @@ void ConstantGroup::dumpHppFile( out << "\n#endif // "<< headerDefine << "\n"; } -void ConstantGroup::dumpDeclaration(FileStream & out) { - for (const unoidl::ConstantGroupEntity::Member& member : entity_->getMembers()) - { +void ConstantGroup::dumpDeclaration(FileStream & out) +{ + for (const unoidl::ConstantGroupEntity::Member& member : entity_->getMembers()) { out << "static const "; switch (member.value.type) { case unoidl::ConstantValue::TYPE_BOOLEAN: @@ -1744,24 +1764,28 @@ void ConstantGroup::dumpDeclaration(FileStream & out) { } } -void dumpTypeParameterName(FileStream & out, OUString const & name) { +void dumpTypeParameterName(FileStream & out, OUString const & name) +{ // Prefix all type parameters with "typeparam_" to avoid problems when a // struct member has the same name as a type parameter, as in // struct<T> { T T; }; out << "typeparam_" << name; } -class PlainStructType: public CppuType { +class PlainStructType: public CppuType +{ public: PlainStructType( rtl::Reference< unoidl::PlainStructTypeEntity > const & entity, OUString const & name, rtl::Reference< TypeManager > const & typeMgr): - CppuType(name, typeMgr), entity_(entity) - { assert(entity.is()); } + CppuType(name, typeMgr), entity_(entity) { + assert(entity.is()); + } private: - virtual sal_uInt32 checkInheritedMemberCount() const override - { return getTotalMemberCount(entity_->getDirectBase()); } + virtual sal_uInt32 checkInheritedMemberCount() const override { + return getTotalMemberCount(entity_->getDirectBase()); + } virtual void dumpDeclaration(FileStream& o) override; @@ -1790,7 +1814,8 @@ private: rtl::Reference< unoidl::PlainStructTypeEntity > entity_; }; -void PlainStructType::dumpDeclaration(FileStream & out) { +void PlainStructType::dumpDeclaration(FileStream & out) +{ out << "\n#ifdef SAL_W32\n# pragma pack(push, 8)\n#endif\n\n" << indent(); out << "struct SAL_DLLPUBLIC_RTTI "; if (canBeWarnUnused(name_)) @@ -1806,8 +1831,7 @@ void PlainStructType::dumpDeclaration(FileStream & out) { if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) { out << "\n" << indent() << "inline " << id_ << "("; bool bFirst = !dumpBaseMembers(out, base, true); - for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { if (!bFirst) { out << ", "; } @@ -1820,16 +1844,14 @@ void PlainStructType::dumpDeclaration(FileStream & out) { if (!entity_->getDirectMembers().empty()) { out << "\n"; for (std::vector< unoidl::PlainStructTypeEntity::Member >:: - const_iterator i(entity_->getDirectMembers().begin()); - i != entity_->getDirectMembers().end(); ++i) - { + const_iterator i(entity_->getDirectMembers().begin()); + i != entity_->getDirectMembers().end(); ++i) { out << indent(); dumpType(out, i->type); out << " " << i->name; if (i == entity_->getDirectMembers().begin() && !base.isEmpty() && i->type != "hyper" && i->type != "unsigned hyper" - && i->type != "double") - { + && i->type != "double") { out << " CPPU_GCC3_ALIGN(" << codemaker::cpp::scopedCppName(u2b(base)) << ")"; } @@ -1859,8 +1881,7 @@ void PlainStructType::dumpHppFile( << "()\n"; bFirst = false; } - for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { out << indent() << (bFirst ? ":" : ",") << " " << member.name; dumpInitializer(out, false, member.type); out << "\n"; @@ -1872,8 +1893,7 @@ void PlainStructType::dumpHppFile( out << "inline " << id_; out << "::" << id_ << "("; bFirst = !dumpBaseMembers(out, base, true); - for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { if (!bFirst) { out << ", "; } @@ -1891,8 +1911,7 @@ void PlainStructType::dumpHppFile( out << ")\n"; bFirst = false; } - for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { out << indent() << (bFirst ? ":" : ",") << " " << member.name << "(" << member.name << "_)\n"; bFirst = false; @@ -1911,8 +1930,7 @@ void PlainStructType::dumpHppFile( << ">(the_lhs), static_cast< " << codemaker::cpp::scopedCppName(u2b(base)) << ">(the_rhs) )\n"; bFirst = false; } - for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { if (!bFirst) out << "\n" << indent() << indent() << "&& "; out << "the_lhs." << member.name << " == the_rhs." << member.name; @@ -1935,7 +1953,8 @@ void PlainStructType::dumpHppFile( out << "\n#endif // "<< headerDefine << "\n"; } -void PlainStructType::dumpLightGetCppuType(FileStream & out) { +void PlainStructType::dumpLightGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << ("//TODO: On certain platforms with weak memory models, the" @@ -1953,7 +1972,8 @@ void PlainStructType::dumpLightGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void PlainStructType::dumpNormalGetCppuType(FileStream & out) { +void PlainStructType::dumpNormalGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << ("//TODO: On certain platforms with weak memory models, the" @@ -1968,8 +1988,7 @@ void PlainStructType::dumpNormalGetCppuType(FileStream & out) { inc(); for (std::vector< unoidl::PlainStructTypeEntity::Member >::const_iterator i( entity_->getDirectMembers().begin()); - i != entity_->getDirectMembers().end();) - { + i != entity_->getDirectMembers().end();) { out << indent() << "::cppu::UnoType< "; dumpType(out, i->type, false, false, false, true); ++i; @@ -1993,7 +2012,8 @@ void PlainStructType::dumpNormalGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out) { +void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out) +{ OUString staticTypeClass("the" + id_ + "Type"); codemaker::cppumaker::dumpNamespaceOpen(out, name_, false); out << " namespace detail {\n\n" << indent() << "struct " @@ -2007,13 +2027,11 @@ void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out) { out << indent() << "::rtl::OUString the_name( \"" << name_ << "\" );\n"; std::map< OUString, sal_uInt32 > types; std::vector< unoidl::PlainStructTypeEntity::Member >::size_type n = 0; - for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { if (types.insert( std::map< OUString, sal_uInt32 >::value_type( member.type, static_cast< sal_uInt32 >(types.size()))). - second) - { + second) { dumpCppuGetType(out, member.type, &name_); // For typedefs, use the resolved type name, as there will be no // information available about the typedef itself at runtime (the @@ -2032,8 +2050,7 @@ void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out) { n = 0; for (std::vector< unoidl::PlainStructTypeEntity::Member >::const_iterator i( entity_->getDirectMembers().begin()); - i != entity_->getDirectMembers().end();) - { + i != entity_->getDirectMembers().end();) { out << indent() << "{ { " << getTypeClass(i->type, true) << ", the_tname" << types.find(i->type)->second << ".pData, the_name" << n++ << ".pData }, false }"; @@ -2086,8 +2103,7 @@ bool PlainStructType::dumpBaseMembers( return false; } hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType); - for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers()) - { + for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers()) { if (hasMember) { out << ", "; } @@ -2135,7 +2151,8 @@ void PlainStructType::addComprehensiveGetCppuTypeIncludes( includes.addTypelibTypedescriptionH(); } -sal_uInt32 PlainStructType::getTotalMemberCount(OUString const & base) const { +sal_uInt32 PlainStructType::getTotalMemberCount(OUString const & base) const +{ if (base.isEmpty()) { return 0; } @@ -2152,17 +2169,19 @@ sal_uInt32 PlainStructType::getTotalMemberCount(OUString const & base) const { return 0; } return getTotalMemberCount(ent2->getDirectBase()) - + ent2->getDirectMembers().size(); //TODO: overflow + + ent2->getDirectMembers().size(); //TODO: overflow } -class PolyStructType: public CppuType { +class PolyStructType: public CppuType +{ public: PolyStructType( rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > const & - entity, + entity, OUString const & name, rtl::Reference< TypeManager > const & typeMgr): - CppuType(name, typeMgr), entity_(entity) - { assert(entity.is()); } + CppuType(name, typeMgr), entity_(entity) { + assert(entity.is()); + } private: virtual void dumpDeclaration(FileStream& o) override; @@ -2184,7 +2203,9 @@ private: virtual void addComprehensiveGetCppuTypeIncludes( codemaker::cppumaker::Includes & includes) const override; - virtual bool isPolymorphic() const override { return true; } + virtual bool isPolymorphic() const override { + return true; + } virtual void dumpTemplateHead(FileStream & out) const override; @@ -2193,7 +2214,8 @@ private: rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > entity_; }; -void PolyStructType::dumpDeclaration(FileStream & out) { +void PolyStructType::dumpDeclaration(FileStream & out) +{ out << "\n#ifdef SAL_W32\n# pragma pack(push, 8)\n#endif\n\n" << indent(); dumpTemplateHead(out); out << "struct SAL_DLLPUBLIC_RTTI " << id_ << " {\n"; @@ -2202,10 +2224,9 @@ void PolyStructType::dumpDeclaration(FileStream & out) { if (!entity_->getMembers().empty()) { out << "\n" << indent() << "inline " << id_ << "("; for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + unoidl::PolymorphicStructTypeTemplateEntity::Member >:: + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { if (i != entity_->getMembers().begin()) { out << ", "; } @@ -2220,8 +2241,7 @@ void PolyStructType::dumpDeclaration(FileStream & out) { out << ");\n\n"; // print the member fields for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : - entity_->getMembers()) - { + entity_->getMembers()) { out << indent(); if (member.parameterized) { dumpTypeParameterName(out, member.type); @@ -2253,9 +2273,8 @@ void PolyStructType::dumpHppFile( out << "::" << id_ << "()\n"; inc(); for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { out << indent() << (i == entity_->getMembers().begin() ? ":" : ",") << " " << i->name; dumpInitializer(out, i->parameterized, i->type); @@ -2270,10 +2289,9 @@ void PolyStructType::dumpHppFile( dumpTemplateParameters(out); out << "::" << id_ << "("; for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + unoidl::PolymorphicStructTypeTemplateEntity::Member >:: + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { if (i != entity_->getMembers().begin()) { out << ", "; } @@ -2288,10 +2306,9 @@ void PolyStructType::dumpHppFile( out << ")\n"; inc(); for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + unoidl::PolymorphicStructTypeTemplateEntity::Member >:: + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { out << indent() << (i == entity_->getMembers().begin() ? ":" : ",") << " " << i->name << "(" << i->name << "_)\n"; } @@ -2303,10 +2320,9 @@ void PolyStructType::dumpHppFile( dumpTemplateParameters(out); out << "\n" << indent() << "make_" << id_ << "("; for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + unoidl::PolymorphicStructTypeTemplateEntity::Member >:: + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { if (i != entity_->getMembers().begin()) { out << ", "; } @@ -2324,10 +2340,9 @@ void PolyStructType::dumpHppFile( dumpTemplateParameters(out); out << "("; for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + unoidl::PolymorphicStructTypeTemplateEntity::Member >:: + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { if (i != entity_->getMembers().begin()) { out << ", "; } @@ -2348,8 +2363,7 @@ void PolyStructType::dumpHppFile( inc(); out << indent() << "return "; bool bFirst = true; - for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity_->getMembers()) - { + for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity_->getMembers()) { if (!bFirst) out << "\n" << indent() << indent() << "&& "; out << "the_lhs." << member.name << " == the_rhs." << member.name; @@ -2377,7 +2391,8 @@ void PolyStructType::dumpHppFile( out << "\n#endif // "<< headerDefine << "\n"; } -void PolyStructType::dumpLightGetCppuType(FileStream & out) { +void PolyStructType::dumpLightGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << ("//TODO: On certain platforms with weak memory models, the" @@ -2391,8 +2406,7 @@ void PolyStructType::dumpLightGetCppuType(FileStream & out) { << "<\");\n"; for (std::vector< OUString >::const_iterator i( entity_->getTypeParameters().begin()); - i != entity_->getTypeParameters().end();) - { + i != entity_->getTypeParameters().end();) { out << indent() << ("the_buffer.append(::rtl::OUStringToOString(" "::cppu::getTypeFavourChar(static_cast< "); @@ -2412,7 +2426,8 @@ void PolyStructType::dumpLightGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void PolyStructType::dumpNormalGetCppuType(FileStream & out) { +void PolyStructType::dumpNormalGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << ("//TODO: On certain platforms with weak memory models, the" @@ -2426,8 +2441,7 @@ void PolyStructType::dumpNormalGetCppuType(FileStream & out) { << "<\");\n"; for (std::vector< OUString >::const_iterator i( entity_->getTypeParameters().begin()); - i != entity_->getTypeParameters().end();) - { + i != entity_->getTypeParameters().end();) { out << indent() << ("the_buffer.append(::rtl::OUStringToOString(" "::cppu::getTypeFavourChar(static_cast< "); @@ -2442,9 +2456,8 @@ void PolyStructType::dumpNormalGetCppuType(FileStream & out) { << "::typelib_TypeDescriptionReference * the_members[] = {\n"; inc(); for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end();) - { + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end();) { out << indent(); if (i->parameterized) { out << "::cppu::getTypeFavourChar(static_cast< "; @@ -2462,9 +2475,8 @@ void PolyStructType::dumpNormalGetCppuType(FileStream & out) { dec(); out << indent() << "static ::sal_Bool const the_parameterizedTypes[] = { "; for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end(); ++i) - { + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end(); ++i) { if (i != entity_->getMembers().begin()) { out << ", "; } @@ -2482,7 +2494,8 @@ void PolyStructType::dumpNormalGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) { +void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) +{ out << "namespace cppu { namespace detail {\n\n" << indent(); dumpTemplateHead(out); OUString staticTypeClass("the" + id_ + "Type"); @@ -2499,8 +2512,7 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) { << "the_buffer.append(\"" << name_ << "<\");\n"; for (std::vector< OUString >::const_iterator i( entity_->getTypeParameters().begin()); - i != entity_->getTypeParameters().end();) - { + i != entity_->getTypeParameters().end();) { out << indent() << "the_buffer.append(::cppu::getTypeFavourChar(static_cast< "; dumpTypeParameterName(out, *i); @@ -2518,15 +2530,13 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) { std::map< OUString, sal_uInt32 > parameters; std::map< OUString, sal_uInt32 > types; std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - size_type n = 0; - for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity_->getMembers()) - { + size_type n = 0; + for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity_->getMembers()) { if (member.parameterized) { if (parameters.insert( std::map< OUString, sal_uInt32 >::value_type( member.type, static_cast< sal_uInt32 >(parameters.size()))). - second) - { + second) { sal_uInt32 k = static_cast< sal_uInt32 >(parameters.size() - 1); out << indent() << "::css::uno::Type const & the_ptype" << k @@ -2542,8 +2552,7 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) { } else if (types.insert( std::map< OUString, sal_uInt32 >::value_type( member.type, static_cast< sal_uInt32 >(types.size()))). - second) - { + second) { dumpCppuGetType(out, member.type, &name_); // For typedefs, use the resolved type name, as there will be no // information available about the typedef itself at runtime (the @@ -2561,9 +2570,8 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) { inc(); n = 0; for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(entity_->getMembers().begin()); - i != entity_->getMembers().end();) - { + const_iterator i(entity_->getMembers().begin()); + i != entity_->getMembers().end();) { out << indent() << "{ { "; if (i->parameterized) { sal_uInt32 k = parameters.find(i->type)->second; @@ -2639,12 +2647,12 @@ void PolyStructType::addComprehensiveGetCppuTypeIncludes( includes.addRtlUstrbufHxx(); } -void PolyStructType::dumpTemplateHead(FileStream & out) const { +void PolyStructType::dumpTemplateHead(FileStream & out) const +{ out << "template< "; for (std::vector< OUString >::const_iterator i( entity_->getTypeParameters().begin()); - i != entity_->getTypeParameters().end(); ++i) - { + i != entity_->getTypeParameters().end(); ++i) { if (i != entity_->getTypeParameters().begin()) { out << ", "; } @@ -2654,12 +2662,12 @@ void PolyStructType::dumpTemplateHead(FileStream & out) const { out << " > "; } -void PolyStructType::dumpTemplateParameters(FileStream & out) const { +void PolyStructType::dumpTemplateParameters(FileStream & out) const +{ out << "< "; for (std::vector< OUString >::const_iterator i( entity_->getTypeParameters().begin()); - i != entity_->getTypeParameters().end(); ++i) - { + i != entity_->getTypeParameters().end(); ++i) { if (i != entity_->getTypeParameters().begin()) { out << ", "; } @@ -2668,7 +2676,8 @@ void PolyStructType::dumpTemplateParameters(FileStream & out) const { out << " >"; } -OUString typeToIdentifier(OUString const & name) { +OUString typeToIdentifier(OUString const & name) +{ sal_Int32 k; OUString n(b2u(codemaker::UnoType::decompose(u2b(name), &k))); OUStringBuffer b; @@ -2684,13 +2693,15 @@ OUString typeToIdentifier(OUString const & name) { return b.makeStringAndClear(); } -class ExceptionType: public CppuType { +class ExceptionType: public CppuType +{ public: ExceptionType( rtl::Reference< unoidl::ExceptionTypeEntity > const & entity, OUString const & name, rtl::Reference< TypeManager > const & typeMgr): - CppuType(name, typeMgr), entity_(entity) - { assert(entity.is()); } + CppuType(name, typeMgr), entity_(entity) { + assert(entity.is()); + } private: virtual void dumpHppFile( @@ -2705,8 +2716,9 @@ private: virtual void dumpComprehensiveGetCppuType(FileStream & out) override; - virtual sal_uInt32 checkInheritedMemberCount() const override - { return getTotalMemberCount(entity_->getDirectBase()); } + virtual sal_uInt32 checkInheritedMemberCount() const override { + return getTotalMemberCount(entity_->getDirectBase()); + } virtual void dumpDeclaration(FileStream & out) override; @@ -2746,8 +2758,7 @@ void ExceptionType::dumpHppFile( << "()\n"; bFirst = false; } - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { out << indent() << (bFirst ? ":" : ",") << " "; out << member.name; dumpInitializer(out, false, member.type); @@ -2768,8 +2779,7 @@ void ExceptionType::dumpHppFile( if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) { out << indent() << "inline " << id_ << "::" << id_ << "("; bFirst = !dumpBaseMembers(out, base, true, false); - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { if (!bFirst) { out << ", "; } @@ -2787,8 +2797,7 @@ void ExceptionType::dumpHppFile( out << ")\n"; bFirst = false; } - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { out << indent() << (bFirst ? ":" : ",") << " " << member.name << "(" << member.name << "_)\n"; bFirst = false; @@ -2813,8 +2822,7 @@ void ExceptionType::dumpHppFile( << "(the_other)"; bFirst = false; } - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { out << (bFirst ? ":" : ",") << " " << member.name << "(the_other." << member.name << ")"; bFirst = false; @@ -2830,8 +2838,7 @@ void ExceptionType::dumpHppFile( out << indent() << codemaker::cpp::scopedCppName(u2b(base)) << "::operator =(the_other);\n"; } - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { out << indent() << member.name << " = the_other." << member.name << ";\n"; } out << indent() << "return *this;\n"; @@ -2845,7 +2852,8 @@ void ExceptionType::dumpHppFile( out << "\n#endif // "<< headerDefine << "\n"; } -void ExceptionType::dumpLightGetCppuType(FileStream & out) { +void ExceptionType::dumpLightGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << "static typelib_TypeDescriptionReference * the_type = 0;\n" @@ -2860,7 +2868,8 @@ void ExceptionType::dumpLightGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void ExceptionType::dumpNormalGetCppuType(FileStream & out) { +void ExceptionType::dumpNormalGetCppuType(FileStream & out) +{ dumpGetCppuTypePreamble(out); out << indent() << "static typelib_TypeDescriptionReference * the_type = 0;\n" @@ -2884,8 +2893,7 @@ void ExceptionType::dumpNormalGetCppuType(FileStream & out) { << entity_->getDirectMembers().size() << "];\n"; std::set< OUString > seen; std::vector< unoidl::ExceptionTypeEntity::Member >::size_type n = 0; - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { OUString type(resolveAllTypedefs(member.type)); OUString modType(typeToIdentifier(type)); if (seen.insert(type).second) { @@ -2920,7 +2928,8 @@ void ExceptionType::dumpNormalGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void ExceptionType::dumpComprehensiveGetCppuType(FileStream & out) { +void ExceptionType::dumpComprehensiveGetCppuType(FileStream & out) +{ codemaker::cppumaker::dumpNamespaceOpen(out, name_, false); out << " namespace detail {\n\n"; OUString staticTypeClass("the" + id_ + "Type"); @@ -2943,8 +2952,7 @@ void ExceptionType::dumpComprehensiveGetCppuType(FileStream & out) { out << " >::get();\n"; } std::set< OUString > seen; - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { if (seen.insert(member.type).second) { dumpCppuGetType(out, member.type); } @@ -2953,8 +2961,7 @@ void ExceptionType::dumpComprehensiveGetCppuType(FileStream & out) { out << "\n" << indent() << "typelib_CompoundMember_Init aMembers[" << entity_->getDirectMembers().size() << "];\n"; std::vector< unoidl::ExceptionTypeEntity::Member >::size_type n = 0; - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { OUString type(resolveAllTypedefs(member.type)); out << indent() << "::rtl::OUString sMemberType" << n << "( \"" << type << "\" );\n" << indent() @@ -2995,7 +3002,8 @@ void ExceptionType::dumpComprehensiveGetCppuType(FileStream & out) { dumpGetCppuTypePostamble(out); } -void ExceptionType::dumpDeclaration(FileStream & out) { +void ExceptionType::dumpDeclaration(FileStream & out) +{ out << "\nclass CPPU_GCC_DLLPUBLIC_EXPORT " << id_; OUString base(entity_->getDirectBase()); if (!base.isEmpty()) { @@ -3009,8 +3017,7 @@ void ExceptionType::dumpDeclaration(FileStream & out) { out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_ << "("; bool eligibleForDefaults = entity_->getDirectMembers().empty(); bool bFirst = !dumpBaseMembers(out, base, true, eligibleForDefaults); - for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) { if (!bFirst) { out << ", "; } @@ -3027,15 +3034,13 @@ void ExceptionType::dumpDeclaration(FileStream & out) { << " & operator =(" << id_ << " const &);\n#endif\n\n"; for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i( entity_->getDirectMembers().begin()); - i != entity_->getDirectMembers().end(); ++i) - { + i != entity_->getDirectMembers().end(); ++i) { out << indent(); dumpType(out, i->type); out << " " << i->name; if (i == entity_->getDirectMembers().begin() && !base.isEmpty() && i->type != "hyper" && i->type != "unsigned hyper" - && i->type != "double") - { + && i->type != "double") { out << " CPPU_GCC3_ALIGN( " << codemaker::cpp::scopedCppName(u2b(base)) << " )"; } @@ -3063,10 +3068,9 @@ bool ExceptionType::dumpBaseMembers( return false; } hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType, - eligibleForDefaults && ent2->getDirectMembers().empty() ); + eligibleForDefaults && ent2->getDirectMembers().empty() ); int memberCount = 0; - for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers()) - { + for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers()) { if (hasMember) { out << ", "; } @@ -3079,10 +3083,10 @@ bool ExceptionType::dumpBaseMembers( // constructors, since most of the time we don't pass a Context object in to the exception // throw sites. if (eligibleForDefaults - && base == "com.sun.star.uno.Exception" - && memberCount == 1 - && member.name == "Context" - && member.type == "com.sun.star.uno.XInterface") { + && base == "com.sun.star.uno.Exception" + && memberCount == 1 + && member.name == "Context" + && member.type == "com.sun.star.uno.XInterface") { out << " = ::css::uno::Reference< ::css::uno::XInterface >()"; } hasMember = true; @@ -3092,7 +3096,8 @@ bool ExceptionType::dumpBaseMembers( return hasMember; } -sal_uInt32 ExceptionType::getTotalMemberCount(OUString const & base) const { +sal_uInt32 ExceptionType::getTotalMemberCount(OUString const & base) const +{ if (base.isEmpty()) { return 0; } @@ -3105,16 +3110,18 @@ sal_uInt32 ExceptionType::getTotalMemberCount(OUString const & base) const { unoidl::ExceptionTypeEntity& ent2( dynamic_cast< unoidl::ExceptionTypeEntity&>(*ent.get())); return getTotalMemberCount(ent2.getDirectBase()) - + ent2.getDirectMembers().size(); //TODO: overflow + + ent2.getDirectMembers().size(); //TODO: overflow } -class EnumType: public CppuType { +class EnumType: public CppuType +{ public: EnumType( rtl::Reference< unoidl::EnumTypeEntity > const & entity, OUString const & name, rtl::Reference< TypeManager > const & typeMgr): - CppuType(name, typeMgr), entity_(entity) - { assert(entity.is()); } + CppuType(name, typeMgr), entity_(entity) { + assert(entity.is()); + } private: virtual void dumpDeclaration(FileStream& o) override; @@ -3139,11 +3146,14 @@ void EnumType::addComprehensiveGetCppuTypeIncludes( void EnumType::dumpDeclaration(FileStream& o) { + o << "\n#if defined LIBO_INTERNAL_ONLY\n"; + o << "\nenum class SAL_DLLPUBLIC_RTTI " << id_ << "\n{\n"; + o << "\n#else\n"; o << "\nenum SAL_DLLPUBLIC_RTTI " << id_ << "\n{\n"; + o << "\n#endif\n"; inc(); - for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) - { + for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) { o << indent() << id_ << "_" << u2b(member.name) << " = " << member.value << ",\n"; } @@ -3152,6 +3162,16 @@ void EnumType::dumpDeclaration(FileStream& o) dec(); o << "};\n\n"; + + // use constexpr to create a kind of type-alias so we don't have to modify existing code + o << "#if defined LIBO_INTERNAL_ONLY\n"; + for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) { + o << "constexpr auto " << id_ << "_" << u2b(member.name) + << " = " + << id_ << "::" << id_ << "_" << u2b(member.name) + << ";\n"; + } + o << "#endif\n"; } void EnumType::dumpHppFile( @@ -3218,8 +3238,7 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o) o << indent() << "rtl_uString* enumValueNames[" << entity_->getMembers().size() << "];\n"; std::vector< unoidl::EnumTypeEntity::Member >::size_type n = 0; - for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) - { + for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) { o << indent() << "::rtl::OUString sEnumValue" << n << "( \"" << u2b(member.name) << "\" );\n"; o << indent() << "enumValueNames[" << n << "] = sEnumValue" << n @@ -3230,8 +3249,7 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o) o << "\n" << indent() << "sal_Int32 enumValues[" << entity_->getMembers().size() << "];\n"; n = 0; - for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) - { + for (const unoidl::EnumTypeEntity::Member& member : entity_->getMembers()) { o << indent() << "enumValues[" << n++ << "] = " << member.value << ";\n"; } @@ -3270,13 +3288,15 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o) dumpGetCppuTypePostamble(o); } -class Typedef: public CppuType { +class Typedef: public CppuType +{ public: Typedef( rtl::Reference< unoidl::TypedefEntity > const & entity, OUString const & name, rtl::Reference< TypeManager > const & typeMgr): - CppuType(name, typeMgr), entity_(entity) - { assert(entity.is()); } + CppuType(name, typeMgr), entity_(entity) { + assert(entity.is()); + } private: virtual void dumpDeclaration(FileStream& o) override; @@ -3331,25 +3351,28 @@ void Typedef::dumpHppFile( o << "\n#endif // "<< headerDefine << "\n"; } -class ConstructiveType: public CppuType { +class ConstructiveType: public CppuType +{ public: ConstructiveType( OUString const & name, rtl::Reference< TypeManager > const & manager): CppuType(name, manager) {} private: - virtual void dumpHdlFile(FileStream &, codemaker::cppumaker::Includes &) override - { assert(false); } // this cannot happen + virtual void dumpHdlFile(FileStream &, codemaker::cppumaker::Includes &) override { + assert(false); // this cannot happen + } - virtual void dumpFiles(OUString const & uri, CppuOptions const & options) override - { dumpFile(uri, name_, true, options); } + virtual void dumpFiles(OUString const & uri, CppuOptions const & options) override { + dumpFile(uri, name_, true, options); + } }; bool hasRestParameter( unoidl::SingleInterfaceBasedServiceEntity::Constructor const & constructor) { return !constructor.parameters.empty() - && constructor.parameters.back().rest; + && constructor.parameters.back().rest; } void includeExceptions( @@ -3359,21 +3382,22 @@ void includeExceptions( if (node->present) { includes.add(node->name); } else { - for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children) - { + for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children) { includeExceptions(includes, pChild.get()); } } } -class ServiceType: public ConstructiveType { +class ServiceType: public ConstructiveType +{ public: ServiceType( rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > const & - entity, + entity, OUString const & name, rtl::Reference< TypeManager > const & manager): - ConstructiveType(name, manager), entity_(entity) - { assert(entity.is()); } + ConstructiveType(name, manager), entity_(entity) { + assert(entity.is()); + } private: virtual void dumpHppFile( @@ -3405,8 +3429,7 @@ void ServiceType::dumpHppFile( includes.addRtlUstringHxx(); includes.add("com.sun.star.uno.DeploymentException"); includes.add("com.sun.star.uno.XComponentContext"); - for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor& cons : entity_->getConstructors()) - { + for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor& cons : entity_->getConstructors()) { if (cons.defaultConstructor) { includes.add("com.sun.star.uno.Exception"); includes.add("com.sun.star.uno.RuntimeException"); @@ -3415,21 +3438,18 @@ void ServiceType::dumpHppFile( includes.addAny(); includes.addSequence(); for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter& param : - cons.parameters) - { + cons.parameters) { if (m_typeMgr->getSort( b2u(codemaker::UnoType::decompose( u2b(param.type)))) - == codemaker::UnoType::Sort::Char) - { + == codemaker::UnoType::Sort::Char) { includes.addCppuUnotypeHxx(); break; } } } codemaker::ExceptionTree tree; - for (const OUString& ex : cons.exceptions) - { + for (const OUString& ex : cons.exceptions) { tree.add(u2b(ex), m_typeMgr); } if (!tree.getRoot().present) { @@ -3458,7 +3478,7 @@ void ServiceType::dumpHppFile( << "\nextern \"C\" ::css::uno::XInterface * SAL_CALL LO_URE_CTOR_FUN_" << name_.replaceAll(".", "_dot_") << "(::css::uno::XComponentContext *, ::css::uno::Sequence< " - "::css::uno::Any > const &);\n#endif\n"; + "::css::uno::Any > const &);\n#endif\n"; } o << "\n"; if (codemaker::cppumaker::dumpNamespaceOpen(o, name_, false)) { @@ -3471,8 +3491,7 @@ void ServiceType::dumpHppFile( OString scopedBaseName(codemaker::cpp::scopedCppName(baseName)); o << "public:\n"; for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor& cons : - entity_->getConstructors()) - { + entity_->getConstructors()) { if (cons.defaultConstructor) { o << indent() << "static ::css::uno::Reference< " << scopedBaseName << " > " @@ -3541,8 +3560,7 @@ void ServiceType::dumpHppFile( " the_context"); bool rest = hasRestParameter(cons); for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter& param : - cons.parameters) - { + cons.parameters) { o << ", "; OUStringBuffer buf; if (param.rest) { @@ -3564,11 +3582,10 @@ void ServiceType::dumpHppFile( << ("::css::uno::Sequence< ::css::uno::Any > the_arguments(") << cons.parameters.size() << ");\n"; std::vector< - unoidl::SingleInterfaceBasedServiceEntity::Constructor:: - Parameter >::size_type n = 0; + unoidl::SingleInterfaceBasedServiceEntity::Constructor:: + Parameter >::size_type n = 0; for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter& j : - cons.parameters) - { + cons.parameters) { o << indent() << "the_arguments[" << n++ << "] "; OString param( codemaker::cpp::translateUnoToCppIdentifier( @@ -3580,8 +3597,7 @@ void ServiceType::dumpHppFile( } else if (m_typeMgr->getSort( b2u(codemaker::UnoType::decompose( u2b(j.type), &rank))) - == codemaker::UnoType::Sort::Char) - { + == codemaker::UnoType::Sort::Char) { o << "= ::css::uno::Any(&" << param << ", ::cppu::UnoType< "; for (sal_Int32 k = 0; k < rank; ++k) { @@ -3601,8 +3617,7 @@ void ServiceType::dumpHppFile( o << indent() << "::css::uno::Reference< " << scopedBaseName << " > the_instance;\n"; codemaker::ExceptionTree tree; - for (const OUString& ex : cons.exceptions) - { + for (const OUString& ex : cons.exceptions) { tree.add(u2b(ex), m_typeMgr); } if (!tree.getRoot().present) { @@ -3624,8 +3639,8 @@ void ServiceType::dumpHppFile( << ")(the_context.get(), "; if (rest) { o << codemaker::cpp::translateUnoToCppIdentifier( - u2b(cons.parameters.back().name), "param", - codemaker::cpp::IdentifierTranslationMode::NonGlobal); + u2b(cons.parameters.back().name), "param", + codemaker::cpp::IdentifierTranslationMode::NonGlobal); } else if (cons.parameters.empty()) { o << "::css::uno::Sequence< ::css::uno::Any >()"; } else { @@ -3651,8 +3666,8 @@ void ServiceType::dumpHppFile( << name_ << "\", "; if (rest) { o << codemaker::cpp::translateUnoToCppIdentifier( - u2b(cons.parameters.back().name), "param", - codemaker::cpp::IdentifierTranslationMode::NonGlobal); + u2b(cons.parameters.back().name), "param", + codemaker::cpp::IdentifierTranslationMode::NonGlobal); } else if (cons.parameters.empty()) { o << ("::css::uno::Sequence< ::css::uno::Any >()"); } else { @@ -3713,20 +3728,21 @@ void ServiceType::dumpCatchClauses( out << indent() << "throw;\n"; dec(); } else { - for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children) - { + for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children) { dumpCatchClauses(out, pChild.get()); } } } -class SingletonType: public ConstructiveType { +class SingletonType: public ConstructiveType +{ public: SingletonType( rtl::Reference< unoidl::InterfaceBasedSingletonEntity > const & entity, OUString const & name, rtl::Reference< TypeManager > const & manager): - ConstructiveType(name, manager), entity_(entity) - { assert(entity.is()); } + ConstructiveType(name, manager), entity_(entity) { + assert(entity.is()); + } private: virtual void dumpHppFile( @@ -3766,7 +3782,7 @@ void SingletonType::dumpHppFile( << "\nextern \"C\" ::css::uno::XInterface * SAL_CALL LO_URE_CTOR_FUN_" << name_.replaceAll(".", "_dot_") << "(::css::uno::XComponentContext *, ::css::uno::Sequence< " - "::css::uno::Any > const &);\n#endif\n"; + "::css::uno::Any > const &);\n#endif\n"; o << "\n"; if (codemaker::cppumaker::dumpNamespaceOpen(o, name_, false)) { o << "\n"; @@ -3797,9 +3813,9 @@ void SingletonType::dumpHppFile( << name_.replaceAll(".", "_dot_") << (")(the_context.get(), ::css::uno::Sequence<" " ::css::uno::Any >())), ::SAL_NO_ACQUIRE)," - " ::css::uno::UNO_QUERY);\n#else\n") + " ::css::uno::UNO_QUERY);\n#else\n") << indent() << ("the_context->getValueByName(" - "::rtl::OUString( \"/singletons/") + "::rtl::OUString( \"/singletons/") << name_ << "\" )) >>= instance;\n#endif\n" << indent() << "if (!instance.is()) {\n"; inc(); @@ -3841,106 +3857,96 @@ void produce( rtl::Reference< unoidl::Entity > ent; rtl::Reference< unoidl::MapCursor > cur; switch (manager->getSort(name, &ent, &cur)) { - case codemaker::UnoType::Sort::Module: - { - OUString prefix; - if (!name.isEmpty()) { - prefix = name + "."; - } - for (;;) { - OUString mem; - if (!cur->getNext(&mem).is()) { - break; - } - produce(prefix + mem, manager, generated, options); - } - break; - } - case codemaker::UnoType::Sort::Enum: - { - EnumType t( - dynamic_cast< unoidl::EnumTypeEntity * >(ent.get()), name, - manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::PlainStruct: - { - PlainStructType t( - dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get()), - name, manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::PolymorphicStructTemplate: - { - PolyStructType t( - dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( - ent.get()), - name, manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::Exception: - { - ExceptionType t( - dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get()), name, - manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::Interface: - { - InterfaceType t( - dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()), name, - manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::Typedef: - { - Typedef t( - dynamic_cast< unoidl::TypedefEntity * >(ent.get()), name, - manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::ConstantGroup: - { - ConstantGroup t( - dynamic_cast< unoidl::ConstantGroupEntity * >(ent.get()), name, - manager); - if (t.hasConstants()) { - t.dump(options); + case codemaker::UnoType::Sort::Module: { + OUString prefix; + if (!name.isEmpty()) { + prefix = name + "."; + } + for (;;) { + OUString mem; + if (!cur->getNext(&mem).is()) { + break; } - break; + produce(prefix + mem, manager, generated, options); } - case codemaker::UnoType::Sort::SingleInterfaceBasedService: - { - ServiceType t( - dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >( - ent.get()), - name, manager); - t.dump(options); - t.dumpDependedTypes(generated, options); - break; - } - case codemaker::UnoType::Sort::InterfaceBasedSingleton: - { - SingletonType t( - dynamic_cast< unoidl::InterfaceBasedSingletonEntity * >( - ent.get()), - name, manager); + break; + } + case codemaker::UnoType::Sort::Enum: { + EnumType t( + dynamic_cast< unoidl::EnumTypeEntity * >(ent.get()), name, + manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::PlainStruct: { + PlainStructType t( + dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get()), + name, manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::PolymorphicStructTemplate: { + PolyStructType t( + dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( + ent.get()), + name, manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::Exception: { + ExceptionType t( + dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get()), name, + manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::Interface: { + InterfaceType t( + dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()), name, + manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::Typedef: { + Typedef t( + dynamic_cast< unoidl::TypedefEntity * >(ent.get()), name, + manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::ConstantGroup: { + ConstantGroup t( + dynamic_cast< unoidl::ConstantGroupEntity * >(ent.get()), name, + manager); + if (t.hasConstants()) { t.dump(options); - t.dumpDependedTypes(generated, options); - break; } + break; + } + case codemaker::UnoType::Sort::SingleInterfaceBasedService: { + ServiceType t( + dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >( + ent.get()), + name, manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } + case codemaker::UnoType::Sort::InterfaceBasedSingleton: { + SingletonType t( + dynamic_cast< unoidl::InterfaceBasedSingletonEntity * >( + ent.get()), + name, manager); + t.dump(options); + t.dumpDependedTypes(generated, options); + break; + } case codemaker::UnoType::Sort::AccumulationBasedService: case codemaker::UnoType::Sort::ServiceBasedSingleton: break; |