From d46739294d04c72af1e434e414e1c012d7e78a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Tue, 4 Feb 2020 16:03:52 +0100 Subject: Add an isImmutable to know if a property is immutable Summary: Add a utility function isImmutable to access immutability quickly. Generated classes uses them internally to avoid code redundance. Sample: ``` /** Set blocked-by-default */ void setBlockedByDefault( bool v ) { if (v != mBlockedByDefault && !isBlockedByDefaultImmutable() ) { mBlockedByDefault = v; Q_EMIT blockedByDefaultChanged(); } } /** Is blocked-by-default Immutable */ bool isBlockedByDefaultImmutable() { return isImmutable( QStringLiteral( "blockedByDefault" ) ); } ``` ``` /** Set org.kde.ActivityManager.ResourceScoringEnabled */ void setResourceScoringEnabled( bool v ) { if (!isResourceScoringEnabledImmutable() ) mResourceScoringEnabled = v; } /** Is org.kde.ActivityManager.ResourceScoringEnabled Immutable */ bool isResourceScoringEnabledImmutable() { return isImmutable( QStringLiteral( "resourceScoringEnabled" ) ); } ``` Reviewers: ervin, #frameworks, dfaure Reviewed By: ervin Subscribers: dfaure, tcanabrava, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D26368 --- autotests/kconfig_compiler/test8b.h.ref | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'autotests/kconfig_compiler/test8b.h.ref') diff --git a/autotests/kconfig_compiler/test8b.h.ref b/autotests/kconfig_compiler/test8b.h.ref index 0f71ba7c..793c6851 100644 --- a/autotests/kconfig_compiler/test8b.h.ref +++ b/autotests/kconfig_compiler/test8b.h.ref @@ -22,7 +22,7 @@ class Test8b : public Test8a static void setSomething( uint v ) { - if (!self()->isImmutable( QStringLiteral( "Something" ) )) + if (!self()->isSomethingImmutable()) self()->mSomething = v; } @@ -35,13 +35,22 @@ class Test8b : public Test8a return self()->mSomething; } + /** + Is Something Immutable + */ + static + bool isSomethingImmutable() + { + return self()->isImmutable( QStringLiteral( "Something" ) ); + } + /** Set FooBoo */ static void setFooBoo( bool v ) { - if (!self()->isImmutable( QStringLiteral( "FooBoo" ) )) + if (!self()->isFooBooImmutable()) self()->mFooBoo = v; } @@ -54,13 +63,22 @@ class Test8b : public Test8a return self()->mFooBoo; } + /** + Is FooBoo Immutable + */ + static + bool isFooBooImmutable() + { + return self()->isImmutable( QStringLiteral( "FooBoo" ) ); + } + /** Set Port */ static void setPort( uint v ) { - if (!self()->isImmutable( QStringLiteral( "Port" ) )) + if (!self()->isPortImmutable()) self()->mPort = v; } @@ -73,6 +91,15 @@ class Test8b : public Test8a return self()->mPort; } + /** + Is Port Immutable + */ + static + bool isPortImmutable() + { + return self()->isImmutable( QStringLiteral( "Port" ) ); + } + protected: Test8b(); friend class Test8bHelper; -- cgit v1.2.1