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 --- src/kconfig_compiler/KConfigCodeGeneratorBase.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/kconfig_compiler/KConfigCodeGeneratorBase.h') diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index 5bbc6b71..0c815c9b 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -82,6 +82,9 @@ public: // TODO: write to the stream directly without returning a QString. QString memberAccessorBody(const CfgEntry *e, bool globalEnums) const; + // Implements the isImmutable for the CfgEntry + void memberImmutableBody(const CfgEntry *e, bool globalEnums); + // Implements the `Set` methods for the CfgEntry void memberMutatorBody(const CfgEntry *e); -- cgit v1.2.1