summaryrefslogtreecommitdiff
path: root/codemaker/source/cppumaker/cpputype.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'codemaker/source/cppumaker/cpputype.cxx')
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx76
1 files changed, 71 insertions, 5 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 12c951205c54..e2288c961133 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -2750,6 +2750,9 @@ public:
}
private:
+ virtual void dumpHdlFile(
+ FileStream & out, codemaker::cppumaker::Includes & includes) override;
+
virtual void dumpHppFile(
FileStream & out, codemaker::cppumaker::Includes & includes) override;
@@ -2777,6 +2780,25 @@ private:
rtl::Reference< unoidl::ExceptionTypeEntity > entity_;
};
+void ExceptionType::dumpHdlFile(
+ FileStream & out, codemaker::cppumaker::Includes & includes)
+{
+ if (name_ == "com.sun.star.uno.Exception")
+ {
+ // LIBO_INTERNAL_ONLY implies GCC >= 7, which we need for this
+ // Merely checking __has_include is not enough because some systems have the header,
+ // but do not have a new enough clang for it to work.
+ includes.addCustom("#if defined LIBO_INTERNAL_ONLY && ((defined __GNUC__ && !defined __clang__) || (defined __clang__ && __clang_major__ >= 8)) && __has_include(<experimental/source_location>)");
+ includes.addCustom("#define LIBO_USE_SOURCE_LOCATION");
+ includes.addCustom("#endif");
+ includes.addCustom("#if defined LIBO_USE_SOURCE_LOCATION");
+ includes.addCustom("#include <experimental/source_location>");
+ includes.addCustom("#include <o3tl/runtimetooustring.hxx>");
+ includes.addCustom("#endif");
+ }
+ dumpHFileContent(out, includes);
+}
+
void ExceptionType::addComprehensiveGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const
{
@@ -2806,13 +2828,23 @@ void ExceptionType::dumpHppFile(
if (codemaker::cppumaker::dumpNamespaceOpen(out, name_, false)) {
out << "\n";
}
- out << "\ninline " << id_ << "::" << id_ << "()\n";
+
+ // default constructor
+ out << "\ninline " << id_ << "::" << id_ << "(\n";
+ out << "#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " std::experimental::source_location location\n";
+ out << "#endif\n";
+ out << " )\n";
inc();
OUString base(entity_->getDirectBase());
bool bFirst = true;
if (!base.isEmpty()) {
out << indent() << ": " << codemaker::cpp::scopedCppName(u2b(base))
- << "()\n";
+ << "(\n";
+ out << "#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " location\n";
+ out << "#endif\n";
+ out << ")\n";
bFirst = false;
}
for (const unoidl::ExceptionTypeEntity::Member& member : entity_->getDirectMembers()) {
@@ -2832,7 +2864,17 @@ void ExceptionType::dumpHppFile(
} else {
out << " ";
}
+ if (name_ == "com.sun.star.uno.Exception")
+ {
+ out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " if (!Message.isEmpty())\n";
+ out << " Message += \" \";\n";
+ out << " Message += o3tl::runtimeToOUString(location.file_name()) + \":\" + OUString::number(location.line());\n";
+ out << "#endif\n";
+ }
out << "}\n\n";
+
+ // fields constructor
if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
out << indent() << "inline " << id_ << "::" << id_ << "(";
bFirst = !dumpBaseMembers(out, base, true, false);
@@ -2844,6 +2886,9 @@ void ExceptionType::dumpHppFile(
out << " " << member.name << "_";
bFirst = false;
}
+ out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " " << (bFirst ? "" : ", ") << "std::experimental::source_location location\n";
+ out << "#endif\n";
out << ")\n";
inc();
bFirst = true;
@@ -2851,6 +2896,9 @@ void ExceptionType::dumpHppFile(
out << indent() << ": " << codemaker::cpp::scopedCppName(u2b(base))
<< "(";
dumpBaseMembers(out, base, false, false);
+ out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " , location\n";
+ out << "#endif\n";
out << ")\n";
bFirst = false;
}
@@ -2869,6 +2917,14 @@ void ExceptionType::dumpHppFile(
} else {
out << " ";
}
+ if (name_ == "com.sun.star.uno.Exception")
+ {
+ out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " if (!Message.isEmpty())\n";
+ out << " Message += \" \";\n";
+ out << " Message += o3tl::runtimeToOUString(location.file_name()) + \":\" + OUString::number(location.line());\n";
+ out << "#endif\n";
+ }
out << "}\n\n";
}
out << "#if !defined LIBO_INTERNAL_ONLY\n" << indent() << id_ << "::" << id_
@@ -3088,8 +3144,15 @@ void ExceptionType::dumpDeclaration(FileStream & out)
}
out << "\n{\npublic:\n";
inc();
- out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_
- << "();\n\n";
+
+ // default constructor
+ out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_ << "(\n";
+ out << "#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << " std::experimental::source_location location = std::experimental::source_location::current()\n";
+ out << "#endif\n\n";
+ out << " );\n";
+
+ // constructor that initializes data members
if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_ << "(";
bool eligibleForDefaults = entity_->getDirectMembers().empty();
@@ -3102,7 +3165,10 @@ void ExceptionType::dumpDeclaration(FileStream & out)
out << " " << member.name << "_";
bFirst = false;
}
- out << ");\n\n";
+ out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
+ out << ", std::experimental::source_location location = std::experimental::source_location::current()\n";
+ out << "#endif\n";
+ out << " );\n\n";
}
out << "#if !defined LIBO_INTERNAL_ONLY\n" << indent()
<< "inline CPPU_GCC_DLLPRIVATE " << id_ << "(" << id_