[Kde-bindings] KDE/kdebindings
Arno Rehn
kde at arnorehn.de
Thu Apr 22 16:37:43 UTC 2010
SVN commit 1117631 by arnorehn:
Properly resolve QFlags. This shouldn't cause any trouble, but could need some testing.
CCMAIL: kde-bindings at kde.org
M +9 -4 generator/generators/smoke/helpers.cpp
M +5 -1 generator/generators/smoke/writeSmokeDataFile.cpp
M +13 -0 generator/generatorvisitor.cpp
M +1 -1 generator/type_compiler.cpp
M +1 -1 smoke/kio/smokeconfig.xml
--- trunk/KDE/kdebindings/generator/generators/smoke/helpers.cpp #1117630:1117631
@@ -456,7 +456,7 @@
QString ret = meth.name();
foreach (const Parameter& param, meth.parameters()) {
const Type* type = param.type();
- if (type->pointerDepth() > 1 || (type->getClass() && type->getClass()->isTemplate()) ||
+ if (type->pointerDepth() > 1 || (type->getClass() && type->getClass()->isTemplate() && (!Options::qtMode || (Options::qtMode && type->getClass()->name() != "QFlags"))) ||
(Options::voidpTypes.contains(type->name()) && !Options::scalarTypes.contains(type->name())) )
{
// QString and QStringList are both mapped to Smoke::t_voidp, but QString is a scalar as well
@@ -465,7 +465,9 @@
// reference to array or hash or unknown
ret += "?";
} else if (type->isIntegral() || type->getEnum() || Options::scalarTypes.contains(type->name()) ||
- (Options::qtMode && !type->isRef() && type->getTypedef() && flagTypes.contains(type->getTypedef())) )
+ (Options::qtMode && !type->isRef() && type->pointerDepth() == 0 &&
+ (type->getTypedef() && flagTypes.contains(type->getTypedef())) ||
+ (type->getClass() && type->getClass()->isTemplate() && type->getClass()->name() == "QFlags")))
{
// plain scalar
ret += "$";
@@ -483,7 +485,8 @@
QString Util::stackItemField(const Type* type)
{
if (Options::qtMode && !type->isRef() && type->pointerDepth() == 0 &&
- type->getTypedef() && flagTypes.contains(type->getTypedef()))
+ ((type->getTypedef() && flagTypes.contains(type->getTypedef()))
+ || (type->getClass() && type->getClass()->isTemplate() && type->getClass()->name() == "QFlags")))
{
return "s_uint";
}
@@ -522,7 +525,9 @@
return var;
} else if (type->getEnum()) {
return var;
- } else if (Options::qtMode && type->getTypedef() && flagTypes.contains(type->getTypedef())) {
+ } else if (Options::qtMode && ( (type->getTypedef() && flagTypes.contains(type->getTypedef()))
+ || (type->getClass() && type->getClass()->isTemplate() && type->getClass()->name() == "QFlags")))
+ {
return "(uint)" + var;
} else {
QString ret = "(void*)new " + type->toString();
--- trunk/KDE/kdebindings/generator/generators/smoke/writeSmokeDataFile.cpp #1117630:1117631
@@ -316,7 +316,11 @@
flags += "|Smoke::t_voidp";
} else if (t->getClass()) {
if (t->getClass()->isTemplate()) {
- flags += "|Smoke::t_voidp";
+ if (Options::qtMode && t->getClass()->name() == "QFlags") {
+ flags += "|Smoke::t_uint";
+ } else {
+ flags += "|Smoke::t_voidp";
+ }
} else {
flags += "|Smoke::t_class";
classIdx = classIndex.value(t->getClass()->toString(), 0);
--- trunk/KDE/kdebindings/generator/generatorvisitor.cpp #1117630:1117631
@@ -104,6 +104,19 @@
// TODO: this might have to be improved for cases like 'Typedef::Nested foo'
BasicTypeDeclaration* GeneratorVisitor::resolveType(QString & name)
{
+ if (ParserOptions::qtMode && name.endsWith("::enum_type")) {
+ // strip off "::enum_type"
+ QString flags = name.left(name.length() - 11);
+ QHash<QString, Typedef>::iterator it = typedefs.find(flags);
+ if (it != typedefs.end()) {
+ QString enumType = it.value().resolve().toString().replace(QRegExp("QFlags<(.*)>"), "\\1");
+ QHash<QString, Enum>::iterator it = enums.find(enumType);
+ if (it != enums.end()) {
+ return &it.value();
+ }
+ }
+ }
+
// check for 'using type;'
// if we use 'type', we can also access type::nested, take care of that
int index = name.indexOf("::");
--- trunk/KDE/kdebindings/generator/type_compiler.cpp #1117630:1117631
@@ -123,7 +123,7 @@
if ((klass = dynamic_cast<Class*>(type))) {
m_realType = Type(klass, isConstant(), isVolatile());
} else if ((tdef = dynamic_cast<Typedef*>(type))) {
- if (!ParserOptions::resolveTypedefs || (ParserOptions::qtMode && flagTypes.contains(tdef)) ) {
+ if (!ParserOptions::resolveTypedefs) {
m_realType = Type(tdef);
} else {
m_realType = tdef->resolve();
--- trunk/KDE/kdebindings/smoke/kio/smokeconfig.xml #1117630:1117631
@@ -34,7 +34,7 @@
<!-- operator(<<|>>)(QDataStream&, KDateTime*) - why are these operators not implemented/exported? -->
<signature>.*operator(<<|>>)\(QDataStream&, (const\s)?KDateTime.*</signature>
- <signature>.*KIO::file_move\(const KUrl&, const KUrl&, KIO::JobFlags.*</signature>
+ <signature>.*KIO::file_move\(const KUrl&, const KUrl&, QFlags<KIO::JobFlag>.*</signature>
<signature>.*KIO::buildHTMLErrorString\(.*</signature>
</exclude>
<functions>
More information about the Kde-bindings
mailing list