[gnome-software: 6/13] lib: Convert some enums from #defines to enum types




commit 81aeed80d6341d2e619a21f6ebbe6cd854fc7eb2
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Jan 26 16:42:28 2021 +0000

    lib: Convert some enums from #defines to enum types
    
    This will break i386 builds at runtime at the moment (see #1007), but
    the following commits will fix that again.
    
    Using enums provides greater type safety, and allows
    gobject-introspection to correctly group the enum members.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-plugin-types.h | 76 ++++++++++++++++++++++++++-------------------------
 1 file changed, 39 insertions(+), 37 deletions(-)
---
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index b4a3e3b4..be4b2b9a 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -45,9 +45,10 @@ typedef enum {
  *
  * The flags for the plugin at this point in time.
  **/
-#define GS_PLUGIN_FLAGS_NONE           (0u)
-#define GS_PLUGIN_FLAGS_INTERACTIVE    (1u << 4)
-typedef guint64 GsPluginFlags;
+typedef enum {
+       GS_PLUGIN_FLAGS_NONE = 0,
+       GS_PLUGIN_FLAGS_INTERACTIVE = 1 << 4,
+} GsPluginFlags;
 
 /**
  * GsPluginError:
@@ -131,40 +132,41 @@ typedef enum {
  *
  * The refine flags.
  **/
-#define GS_PLUGIN_REFINE_FLAGS_DEFAULT                 ((guint64) 0)
-#define GS_PLUGIN_REFINE_FLAGS_USE_HISTORY             ((guint64) 1 << 0) /* unused, TODO: perhaps ->STATE */
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE         ((guint64) 1 << 1)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL             ((guint64) 1 << 2)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION     ((guint64) 1 << 3)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE            ((guint64) 1 << 4)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING          ((guint64) 1 << 5)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION         ((guint64) 1 << 6)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY         ((guint64) 1 << 7)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION    ((guint64) 1 << 8)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS  ((guint64) 1 << 9)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN          ((guint64) 1 << 10)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED         ((guint64) 1 << 11)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH       ((guint64) 1 << 12)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS          ((guint64) 1 << 13)
-#define GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES          ((guint64) 1 << 14) /* TODO: move to request */
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY ((guint64) 1 << 15)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED ((guint64) 1 << 16)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE      ((guint64) 1 << 17)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS         ((guint64) 1 << 18)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS  ((guint64) 1 << 19)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_KEY_COLORS      ((guint64) 1 << 20)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON            ((guint64) 1 << 21)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS     ((guint64) 1 << 22)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME ((guint64) 1 << 23)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI       ((guint64) 1 << 24)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME         ((guint64) 1 << 25)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS     ((guint64) 1 << 26)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES      ((guint64) 1 << 27)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP   ((guint64) 1 << 28)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME  ((guint64) 1 << 29)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS           ((guint64) 1 << 30)
-#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_CONTENT_RATING  ((guint64) 1 << 31)
-typedef guint64 GsPluginRefineFlags;
+typedef enum {
+       GS_PLUGIN_REFINE_FLAGS_DEFAULT                  = 0,
+       GS_PLUGIN_REFINE_FLAGS_USE_HISTORY              = 1 << 0, /* unused, TODO: perhaps ->STATE */
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE          = 1 << 1,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL              = 1 << 2,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION      = 1 << 3,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE             = 1 << 4,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING           = 1 << 5,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION          = 1 << 6,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY          = 1 << 7,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION     = 1 << 8,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS   = 1 << 9,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN           = 1 << 10,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED          = 1 << 11,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH        = 1 << 12,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS           = 1 << 13,
+       GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES           = 1 << 14, /* TODO: move to request */
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY  = 1 << 15,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED  = 1 << 16,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE       = 1 << 17,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS          = 1 << 18,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS   = 1 << 19,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_KEY_COLORS       = 1 << 20,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON             = 1 << 21,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS      = 1 << 22,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME  = 1 << 23,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI        = 1 << 24,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME          = 1 << 25,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS      = 1 << 26,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES       = 1 << 27,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP    = 1 << 28,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME   = 1 << 29,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS            = 1 << 30,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_CONTENT_RATING   = 1 << 31,
+} GsPluginRefineFlags;
 
 /**
  * GsPluginRule:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]