mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 01:36:17 +01:00
Use varargs for enum types definition macros
Makes the syntax a little bit better.
This commit is contained in:
parent
fa05ebe27c
commit
c0766caf20
@ -288,13 +288,13 @@ void g_flags_complete_type_info (GType g_flags_type,
|
|||||||
*
|
*
|
||||||
* Since: 2.74
|
* Since: 2.74
|
||||||
*/
|
*/
|
||||||
#define G_DEFINE_ENUM_VALUE(EnumValue, EnumNick) { EnumValue, #EnumValue, EnumNick },
|
#define G_DEFINE_ENUM_VALUE(EnumValue, EnumNick) { EnumValue, #EnumValue, EnumNick }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* G_DEFINE_ENUM_TYPE:
|
* G_DEFINE_ENUM_TYPE:
|
||||||
* @TypeName: the enumeration type, in `CamelCase`
|
* @TypeName: the enumeration type, in `CamelCase`
|
||||||
* @type_name: the enumeration type prefixed, in `snake_case`
|
* @type_name: the enumeration type prefixed, in `snake_case`
|
||||||
* @values: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()
|
* @...: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()
|
||||||
*
|
*
|
||||||
* A convenience macro for defining enumeration types.
|
* A convenience macro for defining enumeration types.
|
||||||
*
|
*
|
||||||
@ -303,7 +303,7 @@ void g_flags_complete_type_info (GType g_flags_type,
|
|||||||
*
|
*
|
||||||
* |[<!-- language="C" -->
|
* |[<!-- language="C" -->
|
||||||
* G_DEFINE_ENUM_TYPE (GtkOrientation, gtk_orientation,
|
* G_DEFINE_ENUM_TYPE (GtkOrientation, gtk_orientation,
|
||||||
* G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_HORIZONTAL, "horizontal")
|
* G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_HORIZONTAL, "horizontal"),
|
||||||
* G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_VERTICAL, "vertical"))
|
* G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_VERTICAL, "vertical"))
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
@ -313,13 +313,13 @@ void g_flags_complete_type_info (GType g_flags_type,
|
|||||||
*
|
*
|
||||||
* Since: 2.74
|
* Since: 2.74
|
||||||
*/
|
*/
|
||||||
#define G_DEFINE_ENUM_TYPE(TypeName, type_name, values) \
|
#define G_DEFINE_ENUM_TYPE(TypeName, type_name, ...) \
|
||||||
GType \
|
GType \
|
||||||
type_name ## _get_type (void) { \
|
type_name ## _get_type (void) { \
|
||||||
static gsize g_define_type__static = 0; \
|
static gsize g_define_type__static = 0; \
|
||||||
if (g_once_init_enter (&g_define_type__static)) { \
|
if (g_once_init_enter (&g_define_type__static)) { \
|
||||||
static const GEnumValue enum_values[] = { \
|
static const GEnumValue enum_values[] = { \
|
||||||
values \
|
__VA_ARGS__ , \
|
||||||
{ 0, NULL, NULL }, \
|
{ 0, NULL, NULL }, \
|
||||||
}; \
|
}; \
|
||||||
GType g_define_type = g_enum_register_static (g_intern_static_string (#TypeName), enum_values); \
|
GType g_define_type = g_enum_register_static (g_intern_static_string (#TypeName), enum_values); \
|
||||||
@ -332,7 +332,7 @@ type_name ## _get_type (void) { \
|
|||||||
* G_DEFINE_FLAGS_TYPE:
|
* G_DEFINE_FLAGS_TYPE:
|
||||||
* @TypeName: the enumeration type, in `CamelCase`
|
* @TypeName: the enumeration type, in `CamelCase`
|
||||||
* @type_name: the enumeration type prefixed, in `snake_case`
|
* @type_name: the enumeration type prefixed, in `snake_case`
|
||||||
* @values: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()
|
* @...: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()
|
||||||
*
|
*
|
||||||
* A convenience macro for defining flag types.
|
* A convenience macro for defining flag types.
|
||||||
*
|
*
|
||||||
@ -341,11 +341,11 @@ type_name ## _get_type (void) { \
|
|||||||
*
|
*
|
||||||
* |[<!-- language="C" -->
|
* |[<!-- language="C" -->
|
||||||
* G_DEFINE_FLAGS_TYPE (GSettingsBindFlags, g_settings_bind_flags,
|
* G_DEFINE_FLAGS_TYPE (GSettingsBindFlags, g_settings_bind_flags,
|
||||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_DEFAULT, "default")
|
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_DEFAULT, "default"),
|
||||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET, "get")
|
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET, "get"),
|
||||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_SET, "set")
|
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_SET, "set"),
|
||||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_NO_SENSITIVITY, "no-sensitivity")
|
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_NO_SENSITIVITY, "no-sensitivity"),
|
||||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET_NO_CHANGES, "get-no-changes")
|
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET_NO_CHANGES, "get-no-changes"),
|
||||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_INVERT_BOOLEAN, "invert-boolean"))
|
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_INVERT_BOOLEAN, "invert-boolean"))
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
@ -355,13 +355,13 @@ type_name ## _get_type (void) { \
|
|||||||
*
|
*
|
||||||
* Since: 2.74
|
* Since: 2.74
|
||||||
*/
|
*/
|
||||||
#define G_DEFINE_FLAGS_TYPE(TypeName, type_name, values) \
|
#define G_DEFINE_FLAGS_TYPE(TypeName, type_name, ...) \
|
||||||
GType \
|
GType \
|
||||||
type_name ## _get_type (void) { \
|
type_name ## _get_type (void) { \
|
||||||
static gsize g_define_type__static = 0; \
|
static gsize g_define_type__static = 0; \
|
||||||
if (g_once_init_enter (&g_define_type__static)) { \
|
if (g_once_init_enter (&g_define_type__static)) { \
|
||||||
static const GFlagsValue flags_values[] = { \
|
static const GFlagsValue flags_values[] = { \
|
||||||
values \
|
__VA_ARGS__ , \
|
||||||
{ 0, NULL, NULL }, \
|
{ 0, NULL, NULL }, \
|
||||||
}; \
|
}; \
|
||||||
GType g_define_type = g_flags_register_static (g_intern_static_string (#TypeName), flags_values); \
|
GType g_define_type = g_flags_register_static (g_intern_static_string (#TypeName), flags_values); \
|
||||||
|
@ -167,8 +167,8 @@ typedef enum {
|
|||||||
GType test_enum_get_type (void);
|
GType test_enum_get_type (void);
|
||||||
|
|
||||||
G_DEFINE_ENUM_TYPE (TestEnum, test_enum,
|
G_DEFINE_ENUM_TYPE (TestEnum, test_enum,
|
||||||
G_DEFINE_ENUM_VALUE (TEST_ENUM_FIRST_VALUE, "first-value")
|
G_DEFINE_ENUM_VALUE (TEST_ENUM_FIRST_VALUE, "first-value"),
|
||||||
G_DEFINE_ENUM_VALUE (TEST_ENUM_SECOND_VALUE, "second-value")
|
G_DEFINE_ENUM_VALUE (TEST_ENUM_SECOND_VALUE, "second-value"),
|
||||||
G_DEFINE_ENUM_VALUE (TEST_ENUM_THIRD_VALUE, "third-value"))
|
G_DEFINE_ENUM_VALUE (TEST_ENUM_THIRD_VALUE, "third-value"))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -200,9 +200,9 @@ typedef enum {
|
|||||||
GType test_flags_get_type (void);
|
GType test_flags_get_type (void);
|
||||||
|
|
||||||
G_DEFINE_FLAGS_TYPE (TestFlags, test_flags,
|
G_DEFINE_FLAGS_TYPE (TestFlags, test_flags,
|
||||||
G_DEFINE_ENUM_VALUE (TEST_FLAGS_DEFAULT, "default")
|
G_DEFINE_ENUM_VALUE (TEST_FLAGS_DEFAULT, "default"),
|
||||||
G_DEFINE_ENUM_VALUE (TEST_FLAGS_FIRST, "first")
|
G_DEFINE_ENUM_VALUE (TEST_FLAGS_FIRST, "first"),
|
||||||
G_DEFINE_ENUM_VALUE (TEST_FLAGS_SECOND, "second")
|
G_DEFINE_ENUM_VALUE (TEST_FLAGS_SECOND, "second"),
|
||||||
G_DEFINE_ENUM_VALUE (TEST_FLAGS_THIRD, "third"))
|
G_DEFINE_ENUM_VALUE (TEST_FLAGS_THIRD, "third"))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user