summaryrefslogtreecommitdiff
path: root/codemaker/source
diff options
context:
space:
mode:
Diffstat (limited to 'codemaker/source')
-rw-r--r--codemaker/source/codemaker/codemaker.cxx2
-rw-r--r--codemaker/source/codemaker/global.cxx10
-rw-r--r--codemaker/source/codemaker/options.cxx2
-rw-r--r--codemaker/source/codemaker/typemanager.cxx2
-rw-r--r--codemaker/source/commoncpp/commoncpp.cxx244
-rw-r--r--codemaker/source/commonjava/commonjava.cxx30
-rw-r--r--codemaker/source/cppumaker/cppumaker.cxx27
-rw-r--r--codemaker/source/cppumaker/cppuoptions.cxx50
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx248
-rw-r--r--codemaker/source/cppumaker/cpputype.hxx8
-rw-r--r--codemaker/source/cppumaker/dumputils.cxx19
-rw-r--r--codemaker/source/cppumaker/dumputils.hxx7
-rw-r--r--codemaker/source/cppumaker/includes.cxx22
-rw-r--r--codemaker/source/cppumaker/includes.hxx7
-rw-r--r--codemaker/source/javamaker/classfile.cxx30
-rw-r--r--codemaker/source/javamaker/javamaker.cxx19
-rw-r--r--codemaker/source/javamaker/javaoptions.cxx26
-rw-r--r--codemaker/source/javamaker/javatype.cxx534
18 files changed, 674 insertions, 613 deletions
diff --git a/codemaker/source/codemaker/codemaker.cxx b/codemaker/source/codemaker/codemaker.cxx
index cb797533e2b9..df93ed2f5662 100644
--- a/codemaker/source/codemaker/codemaker.cxx
+++ b/codemaker/source/codemaker/codemaker.cxx
@@ -36,7 +36,7 @@ OString convertString(OUString const & string) {
| RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
{
throw CannotDumpException(
- "Failure converting string from UTF-16 to UTF-8");
+ u"Failure converting string from UTF-16 to UTF-8"_ustr);
}
return s;
}
diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx
index 6d831b45dca8..2862336b15bb 100644
--- a/codemaker/source/codemaker/global.cxx
+++ b/codemaker/source/codemaker/global.cxx
@@ -22,6 +22,7 @@
#include <rtl/ustring.hxx>
#include <osl/thread.h>
#include <osl/file.hxx>
+#include <o3tl/string_view.hxx>
#include <string.h>
#include <string_view>
@@ -58,7 +59,7 @@ OString getTempDir(const OString& sFileName)
if ((index=sFileName.lastIndexOf('\\')) > 0)
return sFileName.copy(0, index);
#endif
- return ".";
+ return "."_ostr;
}
OString createFileNameFromType( const OString& destination,
@@ -96,8 +97,7 @@ OString createFileNameFromType( const OString& destination,
if (bWithSeparator)
fileNameBuf.append("/");
- fileNameBuf.append(type);
- fileNameBuf.append(postfix);
+ fileNameBuf.append(type + postfix);
OString fileName(fileNameBuf.makeStringAndClear());
@@ -115,7 +115,7 @@ OString createFileNameFromType( const OString& destination,
sal_Int32 nIndex = 0;
do
{
- buffer.append(fileName.getToken(0, token, nIndex));
+ buffer.append(o3tl::getToken(fileName, 0, token, nIndex));
if( nIndex == -1 )
break;
@@ -272,7 +272,7 @@ bool FileStream::isValid() const
void FileStream::createTempFile(const OString& sPath)
{
- OString sTmp(".");
+ OString sTmp("."_ostr);
OUString sTmpPath;
OUString sTmpName;
diff --git a/codemaker/source/codemaker/options.cxx b/codemaker/source/codemaker/options.cxx
index 2d85b35a9823..906ae69ecba1 100644
--- a/codemaker/source/codemaker/options.cxx
+++ b/codemaker/source/codemaker/options.cxx
@@ -33,7 +33,7 @@ const OString& Options::getOption(const OString& option) const
OptionMap::const_iterator i(m_options.find(option));
if (i == m_options.end())
{
- throw IllegalArgument("Option is not valid or currently not set.");
+ throw IllegalArgument("Option is not valid or currently not set."_ostr);
}
return i->second;
}
diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx
index 194840ca9d5b..48588e2c4200 100644
--- a/codemaker/source/codemaker/typemanager.cxx
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -62,7 +62,7 @@ codemaker::UnoType::Sort TypeManager::getSort(
{
if (name.isEmpty()) {
if (cursor != nullptr) {
- *cursor = manager_->createCursor("");
+ *cursor = manager_->createCursor(u""_ustr);
}
return codemaker::UnoType::Sort::Module;
}
diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx
index c7dc2bdeb26c..a47a8d99526b 100644
--- a/codemaker/source/commoncpp/commoncpp.cxx
+++ b/codemaker/source/commoncpp/commoncpp.cxx
@@ -29,6 +29,7 @@
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>
+#include <o3tl/string_view.hxx>
#include <vector>
@@ -50,7 +51,7 @@ OString scopedCppName(OString const & type, bool ns_alias)
nPos = 0;
do
{
- tmpBuf.append("::" + type.getToken(0, c, nPos));
+ tmpBuf.append(OString::Concat("::") + o3tl::getToken(type, 0, c, nPos));
} while( nPos != -1 );
OString s(tmpBuf.makeStringAndClear());
@@ -166,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/commonjava/commonjava.cxx b/codemaker/source/commonjava/commonjava.cxx
index 6782789ae337..424b1dcbe783 100644
--- a/codemaker/source/commonjava/commonjava.cxx
+++ b/codemaker/source/commonjava/commonjava.cxx
@@ -42,21 +42,21 @@ OString translateUnoToJavaType(
OStringBuffer buf(128);
if (sort <= codemaker::UnoType::Sort::Any) {
OString const javaTypes[static_cast<int>(codemaker::UnoType::Sort::Any) + 1][2] = {
- { "void", "java/lang/Void" },
- { "boolean", "java/lang/Boolean" },
- { "byte", "java/lang/Byte" },
- { "short", "java/lang/Short" },
- { "short", "java/lang/Short" },
- { "int", "java/lang/Integer" },
- { "int", "java/lang/Integer" },
- { "long", "java/lang/Long" },
- { "long", "java/lang/Long" },
- { "float", "java/lang/Float" },
- { "double", "java/lang/Double" },
- { "char", "java/lang/Character" },
- { "java/lang/String", "java/lang/String" },
- { "com/sun/star/uno/Type", "com/sun/star/uno/Type" },
- { "java/lang/Object", "java/lang/Object" } };
+ { "void"_ostr, "java/lang/Void"_ostr },
+ { "boolean"_ostr, "java/lang/Boolean"_ostr },
+ { "byte"_ostr, "java/lang/Byte"_ostr },
+ { "short"_ostr, "java/lang/Short"_ostr },
+ { "short"_ostr, "java/lang/Short"_ostr },
+ { "int"_ostr, "java/lang/Integer"_ostr },
+ { "int"_ostr, "java/lang/Integer"_ostr },
+ { "long"_ostr, "java/lang/Long"_ostr },
+ { "long"_ostr, "java/lang/Long"_ostr },
+ { "float"_ostr, "java/lang/Float"_ostr },
+ { "double"_ostr, "java/lang/Double"_ostr },
+ { "char"_ostr, "java/lang/Character"_ostr },
+ { "java/lang/String"_ostr, "java/lang/String"_ostr },
+ { "com/sun/star/uno/Type"_ostr, "com/sun/star/uno/Type"_ostr },
+ { "java/lang/Object"_ostr, "java/lang/Object"_ostr } };
buf.append(javaTypes[static_cast<int>(sort)][referenceType]);
} else {
if (nucleus == "com/sun/star/uno/XInterface") {
diff --git a/codemaker/source/cppumaker/cppumaker.cxx b/codemaker/source/cppumaker/cppumaker.cxx
index 384e2b5aa079..3fe5c8855712 100644
--- a/codemaker/source/cppumaker/cppumaker.cxx
+++ b/codemaker/source/cppumaker/cppumaker.cxx
@@ -32,6 +32,7 @@
#include <sal/main.h>
#include <sal/types.h>
#include <unoidl/unoidl.hxx>
+#include <o3tl/string_view.hxx>
#include "cppuoptions.hxx"
#include "cpputype.hxx"
@@ -54,35 +55,35 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
typeMgr->loadProvider(convertToFileUrl(f), true);
}
codemaker::GeneratedTypeSet generated;
- if (options.isValid("-T")) {
- OUString names(b2u(options.getOption("-T")));
+ if (options.isValid("-T"_ostr)) {
+ OUString names(b2u(options.getOption("-T"_ostr)));
for (sal_Int32 i = 0; i != -1;) {
- OUString name(names.getToken(0, ';', i));
- if (!name.isEmpty()) {
+ std::u16string_view name(o3tl::getToken(names, 0, ';', i));
+ if (!name.empty()) {
produce(
- (name == "*"
- ? ""
- : name.endsWith(".*")
- ? name.copy(0, name.getLength() - std::strlen(".*"))
+ OUString(name == u"*"
+ ? u""
+ : o3tl::ends_with(name, u".*")
+ ? name.substr(0, name.size() - std::strlen(".*"))
: name),
typeMgr, generated, options);
}
}
} else {
- produce("", typeMgr, generated, options);
+ produce(u""_ustr, typeMgr, generated, options);
}
- if (!options.isValid("-nD")) {
+ if (!options.isValid("-nD"_ostr)) {
// C++ header files generated for the following UNO types are
// included in header files in cppu/inc/com/sun/star/uno (Any.hxx,
// Reference.hxx, Type.h), so it seems best to always generate those
// C++ header files:
produce(
- "com.sun.star.uno.RuntimeException", typeMgr, generated,
+ u"com.sun.star.uno.RuntimeException"_ustr, typeMgr, generated,
options);
produce(
- "com.sun.star.uno.TypeClass", typeMgr, generated, options);
+ u"com.sun.star.uno.TypeClass"_ustr, typeMgr, generated, options);
produce(
- "com.sun.star.uno.XInterface", typeMgr, generated, options);
+ u"com.sun.star.uno.XInterface"_ustr, typeMgr, generated, options);
}
} catch (CannotDumpException & e) {
std::cerr << "ERROR: " << e.getMessage() << '\n';
diff --git a/codemaker/source/cppumaker/cppuoptions.cxx b/codemaker/source/cppumaker/cppuoptions.cxx
index 0a2ad962381a..d16c7dacecba 100644
--- a/codemaker/source/cppumaker/cppuoptions.cxx
+++ b/codemaker/source/cppumaker/cppuoptions.cxx
@@ -71,7 +71,7 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
}
else
{
- OString tmp("'-O', please check");
+ OString tmp("'-O', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i+1] + "'";
@@ -85,7 +85,7 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i] + 2;
}
- m_options["-O"] = OString(s);
+ m_options["-O"_ostr] = OString(s);
break;
case 'n':
if (av[i][2] != 'D' || av[i][3] != '\0')
@@ -94,7 +94,7 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- m_options["-nD"] = OString();
+ m_options["-nD"_ostr] = OString();
break;
case 'T':
if (av[i][2] == '\0')
@@ -106,7 +106,7 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
}
else
{
- OString tmp("'-T', please check");
+ OString tmp("'-T', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i+1] + "'";
@@ -120,20 +120,20 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i] + 2;
}
- if (m_options.count("-T") > 0)
+ if (m_options.count("-T"_ostr) > 0)
{
- OString tmp = m_options["-T"] + ";" + s;
- m_options["-T"] = tmp;
+ OString tmp = m_options["-T"_ostr] + ";" + s;
+ m_options["-T"_ostr] = tmp;
}
else
{
- m_options["-T"] = OString(s);
+ m_options["-T"_ostr] = OString(s);
}
break;
case 'L':
if (av[i][2] != '\0')
{
- OString tmp("'-L', please check");
+ OString tmp("'-L', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -142,18 +142,18 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- if (isValid("-C") || isValid("-CS"))
+ if (isValid("-C"_ostr) || isValid("-CS"_ostr))
{
- throw IllegalArgument("'-L' could not be combined with '-C' or '-CS' option");
+ throw IllegalArgument("'-L' could not be combined with '-C' or '-CS' option"_ostr);
}
- m_options["-L"] = OString();
+ m_options["-L"_ostr] = OString();
break;
case 'C':
if (av[i][2] == 'S')
{
if (av[i][3] != '\0')
{
- OString tmp("'-CS', please check");
+ OString tmp("'-CS', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -162,16 +162,16 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- if (isValid("-L") || isValid("-C"))
+ if (isValid("-L"_ostr) || isValid("-C"_ostr))
{
- throw IllegalArgument("'-CS' could not be combined with '-L' or '-C' option");
+ throw IllegalArgument("'-CS' could not be combined with '-L' or '-C' option"_ostr);
}
- m_options["-CS"] = OString();
+ m_options["-CS"_ostr] = OString();
break;
}
else if (av[i][2] != '\0')
{
- OString tmp("'-C', please check");
+ OString tmp("'-C', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -180,18 +180,18 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- if (isValid("-L") || isValid("-CS"))
+ if (isValid("-L"_ostr) || isValid("-CS"_ostr))
{
- throw IllegalArgument("'-C' could not be combined with '-L' or '-CS' option");
+ throw IllegalArgument("'-C' could not be combined with '-L' or '-CS' option"_ostr);
}
- m_options["-C"] = OString();
+ m_options["-C"_ostr] = OString();
break;
case 'G':
if (av[i][2] == 'c')
{
if (av[i][3] != '\0')
{
- OString tmp("'-Gc', please check");
+ OString tmp("'-Gc', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -200,12 +200,12 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- m_options["-Gc"] = OString();
+ m_options["-Gc"_ostr] = OString();
break;
}
else if (av[i][2] != '\0')
{
- OString tmp("'-G', please check");
+ OString tmp("'-G', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -214,7 +214,7 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- m_options["-G"] = OString();
+ m_options["-G"_ostr] = OString();
break;
case 'X': // support for eXtra type rdbs
{
@@ -227,7 +227,7 @@ bool CppuOptions::initOptions(int ac, char* av[], bool bCmdFile)
}
else
{
- OString tmp("'-X', please check");
+ OString tmp("'-X', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i+1] + "'";
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index dab77fa42292..8d67cdc94e11 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -27,6 +27,7 @@
#include <set>
#include <string_view>
#include <memory>
+#include <utility>
#include <vector>
#include <iostream>
@@ -52,6 +53,8 @@
namespace
{
+using FileType = codemaker::cppumaker::FileType;
+
bool isBootstrapType(OUString const & name)
{
static char const * const names[] = {
@@ -143,19 +146,26 @@ bool isBootstrapType(OUString const & name)
"com.sun.star.uno.XWeak",
"com.sun.star.util.XMacroExpander" };
// cf. cppuhelper/unotypes/Makefile UNOTYPES (plus missing dependencies)
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(names); ++i) {
- if (name.equalsAscii(names[i])) {
- return true;
- }
+ auto const pred = [&name](const char* aName) {
+ return name.equalsAscii(aName);
+ };
+ return std::any_of(std::begin(names), std::end(names), pred);
+}
+
+OString getFileExtension(FileType eFileType)
+{
+ switch(eFileType)
+ {
+ default:
+ case FileType::HDL: return ".hdl"_ostr;
+ case FileType::HPP: return ".hpp"_ostr;
}
- return false;
}
class CppuType
{
public:
- CppuType(
- OUString const & name, rtl::Reference< TypeManager > const & typeMgr);
+ CppuType(OUString name, rtl::Reference< TypeManager > const & typeMgr);
virtual ~CppuType() {}
@@ -165,7 +175,7 @@ public:
void dump(CppuOptions const & options);
void dumpFile(
- std::u16string_view uri, std::u16string_view name, bool hpp,
+ std::u16string_view uri, std::u16string_view name, FileType eFileType,
CppuOptions const & options);
void dumpDependedTypes(
@@ -275,12 +285,12 @@ private:
};
CppuType::CppuType(
- OUString const & name, rtl::Reference< TypeManager > const & typeMgr):
+ OUString name, rtl::Reference< TypeManager > const & typeMgr):
m_inheritedMemberCount(0)
, m_cppuTypeLeak(false)
, m_cppuTypeDynamic(true)
, m_indentLength(0)
- , name_(name)
+ , name_(std::move(name))
, id_(name_.copy(name_.lastIndexOf('.') + 1))
, m_typeMgr(typeMgr)
, m_dependencies(typeMgr, name_)
@@ -307,8 +317,8 @@ const
void CppuType::dumpFiles(OUString const & uri, CppuOptions const & options)
{
- dumpFile(uri, name_, false, options);
- dumpFile(uri, name_, true, options);
+ dumpFile(uri, name_, FileType::HDL, options);
+ dumpFile(uri, name_, FileType::HPP, options);
}
void CppuType::addLightGetCppuTypeIncludes(
@@ -403,27 +413,27 @@ void CppuType::dump(CppuOptions const & options)
// functions; since the introduction of cppu::UnoType this no longer is
// meaningful (getCppuType is just a forward to cppu::UnoType::get now),
// and -CS is handled the same way as -C now:
- if (options.isValid("-L"))
+ if (options.isValid("-L"_ostr))
m_cppuTypeLeak = true;
- if (options.isValid("-C") || options.isValid("-CS"))
+ if (options.isValid("-C"_ostr) || options.isValid("-CS"_ostr))
m_cppuTypeDynamic = false;
}
dumpFiles(
- options.isValid("-O") ? b2u(options.getOption("-O")) : "", options);
+ options.isValid("-O"_ostr) ? b2u(options.getOption("-O"_ostr)) : u""_ustr, options);
}
void CppuType::dumpFile(
- std::u16string_view uri, std::u16string_view name, bool hpp,
+ std::u16string_view uri, std::u16string_view name, FileType eFileType,
CppuOptions const & options)
{
OUString fileUri(
b2u(createFileNameFromType(
- u2b(uri), u2b(name), hpp ? ".hpp" : ".hdl")));
+ u2b(uri), u2b(name), getFileExtension(eFileType))));
if (fileUri.isEmpty()) {
throw CannotDumpException(OUString::Concat("empty target URI for entity ") + name);
}
bool exists = fileExists(u2b(fileUri));
- if (exists && options.isValid("-G")) {
+ if (exists && options.isValid("-G"_ostr)) {
return;
}
FileStream out;
@@ -432,13 +442,17 @@ void CppuType::dumpFile(
if(!out.isValid()) {
throw CannotDumpException("cannot open " + tmpUri + " for writing");
}
- codemaker::cppumaker::Includes includes(m_typeMgr, m_dependencies, hpp);
+ codemaker::cppumaker::Includes includes(m_typeMgr, m_dependencies, eFileType);
try {
- if (hpp) {
- addGetCppuTypeIncludes(includes);
- dumpHppFile(out, includes);
- } else {
- dumpHdlFile(out, includes);
+ switch(eFileType)
+ {
+ case FileType::HPP:
+ addGetCppuTypeIncludes(includes);
+ dumpHppFile(out, includes);
+ break;
+ case FileType::HDL:
+ dumpHdlFile(out, includes);
+ break;
}
} catch (...) {
out.close();
@@ -452,13 +466,13 @@ void CppuType::dumpFile(
}
out.close();
(void)makeValidTypeFile(
- u2b(fileUri), u2b(tmpUri), exists && options.isValid("-Gc"));
+ u2b(fileUri), u2b(tmpUri), exists && options.isValid("-Gc"_ostr));
}
void CppuType::dumpDependedTypes(
codemaker::GeneratedTypeSet & generated, CppuOptions const & options) const
{
- if (!options.isValid("-nD")) {
+ if (!options.isValid("-nD"_ostr)) {
codemaker::cppumaker::Dependencies::Map const & map
= m_dependencies.getMap();
for (const auto& entry : map) {
@@ -656,86 +670,86 @@ OUString CppuType::getTypeClass(OUString const & name, bool cStyle)
switch (m_typeMgr->getSort(name, &ent)) {
case codemaker::UnoType::Sort::Void:
return cStyle
- ? OUString("typelib_TypeClass_VOID")
- : OUString("::css::uno::TypeClass_VOID");
+ ? u"typelib_TypeClass_VOID"_ustr
+ : u"::css::uno::TypeClass_VOID"_ustr;
case codemaker::UnoType::Sort::Boolean:
return cStyle
- ? OUString("typelib_TypeClass_BOOLEAN")
- : OUString("::css::uno::TypeClass_BOOLEAN");
+ ? u"typelib_TypeClass_BOOLEAN"_ustr
+ : u"::css::uno::TypeClass_BOOLEAN"_ustr;
case codemaker::UnoType::Sort::Byte:
return cStyle
- ? OUString("typelib_TypeClass_BYTE")
- : OUString("::css::uno::TypeClass_BYTE");
+ ? u"typelib_TypeClass_BYTE"_ustr
+ : u"::css::uno::TypeClass_BYTE"_ustr;
case codemaker::UnoType::Sort::Short:
return cStyle
- ? OUString("typelib_TypeClass_SHORT")
- : OUString("::css::uno::TypeClass_SHORT");
+ ? u"typelib_TypeClass_SHORT"_ustr
+ : u"::css::uno::TypeClass_SHORT"_ustr;
case codemaker::UnoType::Sort::UnsignedShort:
return cStyle
- ? OUString("typelib_TypeClass_UNSIGNED_SHORT")
- : OUString("::css::uno::TypeClass_UNSIGNED_SHORT");
+ ? u"typelib_TypeClass_UNSIGNED_SHORT"_ustr
+ : u"::css::uno::TypeClass_UNSIGNED_SHORT"_ustr;
case codemaker::UnoType::Sort::Long:
return cStyle
- ? OUString("typelib_TypeClass_LONG")
- : OUString("::css::uno::TypeClass_LONG");
+ ? u"typelib_TypeClass_LONG"_ustr
+ : u"::css::uno::TypeClass_LONG"_ustr;
case codemaker::UnoType::Sort::UnsignedLong:
return cStyle
- ? OUString("typelib_TypeClass_UNSIGNED_LONG")
- : OUString("::css::uno::TypeClass_UNSIGNED_LONG");
+ ? u"typelib_TypeClass_UNSIGNED_LONG"_ustr
+ : u"::css::uno::TypeClass_UNSIGNED_LONG"_ustr;
case codemaker::UnoType::Sort::Hyper:
return cStyle
- ? OUString("typelib_TypeClass_HYPER")
- : OUString("::css::uno::TypeClass_HYPER");
+ ? u"typelib_TypeClass_HYPER"_ustr
+ : u"::css::uno::TypeClass_HYPER"_ustr;
case codemaker::UnoType::Sort::UnsignedHyper:
return cStyle
- ? OUString("typelib_TypeClass_UNSIGNED_HYPER")
- : OUString("::css::uno::TypeClass_UNSIGNED_HYPER");
+ ? u"typelib_TypeClass_UNSIGNED_HYPER"_ustr
+ : u"::css::uno::TypeClass_UNSIGNED_HYPER"_ustr;
case codemaker::UnoType::Sort::Float:
return cStyle
- ? OUString("typelib_TypeClass_FLOAT")
- : OUString("::css::uno::TypeClass_FLOAT");
+ ? u"typelib_TypeClass_FLOAT"_ustr
+ : u"::css::uno::TypeClass_FLOAT"_ustr;
case codemaker::UnoType::Sort::Double:
return cStyle
- ? OUString("typelib_TypeClass_DOUBLE")
- : OUString("::css::uno::TypeClass_DOUBLE");
+ ? u"typelib_TypeClass_DOUBLE"_ustr
+ : u"::css::uno::TypeClass_DOUBLE"_ustr;
case codemaker::UnoType::Sort::Char:
return cStyle
- ? OUString("typelib_TypeClass_CHAR")
- : OUString("::css::uno::TypeClass_CHAR");
+ ? u"typelib_TypeClass_CHAR"_ustr
+ : u"::css::uno::TypeClass_CHAR"_ustr;
case codemaker::UnoType::Sort::String:
return cStyle
- ? OUString("typelib_TypeClass_STRING")
- : OUString("::css::uno::TypeClass_STRING");
+ ? u"typelib_TypeClass_STRING"_ustr
+ : u"::css::uno::TypeClass_STRING"_ustr;
case codemaker::UnoType::Sort::Type:
return cStyle
- ? OUString("typelib_TypeClass_TYPE")
- : OUString("::css::uno::TypeClass_TYPE");
+ ? u"typelib_TypeClass_TYPE"_ustr
+ : u"::css::uno::TypeClass_TYPE"_ustr;
case codemaker::UnoType::Sort::Any:
return cStyle
- ? OUString("typelib_TypeClass_ANY")
- : OUString("::css::uno::TypeClass_ANY");
+ ? u"typelib_TypeClass_ANY"_ustr
+ : u"::css::uno::TypeClass_ANY"_ustr;
case codemaker::UnoType::Sort::Sequence:
return cStyle
- ? OUString("typelib_TypeClass_SEQUENCE")
- : OUString("::css::uno::TypeClass_SEQUENCE");
+ ? u"typelib_TypeClass_SEQUENCE"_ustr
+ : u"::css::uno::TypeClass_SEQUENCE"_ustr;
case codemaker::UnoType::Sort::Enum:
return cStyle
- ? OUString("typelib_TypeClass_ENUM")
- : OUString("::css::uno::TypeClass_ENUM");
+ ? u"typelib_TypeClass_ENUM"_ustr
+ : u"::css::uno::TypeClass_ENUM"_ustr;
case codemaker::UnoType::Sort::PlainStruct:
case codemaker::UnoType::Sort::PolymorphicStructTemplate:
case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
return cStyle
- ? OUString("typelib_TypeClass_STRUCT")
- : OUString("::css::uno::TypeClass_STRUCT");
+ ? u"typelib_TypeClass_STRUCT"_ustr
+ : u"::css::uno::TypeClass_STRUCT"_ustr;
case codemaker::UnoType::Sort::Exception:
return cStyle
- ? OUString("typelib_TypeClass_EXCEPTION")
- : OUString("::css::uno::TypeClass_EXCEPTION");
+ ? u"typelib_TypeClass_EXCEPTION"_ustr
+ : u"::css::uno::TypeClass_EXCEPTION"_ustr;
case codemaker::UnoType::Sort::Interface:
return cStyle
- ? OUString("typelib_TypeClass_INTERFACE")
- : OUString("::css::uno::TypeClass_INTERFACE");
+ ? u"typelib_TypeClass_INTERFACE"_ustr
+ : u"::css::uno::TypeClass_INTERFACE"_ustr;
case codemaker::UnoType::Sort::Typedef:
return getTypeClass(dynamic_cast<unoidl::TypedefEntity&>(*ent).getType(), cStyle);
default:
@@ -1053,9 +1067,9 @@ class BaseOffset
{
public:
BaseOffset(
- rtl::Reference< TypeManager > const & manager,
+ rtl::Reference< TypeManager > manager,
rtl::Reference< unoidl::InterfaceTypeEntity > const & entity):
- manager_(manager), offset_(0) {
+ manager_(std::move(manager)), offset_(0) {
calculateBases(entity);
}
BaseOffset(const BaseOffset&) = delete;
@@ -1186,7 +1200,7 @@ void InterfaceType::dumpHppFile(
out << "\n";
addDefaultHxxIncludes(includes);
includes.dump(out, &name_, !(m_cppuTypeLeak || m_cppuTypeDynamic));
- out << "\n";
+ out << "\n#if defined LIBO_INTERNAL_ONLY\n#include <type_traits>\n#endif\n\n";
dumpGetCppuType(out);
out << "\n::css::uno::Type const & "
<< codemaker::cpp::scopedCppName(u2b(name_))
@@ -1196,7 +1210,15 @@ void InterfaceType::dumpHppFile(
dumpType(out, name_, false, false, true);
out << " >::get();\n";
dec();
- out << "}\n\n#endif // "<< headerDefine << "\n";
+ out << "}\n\n#if defined LIBO_INTERNAL_ONLY\nnamespace cppu::detail {\n";
+ if (name_ == "com.sun.star.uno.XInterface") {
+ out << "template<typename> struct IsUnoInterfaceType: ::std::false_type {};\n"
+ "template<typename T> inline constexpr auto isUnoInterfaceType ="
+ " sizeof (T) && IsUnoInterfaceType<T>::value;\n";
+ }
+ out << "template<> struct IsUnoInterfaceType<";
+ dumpType(out, name_, false, false, true);
+ out << ">: ::std::true_type {};\n}\n#endif\n\n#endif // "<< headerDefine << "\n";
}
void InterfaceType::dumpAttributes(FileStream & out) const
@@ -1375,7 +1397,7 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream & out)
<< indent() << "bInitStarted = true;\n";
std::set< OUString > seen;
// Type for RuntimeException is always needed:
- seen.insert("com.sun.star.uno.RuntimeException");
+ seen.insert(u"com.sun.star.uno.RuntimeException"_ustr);
dumpCppuGetType(out, u"com.sun.star.uno.RuntimeException");
dumpAttributesCppuDecl(out, &seen);
dumpMethodsCppuDecl(out, &seen);
@@ -1437,7 +1459,7 @@ void InterfaceType::addComprehensiveGetCppuTypeIncludes(
includes.addCppuUnotypeHxx();
includes.addRtlInstanceHxx(); // using rtl::StaticWithInit
includes.addOslMutexHxx();
- includes.add("com.sun.star.uno.RuntimeException");
+ includes.add("com.sun.star.uno.RuntimeException"_ostr);
}
void InterfaceType::dumpCppuAttributes(FileStream & out, sal_uInt32 & index)
@@ -1713,7 +1735,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");
@@ -2052,8 +2078,10 @@ void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out)
for (std::vector< unoidl::PlainStructTypeEntity::Member >::const_iterator i(
entity_->getDirectMembers().begin());
i != entity_->getDirectMembers().end();) {
+ const auto iter = types.find(i->type);
+ assert(iter != types.end());
out << indent() << "{ { " << getTypeClass(i->type, true)
- << ", the_tname" << types.find(i->type)->second
+ << ", the_tname" << iter->second
<< ".pData, the_name" << n++ << ".pData }, false }";
++i;
out << (i == entity_->getDirectMembers().end() ? " };" : ",") << "\n";
@@ -2621,11 +2649,15 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out)
i != entity_->getMembers().end();) {
out << indent() << "{ { ";
if (i->parameterized) {
- sal_uInt32 k = parameters.find(i->type)->second;
+ const auto iter = parameters.find(i->type);
+ assert(iter != parameters.end());
+ sal_uInt32 k = iter->second;
out << "the_pclass" << k << ", the_pname" << k << ".pData";
} else {
+ const auto iter = types.find(i->type);
+ assert(iter != types.end());
out << getTypeClass(i->type, true) << ", the_tname"
- << types.find(i->type)->second << ".pData";
+ << iter->second << ".pData";
}
out << ", the_name" << n++ << ".pData }, "
<< (i->parameterized ? "true" : "false") << " }";
@@ -2786,17 +2818,21 @@ void ExceptionType::dumpHdlFile(
{
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 9 supporting __builtin_FILE/LINE/FUNCTION as used by
- // that libstdc++ header.
- includes.addCustom("#if defined LIBO_INTERNAL_ONLY && ((defined __GNUC__ && !defined __clang__) || (defined __clang__ && __clang_major__ >= 9)) && __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");
+ includes.addCustom(u"#if defined(LIBO_INTERNAL_ONLY)"_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"#endif"_ustr);
+ includes.addCustom(u"#if defined LIBO_USE_SOURCE_LOCATION"_ustr);
+ includes.addCustom(u"#include <o3tl/runtimetooustring.hxx>"_ustr);
+ includes.addCustom(u"#endif"_ustr);
}
dumpHFileContent(out, includes);
}
@@ -2834,7 +2870,7 @@ void ExceptionType::dumpHppFile(
// default constructor
out << "\ninline " << id_ << "::" << id_ << "(\n";
out << "#if defined LIBO_USE_SOURCE_LOCATION\n";
- out << " std::experimental::source_location location\n";
+ out << " LIBO_USE_SOURCE_LOCATION::source_location location\n";
out << "#endif\n";
out << " )\n";
inc();
@@ -2871,7 +2907,7 @@ void ExceptionType::dumpHppFile(
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 << " Message += \"at \" + o3tl::runtimeToOUString(location.file_name()) + \":\" + OUString::number(location.line());\n";
out << "#endif\n";
}
out << "}\n\n";
@@ -2889,7 +2925,7 @@ void ExceptionType::dumpHppFile(
bFirst = false;
}
out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
- out << " " << (bFirst ? "" : ", ") << "std::experimental::source_location location\n";
+ out << " " << (bFirst ? "" : ", ") << "LIBO_USE_SOURCE_LOCATION::source_location location\n";
out << "#endif\n";
out << ")\n";
inc();
@@ -2924,7 +2960,7 @@ void ExceptionType::dumpHppFile(
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 << " Message += \"at \" + o3tl::runtimeToOUString(location.file_name()) + \":\" + OUString::number(location.line());\n";
out << "#endif\n";
}
out << "}\n\n";
@@ -3150,7 +3186,7 @@ void ExceptionType::dumpDeclaration(FileStream & out)
// 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 << " LIBO_USE_SOURCE_LOCATION::source_location location = LIBO_USE_SOURCE_LOCATION::source_location::current()\n";
out << "#endif\n\n";
out << " );\n";
@@ -3168,7 +3204,7 @@ void ExceptionType::dumpDeclaration(FileStream & out)
bFirst = false;
}
out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
- out << ", std::experimental::source_location location = std::experimental::source_location::current()\n";
+ out << ", LIBO_USE_SOURCE_LOCATION::source_location location = LIBO_USE_SOURCE_LOCATION::source_location::current()\n";
out << "#endif\n";
out << " );\n\n";
}
@@ -3292,7 +3328,11 @@ void EnumType::addComprehensiveGetCppuTypeIncludes(
void EnumType::dumpDeclaration(FileStream& o)
{
o << "\n#if defined LIBO_INTERNAL_ONLY\n";
+ o << "\n#if defined __GNUC__\n"; // gcc does not like visibility annotation on enum
+ o << "\nenum class " << id_ << "\n{\n";
+ o << "\n#else\n";
o << "\nenum class SAL_DLLPUBLIC_RTTI " << id_ << "\n{\n";
+ o << "\n#endif\n";
o << "\n#else\n";
o << "\nenum SAL_DLLPUBLIC_RTTI " << id_ << "\n{\n";
o << "\n#endif\n";
@@ -3509,7 +3549,7 @@ private:
}
virtual void dumpFiles(OUString const & uri, CppuOptions const & options) override {
- dumpFile(uri, name_, true, options);
+ dumpFile(uri, name_, FileType::HPP, options);
}
};
@@ -3572,12 +3612,12 @@ void ServiceType::dumpHppFile(
includes.addReference();
includes.addRtlUstringH();
includes.addRtlUstringHxx();
- includes.add("com.sun.star.uno.DeploymentException");
- includes.add("com.sun.star.uno.XComponentContext");
+ includes.add("com.sun.star.uno.DeploymentException"_ostr);
+ includes.add("com.sun.star.uno.XComponentContext"_ostr);
for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor& cons : entity_->getConstructors()) {
if (cons.defaultConstructor) {
- includes.add("com.sun.star.uno.Exception");
- includes.add("com.sun.star.uno.RuntimeException");
+ includes.add("com.sun.star.uno.Exception"_ostr);
+ includes.add("com.sun.star.uno.RuntimeException"_ostr);
} else {
if (!hasRestParameter(cons)) {
includes.addAny();
@@ -3598,8 +3638,8 @@ void ServiceType::dumpHppFile(
tree.add(u2b(ex), m_typeMgr);
}
if (!tree.getRoot().present) {
- includes.add("com.sun.star.uno.Exception");
- includes.add("com.sun.star.uno.RuntimeException");
+ includes.add("com.sun.star.uno.Exception"_ostr);
+ includes.add("com.sun.star.uno.RuntimeException"_ostr);
includeExceptions(includes, &tree.getRoot());
}
}
@@ -3641,7 +3681,7 @@ void ServiceType::dumpHppFile(
o << indent() << "static ::css::uno::Reference< "
<< scopedBaseName << " > "
<< codemaker::cpp::translateUnoToCppIdentifier(
- "create", "method", codemaker::cpp::IdentifierTranslationMode::NonGlobal,
+ "create"_ostr, "method", codemaker::cpp::IdentifierTranslationMode::NonGlobal,
&cppName)
<< ("(::css::uno::Reference< ::css::uno::XComponentContext > const &"
" the_context) {\n");
@@ -3911,8 +3951,8 @@ void SingletonType::dumpHppFile(
o << "\n";
//TODO: Decide whether the types added to includes should rather be added to
// m_dependencies (and thus be generated during dumpDependedTypes):
- includes.add("com.sun.star.uno.DeploymentException");
- includes.add("com.sun.star.uno.XComponentContext");
+ includes.add("com.sun.star.uno.DeploymentException"_ostr);
+ includes.add("com.sun.star.uno.XComponentContext"_ostr);
includes.addCassert();
includes.addAny();
includes.addReference();
@@ -3940,7 +3980,7 @@ void SingletonType::dumpHppFile(
o << indent() << "static ::css::uno::Reference< "
<< scopedBaseName << " > "
<< codemaker::cpp::translateUnoToCppIdentifier(
- "get", "method", codemaker::cpp::IdentifierTranslationMode::NonGlobal, &cppName)
+ "get"_ostr, "method", codemaker::cpp::IdentifierTranslationMode::NonGlobal, &cppName)
<< ("(::css::uno::Reference<"
" ::css::uno::XComponentContext > const & the_context)"
" {\n");
diff --git a/codemaker/source/cppumaker/cpputype.hxx b/codemaker/source/cppumaker/cpputype.hxx
index 40fc94f26c29..c41cfa287646 100644
--- a/codemaker/source/cppumaker/cpputype.hxx
+++ b/codemaker/source/cppumaker/cpputype.hxx
@@ -28,6 +28,14 @@ namespace rtl { class OUString; }
class CppuOptions;
class TypeManager;
+namespace codemaker::cppumaker {
+enum class FileType
+{
+ HDL,
+ HPP
+};
+}
+
void produce(
OUString const & name, rtl::Reference< TypeManager > const & manager,
codemaker::GeneratedTypeSet & generated, CppuOptions const & options);
diff --git a/codemaker/source/cppumaker/dumputils.cxx b/codemaker/source/cppumaker/dumputils.cxx
index 15b62e04a407..2a3e809e70f3 100644
--- a/codemaker/source/cppumaker/dumputils.cxx
+++ b/codemaker/source/cppumaker/dumputils.cxx
@@ -24,17 +24,18 @@
#include <rtl/ustring.hxx>
#include <sal/types.h>
+#include <o3tl/string_view.hxx>
namespace codemaker::cppumaker {
bool dumpNamespaceOpen(
- FileStream & out, OUString const & entityName, bool fullModuleType)
+ FileStream & out, std::u16string_view entityName, bool fullModuleType)
{
bool bOutput = false;
bool bFirst = true;
for (sal_Int32 i = 0; i >= 0;) {
- OUString id(entityName.getToken(0, '.', i));
+ std::u16string_view id(o3tl::getToken(entityName, 0, '.', i));
if (fullModuleType || i >= 0) {
if (!bFirst) {
out << " ";
@@ -48,16 +49,16 @@ bool dumpNamespaceOpen(
}
bool dumpNamespaceClose(
- FileStream & out, OUString const & entityName, bool fullModuleType)
+ FileStream & out, std::u16string_view entityName, bool fullModuleType)
{
bool bOutput = false;
bool bFirst = true;
- for (sal_Int32 i = 0; i >= 0;) {
- i = entityName.indexOf('.', i);
- if (i >= 0) {
+ for (size_t i = 0; i != std::u16string_view::npos;) {
+ i = entityName.find('.', i);
+ if (i != std::u16string_view::npos) {
++i;
}
- if (fullModuleType || i >= 0) {
+ if (fullModuleType || i != std::u16string_view::npos) {
if (!bFirst) {
out << " ";
}
@@ -69,8 +70,8 @@ bool dumpNamespaceClose(
return bOutput;
}
-void dumpTypeIdentifier(FileStream & out, OUString const & entityName) {
- out << entityName.subView(entityName.lastIndexOf('.') + 1);
+void dumpTypeIdentifier(FileStream & out, std::u16string_view entityName) {
+ out << entityName.substr(entityName.rfind('.') + 1);
}
}
diff --git a/codemaker/source/cppumaker/dumputils.hxx b/codemaker/source/cppumaker/dumputils.hxx
index 58ccdc93fac5..24e5bae3bede 100644
--- a/codemaker/source/cppumaker/dumputils.hxx
+++ b/codemaker/source/cppumaker/dumputils.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <sal/config.h>
+#include <string_view>
namespace rtl
{
@@ -29,11 +30,11 @@ class FileStream;
namespace codemaker::cppumaker
{
-bool dumpNamespaceOpen(FileStream& out, rtl::OUString const& entityName, bool fullModuleType);
+bool dumpNamespaceOpen(FileStream& out, std::u16string_view entityName, bool fullModuleType);
-bool dumpNamespaceClose(FileStream& out, rtl::OUString const& entityName, bool fullModuleType);
+bool dumpNamespaceClose(FileStream& out, std::u16string_view entityName, bool fullModuleType);
-void dumpTypeIdentifier(FileStream& out, rtl::OUString const& entityName);
+void dumpTypeIdentifier(FileStream& out, std::u16string_view entityName);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx
index db7dae46bccc..05f768bbc505 100644
--- a/codemaker/source/cppumaker/includes.cxx
+++ b/codemaker/source/cppumaker/includes.cxx
@@ -20,6 +20,7 @@
#include "includes.hxx"
+#include "cpputype.hxx"
#include "dependencies.hxx"
#include "dumputils.hxx"
@@ -33,14 +34,15 @@
#include <rtl/ustring.hxx>
#include <sal/types.h>
+#include <utility>
#include <vector>
using codemaker::cppumaker::Includes;
Includes::Includes(
- rtl::Reference< TypeManager > const & manager,
- codemaker::cppumaker::Dependencies const & dependencies, bool hpp):
- m_manager(manager), m_map(dependencies.getMap()), m_hpp(hpp),
+ rtl::Reference< TypeManager > manager,
+ codemaker::cppumaker::Dependencies const & dependencies, FileType eFileType):
+ m_manager(std::move(manager)), m_map(dependencies.getMap()), m_filetype(eFileType),
m_includeCassert(false),
m_includeAny(dependencies.hasAnyDependency()), m_includeReference(false),
m_includeSequence(dependencies.hasSequenceDependency()),
@@ -135,7 +137,7 @@ void dumpEmptyLineBeforeFirst(FileStream & out, bool * first) {
void Includes::dump(
FileStream & out, OUString const * companionHdl, bool exceptions)
{
- OSL_ASSERT(companionHdl == nullptr || m_hpp);
+ OSL_ASSERT(companionHdl == nullptr || m_filetype == FileType::HPP);
if (!m_includeReference) {
for (const auto& pair : m_map)
{
@@ -158,12 +160,12 @@ void Includes::dump(
{
if (exceptions || pair.second != Dependencies::KIND_EXCEPTION) {
dumpEmptyLineBeforeFirst(out, &first);
- if (m_hpp || pair.second == Dependencies::KIND_BASE
+ if ((m_filetype == FileType::HPP) || pair.second == Dependencies::KIND_BASE
|| !isInterfaceType(u2b(pair.first)))
{
// If we know our name, then avoid including ourselves.
if (!companionHdl || *companionHdl != pair.first) {
- dumpInclude(out, u2b(pair.first), m_hpp);
+ dumpInclude(out, u2b(pair.first), (m_filetype == FileType::HPP));
}
} else {
bool ns = dumpNamespaceOpen(out, pair.first, false);
@@ -184,22 +186,22 @@ void Includes::dump(
static char const * hxxExtension[2] = { "h", "hxx" };
if (m_includeAny) {
dumpEmptyLineBeforeFirst(out, &first);
- out << "#include \"com/sun/star/uno/Any." << hxxExtension[m_hpp]
+ out << "#include \"com/sun/star/uno/Any." << hxxExtension[(m_filetype == FileType::HPP)]
<< "\"\n";
}
if (m_includeReference) {
dumpEmptyLineBeforeFirst(out, &first);
- out << "#include \"com/sun/star/uno/Reference." << hxxExtension[m_hpp]
+ out << "#include \"com/sun/star/uno/Reference." << hxxExtension[(m_filetype == FileType::HPP)]
<< "\"\n";
}
if (m_includeSequence) {
dumpEmptyLineBeforeFirst(out, &first);
- out << "#include \"com/sun/star/uno/Sequence." << hxxExtension[m_hpp]
+ out << "#include \"com/sun/star/uno/Sequence." << hxxExtension[(m_filetype == FileType::HPP)]
<< "\"\n";
}
if (m_includeType) {
dumpEmptyLineBeforeFirst(out, &first);
- out << "#include \"com/sun/star/uno/Type." << hxxExtension[m_hpp]
+ out << "#include \"com/sun/star/uno/Type." << hxxExtension[(m_filetype == FileType::HPP)]
<< "\"\n";
}
if (m_includeCppuMacrosHxx) {
diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx
index 0362c417ac2a..dcdcb5836f7e 100644
--- a/codemaker/source/cppumaker/includes.hxx
+++ b/codemaker/source/cppumaker/includes.hxx
@@ -29,12 +29,13 @@ class FileStream;
class TypeManager;
namespace codemaker::cppumaker {
+enum class FileType;
class Includes {
public:
Includes(
- rtl::Reference< TypeManager > const & manager,
- Dependencies const & dependencies, bool hpp);
+ rtl::Reference< TypeManager > manager,
+ Dependencies const & dependencies, FileType eFileType);
~Includes();
@@ -73,7 +74,7 @@ private:
rtl::Reference< TypeManager > m_manager;
Dependencies::Map m_map;
- bool m_hpp;
+ FileType m_filetype;
bool m_includeCassert;
bool m_includeAny;
bool m_includeReference;
diff --git a/codemaker/source/javamaker/classfile.cxx b/codemaker/source/javamaker/classfile.cxx
index 67177a718529..fd32497508c6 100644
--- a/codemaker/source/javamaker/classfile.cxx
+++ b/codemaker/source/javamaker/classfile.cxx
@@ -73,7 +73,7 @@ void appendStream(
void write(FileStream & file, void const * buffer, sal_uInt64 size) {
if (!file.write(buffer, size))
- throw CannotDumpException("Error writing file");
+ throw CannotDumpException(u"Error writing file"_ustr);
}
void writeU2(FileStream & file, sal_uInt16 data) {
@@ -234,7 +234,7 @@ void ClassFile::Code::instrLookupswitch(
// <match--offset pairs...>:
std::vector< std::pair< sal_Int32, Code * > >::size_type size = blocks.size();
if (size > SAL_MAX_INT32) {
- throw CannotDumpException("Lookup-switch too large for Java class file format");
+ throw CannotDumpException(u"Lookup-switch too large for Java class file format"_ustr);
}
Position pos1 = m_code.size();
appendU1(m_code, 0xAB);
@@ -408,7 +408,7 @@ void ClassFile::Code::addException(
{
OSL_ASSERT(start < end && end <= m_code.size() && handler <= m_code.size());
if (m_exceptionTableLength == SAL_MAX_UINT16) {
- throw CannotDumpException("Too many exception handlers for Java class file format");
+ throw CannotDumpException(u"Too many exception handlers for Java class file format"_ustr);
}
++m_exceptionTableLength;
appendU2(m_exceptionTable, static_cast< sal_uInt16 >(start));
@@ -471,7 +471,7 @@ ClassFile::ClassFile(
m_superClass = addClassInfo(superClass);
if (!signature.isEmpty()) {
++m_attributesCount;
- appendU2(m_attributes, addUtf8Info("Signature"));
+ appendU2(m_attributes, addUtf8Info("Signature"_ostr));
appendU4(m_attributes, 2);
appendU2(m_attributes, addUtf8Info(signature));
}
@@ -549,7 +549,7 @@ sal_uInt16 ClassFile::addDoubleInfo(double value) {
void ClassFile::addInterface(OString const & interface) {
if (m_interfacesCount == SAL_MAX_UINT16) {
- throw CannotDumpException("Too many interfaces for Java class file format");
+ throw CannotDumpException(u"Too many interfaces for Java class file format"_ustr);
}
++m_interfacesCount;
appendU2(m_interfaces, addClassInfo(interface));
@@ -561,7 +561,7 @@ void ClassFile::addField(
OString const & signature)
{
if (m_fieldsCount == SAL_MAX_UINT16) {
- throw CannotDumpException("Too many fields for Java class file format");
+ throw CannotDumpException(u"Too many fields for Java class file format"_ustr);
}
++m_fieldsCount;
appendU2(m_fields, static_cast< sal_uInt16 >(accessFlags));
@@ -572,7 +572,7 @@ void ClassFile::addField(
((constantValueIndex == 0 ? 0 : 1)
+ (signature.isEmpty() ? 0 : 1)));
if (constantValueIndex != 0) {
- appendU2(m_fields, addUtf8Info("ConstantValue"));
+ appendU2(m_fields, addUtf8Info("ConstantValue"_ostr));
appendU4(m_fields, 2);
appendU2(m_fields, constantValueIndex);
}
@@ -586,7 +586,7 @@ void ClassFile::addMethod(
OString const & signature)
{
if (m_methodsCount == SAL_MAX_UINT16) {
- throw CannotDumpException("Too many methods for Java class file format");
+ throw CannotDumpException(u"Too many methods for Java class file format"_ustr);
}
++m_methodsCount;
appendU2(m_methods, static_cast< sal_uInt16 >(accessFlags));
@@ -594,7 +594,7 @@ void ClassFile::addMethod(
appendU2(m_methods, addUtf8Info(descriptor));
std::vector< OString >::size_type excs = exceptions.size();
if (excs > SAL_MAX_UINT16) {
- throw CannotDumpException("Too many exception specifications for Java class file format");
+ throw CannotDumpException(u"Too many exception specifications for Java class file format"_ustr);
}
appendU2(
m_methods,
@@ -609,9 +609,9 @@ void ClassFile::addMethod(
> (SAL_MAX_UINT32 - (2 + 2 + 4 + 2 + 2)
- static_cast< sal_uInt32 >(codeSize))))
{
- throw CannotDumpException("Code block is too big for Java class file format");
+ throw CannotDumpException(u"Code block is too big for Java class file format"_ustr);
}
- appendU2(m_methods, addUtf8Info("Code"));
+ appendU2(m_methods, addUtf8Info("Code"_ostr));
appendU4(
m_methods,
(2 + 2 + 4 + static_cast< sal_uInt32 >(codeSize) + 2
@@ -625,7 +625,7 @@ void ClassFile::addMethod(
appendU2(m_methods, 0);
}
if (!exceptions.empty()) {
- appendU2(m_methods, addUtf8Info("Exceptions"));
+ appendU2(m_methods, addUtf8Info("Exceptions"_ostr));
appendU4(
m_methods,
static_cast< sal_uInt32 >(2 + 2 * static_cast< sal_uInt32 >(excs)));
@@ -660,7 +660,7 @@ void ClassFile::write(FileStream & file) const {
sal_uInt16 ClassFile::nextConstantPoolIndex(sal_uInt16 width) {
OSL_ASSERT(width == 1 || width == 2);
if (m_constantPoolCount > SAL_MAX_UINT16 - width) {
- throw CannotDumpException("Too many constant pool items for Java class file format");
+ throw CannotDumpException(u"Too many constant pool items for Java class file format"_ustr);
}
sal_uInt16 index = m_constantPoolCount;
m_constantPoolCount = m_constantPoolCount + width;
@@ -673,7 +673,7 @@ sal_uInt16 ClassFile::addUtf8Info(OString const & value) {
return i->second;
}
if (value.getLength() > SAL_MAX_UINT16) {
- throw CannotDumpException("UTF-8 string too long for Java class file format");
+ throw CannotDumpException(u"UTF-8 string too long for Java class file format"_ustr);
}
sal_uInt16 index = nextConstantPoolIndex(1);
appendU1(m_constantPool, 1);
@@ -819,7 +819,7 @@ void ClassFile::appendSignatureAttribute(
std::vector< unsigned char > & stream, OString const & signature)
{
if (!signature.isEmpty()) {
- appendU2(stream, addUtf8Info("Signature"));
+ appendU2(stream, addUtf8Info("Signature"_ostr));
appendU4(stream, 2);
appendU2(stream, addUtf8Info(signature));
}
diff --git a/codemaker/source/javamaker/javamaker.cxx b/codemaker/source/javamaker/javamaker.cxx
index 044292bf6b8f..4c15f4c1e78b 100644
--- a/codemaker/source/javamaker/javamaker.cxx
+++ b/codemaker/source/javamaker/javamaker.cxx
@@ -32,6 +32,7 @@
#include <sal/main.h>
#include <sal/types.h>
#include <unoidl/unoidl.hxx>
+#include <o3tl/string_view.hxx>
#include "javaoptions.hxx"
#include "javatype.hxx"
@@ -54,22 +55,22 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
typeMgr->loadProvider(convertToFileUrl(i), true);
}
codemaker::GeneratedTypeSet generated;
- if (options.isValid("-T")) {
- OUString names(b2u(options.getOption("-T")));
+ if (options.isValid("-T"_ostr)) {
+ OUString names(b2u(options.getOption("-T"_ostr)));
for (sal_Int32 i = 0; i != -1;) {
- OUString name(names.getToken(0, ';', i));
- if (!name.isEmpty()) {
+ std::u16string_view name(o3tl::getToken(names, 0, ';', i));
+ if (!name.empty()) {
produce(
- (name == "*"
- ? ""
- : name.endsWith(".*")
- ? name.copy(0, name.getLength() - std::strlen(".*"))
+ OUString(name == u"*"
+ ? u""
+ : o3tl::ends_with(name, u".*")
+ ? name.substr(0, name.size() - std::strlen(".*"))
: name),
typeMgr, generated, options);
}
}
} else {
- produce("", typeMgr, generated, options);
+ produce(u""_ustr, typeMgr, generated, options);
}
}
catch (CannotDumpException & e) {
diff --git a/codemaker/source/javamaker/javaoptions.cxx b/codemaker/source/javamaker/javaoptions.cxx
index e0e51c9736f8..4db26c1bbd23 100644
--- a/codemaker/source/javamaker/javaoptions.cxx
+++ b/codemaker/source/javamaker/javaoptions.cxx
@@ -68,7 +68,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i];
} else
{
- OString tmp("'-O', please check");
+ OString tmp("'-O', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i+1] + "'";
@@ -81,7 +81,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i] + 2;
}
- m_options["-O"] = OString(s);
+ m_options["-O"_ostr] = OString(s);
break;
case 'n':
if (av[i][2] != 'D' || av[i][3] != '\0')
@@ -90,7 +90,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- m_options["-nD"] = OString();
+ m_options["-nD"_ostr] = OString();
break;
case 'T':
if (av[i][2] == '\0')
@@ -101,7 +101,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i];
} else
{
- OString tmp("'-T', please check");
+ OString tmp("'-T', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i+1] + "'";
@@ -114,13 +114,13 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i] + 2;
}
- if (m_options.count("-T") > 0)
+ if (m_options.count("-T"_ostr) > 0)
{
- OString tmp = m_options["-T"] + ";" + s;
- m_options["-T"] = tmp;
+ OString tmp = m_options["-T"_ostr] + ";" + s;
+ m_options["-T"_ostr] = tmp;
} else
{
- m_options["-T"] = OString(s);
+ m_options["-T"_ostr] = OString(s);
}
break;
case 'G':
@@ -128,7 +128,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
{
if (av[i][3] != '\0')
{
- OString tmp("'-Gc', please check");
+ OString tmp("'-Gc', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -137,11 +137,11 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- m_options["-Gc"] = OString();
+ m_options["-Gc"_ostr] = OString();
break;
} else if (av[i][2] != '\0')
{
- OString tmp("'-G', please check");
+ OString tmp("'-G', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i] + "'";
@@ -150,7 +150,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
throw IllegalArgument(tmp);
}
- m_options["-G"] = OString();
+ m_options["-G"_ostr] = OString();
break;
case 'X': // support for eXtra type rdbs
{
@@ -162,7 +162,7 @@ bool JavaOptions::initOptions(int ac, char* av[], bool bCmdFile)
s = av[i];
} else
{
- OString tmp("'-X', please check");
+ OString tmp("'-X', please check"_ostr);
if (i <= ac - 1)
{
tmp += OString::Concat(" your input '") + av[i+1] + "'";
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
index c7c84a208b3a..974a8f31be6b 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -44,6 +44,7 @@
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <unoidl/unoidl.hxx>
+#include <o3tl/string_view.hxx>
#include "classfile.hxx"
#include "javaoptions.hxx"
@@ -108,14 +109,18 @@ bool isSpecialType(SpecialType special) {
}
OString translateUnoidlEntityNameToJavaFullyQualifiedName(
- OUString const & name, std::string_view prefix)
+ std::u16string_view name, std::string_view prefix)
{
- assert(!name.startsWith("[]"));
- assert(name.indexOf('<') == -1);
- sal_Int32 i = name.lastIndexOf('.') + 1;
- return codemaker::convertString(name.copy(0, i)).replace('.', '/')
+ assert(!o3tl::starts_with(name, u"[]"));
+ assert(name.find('<') == std::string_view::npos);
+ size_t i = name.rfind('.');
+ if (i == std::string_view::npos)
+ i = 0;
+ else
+ ++i;
+ return codemaker::convertString(OUString(name.substr(0, i))).replace('.', '/')
+ codemaker::java::translateUnoToJavaIdentifier(
- codemaker::convertString(name.copy(i)), prefix);
+ codemaker::convertString(OUString(name.substr(i))), prefix);
}
struct PolymorphicUnoType {
@@ -148,7 +153,7 @@ SpecialType translateUnoTypeToDescriptor(
!= codemaker::UnoType::Sort::InstantiatedPolymorphicStruct));
if (rank > 0xFF - (array ? 1 : 0)) {
throw CannotDumpException(
- "Too many array dimensions for Java class file format");
+ u"Too many array dimensions for Java class file format"_ustr);
}
if (array) {
++rank;
@@ -315,7 +320,7 @@ SpecialType getFieldDescriptor(
class MethodDescriptor {
public:
MethodDescriptor(
- rtl::Reference< TypeManager > const & manager,
+ rtl::Reference< TypeManager > manager,
std::set<OUString> * dependencies, std::u16string_view returnType,
SpecialType * specialReturnType,
PolymorphicUnoType * polymorphicUnoType);
@@ -328,7 +333,7 @@ public:
OString getDescriptor() const;
- OString getSignature() const { return m_needsSignature ? m_signatureStart.toString() + m_signatureEnd : OString();}
+ OString getSignature() const { return m_needsSignature ? m_signatureStart + m_signatureEnd : OString();}
private:
rtl::Reference< TypeManager > m_manager;
@@ -341,10 +346,10 @@ private:
};
MethodDescriptor::MethodDescriptor(
- rtl::Reference< TypeManager > const & manager, std::set<OUString> * dependencies,
+ rtl::Reference< TypeManager > manager, std::set<OUString> * dependencies,
std::u16string_view returnType, SpecialType * specialReturnType,
PolymorphicUnoType * polymorphicUnoType):
- m_manager(manager), m_dependencies(dependencies), m_needsSignature(false)
+ m_manager(std::move(manager)), m_dependencies(dependencies), m_needsSignature(false)
{
assert(dependencies != nullptr);
m_descriptorStart.append('(');
@@ -395,20 +400,20 @@ public:
// KIND_MEMBER:
TypeInfo(
- OString const & name, SpecialType specialType, sal_Int32 index,
+ OString name, SpecialType specialType, sal_Int32 index,
PolymorphicUnoType const & polymorphicUnoType,
sal_Int32 typeParameterIndex);
// KIND_ATTRIBUTE/METHOD:
TypeInfo(
- Kind kind, OString const & name, SpecialType specialType, Flags flags,
- sal_Int32 index, PolymorphicUnoType const & polymorphicUnoType);
+ Kind kind, OString name, SpecialType specialType, Flags flags,
+ sal_Int32 index, PolymorphicUnoType polymorphicUnoType);
// KIND_PARAMETER:
TypeInfo(
- OString const & parameterName, SpecialType specialType,
- bool inParameter, bool outParameter, OString const & methodName,
- sal_Int32 index, PolymorphicUnoType const & polymorphicUnoType);
+ OString parameterName, SpecialType specialType,
+ bool inParameter, bool outParameter, OString methodName,
+ sal_Int32 index, PolymorphicUnoType polymorphicUnoType);
sal_uInt16 generateCode(ClassFile::Code & code, std::set<OUString> * dependencies)
const;
@@ -442,10 +447,10 @@ sal_Int32 translateSpecialTypeFlags(
}
TypeInfo::TypeInfo(
- OString const & name, SpecialType specialType, sal_Int32 index,
+ OString name, SpecialType specialType, sal_Int32 index,
PolymorphicUnoType const & polymorphicUnoType,
sal_Int32 typeParameterIndex):
- m_kind(KIND_MEMBER), m_name(name),
+ m_kind(KIND_MEMBER), m_name(std::move(name)),
m_flags(translateSpecialTypeFlags(specialType, false, false)),
m_index(index), m_polymorphicUnoType(polymorphicUnoType),
m_typeParameterIndex(typeParameterIndex)
@@ -456,24 +461,24 @@ TypeInfo::TypeInfo(
}
TypeInfo::TypeInfo(
- Kind kind, OString const & name, SpecialType specialType, Flags flags,
- sal_Int32 index, PolymorphicUnoType const & polymorphicUnoType):
- m_kind(kind), m_name(name),
+ Kind kind, OString name, SpecialType specialType, Flags flags,
+ sal_Int32 index, PolymorphicUnoType polymorphicUnoType):
+ m_kind(kind), m_name(std::move(name)),
m_flags(flags | translateSpecialTypeFlags(specialType, false, false)),
- m_index(index), m_polymorphicUnoType(polymorphicUnoType),
+ m_index(index), m_polymorphicUnoType(std::move(polymorphicUnoType)),
m_typeParameterIndex(0)
{
assert(kind == KIND_ATTRIBUTE || kind == KIND_METHOD);
}
TypeInfo::TypeInfo(
- OString const & parameterName, SpecialType specialType, bool inParameter,
- bool outParameter, OString const & methodName, sal_Int32 index,
- PolymorphicUnoType const & polymorphicUnoType):
- m_kind(KIND_PARAMETER), m_name(parameterName),
+ OString parameterName, SpecialType specialType, bool inParameter,
+ bool outParameter, OString methodName, sal_Int32 index,
+ PolymorphicUnoType polymorphicUnoType):
+ m_kind(KIND_PARAMETER), m_name(std::move(parameterName)),
m_flags(translateSpecialTypeFlags(specialType, inParameter, outParameter)),
- m_index(index), m_methodName(methodName),
- m_polymorphicUnoType(polymorphicUnoType),
+ m_index(index), m_methodName(std::move(methodName)),
+ m_polymorphicUnoType(std::move(polymorphicUnoType)),
m_typeParameterIndex(0)
{}
@@ -482,7 +487,7 @@ sal_uInt16 TypeInfo::generateCode(
{
switch (m_kind) {
case KIND_MEMBER:
- code.instrNew("com/sun/star/lib/uno/typeinfo/MemberTypeInfo");
+ code.instrNew("com/sun/star/lib/uno/typeinfo/MemberTypeInfo"_ostr);
code.instrDup();
code.loadStringConstant(m_name);
code.loadIntegerConstant(m_index);
@@ -491,24 +496,24 @@ sal_uInt16 TypeInfo::generateCode(
generatePolymorphicUnoTypeCode(code, dependencies);
code.loadIntegerConstant(m_typeParameterIndex);
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/MemberTypeInfo", "<init>",
- "(Ljava/lang/String;IILcom/sun/star/uno/Type;I)V");
+ "com/sun/star/lib/uno/typeinfo/MemberTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;IILcom/sun/star/uno/Type;I)V"_ostr);
return 8;
} else if (m_typeParameterIndex >= 0) {
code.instrAconstNull();
code.loadIntegerConstant(m_typeParameterIndex);
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/MemberTypeInfo", "<init>",
- "(Ljava/lang/String;IILcom/sun/star/uno/Type;I)V");
+ "com/sun/star/lib/uno/typeinfo/MemberTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;IILcom/sun/star/uno/Type;I)V"_ostr);
return 6;
} else {
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/MemberTypeInfo", "<init>",
- "(Ljava/lang/String;II)V");
+ "com/sun/star/lib/uno/typeinfo/MemberTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;II)V"_ostr);
return 4;
}
case KIND_ATTRIBUTE:
- code.instrNew("com/sun/star/lib/uno/typeinfo/AttributeTypeInfo");
+ code.instrNew("com/sun/star/lib/uno/typeinfo/AttributeTypeInfo"_ostr);
code.instrDup();
code.loadStringConstant(m_name);
code.loadIntegerConstant(m_index);
@@ -516,17 +521,17 @@ sal_uInt16 TypeInfo::generateCode(
if (m_polymorphicUnoType.kind != PolymorphicUnoType::KIND_NONE) {
generatePolymorphicUnoTypeCode(code, dependencies);
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/AttributeTypeInfo", "<init>",
- "(Ljava/lang/String;IILcom/sun/star/uno/Type;)V");
+ "com/sun/star/lib/uno/typeinfo/AttributeTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;IILcom/sun/star/uno/Type;)V"_ostr);
return 8;
} else {
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/AttributeTypeInfo", "<init>",
- "(Ljava/lang/String;II)V");
+ "com/sun/star/lib/uno/typeinfo/AttributeTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;II)V"_ostr);
return 4;
}
case KIND_METHOD:
- code.instrNew("com/sun/star/lib/uno/typeinfo/MethodTypeInfo");
+ code.instrNew("com/sun/star/lib/uno/typeinfo/MethodTypeInfo"_ostr);
code.instrDup();
code.loadStringConstant(m_name);
code.loadIntegerConstant(m_index);
@@ -534,17 +539,17 @@ sal_uInt16 TypeInfo::generateCode(
if (m_polymorphicUnoType.kind != PolymorphicUnoType::KIND_NONE) {
generatePolymorphicUnoTypeCode(code, dependencies);
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/MethodTypeInfo", "<init>",
- "(Ljava/lang/String;IILcom/sun/star/uno/Type;)V");
+ "com/sun/star/lib/uno/typeinfo/MethodTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;IILcom/sun/star/uno/Type;)V"_ostr);
return 8;
} else {
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/MethodTypeInfo", "<init>",
- "(Ljava/lang/String;II)V");
+ "com/sun/star/lib/uno/typeinfo/MethodTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;II)V"_ostr);
return 4;
}
case KIND_PARAMETER:
- code.instrNew("com/sun/star/lib/uno/typeinfo/ParameterTypeInfo");
+ code.instrNew("com/sun/star/lib/uno/typeinfo/ParameterTypeInfo"_ostr);
code.instrDup();
code.loadStringConstant(m_name);
code.loadStringConstant(m_methodName);
@@ -553,14 +558,14 @@ sal_uInt16 TypeInfo::generateCode(
if (m_polymorphicUnoType.kind != PolymorphicUnoType::KIND_NONE) {
generatePolymorphicUnoTypeCode(code, dependencies);
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/ParameterTypeInfo", "<init>",
+ "com/sun/star/lib/uno/typeinfo/ParameterTypeInfo"_ostr, "<init>"_ostr,
("(Ljava/lang/String;Ljava/lang/String;II"
- "Lcom/sun/star/uno/Type;)V"));
+ "Lcom/sun/star/uno/Type;)V"_ostr));
return 9;
} else {
code.instrInvokespecial(
- "com/sun/star/lib/uno/typeinfo/ParameterTypeInfo", "<init>",
- "(Ljava/lang/String;Ljava/lang/String;II)V");
+ "com/sun/star/lib/uno/typeinfo/ParameterTypeInfo"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Ljava/lang/String;II)V"_ostr);
return 5;
}
default:
@@ -574,23 +579,23 @@ void TypeInfo::generatePolymorphicUnoTypeCode(
{
assert(dependencies != nullptr);
assert(m_polymorphicUnoType.kind != PolymorphicUnoType::KIND_NONE);
- code.instrNew("com/sun/star/uno/Type");
+ code.instrNew("com/sun/star/uno/Type"_ostr);
code.instrDup();
code.loadStringConstant(
codemaker::convertString(m_polymorphicUnoType.name));
if (m_polymorphicUnoType.kind == PolymorphicUnoType::KIND_STRUCT) {
code.instrGetstatic(
- "com/sun/star/uno/TypeClass", "STRUCT",
- "Lcom/sun/star/uno/TypeClass;");
+ "com/sun/star/uno/TypeClass"_ostr, "STRUCT"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
} else {
code.instrGetstatic(
- "com/sun/star/uno/TypeClass", "SEQUENCE",
- "Lcom/sun/star/uno/TypeClass;");
+ "com/sun/star/uno/TypeClass"_ostr, "SEQUENCE"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
}
- dependencies->insert("com.sun.star.uno.TypeClass");
+ dependencies->insert(u"com.sun.star.uno.TypeClass"_ustr);
code.instrInvokespecial(
- "com/sun/star/uno/Type", "<init>",
- "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V");
+ "com/sun/star/uno/Type"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V"_ostr);
}
void writeClassFile(
@@ -598,16 +603,16 @@ void writeClassFile(
ClassFile const & classFile)
{
OString path;
- if (options.isValid("-O")) {
- path = options.getOption("-O");
+ if (options.isValid("-O"_ostr)) {
+ path = options.getOption("-O"_ostr);
}
- OString filename(createFileNameFromType(path, type, ".class"));
+ OString filename(createFileNameFromType(path, type, ".class"_ostr));
bool bCheck = false;
if (fileExists(filename)) {
- if (options.isValid("-G")) {
+ if (options.isValid("-G"_ostr)) {
return;
}
- bCheck = options.isValid("-Gc");
+ bCheck = options.isValid("-Gc"_ostr);
}
FileStream tempfile;
tempfile.createTempFile(getTempDir(filename));
@@ -643,7 +648,7 @@ void addTypeInfo(
std::vector< TypeInfo >::size_type typeInfos = typeInfo.size();
if (typeInfos > SAL_MAX_INT32) {
throw CannotDumpException(
- "UNOTYPEINFO array too big for Java class file format");
+ u"UNOTYPEINFO array too big for Java class file format"_ustr);
}
if (typeInfos == 0)
return;
@@ -652,11 +657,11 @@ void addTypeInfo(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_STATIC
| ClassFile::ACC_FINAL),
- "UNOTYPEINFO", "[Lcom/sun/star/lib/uno/typeinfo/TypeInfo;",
- 0, "");
+ "UNOTYPEINFO"_ostr, "[Lcom/sun/star/lib/uno/typeinfo/TypeInfo;"_ostr,
+ 0, ""_ostr);
std::unique_ptr< ClassFile::Code > code(classFile->newCode());
code->loadIntegerConstant(static_cast< sal_Int32 >(typeInfos));
- code->instrAnewarray("com/sun/star/lib/uno/typeinfo/TypeInfo");
+ code->instrAnewarray("com/sun/star/lib/uno/typeinfo/TypeInfo"_ostr);
sal_Int32 index = 0;
sal_uInt16 stack = 0;
for (const TypeInfo& ti : typeInfo)
@@ -667,18 +672,18 @@ void addTypeInfo(
code->instrAastore();
}
code->instrPutstatic(
- className, "UNOTYPEINFO",
- "[Lcom/sun/star/lib/uno/typeinfo/TypeInfo;");
+ className, "UNOTYPEINFO"_ostr,
+ "[Lcom/sun/star/lib/uno/typeinfo/TypeInfo;"_ostr);
code->instrReturn();
if (stack > SAL_MAX_UINT16 - 4) {
throw CannotDumpException(
- "Stack too big for Java class file format");
+ u"Stack too big for Java class file format"_ustr);
}
code->setMaxStackAndLocals(static_cast< sal_uInt16 >(stack + 4), 0);
classFile->addMethod(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PRIVATE | ClassFile::ACC_STATIC),
- "<clinit>", "()V", code.get(), std::vector< OString >(), "");
+ "<clinit>"_ostr, "()V"_ostr, code.get(), std::vector< OString >(), ""_ostr);
}
void handleEnumType(
@@ -692,7 +697,7 @@ void handleEnumType(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_FINAL
| ClassFile::ACC_SUPER),
- className, "com/sun/star/uno/Enum", ""));
+ className, "com/sun/star/uno/Enum"_ostr, ""_ostr));
OString classDescriptor("L" + className + ";");
for (const unoidl::EnumTypeEntity::Member& member : entity->getMembers())
{
@@ -706,19 +711,19 @@ void handleEnumType(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_STATIC
| ClassFile::ACC_FINAL),
- fieldName + "_value", "I",
- cf->addIntegerInfo(member.value), "");
+ fieldName + "_value", "I"_ostr,
+ cf->addIntegerInfo(member.value), ""_ostr);
}
std::unique_ptr< ClassFile::Code > code(cf->newCode());
code->loadLocalReference(0);
code->loadLocalInteger(1);
- code->instrInvokespecial("com/sun/star/uno/Enum", "<init>", "(I)V");
+ code->instrInvokespecial("com/sun/star/uno/Enum"_ostr, "<init>"_ostr, "(I)V"_ostr);
code->instrReturn();
code->setMaxStackAndLocals(2, 2);
cf->addMethod(
ClassFile::ACC_PRIVATE,
- "<init>", "(I)V", code.get(),
- std::vector< OString >(), "");
+ "<init>"_ostr, "(I)V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
code = cf->newCode();
code->instrGetstatic(
className,
@@ -729,8 +734,8 @@ void handleEnumType(
cf->addMethod(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_STATIC),
- "getDefault", "()" + classDescriptor,
- code.get(), std::vector< OString >(), "");
+ "getDefault"_ostr, "()" + classDescriptor,
+ code.get(), std::vector< OString >(), ""_ostr);
code = cf->newCode();
code->loadLocalInteger(0);
std::map< sal_Int32, OString > map;
@@ -779,8 +784,7 @@ void handleEnumType(
std::unique_ptr< ClassFile::Code > blockCode(cf->newCode());
blockCode->instrGetstatic(className, pair.second, classDescriptor);
blockCode->instrAreturn();
- blocks.emplace_back(pair.first, blockCode.get());
- blockCode.release();
+ blocks.emplace_back(pair.first, blockCode.release());
}
code->instrLookupswitch(defCode.get(), blocks);
for (const std::pair< sal_Int32, ClassFile::Code * >& pair : blocks)
@@ -792,15 +796,15 @@ void handleEnumType(
cf->addMethod(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_STATIC),
- "fromInt", "(I)" + classDescriptor, code.get(),
- std::vector< OString >(), "");
+ "fromInt"_ostr, "(I)" + classDescriptor, code.get(),
+ std::vector< OString >(), ""_ostr);
code = cf->newCode();
for (const unoidl::EnumTypeEntity::Member& member : entity->getMembers())
{
code->instrNew(className);
code->instrDup();
code->loadIntegerConstant(member.value);
- code->instrInvokespecial(className, "<init>", "(I)V");
+ code->instrInvokespecial(className, "<init>"_ostr, "(I)V"_ostr);
code->instrPutstatic(
className, codemaker::convertString(member.name), classDescriptor);
}
@@ -809,7 +813,7 @@ void handleEnumType(
cf->addMethod(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PRIVATE | ClassFile::ACC_STATIC),
- "<clinit>", "()V", code.get(), std::vector< OString >(), "");
+ "<clinit>"_ostr, "()V"_ostr, code.get(), std::vector< OString >(), ""_ostr);
writeClassFile(options, className, *cf);
}
@@ -826,7 +830,7 @@ void addField(
SpecialType specialType;
PolymorphicUnoType polymorphicUnoType;
if (typeParameterIndex >= 0) {
- descriptor = "Ljava/lang/Object;";
+ descriptor = "Ljava/lang/Object;"_ostr;
signature = "T" + codemaker::convertString(type).replace('.', '/')
+ ";";
specialType = SPECIAL_TYPE_NONE; //TODO: SPECIAL_TYPE_TYPE_PARAMETER?
@@ -879,19 +883,19 @@ sal_uInt16 addFieldInit(
case codemaker::UnoType::Sort::String:
code->loadLocalReference(0);
code->loadStringConstant(OString());
- code->instrPutfield(className, name, "Ljava/lang/String;");
+ code->instrPutfield(className, name, "Ljava/lang/String;"_ostr);
return 2;
case codemaker::UnoType::Sort::Type:
code->loadLocalReference(0);
code->instrGetstatic(
- "com/sun/star/uno/Type", "VOID", "Lcom/sun/star/uno/Type;");
- code->instrPutfield(className, name, "Lcom/sun/star/uno/Type;");
+ "com/sun/star/uno/Type"_ostr, "VOID"_ostr, "Lcom/sun/star/uno/Type;"_ostr);
+ code->instrPutfield(className, name, "Lcom/sun/star/uno/Type;"_ostr);
return 2;
case codemaker::UnoType::Sort::Any:
code->loadLocalReference(0);
code->instrGetstatic(
- "com/sun/star/uno/Any", "VOID", "Lcom/sun/star/uno/Any;");
- code->instrPutfield(className, name, "Ljava/lang/Object;");
+ "com/sun/star/uno/Any"_ostr, "VOID"_ostr, "Lcom/sun/star/uno/Any;"_ostr);
+ code->instrPutfield(className, name, "Ljava/lang/Object;"_ostr);
return 2;
case codemaker::UnoType::Sort::Enum:
{
@@ -919,7 +923,7 @@ sal_uInt16 addFieldInit(
code->instrDup();
code->instrInvokespecial(
codemaker::convertString(nucleus).replace('.', '/'),
- "<init>", "()V");
+ "<init>"_ostr, "()V"_ostr);
OStringBuffer desc(128);
translateUnoTypeToDescriptor(
manager, sort, nucleus, 0, args, false, false, dependencies,
@@ -989,11 +993,11 @@ sal_uInt16 addLoadLocal(
switch (sort) {
case codemaker::UnoType::Sort::Boolean:
if (any) {
- code->instrNew("java/lang/Boolean");
+ code->instrNew("java/lang/Boolean"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Boolean", "<init>", "(Z)V");
+ "java/lang/Boolean"_ostr, "<init>"_ostr, "(Z)V"_ostr);
stack = 3;
} else {
code->loadLocalInteger(*index);
@@ -1003,11 +1007,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Byte:
if (any) {
- code->instrNew("java/lang/Byte");
+ code->instrNew("java/lang/Byte"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Byte", "<init>", "(B)V");
+ "java/lang/Byte"_ostr, "<init>"_ostr, "(B)V"_ostr);
stack = 3;
} else {
code->loadLocalInteger(*index);
@@ -1017,11 +1021,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Short:
if (any) {
- code->instrNew("java/lang/Short");
+ code->instrNew("java/lang/Short"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Short", "<init>", "(S)V");
+ "java/lang/Short"_ostr, "<init>"_ostr, "(S)V"_ostr);
stack = 3;
} else {
code->loadLocalInteger(*index);
@@ -1031,19 +1035,19 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::UnsignedShort:
if (any) {
- code->instrNew("com/sun/star/uno/Any");
+ code->instrNew("com/sun/star/uno/Any"_ostr);
code->instrDup();
code->instrGetstatic(
- "com/sun/star/uno/Type", "UNSIGNED_SHORT",
- "Lcom/sun/star/uno/Type;");
- code->instrNew("java/lang/Short");
+ "com/sun/star/uno/Type"_ostr, "UNSIGNED_SHORT"_ostr,
+ "Lcom/sun/star/uno/Type;"_ostr);
+ code->instrNew("java/lang/Short"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Short", "<init>", "(S)V");
+ "java/lang/Short"_ostr, "<init>"_ostr, "(S)V"_ostr);
code->instrInvokespecial(
- "com/sun/star/uno/Any", "<init>",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V");
+ "com/sun/star/uno/Any"_ostr, "<init>"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V"_ostr);
stack = 6;
} else {
code->loadLocalInteger(*index);
@@ -1053,11 +1057,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Long:
if (any) {
- code->instrNew("java/lang/Integer");
+ code->instrNew("java/lang/Integer"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Integer", "<init>", "(I)V");
+ "java/lang/Integer"_ostr, "<init>"_ostr, "(I)V"_ostr);
stack = 3;
} else {
code->loadLocalInteger(*index);
@@ -1067,19 +1071,19 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::UnsignedLong:
if (any) {
- code->instrNew("com/sun/star/uno/Any");
+ code->instrNew("com/sun/star/uno/Any"_ostr);
code->instrDup();
code->instrGetstatic(
- "com/sun/star/uno/Type", "UNSIGNED_LONG",
- "Lcom/sun/star/uno/Type;");
- code->instrNew("java/lang/Integer");
+ "com/sun/star/uno/Type"_ostr, "UNSIGNED_LONG"_ostr,
+ "Lcom/sun/star/uno/Type;"_ostr);
+ code->instrNew("java/lang/Integer"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Integer", "<init>", "(I)V");
+ "java/lang/Integer"_ostr, "<init>"_ostr, "(I)V"_ostr);
code->instrInvokespecial(
- "com/sun/star/uno/Any", "<init>",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V");
+ "com/sun/star/uno/Any"_ostr, "<init>"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V"_ostr);
stack = 6;
} else {
code->loadLocalInteger(*index);
@@ -1089,11 +1093,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Hyper:
if (any) {
- code->instrNew("java/lang/Long");
+ code->instrNew("java/lang/Long"_ostr);
code->instrDup();
code->loadLocalLong(*index);
code->instrInvokespecial(
- "java/lang/Long", "<init>", "(J)V");
+ "java/lang/Long"_ostr, "<init>"_ostr, "(J)V"_ostr);
stack = 4;
} else {
code->loadLocalLong(*index);
@@ -1103,19 +1107,19 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::UnsignedHyper:
if (any) {
- code->instrNew("com/sun/star/uno/Any");
+ code->instrNew("com/sun/star/uno/Any"_ostr);
code->instrDup();
code->instrGetstatic(
- "com/sun/star/uno/Type", "UNSIGNED_HYPER",
- "Lcom/sun/star/uno/Type;");
- code->instrNew("java/lang/Long");
+ "com/sun/star/uno/Type"_ostr, "UNSIGNED_HYPER"_ostr,
+ "Lcom/sun/star/uno/Type;"_ostr);
+ code->instrNew("java/lang/Long"_ostr);
code->instrDup();
code->loadLocalLong(*index);
code->instrInvokespecial(
- "java/lang/Long", "<init>", "(J)V");
+ "java/lang/Long"_ostr, "<init>"_ostr, "(J)V"_ostr);
code->instrInvokespecial(
- "com/sun/star/uno/Any", "<init>",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V");
+ "com/sun/star/uno/Any"_ostr, "<init>"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V"_ostr);
stack = 7;
} else {
code->loadLocalLong(*index);
@@ -1125,11 +1129,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Float:
if (any) {
- code->instrNew("java/lang/Float");
+ code->instrNew("java/lang/Float"_ostr);
code->instrDup();
code->loadLocalFloat(*index);
code->instrInvokespecial(
- "java/lang/Float", "<init>", "(F)V");
+ "java/lang/Float"_ostr, "<init>"_ostr, "(F)V"_ostr);
stack = 3;
} else {
code->loadLocalFloat(*index);
@@ -1139,11 +1143,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Double:
if (any) {
- code->instrNew("java/lang/Double");
+ code->instrNew("java/lang/Double"_ostr);
code->instrDup();
code->loadLocalDouble(*index);
code->instrInvokespecial(
- "java/lang/Double", "<init>", "(D)V");
+ "java/lang/Double"_ostr, "<init>"_ostr, "(D)V"_ostr);
stack = 4;
} else {
code->loadLocalDouble(*index);
@@ -1153,11 +1157,11 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Char:
if (any) {
- code->instrNew("java/lang/Character");
+ code->instrNew("java/lang/Character"_ostr);
code->instrDup();
code->loadLocalInteger(*index);
code->instrInvokespecial(
- "java/lang/Character", "<init>", "(C)V");
+ "java/lang/Character"_ostr, "<init>"_ostr, "(C)V"_ostr);
stack = 3;
} else {
code->loadLocalInteger(*index);
@@ -1180,24 +1184,24 @@ sal_uInt16 addLoadLocal(
case codemaker::UnoType::Sort::PlainStruct:
case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
if (any) {
- code->instrNew("com/sun/star/uno/Any");
+ code->instrNew("com/sun/star/uno/Any"_ostr);
code->instrDup();
- code->instrNew("com/sun/star/uno/Type");
+ code->instrNew("com/sun/star/uno/Type"_ostr);
code->instrDup();
code->loadStringConstant(
codemaker::convertString(
createUnoName(manager, nucleus, rank, args)));
code->instrGetstatic(
- "com/sun/star/uno/TypeClass", "STRUCT",
- "Lcom/sun/star/uno/TypeClass;");
- dependencies->insert("com.sun.star.uno.TypeClass");
+ "com/sun/star/uno/TypeClass"_ostr, "STRUCT"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
+ dependencies->insert(u"com.sun.star.uno.TypeClass"_ustr);
code->instrInvokespecial(
- "com/sun/star/uno/Type", "<init>",
- "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V");
+ "com/sun/star/uno/Type"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V"_ostr);
code->loadLocalReference(*index);
code->instrInvokespecial(
- "com/sun/star/uno/Any", "<init>",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V");
+ "com/sun/star/uno/Any"_ostr, "<init>"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V"_ostr);
stack = 6;
} else {
code->loadLocalReference(*index);
@@ -1207,22 +1211,22 @@ sal_uInt16 addLoadLocal(
break;
case codemaker::UnoType::Sort::Interface:
if (any && nucleus != "com.sun.star.uno.XInterface") {
- code->instrNew("com/sun/star/uno/Any");
+ code->instrNew("com/sun/star/uno/Any"_ostr);
code->instrDup();
- code->instrNew("com/sun/star/uno/Type");
+ code->instrNew("com/sun/star/uno/Type"_ostr);
code->instrDup();
code->loadStringConstant(codemaker::convertString(nucleus));
code->instrGetstatic(
- "com/sun/star/uno/TypeClass", "INTERFACE",
- "Lcom/sun/star/uno/TypeClass;");
- dependencies->insert("com.sun.star.uno.TypeClass");
+ "com/sun/star/uno/TypeClass"_ostr, "INTERFACE"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
+ dependencies->insert(u"com.sun.star.uno.TypeClass"_ustr);
code->instrInvokespecial(
- "com/sun/star/uno/Type", "<init>",
- "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V");
+ "com/sun/star/uno/Type"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V"_ostr);
code->loadLocalReference(*index);
code->instrInvokespecial(
- "com/sun/star/uno/Any", "<init>",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V");
+ "com/sun/star/uno/Any"_ostr, "<init>"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V"_ostr);
stack = 6;
} else {
code->loadLocalReference(*index);
@@ -1278,19 +1282,19 @@ sal_uInt16 addLoadLocal(
}
}
if (bWrap) {
- code->instrNew("com/sun/star/uno/Any");
+ code->instrNew("com/sun/star/uno/Any"_ostr);
code->instrDup();
- code->instrNew("com/sun/star/uno/Type");
+ code->instrNew("com/sun/star/uno/Type"_ostr);
code->instrDup();
code->loadStringConstant(
codemaker::convertString(
createUnoName(manager, nucleus, rank, args)));
code->instrInvokespecial(
- "com/sun/star/uno/Type", "<init>", "(Ljava/lang/String;)V");
+ "com/sun/star/uno/Type"_ostr, "<init>"_ostr, "(Ljava/lang/String;)V"_ostr);
code->loadLocalReference(*index);
code->instrInvokespecial(
- "com/sun/star/uno/Any", "<init>",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V");
+ "com/sun/star/uno/Any"_ostr, "<init>"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V"_ostr);
stack = 5;
} else {
code->loadLocalReference(*index);
@@ -1301,7 +1305,7 @@ sal_uInt16 addLoadLocal(
}
if (*index > SAL_MAX_UINT16 - size) {
throw CannotDumpException(
- "Too many local variables for Java class file format");
+ u"Too many local variables for Java class file format"_ustr);
}
*index = *index + size;
return stack;
@@ -1318,7 +1322,7 @@ sal_uInt16 addDirectArgument(
OString desc;
if (typeParameter) {
methodDescriptor->addTypeParameter(fieldType);
- desc = "Ljava/lang/Object;";
+ desc = "Ljava/lang/Object;"_ostr;
} else {
methodDescriptor->addParameter(fieldType, false, true, nullptr);
getFieldDescriptor(manager, dependencies, fieldType, &desc, nullptr, nullptr);
@@ -1369,7 +1373,7 @@ void handlePlainStructType(
OString className(codemaker::convertString(name).replace('.', '/'));
OString superClass;
if (entity->getDirectBase().isEmpty()) {
- superClass = "java/lang/Object";
+ superClass = "java/lang/Object"_ostr;
} else {
superClass = codemaker::convertString(entity->getDirectBase()).
replace('.', '/');
@@ -1379,7 +1383,7 @@ void handlePlainStructType(
new ClassFile(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_SUPER),
- className, superClass, ""));
+ className, superClass, ""_ostr));
std::vector< TypeInfo > typeInfo;
sal_Int32 index = 0;
for (const unoidl::PlainStructTypeEntity::Member& member : entity->getDirectMembers())
@@ -1390,7 +1394,7 @@ void handlePlainStructType(
}
std::unique_ptr< ClassFile::Code > code(cf->newCode());
code->loadLocalReference(0);
- code->instrInvokespecial(superClass, "<init>", "()V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "()V"_ostr);
sal_uInt16 stack = 0;
for (const unoidl::PlainStructTypeEntity::Member& member : entity->getDirectMembers())
{
@@ -1403,8 +1407,8 @@ void handlePlainStructType(
code->instrReturn();
code->setMaxStackAndLocals(stack + 1, 1);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", "()V", code.get(),
- std::vector< OString >(), "");
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, "()V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
MethodDescriptor desc(manager, dependencies, u"void", nullptr, nullptr);
code = cf->newCode();
code->loadLocalReference(0);
@@ -1414,7 +1418,7 @@ void handlePlainStructType(
manager, dependencies, &desc, code.get(), entity->getDirectBase(),
&index2);
}
- code->instrInvokespecial(superClass, "<init>", desc.getDescriptor());
+ code->instrInvokespecial(superClass, "<init>"_ostr, desc.getDescriptor());
sal_uInt16 maxSize = index2;
for (const unoidl::PlainStructTypeEntity::Member& member : entity->getDirectMembers())
{
@@ -1427,7 +1431,7 @@ void handlePlainStructType(
code->instrReturn();
code->setMaxStackAndLocals(maxSize, index2);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", desc.getDescriptor(), code.get(),
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, desc.getDescriptor(), code.get(),
std::vector< OString >(), desc.getSignature());
addTypeInfo(className, typeInfo, dependencies, cf.get());
writeClassFile(options, className, *cf);
@@ -1451,7 +1455,7 @@ void handlePolyStructType(
sig.append(codemaker::convertString(param) + ":Ljava/lang/Object;");
if (!typeParameters.emplace(param, index++).second)
{
- throw CannotDumpException("Bad type information"); //TODO
+ throw CannotDumpException(u"Bad type information"_ustr); //TODO
}
}
sig.append(">Ljava/lang/Object;");
@@ -1459,7 +1463,7 @@ void handlePolyStructType(
new ClassFile(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_SUPER),
- className, "java/lang/Object", sig.makeStringAndClear()));
+ className, "java/lang/Object"_ostr, sig.makeStringAndClear()));
std::vector< TypeInfo > typeInfo;
index = 0;
for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity->getMembers())
@@ -1469,7 +1473,7 @@ void handlePolyStructType(
std::map< OUString, sal_Int32 >::iterator it(
typeParameters.find(member.type));
if (it == typeParameters.end()) {
- throw CannotDumpException("Bad type information"); //TODO
+ throw CannotDumpException(u"Bad type information"_ustr); //TODO
}
typeParameterIndex = it->second;
} else {
@@ -1481,7 +1485,7 @@ void handlePolyStructType(
}
std::unique_ptr< ClassFile::Code > code(cf->newCode());
code->loadLocalReference(0);
- code->instrInvokespecial("java/lang/Object", "<init>", "()V");
+ code->instrInvokespecial("java/lang/Object"_ostr, "<init>"_ostr, "()V"_ostr);
sal_uInt16 stack = 0;
for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity->getMembers())
{
@@ -1494,14 +1498,14 @@ void handlePolyStructType(
code->instrReturn();
code->setMaxStackAndLocals(stack + 1, 1);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", "()V", code.get(),
- std::vector< OString >(), "");
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, "()V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
MethodDescriptor desc(manager, dependencies, u"void", nullptr, nullptr);
code = cf->newCode();
code->loadLocalReference(0);
sal_uInt16 index2 = 1;
code->instrInvokespecial(
- "java/lang/Object", "<init>", desc.getDescriptor());
+ "java/lang/Object"_ostr, "<init>"_ostr, desc.getDescriptor());
sal_uInt16 maxSize = index2;
for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity->getMembers())
{
@@ -1514,7 +1518,7 @@ void handlePolyStructType(
code->instrReturn();
code->setMaxStackAndLocals(maxSize, index2);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", desc.getDescriptor(), code.get(),
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, desc.getDescriptor(), code.get(),
std::vector< OString >(), desc.getSignature());
addTypeInfo(className, typeInfo, dependencies, cf.get());
writeClassFile(options, className, *cf);
@@ -1566,10 +1570,10 @@ void handleExceptionType(
OString superClass;
if (className == "com/sun/star/uno/Exception") {
baseException = true;
- superClass = "java/lang/Exception";
+ superClass = "java/lang/Exception"_ostr;
} else if (className == "com/sun/star/uno/RuntimeException") {
baseRuntimeException = true;
- superClass = "java/lang/RuntimeException";
+ superClass = "java/lang/RuntimeException"_ostr;
} else {
if (entity->getDirectBase().isEmpty()) {
throw CannotDumpException(
@@ -1583,13 +1587,13 @@ void handleExceptionType(
new ClassFile(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_SUPER),
- className, superClass, ""));
+ className, superClass, ""_ostr));
std::vector< TypeInfo > typeInfo;
sal_Int32 index = 0;
if (baseRuntimeException) {
addField(
manager, dependencies, cf.get(), &typeInfo, -1,
- "com.sun.star.uno.XInterface", "Context", index++);
+ u"com.sun.star.uno.XInterface"_ustr, u"Context"_ustr, index++);
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
entity->getDirectMembers().begin());
@@ -1605,13 +1609,13 @@ void handleExceptionType(
// create default constructor
std::unique_ptr< ClassFile::Code > code(cf->newCode());
code->loadLocalReference(0);
- code->instrInvokespecial(superClass, "<init>", "()V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "()V"_ostr);
sal_uInt16 stack = 0;
if (baseRuntimeException) {
stack = std::max(
stack,
addFieldInit(
- manager, className, "Context", false,
+ manager, className, u"Context"_ustr, false,
u"com.sun.star.uno.XInterface", dependencies, code.get()));
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
@@ -1629,21 +1633,21 @@ void handleExceptionType(
code->instrReturn();
code->setMaxStackAndLocals(stack + 1, 1);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", "()V", code.get(),
- std::vector< OString >(), "");
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, "()V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
// create (Throwable Cause) constructor
code = cf->newCode();
code->loadLocalReference(0);
code->loadLocalReference(1);
- code->instrInvokespecial(superClass, "<init>", "(Ljava/lang/Throwable;)V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "(Ljava/lang/Throwable;)V"_ostr);
stack = 0;
if (baseRuntimeException) {
stack = std::max(
stack,
addFieldInit(
- manager, className, "Context", false,
+ manager, className, u"Context"_ustr, false,
u"com.sun.star.uno.XInterface", dependencies, code.get()));
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
@@ -1661,8 +1665,8 @@ void handleExceptionType(
code->instrReturn();
code->setMaxStackAndLocals(stack + 2, 2);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", "(Ljava/lang/Throwable;)V", code.get(),
- std::vector< OString >(), "");
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, "(Ljava/lang/Throwable;)V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
// create (Throwable Cause, String Message) constructor
code = cf->newCode();
@@ -1670,18 +1674,18 @@ void handleExceptionType(
if (baseException || baseRuntimeException) {
code->loadLocalReference(2);
code->loadLocalReference(1);
- code->instrInvokespecial(superClass, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "(Ljava/lang/String;Ljava/lang/Throwable;)V"_ostr);
} else {
code->loadLocalReference(1);
code->loadLocalReference(2);
- code->instrInvokespecial(superClass, "<init>", "(Ljava/lang/Throwable;Ljava/lang/String;)V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "(Ljava/lang/Throwable;Ljava/lang/String;)V"_ostr);
}
stack = 0;
if (baseRuntimeException) {
stack = std::max(
stack,
addFieldInit(
- manager, className, "Context", false,
+ manager, className, u"Context"_ustr, false,
u"com.sun.star.uno.XInterface", dependencies, code.get()));
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
@@ -1699,20 +1703,20 @@ void handleExceptionType(
code->instrReturn();
code->setMaxStackAndLocals(stack + 3, 3);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", "(Ljava/lang/Throwable;Ljava/lang/String;)V", code.get(),
- std::vector< OString >(), "");
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, "(Ljava/lang/Throwable;Ljava/lang/String;)V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
// create (String Message) constructor
code = cf->newCode();
code->loadLocalReference(0);
code->loadLocalReference(1);
- code->instrInvokespecial(superClass, "<init>", "(Ljava/lang/String;)V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "(Ljava/lang/String;)V"_ostr);
stack = 0;
if (baseRuntimeException) {
stack = std::max(
stack,
addFieldInit(
- manager, className, "Context", false,
+ manager, className, u"Context"_ustr, false,
u"com.sun.star.uno.XInterface", dependencies, code.get()));
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
@@ -1730,8 +1734,8 @@ void handleExceptionType(
code->instrReturn();
code->setMaxStackAndLocals(stack + 2, 2);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", "(Ljava/lang/String;)V", code.get(),
- std::vector< OString >(), "");
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, "(Ljava/lang/String;)V"_ostr, code.get(),
+ std::vector< OString >(), ""_ostr);
// create (String Message, Object Context, T1 m1, ..., Tn mn) constructor
@@ -1746,14 +1750,14 @@ void handleExceptionType(
manager, dependencies, &desc1, code.get(), entity->getDirectBase(),
&index2);
}
- code->instrInvokespecial(superClass, "<init>", desc1.getDescriptor());
+ code->instrInvokespecial(superClass, "<init>"_ostr, desc1.getDescriptor());
sal_uInt16 maxSize = index2;
if (baseRuntimeException) {
maxSize = std::max(
maxSize,
addDirectArgument(
manager, dependencies, &desc1, code.get(), &index2, className,
- "Context", false, "com.sun.star.uno.XInterface"));
+ "Context"_ostr, false, u"com.sun.star.uno.XInterface"_ustr));
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
entity->getDirectMembers().begin());
@@ -1771,7 +1775,7 @@ void handleExceptionType(
code->instrReturn();
code->setMaxStackAndLocals(maxSize, index2);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", desc1.getDescriptor(), code.get(),
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, desc1.getDescriptor(), code.get(),
std::vector< OString >(), desc1.getSignature());
// create (Throwable Cause, String Message, Object Context, T1 m1, ..., Tn mn) constructor
@@ -1785,14 +1789,14 @@ void handleExceptionType(
if (baseException || baseRuntimeException) {
code->loadLocalReference(2);
code->loadLocalReference(1);
- code->instrInvokespecial(superClass, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V");
+ code->instrInvokespecial(superClass, "<init>"_ostr, "(Ljava/lang/String;Ljava/lang/Throwable;)V"_ostr);
} else {
code->loadLocalReference(1);
code->loadLocalReference(2);
addExceptionBaseArguments(
manager, dependencies, &desc2, code.get(), entity->getDirectBase(),
&index3);
- code->instrInvokespecial(superClass, "<init>", OString::Concat("(Ljava/lang/Throwable;") + desc2.getDescriptor().subView(1));
+ code->instrInvokespecial(superClass, "<init>"_ostr, OString::Concat("(Ljava/lang/Throwable;") + desc2.getDescriptor().subView(1));
}
sal_uInt16 maxSize2 = index3;
if (baseRuntimeException) {
@@ -1800,7 +1804,7 @@ void handleExceptionType(
maxSize2,
addDirectArgument(
manager, dependencies, &desc2, code.get(), &index3, className,
- "Context", false, "com.sun.star.uno.XInterface"));
+ "Context"_ostr, false, u"com.sun.star.uno.XInterface"_ustr));
}
for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator i(
entity->getDirectMembers().begin());
@@ -1818,7 +1822,7 @@ void handleExceptionType(
code->instrReturn();
code->setMaxStackAndLocals(maxSize2, index3);
cf->addMethod(
- ClassFile::ACC_PUBLIC, "<init>", OString::Concat("(Ljava/lang/Throwable;") + desc2.getDescriptor().subView(1), code.get(),
+ ClassFile::ACC_PUBLIC, "<init>"_ostr, OString::Concat("(Ljava/lang/Throwable;") + desc2.getDescriptor().subView(1), code.get(),
std::vector< OString >(), desc2.getSignature());
addTypeInfo(className, typeInfo, dependencies, cf.get());
@@ -1857,7 +1861,7 @@ void handleInterfaceType(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_INTERFACE
| ClassFile::ACC_ABSTRACT),
- className, "java/lang/Object", ""));
+ className, "java/lang/Object"_ostr, ""_ostr));
for (const unoidl::AnnotatedReference& ar : entity->getDirectMandatoryBases())
{
dependencies->insert(ar.name);
@@ -1867,7 +1871,7 @@ void handleInterfaceType(
// java.util.EventListener ("A tagging interface that all event listener
// interfaces must extend"):
if (className == "com/sun/star/lang/XEventListener") {
- cf->addInterface("java/util/EventListener");
+ cf->addInterface("java/util/EventListener"_ostr);
}
std::vector< TypeInfo > typeInfo;
if (className != "com/sun/star/uno/XInterface") {
@@ -2000,7 +2004,7 @@ void handleConstantGroup(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_INTERFACE
| ClassFile::ACC_ABSTRACT),
- className, "java/lang/Object", ""));
+ className, "java/lang/Object"_ostr, ""_ostr));
for (const unoidl::ConstantGroupEntity::Member& member : entity->getMembers())
{
OUString type;
@@ -2094,8 +2098,8 @@ void addConstructor(
code->loadLocalReference(0);
// stack: context
code->instrInvokeinterface(
- "com/sun/star/uno/XComponentContext", "getServiceManager",
- "()Lcom/sun/star/lang/XMultiComponentFactory;", 1);
+ "com/sun/star/uno/XComponentContext"_ostr, "getServiceManager"_ostr,
+ "()Lcom/sun/star/lang/XMultiComponentFactory;"_ostr, 1);
// stack: factory
code->loadStringConstant(unoName);
// stack: factory serviceName
@@ -2112,10 +2116,10 @@ void addConstructor(
// stack: factory serviceName context
tryStart = code->getPosition();
code->instrInvokeinterface(
- "com/sun/star/lang/XMultiComponentFactory",
- "createInstanceWithContext",
+ "com/sun/star/lang/XMultiComponentFactory"_ostr,
+ "createInstanceWithContext"_ostr,
("(Ljava/lang/String;Lcom/sun/star/uno/XComponentContext;)"
- "Ljava/lang/Object;"),
+ "Ljava/lang/Object;"_ostr),
3);
tryEnd = code->getPosition();
// stack: instance
@@ -2133,7 +2137,7 @@ void addConstructor(
} else {
code->loadIntegerConstant(constructor.parameters.size());
// stack: factory serviceName N
- code->instrAnewarray("java/lang/Object");
+ code->instrAnewarray("java/lang/Object"_ostr);
// stack: factory serviceName args
stack = 0;
sal_Int32 n = 0;
@@ -2160,10 +2164,10 @@ void addConstructor(
// stack: factory serviceName args context
tryStart = code->getPosition();
code->instrInvokeinterface(
- "com/sun/star/lang/XMultiComponentFactory",
- "createInstanceWithArgumentsAndContext",
+ "com/sun/star/lang/XMultiComponentFactory"_ostr,
+ "createInstanceWithArgumentsAndContext"_ostr,
("(Ljava/lang/String;[Ljava/lang/Object;"
- "Lcom/sun/star/uno/XComponentContext;)Ljava/lang/Object;"),
+ "Lcom/sun/star/uno/XComponentContext;)Ljava/lang/Object;"_ostr),
4);
tryEnd = code->getPosition();
// stack: instance
@@ -2173,9 +2177,9 @@ void addConstructor(
code->loadLocalReference(0);
// stack: instance context
code->instrInvokestatic(
- className, "$castInstance",
+ className, "$castInstance"_ostr,
("(Ljava/lang/Object;Lcom/sun/star/uno/XComponentContext;)"
- "Ljava/lang/Object;"));
+ "Ljava/lang/Object;"_ostr));
// stack: instance
code->instrCheckcast(
codemaker::convertString(returnType).replace('.', '/'));
@@ -2185,12 +2189,12 @@ void addConstructor(
ClassFile::Code::Position pos1 = code->getPosition();
// stack: e
code->instrInvokevirtual(
- "java/lang/Throwable", "toString", "()Ljava/lang/String;");
+ "java/lang/Throwable"_ostr, "toString"_ostr, "()Ljava/lang/String;"_ostr);
// stack: str
localIndex = std::max< sal_uInt16 >(localIndex, 2);
code->storeLocalReference(1);
// stack: -
- code->instrNew("com/sun/star/uno/DeploymentException");
+ code->instrNew("com/sun/star/uno/DeploymentException"_ostr);
// stack: ex
code->instrDup();
// stack: ex ex
@@ -2201,22 +2205,22 @@ void addConstructor(
code->loadLocalReference(1);
// stack: ex ex "..." str
code->instrInvokevirtual(
- "java/lang/String", "concat",
- "(Ljava/lang/String;)Ljava/lang/String;");
+ "java/lang/String"_ostr, "concat"_ostr,
+ "(Ljava/lang/String;)Ljava/lang/String;"_ostr);
// stack: ex ex "..."
code->loadLocalReference(0);
// stack: ex ex "..." context
code->instrInvokespecial(
- "com/sun/star/uno/DeploymentException", "<init>",
- "(Ljava/lang/String;Ljava/lang/Object;)V");
+ "com/sun/star/uno/DeploymentException"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Ljava/lang/Object;)V"_ostr);
// stack: ex
ClassFile::Code::Position pos2 = code->getPosition();
code->instrAthrow();
addExceptionHandlers(
&tree.getRoot(), tryStart, tryEnd, pos2, code.get());
code->addException(
- tryStart, tryEnd, pos1, "com/sun/star/uno/Exception");
- dependencies->insert("com.sun.star.uno.Exception");
+ tryStart, tryEnd, pos1, "com/sun/star/uno/Exception"_ostr);
+ dependencies->insert(u"com.sun.star.uno.Exception"_ustr);
stack = std::max< sal_uInt16 >(stack, 4);
}
code->setMaxStackAndLocals(stack, localIndex);
@@ -2224,7 +2228,7 @@ void addConstructor(
access,
codemaker::java::translateUnoToJavaIdentifier(
(constructor.defaultConstructor
- ? OString("create") : codemaker::convertString(constructor.name)),
+ ? "create"_ostr : codemaker::convertString(constructor.name)),
"method"),
desc.getDescriptor(), code.get(), exc, desc.getSignature());
}
@@ -2245,15 +2249,15 @@ void handleService(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_FINAL
| ClassFile::ACC_SUPER),
- className, "java/lang/Object", ""));
+ className, "java/lang/Object"_ostr, ""_ostr));
if (!entity->getConstructors().empty()) {
OString realJavaBaseName(
codemaker::convertString(entity->getBase()));
dependencies->insert(entity->getBase());
- dependencies->insert("com.sun.star.lang.XMultiComponentFactory");
- dependencies->insert("com.sun.star.uno.DeploymentException");
- dependencies->insert("com.sun.star.uno.TypeClass");
- dependencies->insert("com.sun.star.uno.XComponentContext");
+ dependencies->insert(u"com.sun.star.lang.XMultiComponentFactory"_ustr);
+ dependencies->insert(u"com.sun.star.uno.DeploymentException"_ustr);
+ dependencies->insert(u"com.sun.star.uno.TypeClass"_ustr);
+ dependencies->insert(u"com.sun.star.uno.XComponentContext"_ustr);
for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor& cons :
entity->getConstructors())
{
@@ -2264,26 +2268,26 @@ void handleService(
// Synthetic castInstance method:
{
std::unique_ptr< ClassFile::Code > code(cf->newCode());
- code->instrNew("com/sun/star/uno/Type");
+ code->instrNew("com/sun/star/uno/Type"_ostr);
// stack: type
code->instrDup();
// stack: type type
code->loadStringConstant(realJavaBaseName);
// stack: type type "..."
code->instrGetstatic(
- "com/sun/star/uno/TypeClass", "INTERFACE",
- "Lcom/sun/star/uno/TypeClass;");
+ "com/sun/star/uno/TypeClass"_ostr, "INTERFACE"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
// stack: type type "..." INTERFACE
code->instrInvokespecial(
- "com/sun/star/uno/Type", "<init>",
- "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V");
+ "com/sun/star/uno/Type"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V"_ostr);
// stack: type
code->loadLocalReference(0);
// stack: type instance
code->instrInvokestatic(
- "com/sun/star/uno/UnoRuntime", "queryInterface",
+ "com/sun/star/uno/UnoRuntime"_ostr, "queryInterface"_ostr,
("(Lcom/sun/star/uno/Type;Ljava/lang/Object;)"
- "Ljava/lang/Object;"));
+ "Ljava/lang/Object;"_ostr));
// stack: instance
code->instrDup();
// stack: instance instance
@@ -2293,7 +2297,7 @@ void handleService(
code->branchHere(branch);
code->instrPop();
// stack: -
- code->instrNew("com/sun/star/uno/DeploymentException");
+ code->instrNew("com/sun/star/uno/DeploymentException"_ostr);
// stack: ex
code->instrDup();
// stack: ex ex
@@ -2304,8 +2308,8 @@ void handleService(
code->loadLocalReference(1);
// stack: ex ex "..." context
code->instrInvokespecial(
- "com/sun/star/uno/DeploymentException", "<init>",
- "(Ljava/lang/String;Ljava/lang/Object;)V");
+ "com/sun/star/uno/DeploymentException"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Ljava/lang/Object;)V"_ostr);
// stack: ex
code->instrAthrow();
code->setMaxStackAndLocals(4, 2);
@@ -2313,10 +2317,10 @@ void handleService(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PRIVATE | ClassFile::ACC_STATIC
| ClassFile::ACC_SYNTHETIC),
- "$castInstance",
+ "$castInstance"_ostr,
("(Ljava/lang/Object;Lcom/sun/star/uno/XComponentContext;)"
- "Ljava/lang/Object;"),
- code.get(), std::vector< OString >(), "");
+ "Ljava/lang/Object;"_ostr),
+ code.get(), std::vector< OString >(), ""_ostr);
}
}
writeClassFile(options, className, *cf);
@@ -2336,15 +2340,15 @@ void handleSingleton(
OString unoName(codemaker::convertString(name));
OString className(
translateUnoidlEntityNameToJavaFullyQualifiedName(name, "singleton"));
- dependencies->insert("com.sun.star.uno.DeploymentException");
- dependencies->insert("com.sun.star.uno.TypeClass");
- dependencies->insert("com.sun.star.uno.XComponentContext");
+ dependencies->insert(u"com.sun.star.uno.DeploymentException"_ustr);
+ dependencies->insert(u"com.sun.star.uno.TypeClass"_ustr);
+ dependencies->insert(u"com.sun.star.uno.XComponentContext"_ustr);
std::unique_ptr< ClassFile > cf(
new ClassFile(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_FINAL
| ClassFile::ACC_SUPER),
- className, "java/lang/Object", ""));
+ className, "java/lang/Object"_ostr, ""_ostr));
MethodDescriptor desc(manager, dependencies, entity->getBase(), nullptr, nullptr);
desc.addParameter(u"com.sun.star.uno.XComponentContext", false, false, nullptr);
std::unique_ptr< ClassFile::Code > code(cf->newCode());
@@ -2353,55 +2357,55 @@ void handleSingleton(
code->loadStringConstant("/singletons/" + unoName);
// stack: context "..."
code->instrInvokeinterface(
- "com/sun/star/uno/XComponentContext", "getValueByName",
- "(Ljava/lang/String;)Ljava/lang/Object;", 2);
+ "com/sun/star/uno/XComponentContext"_ostr, "getValueByName"_ostr,
+ "(Ljava/lang/String;)Ljava/lang/Object;"_ostr, 2);
// stack: value
code->instrDup();
// stack: value value
- code->instrInstanceof("com/sun/star/uno/Any");
+ code->instrInstanceof("com/sun/star/uno/Any"_ostr);
// stack: value 0/1
ClassFile::Code::Branch branch1 = code->instrIfeq();
// stack: value
- code->instrCheckcast("com/sun/star/uno/Any");
+ code->instrCheckcast("com/sun/star/uno/Any"_ostr);
// stack: value
code->instrDup();
// stack: value value
code->instrInvokevirtual(
- "com/sun/star/uno/Any", "getType", "()Lcom/sun/star/uno/Type;");
+ "com/sun/star/uno/Any"_ostr, "getType"_ostr, "()Lcom/sun/star/uno/Type;"_ostr);
// stack: value type
code->instrInvokevirtual(
- "com/sun/star/uno/Type", "getTypeClass",
- "()Lcom/sun/star/uno/TypeClass;");
+ "com/sun/star/uno/Type"_ostr, "getTypeClass"_ostr,
+ "()Lcom/sun/star/uno/TypeClass;"_ostr);
// stack: value typeClass
code->instrGetstatic(
- "com/sun/star/uno/TypeClass", "INTERFACE",
- "Lcom/sun/star/uno/TypeClass;");
+ "com/sun/star/uno/TypeClass"_ostr, "INTERFACE"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
// stack: value typeClass INTERFACE
ClassFile::Code::Branch branch2 = code->instrIfAcmpne();
// stack: value
code->instrInvokevirtual(
- "com/sun/star/uno/Any", "getObject", "()Ljava/lang/Object;");
+ "com/sun/star/uno/Any"_ostr, "getObject"_ostr, "()Ljava/lang/Object;"_ostr);
// stack: value
code->branchHere(branch1);
- code->instrNew("com/sun/star/uno/Type");
+ code->instrNew("com/sun/star/uno/Type"_ostr);
// stack: value type
code->instrDup();
// stack: value type type
code->loadStringConstant(realJavaBaseName);
// stack: value type type "..."
code->instrGetstatic(
- "com/sun/star/uno/TypeClass", "INTERFACE",
- "Lcom/sun/star/uno/TypeClass;");
+ "com/sun/star/uno/TypeClass"_ostr, "INTERFACE"_ostr,
+ "Lcom/sun/star/uno/TypeClass;"_ostr);
// stack: value type type "..." INTERFACE
code->instrInvokespecial(
- "com/sun/star/uno/Type", "<init>",
- "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V");
+ "com/sun/star/uno/Type"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V"_ostr);
// stack: value type
code->instrSwap();
// stack: type value
code->instrInvokestatic(
- "com/sun/star/uno/UnoRuntime", "queryInterface",
- "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)Ljava/lang/Object;");
+ "com/sun/star/uno/UnoRuntime"_ostr, "queryInterface"_ostr,
+ "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)Ljava/lang/Object;"_ostr);
// stack: instance
code->instrDup();
// stack: instance instance
@@ -2414,7 +2418,7 @@ void handleSingleton(
code->branchHere(branch3);
code->instrPop();
// stack: -
- code->instrNew("com/sun/star/uno/DeploymentException");
+ code->instrNew("com/sun/star/uno/DeploymentException"_ostr);
// stack: ex
code->instrDup();
// stack: ex ex
@@ -2425,15 +2429,15 @@ void handleSingleton(
code->loadLocalReference(0);
// stack: ex ex "..." context
code->instrInvokespecial(
- "com/sun/star/uno/DeploymentException", "<init>",
- "(Ljava/lang/String;Ljava/lang/Object;)V");
+ "com/sun/star/uno/DeploymentException"_ostr, "<init>"_ostr,
+ "(Ljava/lang/String;Ljava/lang/Object;)V"_ostr);
// stack: ex
code->instrAthrow();
code->setMaxStackAndLocals(5, 1);
cf->addMethod(
static_cast< ClassFile::AccessFlags >(
ClassFile::ACC_PUBLIC | ClassFile::ACC_STATIC),
- "get", desc.getDescriptor(), code.get(), std::vector< OString >(),
+ "get"_ostr, desc.getDescriptor(), code.get(), std::vector< OString >(),
desc.getSignature());
writeClassFile(options, className, *cf);
}
@@ -2525,7 +2529,7 @@ void produce(
throw CannotDumpException(
"unexpected entity \"" + name + "\" in call to produce");
}
- if (!options.isValid("-nD")) {
+ if (!options.isValid("-nD"_ostr)) {
for (const OUString& d : deps) {
produce(d, manager, generated, options);
}