From 56ceb5db4eb3243d02c56c8cf21522d0373c28a9 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 19 Jan 2024 12:12:01 +0100 Subject: 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 --- codemaker/source/commoncpp/commoncpp.cxx | 241 ++++++++++++++++--------------- codemaker/source/cppumaker/cpputype.cxx | 6 +- 2 files changed, 126 insertions(+), 121 deletions(-) (limited to 'codemaker') 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"); -- cgit