summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2013-03-07 10:25:27 -0300
committerFridrich Strba <fridrich@documentfoundation.org>2013-03-08 04:31:03 +0000
commit75e6856b081ca29e3e0f19493780d9f8fa6d315c (patch)
treeccf9eff69dfcceee951880cb9381f37940ae47d0 /codemaker
parent8035a3af260729ee47a1d805811e17d06d035e3d (diff)
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>
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/source/codemaker/codemaker.cxx7
-rw-r--r--codemaker/source/commoncpp/commoncpp.cxx18
-rw-r--r--codemaker/source/commonjava/commonjava.cxx16
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx13
-rw-r--r--codemaker/source/javamaker/javatype.cxx98
5 files changed, 44 insertions, 108 deletions
diff --git a/codemaker/source/codemaker/codemaker.cxx b/codemaker/source/codemaker/codemaker.cxx
index 454f59c97f35..6c203bf6dc4b 100644
--- a/codemaker/source/codemaker/codemaker.cxx
+++ b/codemaker/source/codemaker/codemaker.cxx
@@ -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(
diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx
index 989052d67030..5db10d481c75 100644
--- a/codemaker/source/commoncpp/commoncpp.cxx
+++ b/codemaker/source/commoncpp/commoncpp.cxx
@@ -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;
}
diff --git a/codemaker/source/commonjava/commonjava.cxx b/codemaker/source/commonjava/commonjava.cxx
index 8c01be992375..e5f6eca8fc5d 100644
--- a/codemaker/source/commonjava/commonjava.cxx
+++ b/codemaker/source/commonjava/commonjava.cxx
@@ -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;
}
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 29516c8cab8f..6ee5f9e45b0f 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -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(
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
index 404626a0316f..64d0e24ed497 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -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