diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-29 08:13:24 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-31 01:16:34 (GMT) |
commit | 29202f033c87b5efe305e606805a26c59886875b (patch) | |
tree | 6d0b770e58a67648f64fd90c6be9f5e2ee45c5f6 /src/tools | |
parent | f5acc7b83f79c0bce554a6e4fe2d9e6ebb4b582b (diff) | |
download | Qt-29202f033c87b5efe305e606805a26c59886875b.zip Qt-29202f033c87b5efe305e606805a26c59886875b.tar.gz Qt-29202f033c87b5efe305e606805a26c59886875b.tar.bz2 |
Add CONSTANT attribute to Q_PROPERTY()
This will be used by the declarative module to determine if a property lacking a NOTIFY signal is truly constant, or just missing a NOTIFY signal.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/moc/generator.cpp | 7 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 23 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 3 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index b872dfd..e4086e6 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -66,7 +66,9 @@ enum PropertyFlags { ResolveEditable = 0x00080000, User = 0x00100000, ResolveUser = 0x00200000, - Notify = 0x00400000 + Notify = 0x00400000, + Dynamic = 0x00800000, + Constant = 0x00000400 }; enum MethodFlags { AccessPrivate = 0x00, @@ -597,6 +599,9 @@ void Generator::generateProperties() if (p.notifyId != -1) flags |= Notify; + if (p.constant) + flags |= Constant; + fprintf(out, " %4d, %4d, ", strreg(p.name), strreg(p.type)); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 797595f..66012ca 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -908,6 +908,12 @@ void Moc::parseProperty(ClassDef *def) propDef.name = lexem(); while (test(IDENTIFIER)) { QByteArray l = lexem(); + + if (l[0] == 'C' && l == "CONSTANT") { + propDef.constant = true; + continue; + } + QByteArray v, v2; if (test(LPAREN)) { v = lexemUntil(RPAREN); @@ -963,6 +969,23 @@ void Moc::parseProperty(ClassDef *def) msg += " has no READ accessor function. The property will be invalid."; warning(msg.constData()); } + if (propDef.constant && !propDef.write.isNull()) { + QByteArray msg; + msg += "Property declaration "; + msg += propDef.name; + msg += " is both WRITEable and CONSTANT. CONSTANT will be ignored."; + propDef.constant = false; + warning(msg.constData()); + } + if (propDef.constant && !propDef.notify.isNull()) { + QByteArray msg; + msg += "Property declaration "; + msg += propDef.name; + msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored."; + propDef.constant = false; + warning(msg.constData()); + } + if(!propDef.notify.isEmpty()) def->notifyableProperties++; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 9fa9ac2..494d53e 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -115,9 +115,10 @@ struct FunctionDef struct PropertyDef { - PropertyDef():notifyId(-1), gspec(ValueSpec){} + PropertyDef():notifyId(-1), constant(false), gspec(ValueSpec){} QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify; int notifyId; + bool constant; enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; Specification gspec; bool stdCppSet() const { |