aboutsummaryrefslogtreecommitdiffstats
path: root/cppgenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-02-20 17:49:26 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-02-20 18:20:32 -0300
commit5ce831e73fc4b8bee7a5b62d7485eee11f498a92 (patch)
treef81c4d1243a75545be0adecdcf298b5420df9438 /cppgenerator.cpp
parent02e5d72cceae2b03ce25068567e3c4c903a4df3d (diff)
Adds the convenience method 'isCString' to ShibokenGenerator.
It checks if an AbstractMetaType represents a C string. Also updated code to make use of the new method.
Diffstat (limited to 'cppgenerator.cpp')
-rw-r--r--cppgenerator.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index fac317088..17ff3f4f1 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -989,22 +989,22 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
QStringList args;
foreach(AbstractMetaArgument* arg, f->arguments()) {
QString strArg;
- bool isCString = arg->type()->isNativePointer() && arg->type()->name() == "char";
- if (isCString) {
+ AbstractMetaType* argType = arg->type();
+ if (isCString(argType)) {
strArg = "str";
- } else if (arg->type()->isPrimitive()) {
- const PrimitiveTypeEntry* ptp = reinterpret_cast<const PrimitiveTypeEntry*>(arg->type()->typeEntry());
+ } else if (argType->isPrimitive()) {
+ const PrimitiveTypeEntry* ptp = reinterpret_cast<const PrimitiveTypeEntry*>(argType->typeEntry());
while (ptp->aliasedTypeEntry())
ptp = ptp->aliasedTypeEntry();
strArg = ptp->name().replace(QRegExp("^signed\\s+"), "");
if (strArg == "double")
strArg = "float";
} else {
- strArg = arg->type()->fullName();
+ strArg = argType->fullName();
}
if (!arg->defaultValueExpression().isEmpty()) {
strArg += " = ";
- if ((isCString || arg->type()->isValuePointer() || arg->type()->typeEntry()->isObject())
+ if ((isCString(argType) || argType->isValuePointer() || argType->typeEntry()->isObject())
&& arg->defaultValueExpression() == "0")
strArg += "None";
else
@@ -1126,7 +1126,7 @@ void CppGenerator::writeArgumentConversion(QTextStream& s,
if (type->isContainer() || type->isPrimitive()) {
// If the type is a const char*, we don't remove the "const".
- if (typeName.startsWith("const ") && !(argType->isNativePointer() && argType->name() == "char"))
+ if (typeName.startsWith("const ") && !(isCString(argType)))
typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
if (typeName.endsWith("&"))
typeName.chop(1);