gitypes: Add ‘none’ members for flags enums

This is a little clearer than using `0` as a precondition failure
return value.

Suggested by John Ralls in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4606#note_2420640.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall
2025-04-30 13:17:15 +01:00
parent d1e28aed1a
commit d496e97b75
2 changed files with 8 additions and 2 deletions

View File

@@ -116,8 +116,8 @@ gi_function_info_get_flags (GIFunctionInfo *info)
GIRealInfo *rinfo;
FunctionBlob *blob;
g_return_val_if_fail (info != NULL, 0);
g_return_val_if_fail (GI_IS_FUNCTION_INFO (info), 0);
g_return_val_if_fail (info != NULL, GI_FUNCTION_INFO_FLAGS_NONE);
g_return_val_if_fail (GI_IS_FUNCTION_INFO (info), GI_FUNCTION_INFO_FLAGS_NONE);
rinfo = (GIRealInfo *)info;
blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];

View File

@@ -366,6 +366,7 @@ typedef enum {
/**
* GIFieldInfoFlags:
* @GI_FIELD_INFO_FLAGS_NONE: no flags set (since: 2.86)
* @GI_FIELD_IS_READABLE: field is readable.
* @GI_FIELD_IS_WRITABLE: field is writable.
*
@@ -376,12 +377,14 @@ typedef enum {
typedef enum
{
GI_FIELD_INFO_FLAGS_NONE GI_AVAILABLE_ENUMERATOR_IN_2_86 = 0,
GI_FIELD_IS_READABLE = 1 << 0,
GI_FIELD_IS_WRITABLE = 1 << 1
} GIFieldInfoFlags;
/**
* GIVFuncInfoFlags:
* @GI_VFUNC_INFO_FLAGS_NONE: no flags set (since: 2.86)
* @GI_VFUNC_MUST_CHAIN_UP: chains up to the parent type
* @GI_VFUNC_MUST_OVERRIDE: overrides
* @GI_VFUNC_MUST_NOT_OVERRIDE: does not override
@@ -392,6 +395,7 @@ typedef enum
*/
typedef enum
{
GI_VFUNC_INFO_FLAGS_NONE GI_AVAILABLE_ENUMERATOR_IN_2_86 = 0,
GI_VFUNC_MUST_CHAIN_UP = 1 << 0,
GI_VFUNC_MUST_OVERRIDE = 1 << 1,
GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2,
@@ -399,6 +403,7 @@ typedef enum
/**
* GIFunctionInfoFlags:
* @GI_FUNCTION_INFO_FLAGS_NONE: no flags set (since: 2.86)
* @GI_FUNCTION_IS_METHOD: is a method.
* @GI_FUNCTION_IS_CONSTRUCTOR: is a constructor.
* @GI_FUNCTION_IS_GETTER: is a getter of a [class@GIRepository.PropertyInfo].
@@ -411,6 +416,7 @@ typedef enum
*/
typedef enum
{
GI_FUNCTION_INFO_FLAGS_NONE GI_AVAILABLE_ENUMERATOR_IN_2_86 = 0,
GI_FUNCTION_IS_METHOD = 1 << 0,
GI_FUNCTION_IS_CONSTRUCTOR = 1 << 1,
GI_FUNCTION_IS_GETTER = 1 << 2,