codemaker/source/commoncpp/commoncpp.cxx |  241 +++++++++++++++----------------
 codemaker/source/cppumaker/cpputype.cxx  |    6 
 cppu/qa/cppumaker/test_cppumaker.cxx     |    1 
 cppu/qa/cppumaker/types.idl              |    4 
 include/codemaker/commoncpp.hxx          |    3 
 solenv/gbuild/UnoApiTarget.mk            |    4 
 6 files changed, 134 insertions(+), 125 deletions(-)

New commits:
commit 56ceb5db4eb3243d02c56c8cf21522d0373c28a9
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Fri Jan 19 12:12:01 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Fri Jan 19 13:44:01 2024 +0100

    cppumaker: Work around problematic constant named "auto"
    
    ...which had been added all the way back in 2002 with
    6cd0bbd8ce6ae2774fc61dacc0f81725ba038d79 "adding new file to HEAD" to 
constants
    group css.drawing.CaptionEscapeDirection, which has meanwhile been 
published, so
    no chance of cleaning that up.
    
    But cppumaker already has a mechanism to work around problematic UNOIDL
    identifiers, but which was only used for "new-style" entities when they got
    introduced, mainly to avoid compatibility issues when retroactively 
changing the
    code generated for existing entities.
    
    But for C++ keywords, the generated code was always broken, so no harm in 
fixing
    it, so introduce an additional IdentifierTranslateMode::KeywordsOnly and use
    that at least for constants, to address the immediate issue.
    
    (And with that, a hack can be removed from 
gb_UnoApiEmbindTarget__add_embind.)
    
    Change-Id: I5cf62fd8b3b298dff2ec28452fb97b424a4ba473
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162305
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/codemaker/source/commoncpp/commoncpp.cxx 
b/codemaker/source/commoncpp/commoncpp.cxx
index 117afaca2c8a..a47a8d99526b 100644
--- a/codemaker/source/commoncpp/commoncpp.cxx
+++ b/codemaker/source/commoncpp/commoncpp.cxx
@@ -167,126 +167,127 @@ OString translateUnoToCppIdentifier(
         /* unoIdentifier == "or_eq" */
         || unoIdentifier == "xor"
         /* unoIdentifier == "xor_eq" */
-        // Standard macros:
-        || (unoIdentifier == "BUFSIZ"
-                || unoIdentifier == "CLOCKS_PER_SEC"
-                || unoIdentifier == "EDOM"
-                || unoIdentifier == "EOF"
-                || unoIdentifier == "ERANGE"
-                || unoIdentifier == "EXIT_FAILURE"
-                || unoIdentifier == "EXIT_SUCCESS"
-                || unoIdentifier == "FILENAME_MAX"
-                || unoIdentifier == "FOPEN_MAX"
-                || unoIdentifier == "HUGE_VAL"
-                || unoIdentifier == "LC_ALL"
-                || unoIdentifier == "LC_COLLATE"
-                || unoIdentifier == "LC_CTYPE"
-                || unoIdentifier == "LC_MONETARY"
-                || unoIdentifier == "LC_NUMERIC"
-                || unoIdentifier == "LC_TIME"
-                || unoIdentifier == "L_tmpnam"
-                || unoIdentifier == "MB_CUR_MAX"
-                || unoIdentifier == "NULL"
-                || unoIdentifier == "RAND_MAX"
-                || unoIdentifier == "SEEK_CUR"
-                || unoIdentifier == "SEEK_END"
-                || unoIdentifier == "SEEK_SET"
-                || unoIdentifier == "SIGABRT"
-                || unoIdentifier == "SIGFPE"
-                || unoIdentifier == "SIGILL"
-                || unoIdentifier == "SIGINT"
-                || unoIdentifier == "SIGSEGV"
-                || unoIdentifier == "SIGTERM"
-                || unoIdentifier == "SIG_DFL"
-                || unoIdentifier == "SIG_ERR"
-                || unoIdentifier == "SIG_IGN"
-                || unoIdentifier == "TMP_MAX"
-                || unoIdentifier == "WCHAR_MAX"
-                || unoIdentifier == "WCHAR_MIN"
-                || unoIdentifier == "WEOF"
-                /* unoIdentifier == "_IOFBF" */
-                /* unoIdentifier == "_IOLBF" */
-                /* unoIdentifier == "_IONBF" */
-                || unoIdentifier == "assert"
-                || unoIdentifier == "errno"
-                || unoIdentifier == "offsetof"
-                || unoIdentifier == "setjmp"
-                || unoIdentifier == "stderr"
-                || unoIdentifier == "stdin"
-                || unoIdentifier == "stdout"
-                /* unoIdentifier == "va_arg" */
-                /* unoIdentifier == "va_end" */
-                /* unoIdentifier == "va_start" */
-                // Standard values:
-                || unoIdentifier == "CHAR_BIT"
-                || unoIdentifier == "CHAR_MAX"
-                || unoIdentifier == "CHAR_MIN"
-                || unoIdentifier == "DBL_DIG"
-                || unoIdentifier == "DBL_EPSILON"
-                || unoIdentifier == "DBL_MANT_DIG"
-                || unoIdentifier == "DBL_MAX"
-                || unoIdentifier == "DBL_MAX_10_EXP"
-                || unoIdentifier == "DBL_MAX_EXP"
-                || unoIdentifier == "DBL_MIN"
-                || unoIdentifier == "DBL_MIN_10_EXP"
-                || unoIdentifier == "DBL_MIN_EXP"
-                || unoIdentifier == "FLT_DIG"
-                || unoIdentifier == "FLT_EPSILON"
-                || unoIdentifier == "FLT_MANT_DIG"
-                || unoIdentifier == "FLT_MAX"
-                || unoIdentifier == "FLT_MAX_10_EXP"
-                || unoIdentifier == "FLT_MAX_EXP"
-                || unoIdentifier == "FLT_MIN"
-                || unoIdentifier == "FLT_MIN_10_EXP"
-                || unoIdentifier == "FLT_MIN_EXP"
-                || unoIdentifier == "FLT_RADIX"
-                || unoIdentifier == "FLT_ROUNDS"
-                || unoIdentifier == "INT_MAX"
-                || unoIdentifier == "INT_MIN"
-                || unoIdentifier == "LDBL_DIG"
-                || unoIdentifier == "LDBL_EPSILON"
-                || unoIdentifier == "LDBL_MANT_DIG"
-                || unoIdentifier == "LDBL_MAX"
-                || unoIdentifier == "LDBL_MAX_10_EXP"
-                || unoIdentifier == "LDBL_MAX_EXP"
-                || unoIdentifier == "LDBL_MIN"
-                || unoIdentifier == "LDBL_MIN_10_EXP"
-                || unoIdentifier == "LDBL_MIN_EXP"
-                || unoIdentifier == "LONG_MAX"
-                || unoIdentifier == "LONG_MIN"
-                || unoIdentifier == "MB_LEN_MAX"
-                || unoIdentifier == "SCHAR_MAX"
-                || unoIdentifier == "SCHAR_MIN"
-                || unoIdentifier == "SHRT_MAX"
-                || unoIdentifier == "SHRT_MIN"
-                || unoIdentifier == "UCHAR_MAX"
-                || unoIdentifier == "UINT_MAX"
-                || unoIdentifier == "ULONG_MAX"
-                || unoIdentifier == "USHRT_MAX")
-            || (transmode == IdentifierTranslationMode::Global
-                && (// Standard types:
-                    /* unoIdentifier == "clock_t" */
-                    /* unoIdentifier == "div_t" */
-                    unoIdentifier == "FILE"
-                    /* unoIdentifier == "fpos_t" */
-                    /* unoIdentifier == "jmp_buf" */
-                    || unoIdentifier == "lconv"
-                    /* unoIdentifier == "ldiv_t" */
-                    /* unoIdentifier == "mbstate_t" */
-                    /* unoIdentifier == "ptrdiff_t" */
-                    /* unoIdentifier == "sig_atomic_t" */
-                    /* unoIdentifier == "size_t" */
-                    /* unoIdentifier == "time_t" */
-                    || unoIdentifier == "tm"
-                    /* unoIdentifier == "va_list" */
-                    /* unoIdentifier == "wctrans_t" */
-                    /* unoIdentifier == "wctype_t" */
-                    /* unoIdentifier == "wint_t" */
-                    // Standard namespaces:
-                    || unoIdentifier == "std"))
-            // Others:
-            || unoIdentifier == "NDEBUG"
-            || (forbidden != nullptr && unoIdentifier == *forbidden) )
+        || (transmode != IdentifierTranslationMode::KeywordsOnly
+            // Standard macros:
+            && ((unoIdentifier == "BUFSIZ"
+                    || unoIdentifier == "CLOCKS_PER_SEC"
+                    || unoIdentifier == "EDOM"
+                    || unoIdentifier == "EOF"
+                    || unoIdentifier == "ERANGE"
+                    || unoIdentifier == "EXIT_FAILURE"
+                    || unoIdentifier == "EXIT_SUCCESS"
+                    || unoIdentifier == "FILENAME_MAX"
+                    || unoIdentifier == "FOPEN_MAX"
+                    || unoIdentifier == "HUGE_VAL"
+                    || unoIdentifier == "LC_ALL"
+                    || unoIdentifier == "LC_COLLATE"
+                    || unoIdentifier == "LC_CTYPE"
+                    || unoIdentifier == "LC_MONETARY"
+                    || unoIdentifier == "LC_NUMERIC"
+                    || unoIdentifier == "LC_TIME"
+                    || unoIdentifier == "L_tmpnam"
+                    || unoIdentifier == "MB_CUR_MAX"
+                    || unoIdentifier == "NULL"
+                    || unoIdentifier == "RAND_MAX"
+                    || unoIdentifier == "SEEK_CUR"
+                    || unoIdentifier == "SEEK_END"
+                    || unoIdentifier == "SEEK_SET"
+                    || unoIdentifier == "SIGABRT"
+                    || unoIdentifier == "SIGFPE"
+                    || unoIdentifier == "SIGILL"
+                    || unoIdentifier == "SIGINT"
+                    || unoIdentifier == "SIGSEGV"
+                    || unoIdentifier == "SIGTERM"
+                    || unoIdentifier == "SIG_DFL"
+                    || unoIdentifier == "SIG_ERR"
+                    || unoIdentifier == "SIG_IGN"
+                    || unoIdentifier == "TMP_MAX"
+                    || unoIdentifier == "WCHAR_MAX"
+                    || unoIdentifier == "WCHAR_MIN"
+                    || unoIdentifier == "WEOF"
+                    /* unoIdentifier == "_IOFBF" */
+                    /* unoIdentifier == "_IOLBF" */
+                    /* unoIdentifier == "_IONBF" */
+                    || unoIdentifier == "assert"
+                    || unoIdentifier == "errno"
+                    || unoIdentifier == "offsetof"
+                    || unoIdentifier == "setjmp"
+                    || unoIdentifier == "stderr"
+                    || unoIdentifier == "stdin"
+                    || unoIdentifier == "stdout"
+                    /* unoIdentifier == "va_arg" */
+                    /* unoIdentifier == "va_end" */
+                    /* unoIdentifier == "va_start" */
+                    // Standard values:
+                    || unoIdentifier == "CHAR_BIT"
+                    || unoIdentifier == "CHAR_MAX"
+                    || unoIdentifier == "CHAR_MIN"
+                    || unoIdentifier == "DBL_DIG"
+                    || unoIdentifier == "DBL_EPSILON"
+                    || unoIdentifier == "DBL_MANT_DIG"
+                    || unoIdentifier == "DBL_MAX"
+                    || unoIdentifier == "DBL_MAX_10_EXP"
+                    || unoIdentifier == "DBL_MAX_EXP"
+                    || unoIdentifier == "DBL_MIN"
+                    || unoIdentifier == "DBL_MIN_10_EXP"
+                    || unoIdentifier == "DBL_MIN_EXP"
+                    || unoIdentifier == "FLT_DIG"
+                    || unoIdentifier == "FLT_EPSILON"
+                    || unoIdentifier == "FLT_MANT_DIG"
+                    || unoIdentifier == "FLT_MAX"
+                    || unoIdentifier == "FLT_MAX_10_EXP"
+                    || unoIdentifier == "FLT_MAX_EXP"
+                    || unoIdentifier == "FLT_MIN"
+                    || unoIdentifier == "FLT_MIN_10_EXP"
+                    || unoIdentifier == "FLT_MIN_EXP"
+                    || unoIdentifier == "FLT_RADIX"
+                    || unoIdentifier == "FLT_ROUNDS"
+                    || unoIdentifier == "INT_MAX"
+                    || unoIdentifier == "INT_MIN"
+                    || unoIdentifier == "LDBL_DIG"
+                    || unoIdentifier == "LDBL_EPSILON"
+                    || unoIdentifier == "LDBL_MANT_DIG"
+                    || unoIdentifier == "LDBL_MAX"
+                    || unoIdentifier == "LDBL_MAX_10_EXP"
+                    || unoIdentifier == "LDBL_MAX_EXP"
+                    || unoIdentifier == "LDBL_MIN"
+                    || unoIdentifier == "LDBL_MIN_10_EXP"
+                    || unoIdentifier == "LDBL_MIN_EXP"
+                    || unoIdentifier == "LONG_MAX"
+                    || unoIdentifier == "LONG_MIN"
+                    || unoIdentifier == "MB_LEN_MAX"
+                    || unoIdentifier == "SCHAR_MAX"
+                    || unoIdentifier == "SCHAR_MIN"
+                    || unoIdentifier == "SHRT_MAX"
+                    || unoIdentifier == "SHRT_MIN"
+                    || unoIdentifier == "UCHAR_MAX"
+                    || unoIdentifier == "UINT_MAX"
+                    || unoIdentifier == "ULONG_MAX"
+                    || unoIdentifier == "USHRT_MAX")
+                || (transmode == IdentifierTranslationMode::Global
+                    && (// Standard types:
+                        /* unoIdentifier == "clock_t" */
+                        /* unoIdentifier == "div_t" */
+                        unoIdentifier == "FILE"
+                        /* unoIdentifier == "fpos_t" */
+                        /* unoIdentifier == "jmp_buf" */
+                        || unoIdentifier == "lconv"
+                        /* unoIdentifier == "ldiv_t" */
+                        /* unoIdentifier == "mbstate_t" */
+                        /* unoIdentifier == "ptrdiff_t" */
+                        /* unoIdentifier == "sig_atomic_t" */
+                        /* unoIdentifier == "size_t" */
+                        /* unoIdentifier == "time_t" */
+                        || unoIdentifier == "tm"
+                        /* unoIdentifier == "va_list" */
+                        /* unoIdentifier == "wctrans_t" */
+                        /* unoIdentifier == "wctype_t" */
+                        /* unoIdentifier == "wint_t" */
+                        // Standard namespaces:
+                        || unoIdentifier == "std"))
+                // Others:
+                || unoIdentifier == "NDEBUG"
+                || (forbidden != nullptr && unoIdentifier == *forbidden))) )
     {
         return OString::Concat(prefix) + "_" + unoIdentifier;
     } else {
diff --git a/codemaker/source/cppumaker/cpputype.cxx 
b/codemaker/source/cppumaker/cpputype.cxx
index cfb1fd750a5f..2b995e1d31ae 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -1937,7 +1937,11 @@ void ConstantGroup::dumpDeclaration(FileStream & out)
             out << "double";
             break;
         }
-        out << " " << member.name << " = ";
+        out << " "
+            << codemaker::cpp::translateUnoToCppIdentifier(
+                u2b(member.name), "constant",
+                codemaker::cpp::IdentifierTranslationMode::KeywordsOnly)
+            << " = ";
         switch (member.value.type) {
         case unoidl::ConstantValue::TYPE_BOOLEAN:
             out << (member.value.booleanValue ? "sal_True" : "sal_False");
diff --git a/cppu/qa/cppumaker/test_cppumaker.cxx 
b/cppu/qa/cppumaker/test_cppumaker.cxx
index a6d3e4942f06..22e0b81e19b6 100644
--- a/cppu/qa/cppumaker/test_cppumaker.cxx
+++ b/cppu/qa/cppumaker/test_cppumaker.cxx
@@ -352,6 +352,7 @@
 #include <test/codemaker/cppumaker/TestException1.hpp>
 #include <test/codemaker/cppumaker/TestException2.hpp>
 #include <test/codemaker/cppumaker/Constants.hpp>
+#include <test/codemaker/cppumaker/ProblematicConstantNames.hpp>
 
 #include <memory>
 #include <com/sun/star/uno/Any.hxx>
diff --git a/cppu/qa/cppumaker/types.idl b/cppu/qa/cppumaker/types.idl
index 25bac18ff920..27455d51700d 100644
--- a/cppu/qa/cppumaker/types.idl
+++ b/cppu/qa/cppumaker/types.idl
@@ -751,6 +751,10 @@ constants UnsignedHyperBits {
     const unsigned hyper ALL = 18446744073709551615;
 };
 
+constants ProblematicConstantNames {
+    const long auto = 0;
+};
+
 }; }; };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/codemaker/commoncpp.hxx b/include/codemaker/commoncpp.hxx
index 629941044dde..8d00cc799c24 100644
--- a/include/codemaker/commoncpp.hxx
+++ b/include/codemaker/commoncpp.hxx
@@ -48,7 +48,8 @@ rtl::OString translateUnoToCppType(
 
 enum class IdentifierTranslationMode {
     Global,
-    NonGlobal
+    NonGlobal,
+    KeywordsOnly
 };
 
 rtl::OString translateUnoToCppIdentifier(
diff --git a/solenv/gbuild/UnoApiTarget.mk b/solenv/gbuild/UnoApiTarget.mk
index 59b2d07e149b..e4f92eb2d985 100644
--- a/solenv/gbuild/UnoApiTarget.mk
+++ b/solenv/gbuild/UnoApiTarget.mk
@@ -243,12 +243,10 @@ $(if $(filter offapi udkapi, $(1)),\
        $(foreach hdr,$(3),$(eval $(call 
gb_UnoApiEmbindTarget__add_embind,$(1),$(2),$(hdr)))))
 endef
 
-# CaptionEscapeDirection contains "auto" as a variable name.. so exclude that
 define gb_UnoApiEmbindTarget__add_embind
-$(if $(filter-out CaptionEscapeDirection_embind, $(3)),\
 $(eval $(call gb_StaticLibrary_add_generated_exception_objects,unoembind,\
        UnoApiHeadersTarget/$(1)/comprehensive/$(2)/$(3) \
-)))
+))
 
 endef
 

Reply via email to