summaryrefslogtreecommitdiff
path: root/codemaker/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-02-08 08:48:28 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-02-08 08:39:24 +0000
commit55717b14e0482c085595069d124ac9dd0c4e69c5 (patch)
treedd458e7cb4f1d90d01f58553980dad47326274c8 /codemaker/source
parentad24a7c7f4deca8ee7755f68018884300fd861e0 (diff)
Remove newly-unnecessary #includes from cppumaker-generated files
...after e57ca02849c3d87142ff5ff9099a212e72b8139c "Remove dynamic exception specifications" dropped uses of UNO exception types from those generated files. This needed first adapting client code that implicitly depended on those #includes in the generated files it included ("Add missing #includes": 6dce9c6757823b9e89863716ae70ff4e8ddd4e60, a34d9150b419ee7471b96599d877ff1091d6b567, fed3783e77e00635e50622e7229b06c9e25451f1). Change-Id: Ia1defda2d586b69092f53feef3644875192cbea4 Reviewed-on: https://gerrit.libreoffice.org/34014 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'codemaker/source')
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx26
-rw-r--r--codemaker/source/cppumaker/dependencies.cxx48
-rw-r--r--codemaker/source/cppumaker/dependencies.hxx9
-rw-r--r--codemaker/source/cppumaker/includes.cxx54
-rw-r--r--codemaker/source/cppumaker/includes.hxx5
5 files changed, 72 insertions, 70 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 6432baee05d6..659061a8fd34 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -468,7 +468,6 @@ void CppuType::addDefaultHIncludes(codemaker::cppumaker::Includes & includes)
if (m_typeMgr->getSort(name_)
== codemaker::UnoType::Sort::Interface)
{
- includes.addException();
includes.addReference();
}
}
@@ -481,7 +480,6 @@ void CppuType::addDefaultHxxIncludes(codemaker::cppumaker::Includes & includes)
if (m_typeMgr->getSort(name_)
== codemaker::UnoType::Sort::Interface)
{
- includes.addException();
includes.addReference();
}
}
@@ -542,7 +540,9 @@ void CppuType::dumpHFileContent(
addDefaultHIncludes(includes);
dumpHeaderDefine(out, "HDL");
out << "\n";
- includes.dump(out, nullptr);
+ includes.dump(out, nullptr, false);
+ // '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)) {
@@ -1156,7 +1156,7 @@ void InterfaceType::dumpHppFile(
OUString headerDefine(dumpHeaderDefine(out, "HPP"));
out << "\n";
addDefaultHxxIncludes(includes);
- includes.dump(out, &name_);
+ includes.dump(out, &name_, !(m_cppuTypeLeak || m_cppuTypeDynamic));
out << "\n";
dumpGetCppuType(out);
out << "\n::css::uno::Type const & "
@@ -1632,7 +1632,7 @@ void ConstantGroup::dumpHdlFile(
OUString headerDefine(dumpHeaderDefine(out, "HDL"));
out << "\n";
addDefaultHIncludes(includes);
- includes.dump(out, nullptr);
+ includes.dump(out, nullptr, true);
out << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(out, name_, true)) {
out << "\n";
@@ -1845,7 +1845,7 @@ void PlainStructType::dumpHppFile(
{
OUString headerDefine(dumpHeaderDefine(out, "HPP"));
out << "\n";
- includes.dump(out, &name_);
+ includes.dump(out, &name_, true);
out << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(out, name_, false)) {
out << "\n";
@@ -2240,7 +2240,7 @@ void PolyStructType::dumpHppFile(
{
OUString headerDefine(dumpHeaderDefine(out, "HPP"));
out << "\n";
- includes.dump(out, &name_);
+ includes.dump(out, &name_, true);
out << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(out, name_, false)) {
out << "\n";
@@ -2732,7 +2732,7 @@ void ExceptionType::dumpHppFile(
OUString headerDefine(dumpHeaderDefine(out, "HPP"));
out << "\n";
addDefaultHxxIncludes(includes);
- includes.dump(out, &name_);
+ includes.dump(out, &name_, true);
out << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(out, name_, false)) {
out << "\n";
@@ -3161,7 +3161,7 @@ void EnumType::dumpHppFile(
o << "\n";
addDefaultHxxIncludes(includes);
- includes.dump(o, &name_);
+ includes.dump(o, &name_, true);
o << "\n";
dumpGetCppuType(o);
@@ -3295,7 +3295,7 @@ void Typedef::dumpHdlFile(
o << "\n";
addDefaultHIncludes(includes);
- includes.dump(o, nullptr);
+ includes.dump(o, nullptr, true);
o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, name_, false)) {
@@ -3325,7 +3325,7 @@ void Typedef::dumpHppFile(
o << "\n";
addDefaultHxxIncludes(includes);
- includes.dump(o, &name_);
+ includes.dump(o, &name_, true);
o << "\n";
o << "\n#endif // "<< headerDefine << "\n";
@@ -3445,7 +3445,7 @@ void ServiceType::dumpHppFile(
u2b(id_), "service", isGlobal()));
OUString headerDefine(dumpHeaderDefine(o, "HPP"));
o << "\n";
- includes.dump(o, nullptr);
+ includes.dump(o, nullptr, true);
if (!entity_->getConstructors().empty()) {
o << ("\n#if defined ANDROID || defined IOS //TODO\n"
"#include <com/sun/star/lang/XInitialization.hpp>\n"
@@ -3754,7 +3754,7 @@ void SingletonType::dumpHppFile(
includes.addReference();
includes.addRtlUstringH();
includes.addRtlUstringHxx();
- includes.dump(o, nullptr);
+ includes.dump(o, nullptr, true);
o << ("\n#if defined ANDROID || defined IOS //TODO\n"
"#include <com/sun/star/lang/XInitialization.hpp>\n"
"#include <osl/detail/component-defines.h>\n#endif\n\n"
diff --git a/codemaker/source/cppumaker/dependencies.cxx b/codemaker/source/cppumaker/dependencies.cxx
index 00c333d23460..c4a224f1f69e 100644
--- a/codemaker/source/cppumaker/dependencies.cxx
+++ b/codemaker/source/cppumaker/dependencies.cxx
@@ -59,11 +59,11 @@ Dependencies::Dependencies(
rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
static_cast< unoidl::PlainStructTypeEntity * >(ent.get()));
if (!ent2->getDirectBase().isEmpty()) {
- insert(ent2->getDirectBase());
+ insert(ent2->getDirectBase(), KIND_NORMAL);
}
for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers())
{
- insert(member.type);
+ insert(member.type, KIND_NORMAL);
}
break;
}
@@ -75,7 +75,7 @@ Dependencies::Dependencies(
for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : ent2->getMembers())
{
if (!member.parameterized) {
- insert(member.type);
+ insert(member.type, KIND_NORMAL);
}
}
break;
@@ -85,11 +85,11 @@ Dependencies::Dependencies(
rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
static_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
if (!ent2->getDirectBase().isEmpty()) {
- insert(ent2->getDirectBase());
+ insert(ent2->getDirectBase(), KIND_NORMAL);
}
for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers())
{
- insert(member.type);
+ insert(member.type, KIND_NORMAL);
}
break;
}
@@ -99,41 +99,43 @@ Dependencies::Dependencies(
static_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
for (const unoidl::AnnotatedReference& ar : ent2->getDirectMandatoryBases())
{
- insert(ar.name, true);
+ insert(ar.name, KIND_BASE);
}
if (!(ent2->getDirectAttributes().empty()
&& ent2->getDirectMethods().empty()))
{
- insert("com.sun.star.uno.RuntimeException");
+ insert("com.sun.star.uno.RuntimeException", KIND_EXCEPTION);
}
for (const unoidl::InterfaceTypeEntity::Attribute& attr : ent2->getDirectAttributes())
{
- insert(attr.type);
+ insert(attr.type, KIND_NORMAL);
for (const OUString& ex : attr.getExceptions)
{
- insert(ex);
+ insert(ex, KIND_EXCEPTION);
}
for (const OUString& ex : attr.setExceptions)
{
- insert(ex);
+ insert(ex, KIND_EXCEPTION);
}
}
for (const unoidl::InterfaceTypeEntity::Method& method : ent2->getDirectMethods())
{
- insert(method.returnType);
+ insert(method.returnType, KIND_NORMAL);
for (const unoidl::InterfaceTypeEntity::Method::Parameter& param : method.parameters)
{
- insert(param.type);
+ insert(param.type, KIND_NORMAL);
}
for (const OUString& ex : method.exceptions)
{
- insert(ex);
+ insert(ex, KIND_EXCEPTION);
}
}
break;
}
case UnoType::Sort::Typedef:
- insert(static_cast< unoidl::TypedefEntity * >(ent.get())->getType());
+ insert(
+ static_cast< unoidl::TypedefEntity * >(ent.get())->getType(),
+ KIND_NORMAL);
break;
case UnoType::Sort::ConstantGroup:
{
@@ -182,21 +184,21 @@ Dependencies::Dependencies(
static_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
ent.get()));
if (!ent2->getConstructors().empty()) {
- insert(ent2->getBase());
+ insert(ent2->getBase(), KIND_NORMAL);
}
for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor& cons : ent2->getConstructors())
{
for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter& param
: cons.parameters)
{
- insert(param.type);
+ insert(param.type, KIND_NORMAL);
if (param.rest) {
m_sequenceDependency = true;
}
}
for (const OUString& ex : cons.exceptions)
{
- insert(ex);
+ insert(ex, KIND_EXCEPTION);
}
}
break;
@@ -204,7 +206,8 @@ Dependencies::Dependencies(
case UnoType::Sort::InterfaceBasedSingleton:
insert(
static_cast< unoidl::InterfaceBasedSingletonEntity * >(ent.get())->
- getBase());
+ getBase(),
+ KIND_NORMAL);
break;
default:
assert(false); // this cannot happen
@@ -213,7 +216,7 @@ Dependencies::Dependencies(
Dependencies::~Dependencies() {}
-void Dependencies::insert(OUString const & name, bool base) {
+void Dependencies::insert(OUString const & name, Kind kind) {
sal_Int32 k;
std::vector< OString > args;
OUString n(b2u(UnoType::decompose(u2b(name), &k, &args)));
@@ -269,7 +272,7 @@ void Dependencies::insert(OUString const & name, bool base) {
case UnoType::Sort::PolymorphicStructTemplate:
for (const OString& arg : args)
{
- insert(b2u(arg));
+ insert(b2u(arg), KIND_NORMAL);
}
SAL_FALLTHROUGH;
case UnoType::Sort::Sequence:
@@ -281,8 +284,9 @@ void Dependencies::insert(OUString const & name, bool base) {
{
std::pair< Map::iterator, bool > i(
m_map.insert(
- Map::value_type(n, base ? KIND_BASE : KIND_NO_BASE)));
- if (!i.second && base) {
+ Map::value_type(n, kind)));
+ if (!i.second && kind == KIND_BASE) {
+ assert(i.first->second != KIND_EXCEPTION);
i.first->second = KIND_BASE;
}
break;
diff --git a/codemaker/source/cppumaker/dependencies.hxx b/codemaker/source/cppumaker/dependencies.hxx
index e1513a3250cc..2434ce953223 100644
--- a/codemaker/source/cppumaker/dependencies.hxx
+++ b/codemaker/source/cppumaker/dependencies.hxx
@@ -41,10 +41,11 @@ namespace codemaker { namespace cppumaker {
class Dependencies {
public:
/**
- Flags to distinguish whether or not one entity depends on another entity
- because the second is a direct base of the first.
+ Flags to distinguish whether one entity depends on another entity because
+ the second is a direct base of the first or an exception thrown by the
+ first.
*/
- enum Kind { KIND_NO_BASE, KIND_BASE };
+ enum Kind { KIND_NORMAL, KIND_BASE, KIND_EXCEPTION };
typedef std::map< rtl::OUString, Kind > Map;
@@ -97,7 +98,7 @@ public:
bool hasSequenceDependency() const { return m_sequenceDependency; }
private:
- void insert(rtl::OUString const & name, bool base = false);
+ void insert(rtl::OUString const & name, Kind kind);
rtl::Reference< TypeManager > m_manager;
Map m_map;
diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx
index d699996a0df3..7ab37166ec61 100644
--- a/codemaker/source/cppumaker/includes.cxx
+++ b/codemaker/source/cppumaker/includes.cxx
@@ -41,7 +41,7 @@ Includes::Includes(
rtl::Reference< TypeManager > const & manager,
codemaker::cppumaker::Dependencies const & dependencies, bool hpp):
m_manager(manager), m_map(dependencies.getMap()), m_hpp(hpp),
- m_includeCassert(false), m_includeException(false),
+ m_includeCassert(false),
m_includeAny(dependencies.hasAnyDependency()), m_includeReference(false),
m_includeSequence(dependencies.hasSequenceDependency()),
m_includeType(dependencies.hasTypeDependency()),
@@ -112,7 +112,7 @@ void Includes::add(OString const & entityName) {
case codemaker::UnoType::Sort::Interface:
case codemaker::UnoType::Sort::Typedef:
m_map.insert(
- Dependencies::Map::value_type(n, Dependencies::KIND_NO_BASE));
+ Dependencies::Map::value_type(n, Dependencies::KIND_NORMAL));
break;
default:
throw CannotDumpException(
@@ -133,7 +133,9 @@ void dumpEmptyLineBeforeFirst(FileStream & out, bool * first) {
}
-void Includes::dump(FileStream & out, OUString const * companionHdl) {
+void Includes::dump(
+ FileStream & out, OUString const * companionHdl, bool exceptions)
+{
OSL_ASSERT(companionHdl == nullptr || m_hpp);
if (!m_includeReference) {
for (const auto& pair : m_map)
@@ -145,14 +147,8 @@ void Includes::dump(FileStream & out, OUString const * companionHdl) {
}
}
out << "#include \"sal/config.h\"\n";
- if (m_includeCassert || m_includeException) {
- out << "\n";
- if (m_includeCassert) {
- out << "#include <cassert>\n";
- }
- if (m_includeException) {
- out << "#include <exception>\n";
- }
+ if (m_includeCassert) {
+ out << "\n#include <cassert>\n";
}
if (companionHdl) {
out << "\n";
@@ -161,24 +157,26 @@ void Includes::dump(FileStream & out, OUString const * companionHdl) {
bool first = true;
for (const auto& pair : m_map)
{
- dumpEmptyLineBeforeFirst(out, &first);
- if (m_hpp || pair.second == Dependencies::KIND_BASE
- || !isInterfaceType(u2b(pair.first)))
- {
- dumpInclude(out, u2b(pair.first), m_hpp);
- } else {
- bool ns = dumpNamespaceOpen(out, pair.first, false);
- if (ns) {
- out << " ";
- }
- out << "class ";
- dumpTypeIdentifier(out, pair.first);
- out << ";";
- if (ns) {
- out << " ";
+ if (exceptions || pair.second != Dependencies::KIND_EXCEPTION) {
+ dumpEmptyLineBeforeFirst(out, &first);
+ if (m_hpp || pair.second == Dependencies::KIND_BASE
+ || !isInterfaceType(u2b(pair.first)))
+ {
+ dumpInclude(out, u2b(pair.first), m_hpp);
+ } else {
+ bool ns = dumpNamespaceOpen(out, pair.first, false);
+ if (ns) {
+ out << " ";
+ }
+ out << "class ";
+ dumpTypeIdentifier(out, pair.first);
+ out << ";";
+ if (ns) {
+ out << " ";
+ }
+ dumpNamespaceClose(out, pair.first, false);
+ out << "\n";
}
- dumpNamespaceClose(out, pair.first, false);
- out << "\n";
}
}
static char const * hxxExtension[2] = { "h", "hxx" };
diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx
index 2a76529259cd..dd33bcc9b62a 100644
--- a/codemaker/source/cppumaker/includes.hxx
+++ b/codemaker/source/cppumaker/includes.hxx
@@ -40,7 +40,6 @@ public:
void add(OString const & entityName);
void addCassert() { m_includeCassert = true; }
- void addException() { m_includeException = true; }
void addAny() { m_includeAny = true; }
void addReference() { m_includeReference = true; }
void addSequence() { m_includeSequence = true; }
@@ -59,7 +58,8 @@ public:
void addTypelibTypeclassH() { m_includeTypelibTypeclassH = true; }
void addTypelibTypedescriptionH()
{ m_includeTypelibTypedescriptionH = true; }
- void dump(FileStream & out, OUString const * companionHdl);
+ void dump(
+ FileStream & out, OUString const * companionHdl, bool exceptions);
static void dumpInclude(
FileStream & out, OString const & entityName, bool hpp);
@@ -74,7 +74,6 @@ private:
Dependencies::Map m_map;
bool m_hpp;
bool m_includeCassert;
- bool m_includeException;
bool m_includeAny;
bool m_includeReference;
bool m_includeSequence;