[glib/wip/smcv/none-flags: 569/576] gtype: Add G_TYPE_FLAG_NONE
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/none-flags: 569/576] gtype: Add G_TYPE_FLAG_NONE
- Date: Thu, 23 Jun 2022 09:42:26 +0000 (UTC)
commit 93be69676372ca02b5f594180f3096f932b53472
Author: Simon McVittie <smcv collabora com>
Date: Thu Mar 31 13:58:36 2022 +0100
gtype: Add G_TYPE_FLAG_NONE
This makes code that sets no flags a bit more self-documenting:
using G_TYPE_FLAG_NONE makes it clearer that no special behaviour is
required than literal 0, and clearer that there is no weird casting
between types than (GTypeFlags) 0.
GTypeFlags and GTypeFundamentalFlags occupy the same namespace and the
same bitfield, so I intentionally haven't added
G_TYPE_FUNDAMENTAL_FLAGS_NONE.
Signed-off-by: Simon McVittie <smcv collabora com>
gobject/gtype.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 66cac1fc58..47e7348afe 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1030,6 +1030,8 @@ typedef void (*GTypeInterfaceCheckFunc) (gpointer check_data,
*/
typedef enum /*< skip >*/
{
+ /* There is no G_TYPE_FUNDAMENTAL_FLAGS_NONE: this is implemented to use
+ * the same bits as GTypeFlags */
G_TYPE_FLAG_CLASSED = (1 << 0),
G_TYPE_FLAG_INSTANTIATABLE = (1 << 1),
G_TYPE_FLAG_DERIVABLE = (1 << 2),
@@ -1037,6 +1039,7 @@ typedef enum /*< skip >*/
} GTypeFundamentalFlags;
/**
* GTypeFlags:
+ * @G_TYPE_FLAG_NONE: No special flags. Since: 2.74
* @G_TYPE_FLAG_ABSTRACT: Indicates an abstract type. No instances can be
* created for an abstract type
* @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type
@@ -1049,6 +1052,7 @@ typedef enum /*< skip >*/
*/
typedef enum /*< skip >*/
{
+ G_TYPE_FLAG_NONE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_TYPE_FLAG_ABSTRACT = (1 << 4),
G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5),
G_TYPE_FLAG_FINAL GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6)
@@ -2197,7 +2201,7 @@ type_name##_get_type (void) \
(GClassInitFunc)(void (*)(void)) type_name##_default_init, \
0, \
(GInstanceInitFunc)NULL, \
- (GTypeFlags) 0); \
+ G_TYPE_FLAG_NONE); \
if (TYPE_PREREQ != G_TYPE_INVALID) \
g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \
{ /* custom code follows */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]