From dc69f56de6dab66f7bb4fe66aa203e84efa9676c Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 30 Apr 2020 14:28:20 -0600 Subject: [PATCH] lib: Coerce flags enums to GIR bitfields The GI scanner decides if an `enum` is really a `bitfield` if it finds any values that have left shifts. With an `enumeration`, the introspecting language may error or convert to a different type if the user tries to combine values. Change all Flags `enum`s to use left-shifted values so that they're represented as `bitfield`s in the GIR. The primary bug here is that you can't combine `REFS_ONLY` and `NO_PRUNE` when calling `OSTree.Repo.prune()` from an introspected language. This is an IABI break since the typelib will change from `enumeration` to `bitfield`. `OstreeRepoImportFlags` is internal but the change is included here to prepare for a subsequent name that would require bit shifting to operate correctly as a flag. --- src/libostree/ostree-gpg-verify-result.h | 2 +- src/libostree/ostree-repo-private.h | 6 +++--- src/libostree/ostree-repo.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libostree/ostree-gpg-verify-result.h b/src/libostree/ostree-gpg-verify-result.h index 6f51ce8a..8f243fcd 100644 --- a/src/libostree/ostree-gpg-verify-result.h +++ b/src/libostree/ostree-gpg-verify-result.h @@ -134,7 +134,7 @@ GVariant * ostree_gpg_verify_result_get_all (OstreeGpgVerifyResult *result, * for future variations. **/ typedef enum { - OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT = 0 + OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT = (0 << 0), } OstreeGpgSignatureFormatFlags; _OSTREE_PUBLIC diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h index a1c7b7b4..a744c069 100644 --- a/src/libostree/ostree-repo-private.h +++ b/src/libostree/ostree-repo-private.h @@ -374,9 +374,9 @@ _ostree_repo_verify_commit_internal (OstreeRepo *self, #endif /* OSTREE_DISABLE_GPGME */ typedef enum { - _OSTREE_REPO_IMPORT_FLAGS_NONE, - _OSTREE_REPO_IMPORT_FLAGS_TRUSTED, - _OSTREE_REPO_IMPORT_FLAGS_VERIFY_BAREUSERONLY, + _OSTREE_REPO_IMPORT_FLAGS_NONE = 0, + _OSTREE_REPO_IMPORT_FLAGS_TRUSTED = (1 << 0), + _OSTREE_REPO_IMPORT_FLAGS_VERIFY_BAREUSERONLY = (1 << 1), } OstreeRepoImportFlags; gboolean diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h index 1027ac77..e28af29c 100644 --- a/src/libostree/ostree-repo.h +++ b/src/libostree/ostree-repo.h @@ -1174,9 +1174,9 @@ void ostree_repo_commit_traverse_iter_cleanup (void *p); * @OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY: Do not traverse individual commit objects, only follow refs */ typedef enum { - OSTREE_REPO_PRUNE_FLAGS_NONE, - OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE, - OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY + OSTREE_REPO_PRUNE_FLAGS_NONE = 0, + OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE = (1 << 0), + OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY = (1 << 1), } OstreeRepoPruneFlags; _OSTREE_PUBLIC