summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx76
-rw-r--r--codemaker/source/cppumaker/includes.cxx2
-rw-r--r--codemaker/source/cppumaker/includes.hxx4
-rw-r--r--stoc/test/testiadapter.cxx8
-rw-r--r--testtools/source/bridgetest/bridgetest.cxx6
5 files changed, 83 insertions, 13 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_
diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx
index 732f5065c191..a07c651bec01 100644
--- a/codemaker/source/cppumaker/includes.cxx
+++ b/codemaker/source/cppumaker/includes.cxx
@@ -254,6 +254,8 @@ void Includes::dump(
dumpEmptyLineBeforeFirst(out, &first);
out << "#include \"typelib/typedescription.h\"\n";
}
+ for (OUString const & s : m_custom)
+ out << s << "\n";
}
void Includes::dumpInclude(
diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx
index 0203868374f2..fb193233dea6 100644
--- a/codemaker/source/cppumaker/includes.hxx
+++ b/codemaker/source/cppumaker/includes.hxx
@@ -22,7 +22,7 @@
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
-
+#include <vector>
#include "dependencies.hxx"
class FileStream;
@@ -58,6 +58,7 @@ public:
void addTypelibTypeclassH() { m_includeTypelibTypeclassH = true; }
void addTypelibTypedescriptionH()
{ m_includeTypelibTypedescriptionH = true; }
+ void addCustom(const OUString& s) { m_custom.push_back(s); }
void dump(
FileStream & out, OUString const * companionHdl, bool exceptions);
@@ -91,6 +92,7 @@ private:
bool m_includeSalTypesH;
bool m_includeTypelibTypeclassH;
bool m_includeTypelibTypedescriptionH;
+ std::vector<OUString> m_custom;
};
}
diff --git a/stoc/test/testiadapter.cxx b/stoc/test/testiadapter.cxx
index 89856bad42ef..ced8c836f5ea 100644
--- a/stoc/test/testiadapter.cxx
+++ b/stoc/test/testiadapter.cxx
@@ -892,7 +892,7 @@ sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT )
catch (const IllegalArgumentException &aExc)
{
OSL_ENSURE( aExc.ArgumentPosition == 5 &&
- aExc.Message == "dum dum dum I dance around the circle...",
+ aExc.Message.startsWith("dum dum dum I dance around the circle..."),
"### unexpected exception content!" );
Reference<XLanguageBindingTest > xLBT2(
@@ -907,7 +907,7 @@ sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT )
}
catch (const RuntimeException & rExc)
{
- OSL_ENSURE( rExc.Message == "dum dum dum I dance around the circle...",
+ OSL_ENSURE( rExc.Message.startsWith("dum dum dum I dance around the circle..."),
"### unexpected exception content!" );
Reference<XLanguageBindingTest > xLBT2(
@@ -922,9 +922,9 @@ sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT )
}
catch (const Exception & aExc)
{
- OSL_ENSURE( aExc.Message == "dum dum dum I dance around the circle...",
+ OSL_ENSURE( aExc.Message.startsWith("dum dum dum I dance around the circle..."),
"### unexpected exception content!" );
- return aExc.Message == "dum dum dum I dance around the circle...";
+ return aExc.Messag.startsWith("dum dum dum I dance around the circle...");
}
return sal_False;
}
diff --git a/testtools/source/bridgetest/bridgetest.cxx b/testtools/source/bridgetest/bridgetest.cxx
index f8129c53d2ba..5ce8a687d5f8 100644
--- a/testtools/source/bridgetest/bridgetest.cxx
+++ b/testtools/source/bridgetest/bridgetest.cxx
@@ -940,7 +940,7 @@ static bool raiseException( const Reference< XBridgeTest > & xLBT )
if (rExc.ArgumentPosition == 5 &&
#if OSL_DEBUG_LEVEL == 0
// java stack traces trash Message
- rExc.Message == STRING_TEST_CONSTANT &&
+ rExc.Message.startsWith(STRING_TEST_CONSTANT) &&
#endif
rExc.Context == xLBT->getInterface())
{
@@ -967,7 +967,7 @@ static bool raiseException( const Reference< XBridgeTest > & xLBT )
if (rExc.Context == xLBT->getInterface()
#if OSL_DEBUG_LEVEL == 0
// java stack traces trash Message
- && rExc.Message == STRING_TEST_CONSTANT
+ && rExc.Message.startsWith(STRING_TEST_CONSTANT)
#endif
)
{
@@ -987,7 +987,7 @@ static bool raiseException( const Reference< XBridgeTest > & xLBT )
if (rExc.Context == xLBT->getInterface()
#if OSL_DEBUG_LEVEL == 0
// java stack traces trash Message
- && rExc.Message == STRING_TEST_CONSTANT
+ && rExc.Message.startsWith(STRING_TEST_CONSTANT)
#endif
)
{