mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-27 22:55:06 +02:00
gienuminfo: Split out GIFlagsInfo as a derived type
Flag enums are already treated as a special kind of enum within `GIInfoType`, so it would be tidier to give it its own `GType` too, with a subtype relation to `GI_TYPE_ENUM_INFO`. This will simplify implementing `GI_IS_ENUM_INFO` in a following commit too. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3216
This commit is contained in:
parent
d82675ffd3
commit
eafc35e5ed
@ -254,6 +254,7 @@ GI_DEFINE_BASE_INFO_TYPE (gi_registered_type_info, GI_INFO_TYPE_REGISTERED_TYPE)
|
|||||||
GI_DEFINE_BASE_INFO_TYPE (gi_struct_info, GI_INFO_TYPE_STRUCT)
|
GI_DEFINE_BASE_INFO_TYPE (gi_struct_info, GI_INFO_TYPE_STRUCT)
|
||||||
GI_DEFINE_BASE_INFO_TYPE (gi_union_info, GI_INFO_TYPE_UNION)
|
GI_DEFINE_BASE_INFO_TYPE (gi_union_info, GI_INFO_TYPE_UNION)
|
||||||
GI_DEFINE_BASE_INFO_TYPE (gi_enum_info, GI_INFO_TYPE_ENUM)
|
GI_DEFINE_BASE_INFO_TYPE (gi_enum_info, GI_INFO_TYPE_ENUM)
|
||||||
|
GI_DEFINE_BASE_INFO_TYPE (gi_flags_info, GI_INFO_TYPE_FLAGS)
|
||||||
GI_DEFINE_BASE_INFO_TYPE (gi_object_info, GI_INFO_TYPE_OBJECT)
|
GI_DEFINE_BASE_INFO_TYPE (gi_object_info, GI_INFO_TYPE_OBJECT)
|
||||||
GI_DEFINE_BASE_INFO_TYPE (gi_interface_info, GI_INFO_TYPE_INTERFACE)
|
GI_DEFINE_BASE_INFO_TYPE (gi_interface_info, GI_INFO_TYPE_INTERFACE)
|
||||||
GI_DEFINE_BASE_INFO_TYPE (gi_constant_info, GI_INFO_TYPE_CONSTANT)
|
GI_DEFINE_BASE_INFO_TYPE (gi_constant_info, GI_INFO_TYPE_CONSTANT)
|
||||||
@ -291,6 +292,7 @@ gi_base_info_init_types (void)
|
|||||||
{ GI_INFO_TYPE_STRUCT, "GIStructInfo", sizeof (GIStructInfo), gi_struct_info_class_init, 0, G_TYPE_FLAG_NONE },
|
{ GI_INFO_TYPE_STRUCT, "GIStructInfo", sizeof (GIStructInfo), gi_struct_info_class_init, 0, G_TYPE_FLAG_NONE },
|
||||||
{ GI_INFO_TYPE_UNION, "GIUnionInfo", sizeof (GIUnionInfo), gi_union_info_class_init, 0, G_TYPE_FLAG_NONE },
|
{ GI_INFO_TYPE_UNION, "GIUnionInfo", sizeof (GIUnionInfo), gi_union_info_class_init, 0, G_TYPE_FLAG_NONE },
|
||||||
{ GI_INFO_TYPE_ENUM, "GIEnumInfo", sizeof (GIEnumInfo), gi_enum_info_class_init, 0, G_TYPE_FLAG_NONE },
|
{ GI_INFO_TYPE_ENUM, "GIEnumInfo", sizeof (GIEnumInfo), gi_enum_info_class_init, 0, G_TYPE_FLAG_NONE },
|
||||||
|
{ GI_INFO_TYPE_FLAGS, "GIFlagsInfo", sizeof (GIFlagsInfo), gi_flags_info_class_init, GI_INFO_TYPE_ENUM, G_TYPE_FLAG_NONE },
|
||||||
{ GI_INFO_TYPE_OBJECT, "GIObjectInfo", sizeof (GIObjectInfo), gi_object_info_class_init, 0, G_TYPE_FLAG_NONE },
|
{ GI_INFO_TYPE_OBJECT, "GIObjectInfo", sizeof (GIObjectInfo), gi_object_info_class_init, 0, G_TYPE_FLAG_NONE },
|
||||||
{ GI_INFO_TYPE_INTERFACE, "GIInterfaceInfo", sizeof (GIInterfaceInfo), gi_interface_info_class_init, 0, G_TYPE_FLAG_NONE },
|
{ GI_INFO_TYPE_INTERFACE, "GIInterfaceInfo", sizeof (GIInterfaceInfo), gi_interface_info_class_init, 0, G_TYPE_FLAG_NONE },
|
||||||
{ GI_INFO_TYPE_CONSTANT, "GIConstantInfo", sizeof (GIConstantInfo), gi_constant_info_class_init, 0, G_TYPE_FLAG_NONE },
|
{ GI_INFO_TYPE_CONSTANT, "GIConstantInfo", sizeof (GIConstantInfo), gi_constant_info_class_init, 0, G_TYPE_FLAG_NONE },
|
||||||
|
56
girepository/giflagsinfo.c
Normal file
56
girepository/giflagsinfo.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
|
* GObject introspection: Enum implementation
|
||||||
|
*
|
||||||
|
* Copyright 2024 GNOME Foundation, Inc.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include <girepository/girepository.h>
|
||||||
|
#include "gibaseinfo-private.h"
|
||||||
|
#include "girepository-private.h"
|
||||||
|
#include "gitypelib-internal.h"
|
||||||
|
#include "giflagsinfo.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GIFlagsInfo:
|
||||||
|
*
|
||||||
|
* A `GIFlagsInfo` represents an enumeration which defines flag values
|
||||||
|
* (independently set bits).
|
||||||
|
*
|
||||||
|
* The `GIFlagsInfo` contains a set of values (each a
|
||||||
|
* [class@GIRepository.ValueInfo]) and a type.
|
||||||
|
*
|
||||||
|
* The [class@GIRepository.ValueInfo] for a value is fetched by calling
|
||||||
|
* [method@GIRepository.EnumInfo.get_value] on a `GIFlagsInfo`.
|
||||||
|
*
|
||||||
|
* Since: 2.80
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
gi_flags_info_class_init (gpointer g_class,
|
||||||
|
gpointer class_data)
|
||||||
|
{
|
||||||
|
GIBaseInfoClass *info_class = g_class;
|
||||||
|
|
||||||
|
info_class->info_type = GI_INFO_TYPE_FLAGS;
|
||||||
|
}
|
46
girepository/giflagsinfo.h
Normal file
46
girepository/giflagsinfo.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
|
* GObject introspection: Flags type
|
||||||
|
*
|
||||||
|
* Copyright 2024 GNOME Foundation, Inc.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION)
|
||||||
|
#error "Only <girepository.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <girepository/gitypes.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GI_TYPE_FLAGS_INFO (gi_flags_info_get_type ())
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GI_IS_FLAGS_INFO:
|
||||||
|
* @info: an info structure
|
||||||
|
*
|
||||||
|
* Checks if @info is a [class@GIRepository.FlagsInfo] (or a derived type).
|
||||||
|
*
|
||||||
|
* Since: 2.80
|
||||||
|
*/
|
||||||
|
#define GI_IS_FLAGS_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_FLAGS_INFO))
|
||||||
|
|
||||||
|
G_END_DECLS
|
@ -114,6 +114,14 @@ struct _GIEnumInfo
|
|||||||
void gi_enum_info_class_init (gpointer g_class,
|
void gi_enum_info_class_init (gpointer g_class,
|
||||||
gpointer class_data);
|
gpointer class_data);
|
||||||
|
|
||||||
|
struct _GIFlagsInfo
|
||||||
|
{
|
||||||
|
GIEnumInfo parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
void gi_flags_info_class_init (gpointer g_class,
|
||||||
|
gpointer class_data);
|
||||||
|
|
||||||
struct _GIObjectInfo
|
struct _GIObjectInfo
|
||||||
{
|
{
|
||||||
GIBaseInfo parent;
|
GIBaseInfo parent;
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <girepository/giconstantinfo.h>
|
#include <girepository/giconstantinfo.h>
|
||||||
#include <girepository/gienuminfo.h>
|
#include <girepository/gienuminfo.h>
|
||||||
#include <girepository/gifieldinfo.h>
|
#include <girepository/gifieldinfo.h>
|
||||||
|
#include <girepository/giflagsinfo.h>
|
||||||
#include <girepository/gifunctioninfo.h>
|
#include <girepository/gifunctioninfo.h>
|
||||||
#include <girepository/giinterfaceinfo.h>
|
#include <girepository/giinterfaceinfo.h>
|
||||||
#include <girepository/giobjectinfo.h>
|
#include <girepository/giobjectinfo.h>
|
||||||
|
@ -69,6 +69,10 @@ GI_AVAILABLE_IN_ALL GType gi_union_info_get_type (void);
|
|||||||
typedef struct _GIEnumInfo GIEnumInfo;
|
typedef struct _GIEnumInfo GIEnumInfo;
|
||||||
GI_AVAILABLE_IN_ALL GType gi_enum_info_get_type (void);
|
GI_AVAILABLE_IN_ALL GType gi_enum_info_get_type (void);
|
||||||
|
|
||||||
|
/* Documented in giflagsinfo.c */
|
||||||
|
typedef struct _GIFlagsInfo GIFlagsInfo;
|
||||||
|
GI_AVAILABLE_IN_ALL GType gi_flags_info_get_type (void);
|
||||||
|
|
||||||
/* Documented in giobjectinfo.c */
|
/* Documented in giobjectinfo.c */
|
||||||
typedef struct _GIObjectInfo GIObjectInfo;
|
typedef struct _GIObjectInfo GIObjectInfo;
|
||||||
GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void);
|
GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void);
|
||||||
|
@ -49,6 +49,7 @@ girepo_headers = files(
|
|||||||
'giconstantinfo.h',
|
'giconstantinfo.h',
|
||||||
'gienuminfo.h',
|
'gienuminfo.h',
|
||||||
'gifieldinfo.h',
|
'gifieldinfo.h',
|
||||||
|
'giflagsinfo.h',
|
||||||
'gifunctioninfo.h',
|
'gifunctioninfo.h',
|
||||||
'giinterfaceinfo.h',
|
'giinterfaceinfo.h',
|
||||||
'giobjectinfo.h',
|
'giobjectinfo.h',
|
||||||
@ -149,6 +150,7 @@ girepo_sources = files(
|
|||||||
'giconstantinfo.c',
|
'giconstantinfo.c',
|
||||||
'gienuminfo.c',
|
'gienuminfo.c',
|
||||||
'gifieldinfo.c',
|
'gifieldinfo.c',
|
||||||
|
'giflagsinfo.c',
|
||||||
'gifunctioninfo.c',
|
'gifunctioninfo.c',
|
||||||
'ginvoke.c',
|
'ginvoke.c',
|
||||||
'giinterfaceinfo.c',
|
'giinterfaceinfo.c',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user