diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-02-18 18:51:46 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-20 11:28:04 +0100 |
commit | fec37f0e9a9e4c18fd20f7b39919f08c7cb2139e (patch) | |
tree | 8c80d55b8223cc2dd92fcc1e639cdf0b178269d2 /src/tools/moc/generator.cpp | |
parent | cbe21c59a05ceb357c1a6bd2a84480dab0e79ea0 (diff) |
moc: Get rid of implicit conversions to const char *
moc mostly operates on QByteArrays. When an actual const char * is
needed, it should be explicit.
Change-Id: I0b3e262830128306688f4512a4b59ce8966c2579
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r-- | src/tools/moc/generator.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 7355275587..937a62e87c 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -54,19 +54,19 @@ QT_BEGIN_NAMESPACE -uint qvariant_nameToType(const char* name) +uint qvariant_nameToType(const QByteArray &name) { - if (!name) + if (name.isEmpty()) return 0; - uint tp = QMetaType::type(name); + uint tp = QMetaType::type(name.constData()); return tp < QMetaType::User ? tp : 0; } /* Returns true if the type is a QVariant types. */ -bool isVariantType(const char* type) +bool isVariantType(const QByteArray &type) { return qvariant_nameToType(type) != 0; } @@ -74,9 +74,9 @@ bool isVariantType(const char* type) /*! Returns true if the type is qreal. */ -static bool isQRealType(const char *type) +static bool isQRealType(const QByteArray &type) { - return strcmp(type, "qreal") == 0; + return (type == "qreal"); } Generator::Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, FILE *outfile) @@ -109,11 +109,9 @@ static inline int lengthOfEscapeSequence(const QByteArray &s, int i) return i - startPos; } -int Generator::strreg(const char *s) +int Generator::strreg(const QByteArray &s) { int idx = 0; - if (!s) - s = ""; for (int i = 0; i < strings.size(); ++i) { const QByteArray &str = strings.at(i); if (str == s) @@ -387,7 +385,7 @@ void Generator::generateCode() for (int i = 1; i < cdef->superclassList.size(); ++i) { // for all superclasses but the first one if (cdef->superclassList.at(i).second == FunctionDef::Private) continue; - const char *cname = cdef->superclassList.at(i).first; + const char *cname = cdef->superclassList.at(i).first.constData(); fprintf(out, " if (!strcmp(_clname, \"%s\"))\n return static_cast< %s*>(const_cast< %s*>(this));\n", cname, cname, cdef->classname.constData()); } |