giboxedinfo: Add a tag type for boxed types

Boxed types are already represented within `GIInfoType`, so they should
have a `GType` representation as well.

In an upcoming commit, this will allow us to represent the subtype
relation between `GIBoxedInfo` and `GIRegisteredTypeInfo` too.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
This commit is contained in:
Philip Withnall 2024-01-17 15:37:47 +00:00
parent eafc35e5ed
commit 7228c6d3e0
7 changed files with 116 additions and 1 deletions

View File

@ -257,6 +257,7 @@ 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_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_boxed_info, GI_INFO_TYPE_BOXED)
GI_DEFINE_BASE_INFO_TYPE (gi_constant_info, GI_INFO_TYPE_CONSTANT) GI_DEFINE_BASE_INFO_TYPE (gi_constant_info, GI_INFO_TYPE_CONSTANT)
GI_DEFINE_BASE_INFO_TYPE (gi_value_info, GI_INFO_TYPE_VALUE) GI_DEFINE_BASE_INFO_TYPE (gi_value_info, GI_INFO_TYPE_VALUE)
GI_DEFINE_BASE_INFO_TYPE (gi_signal_info, GI_INFO_TYPE_SIGNAL) GI_DEFINE_BASE_INFO_TYPE (gi_signal_info, GI_INFO_TYPE_SIGNAL)
@ -295,6 +296,7 @@ gi_base_info_init_types (void)
{ GI_INFO_TYPE_FLAGS, "GIFlagsInfo", sizeof (GIFlagsInfo), gi_flags_info_class_init, GI_INFO_TYPE_ENUM, 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_BOXED, "GIBoxedInfo", sizeof (GIBoxedInfo), gi_boxed_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 },
{ GI_INFO_TYPE_VALUE, "GIValueInfo", sizeof (GIValueInfo), gi_value_info_class_init, 0, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_VALUE, "GIValueInfo", sizeof (GIValueInfo), gi_value_info_class_init, 0, G_TYPE_FLAG_NONE },
{ GI_INFO_TYPE_SIGNAL, "GISignalInfo", sizeof (GISignalInfo), gi_signal_info_class_init, GI_INFO_TYPE_CALLABLE, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_SIGNAL, "GISignalInfo", sizeof (GISignalInfo), gi_signal_info_class_init, GI_INFO_TYPE_CALLABLE, G_TYPE_FLAG_NONE },

View File

@ -0,0 +1,52 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
* GObject introspection: Boxed type 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 "giboxedinfo.h"
/**
* GIBoxedInfo:
*
* A `GIBoxedInfo` represents a boxed type.
*
* There isnt much you can do with a boxed type; `GIBoxedInfo` exists mainly to
* tag the type.
*
* Since: 2.80
*/
void
gi_boxed_info_class_init (gpointer g_class,
gpointer class_data)
{
GIBaseInfoClass *info_class = g_class;
info_class->info_type = GI_INFO_TYPE_BOXED;
}

View File

@ -0,0 +1,46 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
* GObject introspection: Boxed types
*
* 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_BOXED_INFO (gi_boxed_info_get_type ())
/**
* GI_IS_BOXED_INFO:
* @info: an info structure
*
* Checks if @info is a [class@GIRepository.BoxedInfo] (or a derived type).
*
* Since: 2.80
*/
#define GI_IS_BOXED_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_BOXED_INFO))
G_END_DECLS

View File

@ -132,12 +132,20 @@ void gi_object_info_class_init (gpointer g_class,
struct _GIInterfaceInfo struct _GIInterfaceInfo
{ {
GIBaseInfo parent; GIRegisteredTypeInfo parent;
}; };
void gi_interface_info_class_init (gpointer g_class, void gi_interface_info_class_init (gpointer g_class,
gpointer class_data); gpointer class_data);
struct _GIBoxedInfo
{
GIBaseInfo parent;
};
void gi_boxed_info_class_init (gpointer g_class,
gpointer class_data);
struct _GIConstantInfo struct _GIConstantInfo
{ {
GIBaseInfo parent; GIBaseInfo parent;

View File

@ -33,6 +33,7 @@
#include <girepository/giarginfo.h> #include <girepository/giarginfo.h>
#include <girepository/gibaseinfo.h> #include <girepository/gibaseinfo.h>
#include <girepository/giboxedinfo.h>
#include <girepository/gicallableinfo.h> #include <girepository/gicallableinfo.h>
#include <girepository/gicallbackinfo.h> #include <girepository/gicallbackinfo.h>
#include <girepository/giconstantinfo.h> #include <girepository/giconstantinfo.h>

View File

@ -81,6 +81,10 @@ GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void);
typedef struct _GIInterfaceInfo GIInterfaceInfo; typedef struct _GIInterfaceInfo GIInterfaceInfo;
GI_AVAILABLE_IN_ALL GType gi_interface_info_get_type (void); GI_AVAILABLE_IN_ALL GType gi_interface_info_get_type (void);
/* Documented in giboxedinfo.c */
typedef struct _GIBoxedInfo GIBoxedInfo;
GI_AVAILABLE_IN_ALL GType gi_boxed_info_get_type (void);
/* Documented in giconstantinfo.c */ /* Documented in giconstantinfo.c */
typedef struct _GIConstantInfo GIConstantInfo; typedef struct _GIConstantInfo GIConstantInfo;
GI_AVAILABLE_IN_ALL GType gi_constant_info_get_type (void); GI_AVAILABLE_IN_ALL GType gi_constant_info_get_type (void);

View File

@ -44,6 +44,7 @@ gi_visibility_h = custom_target(
girepo_headers = files( girepo_headers = files(
'giarginfo.h', 'giarginfo.h',
'gibaseinfo.h', 'gibaseinfo.h',
'giboxedinfo.h',
'gicallableinfo.h', 'gicallableinfo.h',
'gicallbackinfo.h', 'gicallbackinfo.h',
'giconstantinfo.h', 'giconstantinfo.h',
@ -145,6 +146,7 @@ girepo_sources = files(
'gdump.c', 'gdump.c',
'giarginfo.c', 'giarginfo.c',
'gibaseinfo.c', 'gibaseinfo.c',
'giboxedinfo.c',
'gicallableinfo.c', 'gicallableinfo.c',
'gicallbackinfo.c', 'gicallbackinfo.c',
'giconstantinfo.c', 'giconstantinfo.c',