fdo#57950: Remove chained appends in codemaker
And another cleanups like removing RTL_CONST* macros and other simple things. Much more can be done inside codemaker. Change-Id: I338e1c0e88558124741c6202896355533535a129 Reviewed-on: https://gerrit.libreoffice.org/2583 Reviewed-by: Thomas Arnhold <thomas@arnhold.org> Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
This commit is contained in:
committed by
Fridrich Strba
parent
8035a3af26
commit
75e6856b08
@@ -66,11 +66,8 @@ rtl::OString convertString(rtl::OUString const & string) {
|
||||
return s;
|
||||
}
|
||||
|
||||
rtl::OString errorMsg(rtl::OString const & desc, rtl::OString const & type) {
|
||||
rtl::OStringBuffer msg(128);
|
||||
msg.append(desc);
|
||||
msg.append(type);
|
||||
return msg.makeStringAndClear();
|
||||
OString errorMsg(OString const & desc, OString const & type) {
|
||||
return desc + type;
|
||||
}
|
||||
|
||||
codemaker::UnoType::Sort decomposeAndResolve(
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
namespace codemaker { namespace cpp {
|
||||
|
||||
rtl::OString scopedCppName(rtl::OString const & type, bool ns_alias)
|
||||
OString scopedCppName(OString const & type, bool ns_alias)
|
||||
{
|
||||
char c('/');
|
||||
sal_Int32 nPos = type.lastIndexOf( c );
|
||||
@@ -49,12 +49,11 @@ rtl::OString scopedCppName(rtl::OString const & type, bool ns_alias)
|
||||
c = '.';
|
||||
}
|
||||
|
||||
rtl::OStringBuffer tmpBuf(type.getLength()*2);
|
||||
OStringBuffer tmpBuf(type.getLength()*2);
|
||||
nPos = 0;
|
||||
do
|
||||
{
|
||||
tmpBuf.append("::");
|
||||
tmpBuf.append(type.getToken(0, c, nPos));
|
||||
tmpBuf.append("::" + type.getToken(0, c, nPos));
|
||||
} while( nPos != -1 );
|
||||
|
||||
rtl::OString s(tmpBuf.makeStringAndClear());
|
||||
@@ -67,16 +66,16 @@ rtl::OString scopedCppName(rtl::OString const & type, bool ns_alias)
|
||||
}
|
||||
|
||||
|
||||
rtl::OString translateUnoToCppType(
|
||||
OString translateUnoToCppType(
|
||||
codemaker::UnoType::Sort sort, RTTypeClass typeClass,
|
||||
rtl::OString const & nucleus, bool shortname)
|
||||
OString const & nucleus, bool shortname)
|
||||
{
|
||||
rtl::OStringBuffer buf;
|
||||
if (sort == codemaker::UnoType::SORT_COMPLEX) {
|
||||
if (typeClass == RT_TYPE_INTERFACE
|
||||
&& nucleus == rtl::OString("com/sun/star/uno/XInterface"))
|
||||
{
|
||||
buf.append(RTL_CONSTASCII_STRINGPARAM("::com::sun::star::uno::XInterface"));
|
||||
buf.append("::com::sun::star::uno::XInterface");
|
||||
} else {
|
||||
//TODO: check that nucleus is a valid (UTF-8) identifier
|
||||
buf.append(nucleus);
|
||||
@@ -303,10 +302,7 @@ rtl::OString translateUnoToCppIdentifier(
|
||||
|| unoIdentifier == "NDEBUG"
|
||||
|| (forbidden != 0 && unoIdentifier == *forbidden) )
|
||||
{
|
||||
rtl::OStringBuffer buf(prefix);
|
||||
buf.append('_');
|
||||
buf.append(unoIdentifier);
|
||||
return buf.makeStringAndClear();
|
||||
return prefix + "_" + unoIdentifier;
|
||||
} else {
|
||||
return unoIdentifier;
|
||||
}
|
||||
|
@@ -39,16 +39,15 @@
|
||||
|
||||
namespace codemaker { namespace java {
|
||||
|
||||
rtl::OString translateUnoToJavaType(
|
||||
OString translateUnoToJavaType(
|
||||
codemaker::UnoType::Sort sort, RTTypeClass typeClass,
|
||||
rtl::OString const & nucleus, bool referenceType)
|
||||
OString const & nucleus, bool referenceType)
|
||||
{
|
||||
rtl::OStringBuffer buf;
|
||||
OStringBuffer buf;
|
||||
if (sort == codemaker::UnoType::SORT_COMPLEX) {
|
||||
if (typeClass == RT_TYPE_INTERFACE
|
||||
&& nucleus == rtl::OString("com/sun/star/uno/XInterface"))
|
||||
if (typeClass == RT_TYPE_INTERFACE && nucleus == "com/sun/star/uno/XInterface")
|
||||
{
|
||||
buf.append(RTL_CONSTASCII_STRINGPARAM("java/lang/Object"));
|
||||
buf.append("java/lang/Object");
|
||||
} else {
|
||||
//TODO: check that nucleus is a valid (Java-modified UTF-8)
|
||||
// identifier
|
||||
@@ -145,10 +144,7 @@ rtl::OString translateUnoToJavaIdentifier(
|
||||
|| identifier == "volatile"
|
||||
|| identifier == "while")
|
||||
{
|
||||
rtl::OStringBuffer buf(prefix);
|
||||
buf.append('_');
|
||||
buf.append(identifier);
|
||||
return buf.makeStringAndClear();
|
||||
return prefix + "_" + identifier;
|
||||
} else {
|
||||
return identifier;
|
||||
}
|
||||
|
@@ -403,13 +403,10 @@ OString CppuType::dumpHeaderDefine(
|
||||
|
||||
OStringBuffer tmpBuf(length);
|
||||
|
||||
tmpBuf.append("INCLUDED_");
|
||||
tmpBuf.append(m_typeName);
|
||||
tmpBuf.append('_');
|
||||
tmpBuf.append("INCLUDED_" + m_typeName + "_");
|
||||
if (bExtended)
|
||||
{
|
||||
tmpBuf.append(m_name);
|
||||
tmpBuf.append('_');
|
||||
tmpBuf.append(m_name + "_");
|
||||
}
|
||||
tmpBuf.append(prefix);
|
||||
|
||||
@@ -1222,9 +1219,9 @@ OString CppuType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOn
|
||||
}
|
||||
|
||||
if (bResolveTypeOnly) {
|
||||
rtl::OStringBuffer buf;
|
||||
OStringBuffer buf;
|
||||
for (sal_Int32 i = 0; i < rank; ++i) {
|
||||
buf.append(RTL_CONSTASCII_STRINGPARAM("[]"));
|
||||
buf.append("[]");
|
||||
}
|
||||
baseType = buf.makeStringAndClear() + baseType;
|
||||
}
|
||||
@@ -4025,7 +4022,7 @@ sal_Bool ServiceType::dumpHxxFile(
|
||||
if ((m_reader.getMethodParameterFlags(i, j) & RT_PARAM_REST)
|
||||
!= 0)
|
||||
{
|
||||
buf.append(RTL_CONSTASCII_STRINGPARAM("[]"));
|
||||
buf.append("[]");
|
||||
}
|
||||
buf.append(
|
||||
rtl::OUStringToOString(
|
||||
|
@@ -63,7 +63,7 @@ void appendUnoName(
|
||||
{
|
||||
OSL_ASSERT(rank >= 0 && buffer != 0);
|
||||
for (sal_Int32 i = 0; i < rank; ++i) {
|
||||
buffer->append(RTL_CONSTASCII_STRINGPARAM("[]"));
|
||||
buffer->append("[]");
|
||||
}
|
||||
buffer->append(nucleus.replace('/', '.'));
|
||||
if (!arguments.empty()) {
|
||||
@@ -171,20 +171,13 @@ SpecialType translateUnoTypeToDescriptor(
|
||||
}
|
||||
if (sort == codemaker::UnoType::SORT_COMPLEX) {
|
||||
//TODO: check that nucleus is a valid (Java-modified UTF-8) identifier
|
||||
if (typeClass == RT_TYPE_INTERFACE
|
||||
&& (nucleus
|
||||
== rtl::OString(
|
||||
RTL_CONSTASCII_STRINGPARAM("com/sun/star/uno/XInterface"))))
|
||||
if (typeClass == RT_TYPE_INTERFACE && nucleus == "com/sun/star/uno/XInterface")
|
||||
{
|
||||
if (descriptor != 0) {
|
||||
descriptor->append(
|
||||
rtl::OString(
|
||||
RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;")));
|
||||
descriptor->append("Ljava/lang/Object;");
|
||||
}
|
||||
if (signature != 0) {
|
||||
signature->append(
|
||||
rtl::OString(
|
||||
RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;")));
|
||||
signature->append("Ljava/lang/Object;");
|
||||
}
|
||||
if (polymorphicUnoType != 0) {
|
||||
polymorphicUnoType->kind = PolymorphicUnoType::KIND_NONE;
|
||||
@@ -195,13 +188,10 @@ SpecialType translateUnoTypeToDescriptor(
|
||||
dependencies->insert(nucleus);
|
||||
}
|
||||
if (descriptor != 0) {
|
||||
descriptor->append('L');
|
||||
descriptor->append(nucleus);
|
||||
descriptor->append(';');
|
||||
descriptor->append("L" + nucleus + ";");
|
||||
}
|
||||
if (signature != 0) {
|
||||
signature->append('L');
|
||||
signature->append(nucleus);
|
||||
signature->append("L" + nucleus);
|
||||
if (!arguments.empty()) {
|
||||
signature->append('<');
|
||||
for (std::vector< rtl::OString >::const_iterator i(
|
||||
@@ -411,11 +401,9 @@ SpecialType MethodDescriptor::addParameter(
|
||||
polymorphicUnoType);
|
||||
}
|
||||
|
||||
void MethodDescriptor::addTypeParameter(rtl::OString const & name) {
|
||||
m_descriptorStart.append(RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;"));
|
||||
m_signatureStart.append('T');
|
||||
m_signatureStart.append(name);
|
||||
m_signatureStart.append(';');
|
||||
void MethodDescriptor::addTypeParameter(OString const & name) {
|
||||
m_descriptorStart.append("Ljava/lang/Object;");
|
||||
m_signatureStart.append("T" + name + ";");
|
||||
m_needsSignature = true;
|
||||
}
|
||||
|
||||
@@ -427,9 +415,7 @@ rtl::OString MethodDescriptor::getDescriptor() const {
|
||||
|
||||
rtl::OString MethodDescriptor::getSignature() const {
|
||||
if (m_needsSignature) {
|
||||
rtl::OStringBuffer buf(m_signatureStart);
|
||||
buf.append(m_signatureEnd);
|
||||
return buf.makeStringAndClear();
|
||||
return m_signatureStart + m_signatureEnd;
|
||||
} else {
|
||||
return rtl::OString();
|
||||
}
|
||||
@@ -756,12 +742,7 @@ void writeClassFile(
|
||||
}
|
||||
tempfile.close();
|
||||
if (!makeValidTypeFile(filename, tempname, check)) {
|
||||
rtl::OStringBuffer msg;
|
||||
msg.append(RTL_CONSTASCII_STRINGPARAM("Cannot create "));
|
||||
msg.append(filename);
|
||||
msg.append(RTL_CONSTASCII_STRINGPARAM(" from temporary file "));
|
||||
msg.append(tempname);
|
||||
throw CannotDumpException(msg.makeStringAndClear());
|
||||
throw CannotDumpException("Cannot create " + filename + " from temporary file " + tempname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1029,13 +1010,8 @@ void addField(
|
||||
SpecialType specialType;
|
||||
PolymorphicUnoType polymorphicUnoType;
|
||||
if (typeParameterIndex >= 0) {
|
||||
descriptor = rtl::OString(
|
||||
RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;"));
|
||||
rtl::OStringBuffer buf;
|
||||
buf.append('T');
|
||||
buf.append(type);
|
||||
buf.append(';');
|
||||
signature = buf.makeStringAndClear();
|
||||
descriptor = "Ljava/lang/Object;";
|
||||
signature = "T" + type + ";";
|
||||
specialType = SPECIAL_TYPE_NONE; //TODO: SPECIAL_TYPE_TYPE_PARAMETER?
|
||||
} else {
|
||||
specialType = getFieldDescriptor(
|
||||
@@ -1894,26 +1870,21 @@ void handleAggregatingType(
|
||||
if (reader.getReferenceFlags(i) != RT_ACCESS_INVALID
|
||||
|| reader.getReferenceSort(i) != RT_REF_TYPE_PARAMETER)
|
||||
{
|
||||
throw CannotDumpException(
|
||||
rtl::OString(
|
||||
RTL_CONSTASCII_STRINGPARAM("Bad type information")));
|
||||
throw CannotDumpException("Bad type information");
|
||||
//TODO
|
||||
}
|
||||
rtl::OString name(
|
||||
codemaker::convertString(reader.getReferenceTypeName(i)));
|
||||
buf.append(name);
|
||||
buf.append(RTL_CONSTASCII_STRINGPARAM(":Ljava/lang/Object;"));
|
||||
buf.append(name + ":Ljava/lang/Object;");
|
||||
if (!typeParameters.insert(
|
||||
std::map< rtl::OString, sal_Int32 >::value_type(name, i)).
|
||||
second)
|
||||
{
|
||||
throw CannotDumpException(
|
||||
rtl::OString(
|
||||
RTL_CONSTASCII_STRINGPARAM("Bad type information")));
|
||||
throw CannotDumpException("Bad type information");
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
buf.append(RTL_CONSTASCII_STRINGPARAM(">Ljava/lang/Object;"));
|
||||
buf.append(">Ljava/lang/Object;");
|
||||
sig = buf.makeStringAndClear();
|
||||
}
|
||||
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
||||
@@ -2571,9 +2542,7 @@ void handleModule(
|
||||
rtl::OString(RTL_CONSTASCII_STRINGPARAM("Bad type information")));
|
||||
//TODO
|
||||
}
|
||||
rtl::OStringBuffer buf(codemaker::convertString(reader.getTypeName()));
|
||||
buf.append('/');
|
||||
rtl::OString prefix(buf.makeStringAndClear());
|
||||
rtl::OString prefix(codemaker::convertString(reader.getTypeName()) + "/");
|
||||
sal_uInt16 fields = reader.getFieldCount();
|
||||
for (sal_uInt16 i = 0; i < fields; ++i) {
|
||||
rtl::OString className(
|
||||
@@ -2774,15 +2743,8 @@ void addConstructor(
|
||||
// stack: ex
|
||||
code->instrDup();
|
||||
// stack: ex ex
|
||||
rtl::OStringBuffer msg;
|
||||
msg.append(
|
||||
RTL_CONSTASCII_STRINGPARAM(
|
||||
"component context fails to supply service "));
|
||||
msg.append(unoName);
|
||||
msg.append(RTL_CONSTASCII_STRINGPARAM(" of type "));
|
||||
msg.append(realJavaBaseName);
|
||||
msg.append(RTL_CONSTASCII_STRINGPARAM(": "));
|
||||
code->loadStringConstant(msg.makeStringAndClear());
|
||||
code->loadStringConstant("component context fails to supply service " + unoName +
|
||||
" of type " + realJavaBaseName + ": ");
|
||||
// stack: ex ex "..."
|
||||
code->loadLocalReference(1);
|
||||
// stack: ex ex "..." str
|
||||
@@ -2957,14 +2919,8 @@ void handleService(
|
||||
// stack: ex
|
||||
code->instrDup();
|
||||
// stack: ex ex
|
||||
rtl::OStringBuffer msg;
|
||||
msg.append(
|
||||
RTL_CONSTASCII_STRINGPARAM(
|
||||
"component context fails to supply service "));
|
||||
msg.append(unoName);
|
||||
msg.append(RTL_CONSTASCII_STRINGPARAM(" of type "));
|
||||
msg.append(realJavaBaseName);
|
||||
code->loadStringConstant(msg.makeStringAndClear());
|
||||
code->loadStringConstant("component context fails to supply service " + unoName +
|
||||
" of type " + realJavaBaseName);
|
||||
// stack: ex ex "..."
|
||||
code->loadLocalReference(1);
|
||||
// stack: ex ex "..." context
|
||||
@@ -3152,14 +3108,8 @@ void handleSingleton(
|
||||
// stack: ex
|
||||
code->instrDup();
|
||||
// stack: ex ex
|
||||
rtl::OStringBuffer msg;
|
||||
msg.append(
|
||||
RTL_CONSTASCII_STRINGPARAM(
|
||||
"component context fails to supply singleton "));
|
||||
msg.append(unoName);
|
||||
msg.append(RTL_CONSTASCII_STRINGPARAM(" of type "));
|
||||
msg.append(realJavaBaseName);
|
||||
code->loadStringConstant(msg.makeStringAndClear());
|
||||
code->loadStringConstant("component context fails to supply singleton " + unoName +
|
||||
" of type " + realJavaBaseName);
|
||||
// stack: ex ex "..."
|
||||
code->loadLocalReference(0);
|
||||
// stack: ex ex "..." context
|
||||
|
Reference in New Issue
Block a user