summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-05-22 07:53:36 +0200
committerNoel Grandin <noel@peralex.com>2014-05-23 15:05:59 +0200
commitc5d47c327a57df55fa3dac0fff6b65888d0345e4 (patch)
tree0fbcbfc87494f0f65d3b30312a9420f651521750 /codemaker
parent66fc6d223fd086b7611eb8bf3111a55e858bade0 (diff)
add default value for Context param in uno::Exception constructors
and all it's subtypes, which is almost never used, so this allows us to simplify lots of call sites. Change-Id: I0b05793ea2bdd1027679f63252d42ce4af89433b
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx31
1 files changed, 24 insertions, 7 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 3d14ec8ba194..29f4b15bea78 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -24,6 +24,7 @@
#include <map>
#include <set>
#include <vector>
+#include <iostream>
#include "boost/noncopyable.hpp"
#include "rtl/alloc.h"
@@ -2680,7 +2681,8 @@ private:
virtual void dumpDeclaration(FileStream & out) SAL_OVERRIDE;
bool dumpBaseMembers(
- FileStream & out, OUString const & base, bool withType);
+ FileStream & out, OUString const & base, bool withType,
+ bool withDefaults, bool parentsHadDirectMember);
sal_uInt32 getTotalMemberCount(OUString const & base) const;
@@ -2730,7 +2732,7 @@ void ExceptionType::dumpHxxFile(
out << "}\n\n";
if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
out << indent() << "inline " << id_ << "::" << id_ << "(";
- first = !dumpBaseMembers(out, base, true);
+ first = !dumpBaseMembers(out, base, true, false, false);
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator
i(entity_->getDirectMembers().begin());
i != entity_->getDirectMembers().end(); ++i)
@@ -2748,7 +2750,7 @@ void ExceptionType::dumpHxxFile(
if (!base.isEmpty()) {
out << indent() << ": " << codemaker::cpp::scopedCppName(u2b(base))
<< "(";
- dumpBaseMembers(out, base, false);
+ dumpBaseMembers(out, base, false, false, false);
out << ")\n";
first = false;
}
@@ -2984,7 +2986,9 @@ void ExceptionType::dumpDeclaration(FileStream & out) {
<< "() SAL_THROW(());\n\n";
if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_ << "(";
- bool first = !dumpBaseMembers(out, base, true);
+ bool withDefaults = true;
+ bool parentsHadDirectMembers = !entity_->getDirectMembers().empty();
+ bool first = !dumpBaseMembers(out, base, true, withDefaults, parentsHadDirectMembers);
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator
i(entity_->getDirectMembers().begin());
i != entity_->getDirectMembers().end(); ++i)
@@ -3023,7 +3027,7 @@ void ExceptionType::dumpDeclaration(FileStream & out) {
}
bool ExceptionType::dumpBaseMembers(
- FileStream & out, OUString const & base, bool withType)
+ FileStream & out, OUString const & base, bool withType, bool withDefaults, bool parentsHadDirectMember)
{
bool hasMember = false;
if (!base.isEmpty()) {
@@ -3036,10 +3040,12 @@ bool ExceptionType::dumpBaseMembers(
rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
assert(ent2.is());
- hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType);
+ hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType,
+ withDefaults, parentsHadDirectMember || !ent2->getDirectMembers().empty() );
+ int memberCount = 0;
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator
i(ent2->getDirectMembers().begin());
- i != ent2->getDirectMembers().end(); ++i)
+ i != ent2->getDirectMembers().end(); ++i, ++memberCount)
{
if (hasMember) {
out << ", ";
@@ -3049,6 +3055,17 @@ bool ExceptionType::dumpBaseMembers(
out << " ";
}
out << i->name << "_";
+ // We want to provide a default parameter value for uno::Exception subtype
+ // constructors, since most of the time we don't pass a Context object in to the exception
+ // throw sites.
+ if (withDefaults
+ && !parentsHadDirectMember
+ && base == "com.sun.star.uno.Exception"
+ && memberCount == 1
+ && i->name == "Context"
+ && i->type == "com.sun.star.uno.XInterface") {
+ out << " = ::css::uno::Reference< ::css::uno::XInterface >()";
+ }
hasMember = true;
}
}