codemaker/source/cppumaker/cpputype.cxx |   25 +++++++----------------
 include/o3tl/source_location.hxx        |   34 ++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 17 deletions(-)

New commits:
commit 91b1153bb75d7527e7de3aacc476259563292ab4
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 25 11:35:46 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 25 11:54:49 2024 +0100

    Move LIBO_USE_SOURCE_LOCATION to o3tl for possible reuse
    
    Change-Id: I045fc1d86576f6017def01a14dd9a091ee35a544
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179323
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/codemaker/source/cppumaker/cpputype.cxx 
b/codemaker/source/cppumaker/cpputype.cxx
index 5f6d47ac6c70..aa332fb026e7 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -2819,16 +2819,7 @@ void ExceptionType::dumpHdlFile(
     if (name_ == "com.sun.star.uno.Exception")
     {
         includes.addCustom(u"#if defined(LIBO_INTERNAL_ONLY) && 
!defined(NDEBUG)"_ustr);
-        includes.addCustom(u"#if __has_include(<version>)"_ustr);
-        includes.addCustom(u"#include <version>"_ustr);
-        includes.addCustom(u"#endif"_ustr);
-        includes.addCustom(u"#if defined(__cpp_lib_source_location) && 
__cpp_lib_source_location >= 201907"_ustr);
-        includes.addCustom(u"#include <source_location>"_ustr);
-        includes.addCustom(u"#define LIBO_USE_SOURCE_LOCATION std"_ustr);
-        includes.addCustom(u"#elif 
__has_include(<experimental/source_location>)"_ustr);
-        includes.addCustom(u"#include <experimental/source_location>"_ustr);
-        includes.addCustom(u"#define LIBO_USE_SOURCE_LOCATION 
std::experimental"_ustr);
-        includes.addCustom(u"#endif"_ustr);
+        includes.addCustom(u"#include <o3tl/source_location.hxx>"_ustr);
         includes.addCustom(u"#endif"_ustr);
         includes.addCustom(u"#if defined LIBO_USE_SOURCE_LOCATION"_ustr);
         includes.addCustom(u"#include <o3tl/runtimetooustring.hxx>"_ustr);
@@ -2870,9 +2861,9 @@ void ExceptionType::dumpHppFile(
     // default constructor
     out << "
inline " << id_ << "::" << id_ << "(
";
     out << "#if defined LIBO_USE_SOURCE_LOCATION
";
-    out << "    LIBO_USE_SOURCE_LOCATION::source_location location
";
+    out << "    o3tl::source_location location
";
     out << "#endif
";
-    out << "    )
";
+    out << ")
";
     inc();
     OUString base(entity_->getDirectBase());
     bool bFirst = true;
@@ -2925,7 +2916,7 @@ void ExceptionType::dumpHppFile(
             bFirst = false;
         }
         out << "
#if defined LIBO_USE_SOURCE_LOCATION
";
-        out << "    " << (bFirst ? "" : ", ") << 
"LIBO_USE_SOURCE_LOCATION::source_location location
";
+        out << "    " << (bFirst ? "" : ", ") << "o3tl::source_location 
location
";
         out << "#endif
";
         out << ")
";
         inc();
@@ -3186,9 +3177,9 @@ void ExceptionType::dumpDeclaration(FileStream & out)
     // default constructor
     out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_ << "(
";
     out << "#if defined LIBO_USE_SOURCE_LOCATION
";
-    out << "    LIBO_USE_SOURCE_LOCATION::source_location location = 
LIBO_USE_SOURCE_LOCATION::source_location::current()
";
-    out << "#endif

";
-    out << "    );
";
+    out << "        o3tl::source_location location = 
o3tl::source_location::current()
";
+    out << "#endif
";
+    out << "    );

";
 
     // constructor that initializes data members
     if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) 
{
@@ -3204,7 +3195,7 @@ void ExceptionType::dumpDeclaration(FileStream & out)
             bFirst = false;
         }
         out << "
#if defined LIBO_USE_SOURCE_LOCATION
";
-        out << ", LIBO_USE_SOURCE_LOCATION::source_location location = 
LIBO_USE_SOURCE_LOCATION::source_location::current()
";
+        out << "        , o3tl::source_location location = 
o3tl::source_location::current()
";
         out << "#endif
";
         out << "    );

";
     }
diff --git a/include/o3tl/source_location.hxx b/include/o3tl/source_location.hxx
new file mode 100644
index 000000000000..919e9403f87b
--- /dev/null
+++ b/include/o3tl/source_location.hxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_O3TL_SOURCE_LOCATION_HXX
+#define INCLUDED_O3TL_SOURCE_LOCATION_HXX
+
+#if __has_include(<version>)
+#include <version>
+#endif
+
+#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907
+#include <source_location>
+#define LIBO_USE_SOURCE_LOCATION std
+#elif __has_include(<experimental/source_location>)
+#include <experimental/source_location>
+#define LIBO_USE_SOURCE_LOCATION std::experimental
+#endif
+
+#if defined LIBO_USE_SOURCE_LOCATION
+namespace o3tl
+{
+using source_location = LIBO_USE_SOURCE_LOCATION::source_location;
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to