mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 10:16:17 +01:00
Merge branch 'ebassi/gir-more' into 'main'
Port GIRepository to GTypeInstance and add introspection See merge request GNOME/glib!3703
This commit is contained in:
commit
d74a9bc73e
@ -11,11 +11,11 @@ cache:
|
||||
- _ccache/
|
||||
|
||||
variables:
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v24"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v25"
|
||||
COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v7"
|
||||
DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v18"
|
||||
DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v19"
|
||||
ALPINE_IMAGE: "registry.gitlab.gnome.org/gnome/glib/alpine:v3"
|
||||
MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v14"
|
||||
MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v15"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 4
|
||||
G_MESSAGES_DEBUG: all
|
||||
MESON_COMMON_OPTIONS: "--buildtype debug --wrap-mode=nodownload --fatal-meson-warnings"
|
||||
@ -120,6 +120,7 @@ fedora-x86_64:
|
||||
-Ddtrace=true
|
||||
-Dinstalled_tests=true
|
||||
-Ddocumentation=true
|
||||
-Dintrospection=enabled
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- mkdir -p _coverage
|
||||
@ -294,6 +295,7 @@ G_DISABLE_ASSERT:
|
||||
-Ddtrace=true
|
||||
-Dinstalled_tests=true
|
||||
-Dglib_assert=false
|
||||
-Dintrospection=enabled
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- bash -x ./.gitlab-ci/run-tests.sh
|
||||
@ -325,6 +327,7 @@ valgrind:
|
||||
-Dsystemtap=true
|
||||
-Ddtrace=true
|
||||
-Dinstalled_tests=true
|
||||
-Dintrospection=enabled
|
||||
_build
|
||||
- meson compile -C _build
|
||||
# Valgrind doesn’t work when the soft FD limit is set too high
|
||||
@ -547,7 +550,10 @@ freebsd-12-x86_64:
|
||||
- "_build/meson-logs"
|
||||
|
||||
freebsd-13-x86_64:
|
||||
extends: .only-origin
|
||||
# FIXME: Temporarily only run the FreeBSD 13 CI on a schedule, rather than on
|
||||
# every commit to origin, because it’s broken:
|
||||
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3740#note_1935427
|
||||
extends: .only-schedules
|
||||
stage: build
|
||||
tags:
|
||||
- freebsd-13
|
||||
@ -672,6 +678,7 @@ scan-build:
|
||||
-Dsystemtap=true
|
||||
-Ddtrace=true
|
||||
-Dinstalled_tests=true
|
||||
-Dintrospection=enabled
|
||||
_scan_build
|
||||
- ninja -C _scan_build scan-build
|
||||
artifacts:
|
||||
@ -701,6 +708,7 @@ scan-build:
|
||||
-Dsystemtap=true
|
||||
-Ddtrace=true
|
||||
-Dinstalled_tests=true
|
||||
-Dintrospection=enabled
|
||||
_coverity_build
|
||||
- $HOME/cov-analysis-linux64-*/bin/cov-build --dir cov-int meson compile -C _coverity_build
|
||||
- tar cfz cov-int.tar.gz cov-int
|
||||
|
@ -19,6 +19,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
|
||||
gi-docgen \
|
||||
git \
|
||||
libc6-dev \
|
||||
gobject-introspection \
|
||||
gtk-doc-tools \
|
||||
itstool \
|
||||
lcov \
|
||||
@ -26,6 +27,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
|
||||
libdbus-1-dev \
|
||||
libelf-dev \
|
||||
libffi-dev \
|
||||
libgirepository1.0-dev \
|
||||
libmount-dev \
|
||||
libpcre2-dev \
|
||||
libselinux1-dev \
|
||||
|
@ -35,6 +35,8 @@ RUN dnf -y update \
|
||||
glibc-langpack-th \
|
||||
glibc-langpack-tr \
|
||||
"gnome-desktop-testing >= 2018.1" \
|
||||
gobject-introspection \
|
||||
gobject-introspection-devel \
|
||||
gtk-doc \
|
||||
itstool \
|
||||
lcov \
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM registry.gitlab.gnome.org/gnome/glib/fedora:v24
|
||||
FROM registry.gitlab.gnome.org/gnome/glib/fedora:v25
|
||||
|
||||
USER root
|
||||
|
||||
|
50
docs/reference/girepository/girepository.toml.in
Normal file
50
docs/reference/girepository/girepository.toml.in
Normal file
@ -0,0 +1,50 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
# Copyright 2023 Matthias Clasen
|
||||
# Copyright 2023 Philip Withnall
|
||||
|
||||
[library]
|
||||
name = "Girepository"
|
||||
version = "@VERSION@"
|
||||
browse_url = "https://gitlab.gnome.org/GNOME/glib/"
|
||||
repository_url = "https://gitlab.gnome.org/GNOME/glib.git"
|
||||
website_url = "https://www.gtk.org"
|
||||
docs_urls = "https://docs.gtk.org/girepository/"
|
||||
authors = "GLib Development Team"
|
||||
license = "LGPL-2.1-or-later"
|
||||
description = "GIRepository is a library providing access to typelibs and introspection data which describes C APIs"
|
||||
dependencies = [ "GLib-2.0", "GModule-2.0", "GObject-2.0", "Gio-2.0" ]
|
||||
devhelp = true
|
||||
search_index = true
|
||||
|
||||
[dependencies."GLib-2.0"]
|
||||
name = "GLib"
|
||||
description = "The base utility library"
|
||||
docs_url = "https://docs.gtk.org/glib/"
|
||||
|
||||
[dependencies."GModule-2.0"]
|
||||
name = "GModule"
|
||||
description = "Portable API for dynamically loading modules"
|
||||
docs_url = "https://docs.gtk.org/gmodule/"
|
||||
|
||||
[dependencies."GObject-2.0"]
|
||||
name = "GObject"
|
||||
description = "The base type system library"
|
||||
docs_url = "https://docs.gtk.org/gobject/"
|
||||
|
||||
[dependencies."Gio-2.0"]
|
||||
name = "Gio"
|
||||
description = "Useful classes for general purpose I/O, networking, IPC, settings, etc."
|
||||
docs_url = "https://docs.gtk.org/gio/"
|
||||
|
||||
[theme]
|
||||
name = "basic"
|
||||
show_index_summary = true
|
||||
show_class_hierarchy = true
|
||||
|
||||
[extra]
|
||||
urlmap_file = "urlmap.js"
|
||||
# The same order will be used when generating the index
|
||||
content_files = [
|
||||
]
|
||||
content_images = [
|
||||
]
|
23
docs/reference/girepository/meson.build
Normal file
23
docs/reference/girepository/meson.build
Normal file
@ -0,0 +1,23 @@
|
||||
girepository_toml = configure_file(
|
||||
input: 'girepository.toml.in',
|
||||
output: 'girepository.toml',
|
||||
configuration: toml_conf,
|
||||
)
|
||||
|
||||
custom_target('girepository-docs',
|
||||
input: [ girepository_toml, girepository_gir[0] ],
|
||||
output: 'girepository',
|
||||
command: [
|
||||
gidocgen,
|
||||
'generate',
|
||||
gidocgen_common_args,
|
||||
'--config=@INPUT0@',
|
||||
'--output-dir=@OUTPUT@',
|
||||
'--content-dir=@0@'.format(meson.current_source_dir()),
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gobject'),
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gmodule'),
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gio'),
|
||||
'@INPUT1@',
|
||||
],
|
||||
build_by_default: true,
|
||||
)
|
10
docs/reference/girepository/urlmap.js
Normal file
10
docs/reference/girepository/urlmap.js
Normal file
@ -0,0 +1,10 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
// SPDX-FileCopyrightText: 2023 Matthias Clasen
|
||||
var baseURLs = [
|
||||
[ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ],
|
||||
[ 'GLib', 'https://docs.gtk.org/glib/' ],
|
||||
[ 'GModule', 'https://docs.gtk.org/gmodule/' ],
|
||||
[ 'GObject', 'https://docs.gtk.org/gobject/' ],
|
||||
[ 'Gio', 'https://docs.gtk.org/gio/' ],
|
||||
[ 'Gtk', 'https://docs.gtk.org/gtk4/' ],
|
||||
];
|
@ -18,4 +18,5 @@ if get_option('documentation') and enable_gir
|
||||
subdir('gmodule')
|
||||
subdir('gobject')
|
||||
subdir('gio')
|
||||
subdir('girepository')
|
||||
endif
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "girepository-private.h"
|
||||
#include "giarginfo.h"
|
||||
@ -175,7 +176,7 @@ gi_arg_info_may_be_null (GIArgInfo *info)
|
||||
* Obtain if an argument is only useful in C.
|
||||
*
|
||||
* Returns: %TRUE if argument is only useful in C.
|
||||
* Since: 1.30
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_arg_info_is_skip (GIArgInfo *info)
|
||||
@ -291,7 +292,7 @@ gi_arg_info_get_destroy (GIArgInfo *info)
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_arg_info_get_type:
|
||||
* gi_arg_info_get_type_info:
|
||||
* @info: a #GIArgInfo
|
||||
*
|
||||
* Obtain the type information for @info.
|
||||
@ -301,7 +302,7 @@ gi_arg_info_get_destroy (GIArgInfo *info)
|
||||
* when done.
|
||||
*/
|
||||
GITypeInfo *
|
||||
gi_arg_info_get_type (GIArgInfo *info)
|
||||
gi_arg_info_get_type_info (GIArgInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
|
||||
@ -317,7 +318,7 @@ gi_arg_info_get_type (GIArgInfo *info)
|
||||
* @type: (out caller-allocates): Initialized with information about type of @info
|
||||
*
|
||||
* Obtain information about a the type of given argument @info; this
|
||||
* function is a variant of gi_arg_info_get_type() designed for stack
|
||||
* function is a variant of gi_arg_info_get_type_info() designed for stack
|
||||
* allocation.
|
||||
*
|
||||
* The initialized @type must not be referenced after @info is deallocated.
|
||||
@ -331,5 +332,14 @@ gi_arg_info_load_type (GIArgInfo *info,
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (GI_IS_ARG_INFO (info));
|
||||
|
||||
gi_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
|
||||
gi_type_info_init ((GIBaseInfo *) type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
|
||||
}
|
||||
|
||||
void
|
||||
gi_arg_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_ARG;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a GIArgInfo.
|
||||
*/
|
||||
#define GI_IS_ARG_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ARG)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_ARG)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
@ -73,7 +73,7 @@ GI_AVAILABLE_IN_ALL
|
||||
gint gi_arg_info_get_destroy (GIArgInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GITypeInfo * gi_arg_info_get_type (GIArgInfo *info);
|
||||
GITypeInfo * gi_arg_info_get_type_info (GIArgInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
void gi_arg_info_load_type (GIArgInfo *info,
|
||||
|
58
girepository/gibaseinfo-private.h
Normal file
58
girepository/gibaseinfo-private.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
* GObject introspection: Parsed GIR
|
||||
*
|
||||
* Copyright 2023 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
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "gitypes.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Keep this in sync with the GIInfoType enumeration.
|
||||
*
|
||||
* We don't add an "n-types" value to avoid having to handle
|
||||
* it in every single switch.
|
||||
*/
|
||||
#define GI_INFO_TYPE_N_TYPES (GI_INFO_TYPE_REGISTERED_TYPE + 1)
|
||||
|
||||
#define GI_IS_BASE_INFO_TYPE(info,type) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((info), GI_TYPE_BASE_INFO, GIBaseInfoClass)->info_type == (type))
|
||||
|
||||
struct _GIBaseInfoClass
|
||||
{
|
||||
GTypeClass parent_class;
|
||||
|
||||
GIInfoType info_type;
|
||||
|
||||
void (* finalize) (GIBaseInfo *info);
|
||||
};
|
||||
|
||||
void gi_base_info_init_types (void);
|
||||
|
||||
GType gi_base_info_type_register_static (const char *type_name,
|
||||
gsize instance_size,
|
||||
GClassInitFunc class_init);
|
||||
|
||||
G_END_DECLS
|
@ -29,26 +29,284 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
||||
#include "gitypelib-internal.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gibaseinfo.h"
|
||||
#include "gibaseinfo-private.h"
|
||||
|
||||
#define INVALID_REFCOUNT 0x7FFFFFFF
|
||||
|
||||
/* GBoxed registration of BaseInfo. */
|
||||
GType
|
||||
gi_base_info_gtype_get_type (void)
|
||||
{
|
||||
static GType our_type = 0;
|
||||
|
||||
if (our_type == 0)
|
||||
our_type =
|
||||
g_boxed_type_register_static ("GIBaseInfo",
|
||||
(GBoxedCopyFunc) gi_base_info_ref,
|
||||
(GBoxedFreeFunc) gi_base_info_unref);
|
||||
/* Type registration of BaseInfo. */
|
||||
#define GI_BASE_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GI_TYPE_BASE_INFO, GIBaseInfoClass))
|
||||
|
||||
return our_type;
|
||||
static void
|
||||
value_base_info_init (GValue *value)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
value_base_info_free_value (GValue *value)
|
||||
{
|
||||
if (value->data[0].v_pointer != NULL)
|
||||
gi_base_info_unref (value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
static void
|
||||
value_base_info_copy_value (const GValue *src,
|
||||
GValue *dst)
|
||||
{
|
||||
if (src->data[0].v_pointer != NULL)
|
||||
dst->data[0].v_pointer = gi_base_info_ref (src->data[0].v_pointer);
|
||||
else
|
||||
dst->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
value_base_info_peek_pointer (const GValue *value)
|
||||
{
|
||||
return value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
static char *
|
||||
value_base_info_collect_value (GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
GIBaseInfo *info = collect_values[0].v_pointer;
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (info->parent_instance.g_class == NULL)
|
||||
return g_strconcat ("invalid unclassed GIBaseInfo pointer for "
|
||||
"value type '",
|
||||
G_VALUE_TYPE_NAME (value),
|
||||
"'",
|
||||
NULL);
|
||||
|
||||
value->data[0].v_pointer = gi_base_info_ref (info);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
value_base_info_lcopy_value (const GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
GIBaseInfo **node_p = collect_values[0].v_pointer;
|
||||
|
||||
if (node_p == NULL)
|
||||
return g_strconcat ("value location for '",
|
||||
G_VALUE_TYPE_NAME (value),
|
||||
"' passed as NULL",
|
||||
NULL);
|
||||
|
||||
if (value->data[0].v_pointer == NULL)
|
||||
*node_p = NULL;
|
||||
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
|
||||
*node_p = value->data[0].v_pointer;
|
||||
else
|
||||
*node_p = gi_base_info_ref (value->data[0].v_pointer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gi_base_info_finalize (GIBaseInfo *self)
|
||||
{
|
||||
if (self->container && self->container->ref_count != INVALID_REFCOUNT)
|
||||
gi_base_info_unref (self->container);
|
||||
|
||||
g_clear_object (&self->repository);
|
||||
|
||||
g_type_free_instance ((GTypeInstance *) self);
|
||||
}
|
||||
|
||||
static void
|
||||
gi_base_info_class_init (GIBaseInfoClass *klass)
|
||||
{
|
||||
klass->info_type = GI_INFO_TYPE_INVALID;
|
||||
klass->finalize = gi_base_info_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gi_base_info_init (GIBaseInfo *self)
|
||||
{
|
||||
g_atomic_ref_count_init (&self->ref_count);
|
||||
}
|
||||
|
||||
GType
|
||||
gi_base_info_get_type (void)
|
||||
{
|
||||
static GType base_info_type = 0;
|
||||
|
||||
if (g_once_init_enter_pointer (&base_info_type))
|
||||
{
|
||||
static const GTypeFundamentalInfo finfo = {
|
||||
(G_TYPE_FLAG_CLASSED |
|
||||
G_TYPE_FLAG_INSTANTIATABLE |
|
||||
G_TYPE_FLAG_DERIVABLE |
|
||||
G_TYPE_FLAG_DEEP_DERIVABLE),
|
||||
};
|
||||
|
||||
static const GTypeValueTable value_table = {
|
||||
value_base_info_init,
|
||||
value_base_info_free_value,
|
||||
value_base_info_copy_value,
|
||||
value_base_info_peek_pointer,
|
||||
"p",
|
||||
value_base_info_collect_value,
|
||||
"p",
|
||||
value_base_info_lcopy_value,
|
||||
};
|
||||
|
||||
const GTypeInfo type_info = {
|
||||
/* Class */
|
||||
sizeof (GIBaseInfoClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gi_base_info_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL,
|
||||
|
||||
/* Instance */
|
||||
sizeof (GIBaseInfo),
|
||||
0,
|
||||
(GInstanceInitFunc) gi_base_info_init,
|
||||
|
||||
/* GValue */
|
||||
&value_table,
|
||||
};
|
||||
|
||||
GType _base_info_type =
|
||||
g_type_register_fundamental (g_type_fundamental_next (),
|
||||
g_intern_static_string ("GIBaseInfo"),
|
||||
&type_info, &finfo,
|
||||
G_TYPE_FLAG_ABSTRACT);
|
||||
|
||||
g_once_init_leave_pointer (&base_info_type, _base_info_type);
|
||||
}
|
||||
|
||||
return base_info_type;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gi_base_info_type_register_static:
|
||||
* @type_name: the name of the type
|
||||
* @instance_size: size (in bytes) of the type’s instance struct
|
||||
* @class_init: class init function for the type
|
||||
*
|
||||
* Registers a new [type@GIRepository.BaseInfo] type for the given @type_name
|
||||
* using the type information provided.
|
||||
*
|
||||
* Returns: the newly registered [type@GObject.Type]
|
||||
* Since: 2.80
|
||||
*/
|
||||
GType
|
||||
gi_base_info_type_register_static (const char *type_name,
|
||||
gsize instance_size,
|
||||
GClassInitFunc class_init)
|
||||
{
|
||||
GTypeInfo info;
|
||||
|
||||
info.class_size = sizeof (GIBaseInfoClass);
|
||||
info.base_init = NULL;
|
||||
info.base_finalize = NULL;
|
||||
info.class_init = class_init;
|
||||
info.class_finalize = NULL;
|
||||
info.instance_size = instance_size;
|
||||
info.n_preallocs = 0;
|
||||
info.instance_init = NULL;
|
||||
info.value_table = NULL;
|
||||
|
||||
return g_type_register_static (GI_TYPE_BASE_INFO, type_name, &info, 0);
|
||||
}
|
||||
|
||||
static GType gi_base_info_types[GI_INFO_TYPE_N_TYPES];
|
||||
|
||||
#define GI_DEFINE_BASE_INFO_TYPE(type_name, TYPE_ENUM_VALUE) \
|
||||
GType \
|
||||
type_name ## _get_type (void) \
|
||||
{ \
|
||||
gi_base_info_init_types (); \
|
||||
g_assert (gi_base_info_types[TYPE_ENUM_VALUE] != G_TYPE_INVALID); \
|
||||
return gi_base_info_types[TYPE_ENUM_VALUE]; \
|
||||
}
|
||||
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_callable_info, GI_INFO_TYPE_CALLABLE)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_function_info, GI_INFO_TYPE_FUNCTION)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_callback_info, GI_INFO_TYPE_CALLBACK)
|
||||
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_union_info, GI_INFO_TYPE_UNION)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_enum_info, GI_INFO_TYPE_ENUM)
|
||||
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_constant_info, GI_INFO_TYPE_CONSTANT)
|
||||
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_vfunc_info, GI_INFO_TYPE_VFUNC)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_property_info, GI_INFO_TYPE_PROPERTY)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_field_info, GI_INFO_TYPE_FIELD)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_arg_info, GI_INFO_TYPE_ARG)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_type_info, GI_INFO_TYPE_TYPE)
|
||||
GI_DEFINE_BASE_INFO_TYPE (gi_unresolved_info, GI_INFO_TYPE_UNRESOLVED)
|
||||
|
||||
void
|
||||
gi_base_info_init_types (void)
|
||||
{
|
||||
static gsize register_types_once = 0;
|
||||
|
||||
if (g_once_init_enter (®ister_types_once))
|
||||
{
|
||||
const struct
|
||||
{
|
||||
GIInfoType info_type;
|
||||
const char *type_name;
|
||||
gsize instance_size;
|
||||
GClassInitFunc class_init;
|
||||
}
|
||||
types[] =
|
||||
{
|
||||
{ GI_INFO_TYPE_CALLABLE, "GICallableInfo", sizeof (GICallableInfo), gi_callable_info_class_init },
|
||||
{ GI_INFO_TYPE_FUNCTION, "GIFunctionInfo", sizeof (GIFunctionInfo), gi_function_info_class_init },
|
||||
{ GI_INFO_TYPE_CALLBACK, "GICallbackInfo", sizeof (GICallbackInfo), gi_callback_info_class_init },
|
||||
{ GI_INFO_TYPE_REGISTERED_TYPE, "GIRegisteredTypeInfo", sizeof (GIRegisteredTypeInfo), gi_registered_type_info_class_init },
|
||||
{ GI_INFO_TYPE_STRUCT, "GIStructInfo", sizeof (GIStructInfo), gi_struct_info_class_init },
|
||||
{ GI_INFO_TYPE_UNION, "GIUnionInfo", sizeof (GIUnionInfo), gi_union_info_class_init },
|
||||
{ GI_INFO_TYPE_ENUM, "GIEnumInfo", sizeof (GIEnumInfo), gi_enum_info_class_init },
|
||||
{ GI_INFO_TYPE_OBJECT, "GIObjectInfo", sizeof (GIObjectInfo), gi_object_info_class_init },
|
||||
{ GI_INFO_TYPE_INTERFACE, "GIInterfaceInfo", sizeof (GIInterfaceInfo), gi_interface_info_class_init },
|
||||
{ GI_INFO_TYPE_CONSTANT, "GIConstantInfo", sizeof (GIConstantInfo), gi_constant_info_class_init },
|
||||
{ GI_INFO_TYPE_VALUE, "GIValueInfo", sizeof (GIValueInfo), gi_value_info_class_init },
|
||||
{ GI_INFO_TYPE_SIGNAL, "GISignalInfo", sizeof (GISignalInfo), gi_signal_info_class_init },
|
||||
{ GI_INFO_TYPE_VFUNC, "GIVFuncInfo", sizeof (GIVFuncInfo), gi_vfunc_info_class_init },
|
||||
{ GI_INFO_TYPE_PROPERTY, "GIPropertyInfo", sizeof (GIPropertyInfo), gi_property_info_class_init },
|
||||
{ GI_INFO_TYPE_FIELD, "GIFieldInfo", sizeof (GIFieldInfo), gi_field_info_class_init },
|
||||
{ GI_INFO_TYPE_ARG, "GIArgInfo", sizeof (GIArgInfo), gi_arg_info_class_init },
|
||||
{ GI_INFO_TYPE_TYPE, "GITypeInfo", sizeof (GITypeInfo), gi_type_info_class_init },
|
||||
{ GI_INFO_TYPE_UNRESOLVED, "GIUnresolvedInfo", sizeof (GIUnresolvedInfo), gi_unresolved_info_class_init },
|
||||
};
|
||||
|
||||
for (gsize i = 0; i < G_N_ELEMENTS (types); i++)
|
||||
{
|
||||
GType registered_type = gi_base_info_type_register_static (g_intern_static_string (types[i].type_name),
|
||||
types[i].instance_size,
|
||||
types[i].class_init);
|
||||
gi_base_info_types[types[i].info_type] = registered_type;
|
||||
}
|
||||
|
||||
g_once_init_leave (®ister_types_once, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* info creation */
|
||||
@ -62,16 +320,21 @@ gi_info_new_full (GIInfoType type,
|
||||
GIRealInfo *info;
|
||||
|
||||
g_return_val_if_fail (container != NULL || repository != NULL, NULL);
|
||||
g_return_val_if_fail (GI_IS_REPOSITORY (repository), NULL);
|
||||
|
||||
info = g_slice_new (GIRealInfo);
|
||||
gi_base_info_init_types ();
|
||||
g_assert (gi_base_info_types[type] != G_TYPE_INVALID);
|
||||
info = (GIRealInfo *) g_type_create_instance (gi_base_info_types[type]);
|
||||
|
||||
gi_info_init (info, type, repository, container, typelib, offset);
|
||||
info->ref_count = 1;
|
||||
info->typelib = typelib;
|
||||
info->offset = offset;
|
||||
|
||||
if (container && ((GIRealInfo *) container)->ref_count != INVALID_REFCOUNT)
|
||||
if (container)
|
||||
info->container = container;
|
||||
if (container && container->ref_count != INVALID_REFCOUNT)
|
||||
gi_base_info_ref (info->container);
|
||||
|
||||
g_object_ref (info->repository);
|
||||
info->repository = g_object_ref (repository);
|
||||
|
||||
return (GIBaseInfo*)info;
|
||||
}
|
||||
@ -85,7 +348,7 @@ gi_info_new_full (GIInfoType type,
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
* Returns: TODO
|
||||
* Returns: (transfer full): TODO
|
||||
*/
|
||||
GIBaseInfo *
|
||||
gi_info_new (GIInfoType type,
|
||||
@ -108,8 +371,6 @@ gi_info_init (GIRealInfo *info,
|
||||
|
||||
/* Invalid refcount used to flag stack-allocated infos */
|
||||
info->ref_count = INVALID_REFCOUNT;
|
||||
info->type = type;
|
||||
|
||||
info->typelib = typelib;
|
||||
info->offset = offset;
|
||||
|
||||
@ -140,12 +401,12 @@ gi_info_from_entry (GIRepository *repository,
|
||||
{
|
||||
GIUnresolvedInfo *unresolved;
|
||||
|
||||
unresolved = g_slice_new0 (GIUnresolvedInfo);
|
||||
unresolved = (GIUnresolvedInfo *) gi_info_new_full (GI_INFO_TYPE_UNRESOLVED,
|
||||
repository,
|
||||
NULL,
|
||||
typelib,
|
||||
entry->offset);
|
||||
|
||||
unresolved->type = GI_INFO_TYPE_UNRESOLVED;
|
||||
unresolved->ref_count = 1;
|
||||
unresolved->repository = g_object_ref (repository);
|
||||
unresolved->container = NULL;
|
||||
unresolved->name = name;
|
||||
unresolved->namespace = namespace;
|
||||
|
||||
@ -243,7 +504,7 @@ gi_base_info_ref (GIBaseInfo *info)
|
||||
GIRealInfo *rinfo = (GIRealInfo*)info;
|
||||
|
||||
g_assert (rinfo->ref_count != INVALID_REFCOUNT);
|
||||
g_atomic_int_inc (&rinfo->ref_count);
|
||||
g_atomic_ref_count_inc (&rinfo->ref_count);
|
||||
|
||||
return info;
|
||||
}
|
||||
@ -262,23 +523,12 @@ gi_base_info_unref (GIBaseInfo *info)
|
||||
|
||||
g_assert (rinfo->ref_count > 0 && rinfo->ref_count != INVALID_REFCOUNT);
|
||||
|
||||
if (!g_atomic_int_dec_and_test (&rinfo->ref_count))
|
||||
return;
|
||||
|
||||
if (rinfo->container && ((GIRealInfo *) rinfo->container)->ref_count != INVALID_REFCOUNT)
|
||||
gi_base_info_unref (rinfo->container);
|
||||
|
||||
if (rinfo->repository)
|
||||
g_object_unref (rinfo->repository);
|
||||
|
||||
if (rinfo->type == GI_INFO_TYPE_UNRESOLVED)
|
||||
g_slice_free (GIUnresolvedInfo, (GIUnresolvedInfo *) rinfo);
|
||||
else
|
||||
g_slice_free (GIRealInfo, rinfo);
|
||||
if (g_atomic_ref_count_dec (&rinfo->ref_count))
|
||||
GI_BASE_INFO_GET_CLASS (info)->finalize (info);
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_base_info_get_type:
|
||||
* gi_base_info_get_info_type:
|
||||
* @info: a #GIBaseInfo
|
||||
*
|
||||
* Obtain the info type of the GIBaseInfo.
|
||||
@ -286,10 +536,9 @@ gi_base_info_unref (GIBaseInfo *info)
|
||||
* Returns: the info type of @info
|
||||
*/
|
||||
GIInfoType
|
||||
gi_base_info_get_type (GIBaseInfo *info)
|
||||
gi_base_info_get_info_type (GIBaseInfo *info)
|
||||
{
|
||||
|
||||
return ((GIRealInfo*)info)->type;
|
||||
return GI_BASE_INFO_GET_CLASS (info)->info_type;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,7 +556,7 @@ gi_base_info_get_name (GIBaseInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo*)info;
|
||||
g_assert (rinfo->ref_count > 0);
|
||||
switch (rinfo->type)
|
||||
switch (gi_base_info_get_info_type ((GIBaseInfo *) info))
|
||||
{
|
||||
case GI_INFO_TYPE_FUNCTION:
|
||||
case GI_INFO_TYPE_CALLBACK:
|
||||
@ -407,7 +656,7 @@ gi_base_info_get_namespace (GIBaseInfo *info)
|
||||
|
||||
g_assert (rinfo->ref_count > 0);
|
||||
|
||||
if (rinfo->type == GI_INFO_TYPE_UNRESOLVED)
|
||||
if (gi_base_info_get_info_type (info) == GI_INFO_TYPE_UNRESOLVED)
|
||||
{
|
||||
GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info;
|
||||
|
||||
@ -430,7 +679,7 @@ gboolean
|
||||
gi_base_info_is_deprecated (GIBaseInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo*) info;
|
||||
switch (rinfo->type)
|
||||
switch (gi_base_info_get_info_type ((GIBaseInfo *) info))
|
||||
{
|
||||
case GI_INFO_TYPE_FUNCTION:
|
||||
case GI_INFO_TYPE_CALLBACK:
|
||||
|
@ -48,11 +48,11 @@ typedef struct {
|
||||
gpointer data4;
|
||||
} GIAttributeIter;
|
||||
|
||||
#define GI_TYPE_BASE_INFO (gi_base_info_gtype_get_type ())
|
||||
#define GI_TYPE_BASE_INFO (gi_base_info_get_type ())
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GType gi_base_info_gtype_get_type (void) G_GNUC_CONST;
|
||||
GType gi_base_info_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIBaseInfo * gi_base_info_ref (GIBaseInfo *info);
|
||||
@ -61,7 +61,7 @@ GI_AVAILABLE_IN_ALL
|
||||
void gi_base_info_unref (GIBaseInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIInfoType gi_base_info_get_type (GIBaseInfo *info);
|
||||
GIInfoType gi_base_info_get_info_type (GIBaseInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
const gchar * gi_base_info_get_name (GIBaseInfo *info);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "girffi.h"
|
||||
@ -59,7 +60,7 @@ signature_offset (GICallableInfo *info)
|
||||
GIRealInfo *rinfo = (GIRealInfo*)info;
|
||||
int sigoff = -1;
|
||||
|
||||
switch (rinfo->type)
|
||||
switch (gi_base_info_get_info_type ((GIBaseInfo *) info))
|
||||
{
|
||||
case GI_INFO_TYPE_FUNCTION:
|
||||
sigoff = G_STRUCT_OFFSET (FunctionBlob, signature);
|
||||
@ -87,7 +88,7 @@ signature_offset (GICallableInfo *info)
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
* Since: 1.34
|
||||
* Since: 2.80
|
||||
* Returns: %TRUE if this #GICallableInfo can throw a #GError
|
||||
*/
|
||||
gboolean
|
||||
@ -105,7 +106,7 @@ gi_callable_info_can_throw_gerror (GICallableInfo *info)
|
||||
* to support the other callables. For Functions and VFuncs,
|
||||
* also check their legacy flag for compatibility.
|
||||
*/
|
||||
switch (rinfo->type) {
|
||||
switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) {
|
||||
case GI_INFO_TYPE_FUNCTION:
|
||||
{
|
||||
FunctionBlob *blob;
|
||||
@ -141,13 +142,13 @@ gi_callable_info_can_throw_gerror (GICallableInfo *info)
|
||||
* or "this" object.
|
||||
*
|
||||
* Returns: %TRUE if @info is a method, %FALSE otherwise
|
||||
* Since: 1.34
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_callable_info_is_method (GICallableInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo*)info;
|
||||
switch (rinfo->type) {
|
||||
switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) {
|
||||
case GI_INFO_TYPE_FUNCTION:
|
||||
{
|
||||
FunctionBlob *blob;
|
||||
@ -211,7 +212,7 @@ gi_callable_info_load_return_type (GICallableInfo *info,
|
||||
|
||||
offset = signature_offset (info);
|
||||
|
||||
gi_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, offset);
|
||||
gi_type_info_init ((GIBaseInfo *) type, (GIBaseInfo*)info, rinfo->typelib, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,7 +294,7 @@ gi_callable_info_get_caller_owns (GICallableInfo *info)
|
||||
* Obtains the ownership transfer for the instance argument.
|
||||
* #GITransfer contains a list of possible transfer values.
|
||||
*
|
||||
* Since: 1.42
|
||||
* Since: 2.80
|
||||
* Returns: the transfer mode of the instance argument
|
||||
*/
|
||||
GITransfer
|
||||
@ -458,7 +459,7 @@ gi_callable_info_iterate_return_attributes (GICallableInfo *info,
|
||||
if (iterator->data != NULL)
|
||||
next = (AttributeBlob *) iterator->data;
|
||||
else
|
||||
next = _attribute_blob_find_first (info, blob_offset);
|
||||
next = _attribute_blob_find_first ((GIBaseInfo *) info, blob_offset);
|
||||
|
||||
if (next == NULL || next->offset != blob_offset || next >= after)
|
||||
return FALSE;
|
||||
@ -489,7 +490,7 @@ gi_callable_info_iterate_return_attributes (GICallableInfo *info,
|
||||
* The @interface_type argument only applies if @return_tag is
|
||||
* %GI_TYPE_TAG_INTERFACE. Otherwise it is ignored.
|
||||
*
|
||||
* Since: 1.72
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_type_tag_extract_ffi_return_value (GITypeTag return_tag,
|
||||
@ -573,7 +574,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info,
|
||||
if (return_tag == GI_TYPE_TAG_INTERFACE)
|
||||
{
|
||||
GIBaseInfo *interface_info = gi_type_info_get_interface (return_info);
|
||||
interface_type = gi_base_info_get_type (interface_info);
|
||||
interface_type = gi_base_info_get_info_type (interface_info);
|
||||
gi_base_info_unref (interface_info);
|
||||
}
|
||||
|
||||
@ -597,7 +598,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info,
|
||||
* TODO
|
||||
*/
|
||||
gboolean
|
||||
gi_callable_info_invoke (GIFunctionInfo *info,
|
||||
gi_callable_info_invoke (GICallableInfo *info,
|
||||
gpointer function,
|
||||
const GIArgument *in_args,
|
||||
int n_in_args,
|
||||
@ -666,7 +667,7 @@ gi_callable_info_invoke (GIFunctionInfo *info,
|
||||
switch (gi_arg_info_get_direction (ainfo))
|
||||
{
|
||||
case GI_DIRECTION_IN:
|
||||
tinfo = gi_arg_info_get_type (ainfo);
|
||||
tinfo = gi_arg_info_get_type_info (ainfo);
|
||||
atypes[i+offset] = gi_type_info_get_ffi_type (tinfo);
|
||||
gi_base_info_unref ((GIBaseInfo *)ainfo);
|
||||
gi_base_info_unref ((GIBaseInfo *)tinfo);
|
||||
@ -791,3 +792,12 @@ gi_callable_info_invoke (GIFunctionInfo *info,
|
||||
gi_base_info_unref ((GIBaseInfo *)rinfo);
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
gi_callable_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_CALLABLE;
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GICallableInfo or derived from it.
|
||||
*/
|
||||
#define GI_IS_CALLABLE_INFO(info) \
|
||||
((gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FUNCTION) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_CALLBACK) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_SIGNAL) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VFUNC))
|
||||
((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FUNCTION) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CALLBACK) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_SIGNAL) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_VFUNC))
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
52
girepository/gicallbackinfo.c
Normal file
52
girepository/gicallbackinfo.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
* GObject introspection: Callable implementation
|
||||
*
|
||||
* Copyright (C) 2005 Matthias Clasen
|
||||
* Copyright 2023 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 <stdlib.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gicallbackinfo.h"
|
||||
|
||||
/**
|
||||
* SECTION:gicallback
|
||||
* @title: GICallbackInfo
|
||||
* @short_description: Struct representing a callback
|
||||
*
|
||||
* GICallbackInfo represents a callback.
|
||||
*/
|
||||
|
||||
void
|
||||
gi_callback_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_CALLBACK;
|
||||
}
|
43
girepository/gicallbackinfo.h
Normal file
43
girepository/gicallbackinfo.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
* GObject introspection: Callable
|
||||
*
|
||||
* Copyright 2023 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
|
||||
|
||||
/**
|
||||
* GI_IS_CALLBACK_INFO
|
||||
* @info: an info structure
|
||||
*
|
||||
* Checks if @info is a #GICallbackInfo or derived from it.
|
||||
*/
|
||||
#define GI_IS_CALLBACK_INFO(info) \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CALLBACK)
|
||||
|
||||
G_END_DECLS
|
@ -28,6 +28,7 @@
|
||||
#include <string.h> // memcpy
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "giconstantinfo.h"
|
||||
@ -40,13 +41,13 @@
|
||||
* GIConstantInfo represents a constant.
|
||||
*
|
||||
* A constant has a type associated which can be obtained by calling
|
||||
* gi_constant_info_get_type() and a value, which can be obtained by
|
||||
* gi_constant_info_get_type_info() and a value, which can be obtained by
|
||||
* calling gi_constant_info_get_value().
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* gi_constant_info_get_type:
|
||||
* gi_constant_info_get_type_info:
|
||||
* @info: a #GIConstantInfo
|
||||
*
|
||||
* Obtain the type of the constant as a #GITypeInfo.
|
||||
@ -55,7 +56,7 @@
|
||||
* gi_base_info_unref() when done.
|
||||
*/
|
||||
GITypeInfo *
|
||||
gi_constant_info_get_type (GIConstantInfo *info)
|
||||
gi_constant_info_get_type_info (GIConstantInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
|
||||
@ -75,7 +76,7 @@ gi_constant_info_get_type (GIConstantInfo *info)
|
||||
*
|
||||
* Free the value returned from gi_constant_info_get_value().
|
||||
*
|
||||
* Since: 1.32
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_constant_info_free_value (GIConstantInfo *info,
|
||||
@ -176,3 +177,11 @@ gi_constant_info_get_value (GIConstantInfo *info,
|
||||
return blob->size;
|
||||
}
|
||||
|
||||
void
|
||||
gi_constant_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_CONSTANT;
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIConstantInfo.
|
||||
*/
|
||||
#define GI_IS_CONSTANT_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_CONSTANT)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CONSTANT)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GITypeInfo * gi_constant_info_get_type (GIConstantInfo *info);
|
||||
GITypeInfo * gi_constant_info_get_type_info (GIConstantInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
void gi_constant_info_free_value (GIConstantInfo *info,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gienuminfo.h"
|
||||
@ -76,7 +77,7 @@ gi_enum_info_get_n_values (GIEnumInfo *info)
|
||||
*
|
||||
* Returns: (transfer none): the string form of the error domain associated
|
||||
* with this enum, or %NULL.
|
||||
* Since: 1.30
|
||||
* Since: 2.80
|
||||
*/
|
||||
const gchar *
|
||||
gi_enum_info_get_error_domain (GIEnumInfo *info)
|
||||
@ -130,7 +131,7 @@ gi_enum_info_get_value (GIEnumInfo *info,
|
||||
* Obtain the number of methods that this enum type has.
|
||||
*
|
||||
* Returns: number of methods
|
||||
* Since: 1.30
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_enum_info_get_n_methods (GIEnumInfo *info)
|
||||
@ -155,7 +156,7 @@ gi_enum_info_get_n_methods (GIEnumInfo *info)
|
||||
*
|
||||
* Returns: (transfer full): the #GIFunctionInfo. Free the struct by calling
|
||||
* gi_base_info_unref() when done.
|
||||
* Since: 1.30
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIFunctionInfo *
|
||||
gi_enum_info_get_method (GIEnumInfo *info,
|
||||
@ -207,6 +208,15 @@ gi_enum_info_get_storage_type (GIEnumInfo *info)
|
||||
return blob->storage_type;
|
||||
}
|
||||
|
||||
void
|
||||
gi_enum_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_ENUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_value_info_get_value:
|
||||
* @info: a #GIValueInfo
|
||||
@ -233,3 +243,12 @@ gi_value_info_get_value (GIValueInfo *info)
|
||||
else
|
||||
return (gint64)blob->value;
|
||||
}
|
||||
|
||||
void
|
||||
gi_value_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_VALUE;
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIEnumInfo.
|
||||
*/
|
||||
#define GI_IS_ENUM_INFO(info) \
|
||||
((gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FLAGS))
|
||||
((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_ENUM) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FLAGS))
|
||||
|
||||
/**
|
||||
* GI_IS_VALUE_INFO
|
||||
@ -49,7 +49,7 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIValueInfo.
|
||||
*/
|
||||
#define GI_IS_VALUE_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VALUE)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_VALUE)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -27,35 +27,40 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "config.h"
|
||||
#include "gifieldinfo.h"
|
||||
|
||||
/**
|
||||
* SECTION:gifieldinfo
|
||||
* @title: GIFieldInfo
|
||||
* @short_description: Struct representing a struct or union field
|
||||
* GIFieldInfo:
|
||||
*
|
||||
* A GIFieldInfo struct represents a field of a struct, union, or object.
|
||||
* A `GIFieldInfo` struct represents a field of a struct, union, or object.
|
||||
*
|
||||
* The GIFieldInfo is fetched by calling gi_struct_info_get_field(),
|
||||
* gi_union_info_get_field() or gi_object_info_get_field().
|
||||
* The `GIFieldInfo` is fetched by calling
|
||||
* [method@GIRepository.StructInfo.get_field],
|
||||
* [method@GIRepository.UnionInfo.get_field] or
|
||||
* [method@GIRepository.ObjectInfo.get_field].
|
||||
*
|
||||
* A field has a size, type and a struct offset asssociated and a set of flags,
|
||||
* which are currently #GI_FIELD_IS_READABLE or #GI_FIELD_IS_WRITABLE.
|
||||
* A field has a size, type and a struct offset associated and a set of flags,
|
||||
* which are currently `GI_FIELD_IS_READABLE` or `GI_FIELD_IS_WRITABLE`.
|
||||
*
|
||||
* See also: #GIStructInfo, #GIUnionInfo, #GIObjectInfo
|
||||
* See also: [type@GIRepository.StructInfo], [type@GIRepository.UnionInfo],
|
||||
* [type@GIRepository.ObjectInfo]
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
|
||||
/**
|
||||
* gi_field_info_get_flags:
|
||||
* @info: a #GIFieldInfo
|
||||
*
|
||||
* Obtain the flags for this #GIFieldInfo. See #GIFieldInfoFlags for possible
|
||||
* flag values.
|
||||
* Obtain the flags for this `GIFieldInfo`. See
|
||||
* [flags@GIRepository.FieldInfoFlags] for possible flag values.
|
||||
*
|
||||
* Returns: the flags
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIFieldInfoFlags
|
||||
gi_field_info_get_flags (GIFieldInfo *info)
|
||||
@ -84,10 +89,11 @@ gi_field_info_get_flags (GIFieldInfo *info)
|
||||
* gi_field_info_get_size:
|
||||
* @info: a #GIFieldInfo
|
||||
*
|
||||
* Obtain the size in bits of the field member, this is how
|
||||
* Obtain the size of the field member, in bits. This is how
|
||||
* much space you need to allocate to store the field.
|
||||
*
|
||||
* Returns: the field size
|
||||
* Returns: the field size, in bits
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_field_info_get_size (GIFieldInfo *info)
|
||||
@ -107,10 +113,11 @@ gi_field_info_get_size (GIFieldInfo *info)
|
||||
* gi_field_info_get_offset:
|
||||
* @info: a #GIFieldInfo
|
||||
*
|
||||
* Obtain the offset in bytes of the field member, this is relative
|
||||
* Obtain the offset of the field member, in bytes. This is relative
|
||||
* to the beginning of the struct or union.
|
||||
*
|
||||
* Returns: the field offset
|
||||
* Returns: the field offset, in bytes
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_field_info_get_offset (GIFieldInfo *info)
|
||||
@ -127,16 +134,16 @@ gi_field_info_get_offset (GIFieldInfo *info)
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_field_info_get_type:
|
||||
* gi_field_info_get_type_info:
|
||||
* @info: a #GIFieldInfo
|
||||
*
|
||||
* Obtain the type of a field as a #GITypeInfo.
|
||||
* Obtain the type of a field as a [type@GIRepository.TypeInfo].
|
||||
*
|
||||
* Returns: (transfer full): the #GITypeInfo. Free the struct by calling
|
||||
* gi_base_info_unref() when done.
|
||||
* Returns: (transfer full): the [type@GIRepository.TypeInfo]. Free the struct
|
||||
* by calling [method@GIRepository.BaseInfo.unref] when done.
|
||||
*/
|
||||
GITypeInfo *
|
||||
gi_field_info_get_type (GIFieldInfo *info)
|
||||
gi_field_info_get_type_info (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
Header *header = (Header *)rinfo->typelib->data;
|
||||
@ -158,21 +165,24 @@ gi_field_info_get_type (GIFieldInfo *info)
|
||||
else
|
||||
return gi_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (FieldBlob, type));
|
||||
|
||||
return (GIBaseInfo*)type_info;
|
||||
return (GITypeInfo *) type_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_field_info_get_field: (skip)
|
||||
* @field_info: a #GIFieldInfo
|
||||
* @mem: pointer to a block of memory representing a C structure or union
|
||||
* @value: a #GIArgument into which to store the value retrieved
|
||||
* @value: a [type@GIRepository.Argument] into which to store the value retrieved
|
||||
*
|
||||
* Reads a field identified by a #GIFieldInfo from a C structure or
|
||||
* union. This only handles fields of simple C types. It will fail
|
||||
* for a field of a composite type like a nested structure or union
|
||||
* even if that is actually readable.
|
||||
* Reads a field identified by a `GIFieldInfo` from a C structure or
|
||||
* union.
|
||||
*
|
||||
* Returns: %TRUE if reading the field succeeded, otherwise %FALSE
|
||||
* This only handles fields of simple C types. It will fail for a field of a
|
||||
* composite type like a nested structure or union even if that is actually
|
||||
* readable.
|
||||
*
|
||||
* Returns: true if reading the field succeeded, false otherwise
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
@ -190,7 +200,7 @@ gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
return FALSE;
|
||||
|
||||
offset = gi_field_info_get_offset (field_info);
|
||||
type_info = gi_field_info_get_type (field_info);
|
||||
type_info = gi_field_info_get_type_info (field_info);
|
||||
|
||||
if (gi_type_info_is_pointer (type_info))
|
||||
{
|
||||
@ -263,7 +273,7 @@ gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
case GI_TYPE_TAG_INTERFACE:
|
||||
{
|
||||
GIBaseInfo *interface = gi_type_info_get_interface (type_info);
|
||||
switch (gi_base_info_get_type (interface))
|
||||
switch (gi_base_info_get_info_type (interface))
|
||||
{
|
||||
case GI_INFO_TYPE_STRUCT:
|
||||
case GI_INFO_TYPE_UNION:
|
||||
@ -317,7 +327,7 @@ gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
case GI_INFO_TYPE_CALLBACK:
|
||||
g_warning("Field %s: Interface type %d should have is_pointer set",
|
||||
gi_base_info_get_name ((GIBaseInfo *)field_info),
|
||||
gi_base_info_get_type (interface));
|
||||
gi_base_info_get_info_type (interface));
|
||||
break;
|
||||
case GI_INFO_TYPE_INVALID:
|
||||
case GI_INFO_TYPE_INTERFACE:
|
||||
@ -333,7 +343,7 @@ gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
case GI_INFO_TYPE_UNRESOLVED:
|
||||
g_warning("Field %s: Interface type %d not expected",
|
||||
gi_base_info_get_name ((GIBaseInfo *)field_info),
|
||||
gi_base_info_get_type (interface));
|
||||
gi_base_info_get_info_type (interface));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -357,16 +367,19 @@ gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
* gi_field_info_set_field: (skip)
|
||||
* @field_info: a #GIFieldInfo
|
||||
* @mem: pointer to a block of memory representing a C structure or union
|
||||
* @value: a #GIArgument holding the value to store
|
||||
* @value: a [type@GIRepository.Argument] holding the value to store
|
||||
*
|
||||
* Writes a field identified by a #GIFieldInfo to a C structure or
|
||||
* union. This only handles fields of simple C types. It will fail
|
||||
* for a field of a composite type like a nested structure or union
|
||||
* even if that is actually writable. Note also that that it will refuse
|
||||
* to write fields where memory management would by required. A field
|
||||
* with a type such as 'char *' must be set with a setter function.
|
||||
* Writes a field identified by a `GIFieldInfo` to a C structure or
|
||||
* union.
|
||||
*
|
||||
* Returns: %TRUE if writing the field succeeded, otherwise %FALSE
|
||||
* This only handles fields of simple C types. It will fail for a field of a
|
||||
* composite type like a nested structure or union even if that is actually
|
||||
* writable. Note also that that it will refuse to write fields where memory
|
||||
* management would by required. A field with a type such as `char *` must be
|
||||
* set with a setter function.
|
||||
*
|
||||
* Returns: true if writing the field succeeded, false otherwise
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
@ -384,7 +397,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
return FALSE;
|
||||
|
||||
offset = gi_field_info_get_offset (field_info);
|
||||
type_info = gi_field_info_get_type (field_info);
|
||||
type_info = gi_field_info_get_type_info (field_info);
|
||||
|
||||
if (!gi_type_info_is_pointer (type_info))
|
||||
{
|
||||
@ -447,7 +460,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
case GI_TYPE_TAG_INTERFACE:
|
||||
{
|
||||
GIBaseInfo *interface = gi_type_info_get_interface (type_info);
|
||||
switch (gi_base_info_get_type (interface))
|
||||
switch (gi_base_info_get_info_type (interface))
|
||||
{
|
||||
case GI_INFO_TYPE_STRUCT:
|
||||
case GI_INFO_TYPE_UNION:
|
||||
@ -497,7 +510,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
case GI_INFO_TYPE_CALLBACK:
|
||||
g_warning("Field%s: Interface type %d should have is_pointer set",
|
||||
gi_base_info_get_name ((GIBaseInfo *)field_info),
|
||||
gi_base_info_get_type (interface));
|
||||
gi_base_info_get_info_type (interface));
|
||||
break;
|
||||
case GI_INFO_TYPE_INVALID:
|
||||
case GI_INFO_TYPE_INTERFACE:
|
||||
@ -513,7 +526,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
case GI_INFO_TYPE_UNRESOLVED:
|
||||
g_warning("Field %s: Interface type %d not expected",
|
||||
gi_base_info_get_name ((GIBaseInfo *)field_info),
|
||||
gi_base_info_get_type (interface));
|
||||
gi_base_info_get_info_type (interface));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -532,7 +545,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
case GI_TYPE_TAG_INTERFACE:
|
||||
{
|
||||
GIBaseInfo *interface = gi_type_info_get_interface (type_info);
|
||||
switch (gi_base_info_get_type (interface))
|
||||
switch (gi_base_info_get_info_type (interface))
|
||||
{
|
||||
case GI_INFO_TYPE_OBJECT:
|
||||
case GI_INFO_TYPE_INTERFACE:
|
||||
@ -554,3 +567,12 @@ gi_field_info_set_field (GIFieldInfo *field_info,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gi_field_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_FIELD;
|
||||
}
|
||||
|
@ -33,14 +33,15 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GI_IS_FIELD_INFO
|
||||
* GI_IS_FIELD_INFO:
|
||||
* @info: an info structure
|
||||
*
|
||||
* Checks if @info is a #GIFieldInfo.
|
||||
* Checks if @info is a [class@GIRepository.FieldInfo].
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_IS_FIELD_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FIELD)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FIELD)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
@ -53,7 +54,7 @@ GI_AVAILABLE_IN_ALL
|
||||
gint gi_field_info_get_offset (GIFieldInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GITypeInfo * gi_field_info_get_type (GIFieldInfo *info);
|
||||
GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
gboolean gi_field_info_get_field (GIFieldInfo *field_info,
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gifunctioninfo.h"
|
||||
@ -158,7 +159,7 @@ gi_function_info_get_flags (GIFunctionInfo *info)
|
||||
GIPropertyInfo *
|
||||
gi_function_info_get_property (GIFunctionInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo, *container_rinfo;
|
||||
GIRealInfo *rinfo;
|
||||
FunctionBlob *blob;
|
||||
|
||||
g_return_val_if_fail (info != NULL, NULL);
|
||||
@ -166,15 +167,14 @@ gi_function_info_get_property (GIFunctionInfo *info)
|
||||
|
||||
rinfo = (GIRealInfo *)info;
|
||||
blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
container_rinfo = (GIRealInfo *)rinfo->container;
|
||||
|
||||
if (container_rinfo->type == GI_INFO_TYPE_INTERFACE)
|
||||
if (gi_base_info_get_info_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_INTERFACE)
|
||||
{
|
||||
GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container;
|
||||
|
||||
return gi_interface_info_get_property (container, blob->index);
|
||||
}
|
||||
else if (container_rinfo->type == GI_INFO_TYPE_OBJECT)
|
||||
else if (gi_base_info_get_info_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_OBJECT)
|
||||
{
|
||||
GIObjectInfo *container = (GIObjectInfo *)rinfo->container;
|
||||
|
||||
@ -295,3 +295,12 @@ gi_function_info_invoke (GIFunctionInfo *info,
|
||||
throws,
|
||||
error);
|
||||
}
|
||||
|
||||
void
|
||||
gi_function_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_FUNCTION;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIFunctionInfo.
|
||||
*/
|
||||
#define GI_IS_FUNCTION_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FUNCTION)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FUNCTION)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "giinterfaceinfo.h"
|
||||
@ -297,7 +298,7 @@ gi_interface_info_get_signal (GIInterfaceInfo *info,
|
||||
*
|
||||
* Returns: (transfer full): Info for the signal with name @name in @info, or
|
||||
* %NULL on failure.
|
||||
* Since: 1.34
|
||||
* Since: 2.80
|
||||
*/
|
||||
GISignalInfo *
|
||||
gi_interface_info_find_signal (GIInterfaceInfo *info,
|
||||
@ -311,7 +312,7 @@ gi_interface_info_find_signal (GIInterfaceInfo *info,
|
||||
{
|
||||
GISignalInfo *siginfo = gi_interface_info_get_signal (info, i);
|
||||
|
||||
if (g_strcmp0 (gi_base_info_get_name (siginfo), name) != 0)
|
||||
if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0)
|
||||
{
|
||||
gi_base_info_unref ((GIBaseInfo*)siginfo);
|
||||
continue;
|
||||
@ -501,3 +502,11 @@ gi_interface_info_get_iface_struct (GIInterfaceInfo *info)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gi_interface_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_INTERFACE;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIInterfaceInfo.
|
||||
*/
|
||||
#define GI_IS_INTERFACE_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_INTERFACE)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_INTERFACE)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "giobjectinfo.h"
|
||||
@ -141,7 +142,7 @@ gi_object_info_get_abstract (GIObjectInfo *info)
|
||||
*
|
||||
* Returns: %TRUE if the object type is final
|
||||
*
|
||||
* Since: 1.70
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_object_info_get_final (GIObjectInfo *info)
|
||||
@ -496,7 +497,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
|
||||
|
||||
result = gi_object_info_find_method (info, name);
|
||||
if (result)
|
||||
implementor_result = gi_base_info_ref ((GIBaseInfo*) info);
|
||||
implementor_result = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo*) info);
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
@ -514,7 +515,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
|
||||
|
||||
if (result != NULL)
|
||||
{
|
||||
implementor_result = iface_info;
|
||||
implementor_result = (GIObjectInfo *) iface_info;
|
||||
break;
|
||||
}
|
||||
gi_base_info_unref ((GIBaseInfo*) iface_info);
|
||||
@ -607,7 +608,7 @@ gi_object_info_find_signal (GIObjectInfo *info,
|
||||
{
|
||||
GISignalInfo *siginfo = gi_object_info_get_signal (info, i);
|
||||
|
||||
if (g_strcmp0 (gi_base_info_get_name (siginfo), name) != 0)
|
||||
if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0)
|
||||
{
|
||||
gi_base_info_unref ((GIBaseInfo*)siginfo);
|
||||
continue;
|
||||
@ -750,7 +751,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
|
||||
|
||||
result = gi_object_info_find_vfunc (info, name);
|
||||
if (result)
|
||||
implementor_result = gi_base_info_ref ((GIBaseInfo*) info);
|
||||
implementor_result = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo*) info);
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
@ -768,7 +769,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
|
||||
|
||||
if (result != NULL)
|
||||
{
|
||||
implementor_result = iface_info;
|
||||
implementor_result = (GIObjectInfo *) iface_info;
|
||||
break;
|
||||
}
|
||||
gi_base_info_unref ((GIBaseInfo*) iface_info);
|
||||
@ -881,7 +882,7 @@ _get_func(GIObjectInfo *info,
|
||||
GIObjectInfo *parent_info;
|
||||
gpointer func = NULL;
|
||||
|
||||
parent_info = gi_base_info_ref (info);
|
||||
parent_info = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo *) info);
|
||||
while (parent_info != NULL)
|
||||
{
|
||||
parents = g_slist_prepend (parents, parent_info);
|
||||
@ -1097,3 +1098,12 @@ gi_object_info_get_get_value_function_pointer (GIObjectInfo *info)
|
||||
|
||||
return (GIObjectInfoGetValueFunction)_get_func(info, (SymbolGetter)gi_object_info_get_get_value_function);
|
||||
}
|
||||
|
||||
void
|
||||
gi_object_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_OBJECT;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ typedef void * (*GIObjectInfoGetValueFunction) (const GValue *value);
|
||||
* Checks if @info is a #GIObjectInfo.
|
||||
*/
|
||||
#define GI_IS_OBJECT_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_OBJECT)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_OBJECT)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gipropertyinfo.h"
|
||||
@ -80,7 +81,7 @@ gi_property_info_get_flags (GIPropertyInfo *info)
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_property_info_get_type:
|
||||
* gi_property_info_get_type_info:
|
||||
* @info: a #GIPropertyInfo
|
||||
*
|
||||
* Obtain the type information for the property @info.
|
||||
@ -89,7 +90,7 @@ gi_property_info_get_flags (GIPropertyInfo *info)
|
||||
* gi_base_info_unref() when done.
|
||||
*/
|
||||
GITypeInfo *
|
||||
gi_property_info_get_type (GIPropertyInfo *info)
|
||||
gi_property_info_get_type_info (GIPropertyInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
|
||||
@ -160,7 +161,7 @@ gi_property_info_get_setter (GIPropertyInfo *info)
|
||||
return NULL;
|
||||
|
||||
container = rinfo->container;
|
||||
parent_type = gi_base_info_get_type (container);
|
||||
parent_type = gi_base_info_get_info_type (container);
|
||||
if (parent_type == GI_INFO_TYPE_OBJECT)
|
||||
return gi_object_info_get_method ((GIObjectInfo *) container, blob->setter);
|
||||
else if (parent_type == GI_INFO_TYPE_INTERFACE)
|
||||
@ -199,7 +200,7 @@ gi_property_info_get_getter (GIPropertyInfo *info)
|
||||
return NULL;
|
||||
|
||||
container = rinfo->container;
|
||||
parent_type = gi_base_info_get_type (container);
|
||||
parent_type = gi_base_info_get_info_type (container);
|
||||
if (parent_type == GI_INFO_TYPE_OBJECT)
|
||||
return gi_object_info_get_method ((GIObjectInfo *) container, blob->getter);
|
||||
else if (parent_type == GI_INFO_TYPE_INTERFACE)
|
||||
@ -207,3 +208,12 @@ gi_property_info_get_getter (GIPropertyInfo *info)
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gi_property_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_PROPERTY;
|
||||
}
|
||||
|
@ -39,14 +39,14 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIPropertyInfo.
|
||||
*/
|
||||
#define GI_IS_PROPERTY_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_PROPERTY)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_PROPERTY)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GParamFlags gi_property_info_get_flags (GIPropertyInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GITypeInfo * gi_property_info_get_type (GIPropertyInfo *info);
|
||||
GITypeInfo *gi_property_info_get_type_info (GIPropertyInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GITransfer gi_property_info_get_ownership_transfer (GIPropertyInfo *info);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "giregisteredtypeinfo.h"
|
||||
@ -144,3 +145,11 @@ gi_registered_type_info_get_g_type (GIRegisteredTypeInfo *info)
|
||||
return (* get_type_func) ();
|
||||
}
|
||||
|
||||
void
|
||||
gi_registered_type_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_REGISTERED_TYPE;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIRegisteredTypeInfo or derived from it.
|
||||
*/
|
||||
#define GI_IS_REGISTERED_TYPE_INFO(info) \
|
||||
((gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_BOXED) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FLAGS) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_INTERFACE) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_OBJECT) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_STRUCT) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION) || \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_BOXED))
|
||||
((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_BOXED) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_ENUM) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FLAGS) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_INTERFACE) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_OBJECT) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_STRUCT) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNION) || \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_BOXED))
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
const gchar * gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info);
|
||||
|
@ -32,7 +32,9 @@
|
||||
#include <girepository/girepository.h>
|
||||
#include <girepository/gitypelib.h>
|
||||
|
||||
typedef struct _GIRealInfo GIRealInfo;
|
||||
/* FIXME: For now, GIRealInfo is a compatibility define. This will eventually
|
||||
* be removed. */
|
||||
typedef struct _GIBaseInfo GIRealInfo;
|
||||
|
||||
/* We changed a gint32 -> gint in the structure below, which should be
|
||||
* valid everywhere we care about.
|
||||
@ -45,39 +47,169 @@ G_STATIC_ASSERT (sizeof (int) == sizeof (gint32));
|
||||
* from the typelib, and not having computed data in
|
||||
* per-type structures.
|
||||
*/
|
||||
struct _GIRealInfo
|
||||
struct _GIBaseInfo
|
||||
{
|
||||
/* Keep this part in sync with GIUnresolvedInfo below */
|
||||
gint32 type;
|
||||
volatile gint ref_count;
|
||||
/*< private >*/
|
||||
GTypeInstance parent_instance;
|
||||
gatomicrefcount ref_count;
|
||||
|
||||
GIRepository *repository;
|
||||
GIBaseInfo *container;
|
||||
|
||||
/* Resolved specific */
|
||||
|
||||
GITypelib *typelib;
|
||||
guint32 offset;
|
||||
|
||||
guint32 type_is_embedded : 1; /* Used by GITypeInfo */
|
||||
guint32 reserved : 31;
|
||||
|
||||
gpointer reserved2[4];
|
||||
};
|
||||
|
||||
/* Subtypes */
|
||||
struct _GICallableInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_callable_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIFunctionInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_function_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GICallbackInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_callback_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIRegisteredTypeInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_registered_type_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIStructInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_struct_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIUnionInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_union_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIEnumInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_enum_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIObjectInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_object_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIInterfaceInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_interface_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIConstantInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_constant_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIValueInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_value_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GISignalInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_signal_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIVFuncInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_vfunc_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIPropertyInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_property_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIFieldInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_field_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIArgInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_arg_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GITypeInfo
|
||||
{
|
||||
GIBaseInfo parent;
|
||||
};
|
||||
|
||||
void gi_type_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
struct _GIUnresolvedInfo
|
||||
{
|
||||
/* Keep this part in sync with GIBaseInfo above */
|
||||
gint32 type;
|
||||
volatile gint ref_count;
|
||||
GIRepository *repository;
|
||||
GIBaseInfo *container;
|
||||
|
||||
/* Unresolved specific */
|
||||
GIBaseInfo parent;
|
||||
|
||||
const gchar *name;
|
||||
const gchar *namespace;
|
||||
};
|
||||
|
||||
void gi_unresolved_info_class_init (gpointer g_class,
|
||||
gpointer class_data);
|
||||
|
||||
void gi_info_init (GIRealInfo *info,
|
||||
GIInfoType type,
|
||||
GIRepository *repository,
|
||||
|
@ -129,7 +129,7 @@ gi_repository_init (GIRepository *repository)
|
||||
repository->priv = gi_repository_get_instance_private (repository);
|
||||
repository->priv->typelibs
|
||||
= g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify) NULL,
|
||||
(GDestroyNotify) g_free,
|
||||
(GDestroyNotify) gi_typelib_free);
|
||||
repository->priv->lazy_typelibs
|
||||
= g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
@ -184,7 +184,7 @@ init_globals (void)
|
||||
return;
|
||||
|
||||
if (default_repository == NULL)
|
||||
default_repository = g_object_new (GI_TYPE_REPOSITORY, NULL);
|
||||
default_repository = gi_repository_new ();
|
||||
|
||||
if (typelib_search_path == NULL)
|
||||
{
|
||||
@ -441,7 +441,9 @@ register_internal (GIRepository *repository,
|
||||
else
|
||||
key = build_typelib_key (namespace, source);
|
||||
|
||||
g_hash_table_insert (repository->priv->typelibs, key, (void *)typelib);
|
||||
g_hash_table_insert (repository->priv->typelibs,
|
||||
g_steal_pointer (&key),
|
||||
(void *)typelib);
|
||||
}
|
||||
|
||||
/* These types might be resolved now, clear the cache */
|
||||
@ -468,7 +470,7 @@ register_internal (GIRepository *repository,
|
||||
* Returns: (transfer full): Zero-terminated string array of immediate versioned
|
||||
* dependencies
|
||||
*
|
||||
* Since: 1.44
|
||||
* Since: 2.80
|
||||
*/
|
||||
char **
|
||||
gi_repository_get_immediate_dependencies (GIRepository *repository,
|
||||
@ -688,6 +690,23 @@ gi_repository_get_default (void)
|
||||
return get_repository (NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_repository_new:
|
||||
*
|
||||
* Create a new (non-singleton) #GIRepository.
|
||||
*
|
||||
* Most callers should use gi_repository_get_default() instead, as a singleton
|
||||
* repository is more useful in most situations.
|
||||
*
|
||||
* Returns: (transfer full): a new #GIRepository
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIRepository *
|
||||
gi_repository_new (void)
|
||||
{
|
||||
return g_object_new (GI_TYPE_REPOSITORY, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_repository_get_n_infos:
|
||||
* @repository: (allow-none): A #GIRepository or %NULL for the singleton
|
||||
@ -943,7 +962,7 @@ find_by_error_domain_foreach (gpointer key,
|
||||
*
|
||||
* Returns: (transfer full): #GIEnumInfo representing metadata about @domain's
|
||||
* enum type, or %NULL
|
||||
* Since: 1.30
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIEnumInfo *
|
||||
gi_repository_find_by_error_domain (GIRepository *repository,
|
||||
@ -958,7 +977,7 @@ gi_repository_find_by_error_domain (GIRepository *repository,
|
||||
GUINT_TO_POINTER (domain));
|
||||
|
||||
if (cached != NULL)
|
||||
return gi_base_info_ref ((GIBaseInfo *)cached);
|
||||
return (GIEnumInfo *) gi_base_info_ref ((GIBaseInfo *)cached);
|
||||
|
||||
data.repository = repository;
|
||||
data.domain = domain;
|
||||
@ -971,13 +990,13 @@ gi_repository_find_by_error_domain (GIRepository *repository,
|
||||
|
||||
if (data.result != NULL)
|
||||
{
|
||||
cached = gi_info_new_full (data.result->blob_type,
|
||||
repository,
|
||||
NULL, data.result_typelib, data.result->offset);
|
||||
cached = (GIEnumInfo *) gi_info_new_full (data.result->blob_type,
|
||||
repository,
|
||||
NULL, data.result_typelib, data.result->offset);
|
||||
|
||||
g_hash_table_insert (repository->priv->info_by_error_domain,
|
||||
GUINT_TO_POINTER (domain),
|
||||
gi_base_info_ref (cached));
|
||||
gi_base_info_ref ((GIBaseInfo *) cached));
|
||||
return cached;
|
||||
}
|
||||
return NULL;
|
||||
@ -1002,7 +1021,7 @@ gi_repository_find_by_error_domain (GIRepository *repository,
|
||||
* returning a concrete class of #GLocalFile, which is a #GType we
|
||||
* see at runtime, but not statically.
|
||||
*
|
||||
* Since: 1.62
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_repository_get_object_gtype_interfaces (GIRepository *repository,
|
||||
@ -1034,7 +1053,7 @@ gi_repository_get_object_gtype_interfaces (GIRepository *repository,
|
||||
if (base_info == NULL)
|
||||
continue;
|
||||
|
||||
if (gi_base_info_get_type (base_info) != GI_INFO_TYPE_INTERFACE)
|
||||
if (gi_base_info_get_info_type (base_info) != GI_INFO_TYPE_INTERFACE)
|
||||
{
|
||||
/* FIXME - could this really happen? */
|
||||
gi_base_info_unref (base_info);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <girepository/giarginfo.h>
|
||||
#include <girepository/gibaseinfo.h>
|
||||
#include <girepository/gicallableinfo.h>
|
||||
#include <girepository/gicallbackinfo.h>
|
||||
#include <girepository/giconstantinfo.h>
|
||||
#include <girepository/gienuminfo.h>
|
||||
#include <girepository/gifieldinfo.h>
|
||||
@ -48,6 +49,7 @@
|
||||
#include <girepository/gitypelib.h>
|
||||
#include <girepository/gitypes.h>
|
||||
#include <girepository/giunioninfo.h>
|
||||
#include <girepository/giunresolvedinfo.h>
|
||||
#include <girepository/givfuncinfo.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -101,6 +103,9 @@ GType gi_repository_get_type (void) G_GNUC_CONST;
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIRepository *gi_repository_get_default (void);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIRepository *gi_repository_new (void);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
void gi_repository_prepend_search_path (const char *directory);
|
||||
|
||||
|
@ -146,7 +146,7 @@ gi_type_info_get_ffi_type (GITypeInfo *info)
|
||||
if (gi_type_info_get_tag (info) == GI_TYPE_TAG_INTERFACE)
|
||||
{
|
||||
iinfo = gi_type_info_get_interface (info);
|
||||
switch (gi_base_info_get_type (iinfo))
|
||||
switch (gi_base_info_get_info_type (iinfo))
|
||||
{
|
||||
case GI_INFO_TYPE_ENUM:
|
||||
case GI_INFO_TYPE_FLAGS:
|
||||
@ -293,7 +293,7 @@ gi_function_info_prep_invoker (GIFunctionInfo *info,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return gi_function_invoker_new_for_address (addr, info, invoker, error);
|
||||
return gi_function_invoker_new_for_address (addr, (GICallableInfo *) info, invoker, error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,7 +165,7 @@ xml_free (Xml *xml)
|
||||
static void
|
||||
check_unresolved (GIBaseInfo *info)
|
||||
{
|
||||
if (gi_base_info_get_type (info) != GI_INFO_TYPE_UNRESOLVED)
|
||||
if (gi_base_info_get_info_type (info) != GI_INFO_TYPE_UNRESOLVED)
|
||||
return;
|
||||
|
||||
g_critical ("Found unresolved type '%s' '%s'\n",
|
||||
@ -423,13 +423,13 @@ write_field_info (const gchar *ns,
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
type = gi_field_info_get_type (info);
|
||||
type = gi_field_info_get_type_info (info);
|
||||
|
||||
if (branch)
|
||||
{
|
||||
xml_printf (file, " branch=\"");
|
||||
gi_base_info_unref ((GIBaseInfo *)type);
|
||||
type = gi_constant_info_get_type (branch);
|
||||
type = gi_constant_info_get_type_info (branch);
|
||||
gi_constant_info_get_value (branch, &value);
|
||||
write_constant_value (ns, type, &value, file);
|
||||
xml_printf (file, "\"");
|
||||
@ -442,7 +442,7 @@ write_field_info (const gchar *ns,
|
||||
}
|
||||
|
||||
interface = gi_type_info_get_interface (type);
|
||||
if (interface && gi_base_info_get_type(interface) == GI_INFO_TYPE_CALLBACK)
|
||||
if (interface && gi_base_info_get_info_type (interface) == GI_INFO_TYPE_CALLBACK)
|
||||
write_callback_info (ns, (GICallbackInfo *)interface, file);
|
||||
else
|
||||
write_type_info (ns, type, file);
|
||||
@ -555,7 +555,7 @@ write_callable_info (const gchar *ns,
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) arg);
|
||||
|
||||
type = gi_arg_info_get_type (arg);
|
||||
type = gi_arg_info_get_type_info (arg);
|
||||
write_type_info (ns, type, file);
|
||||
|
||||
xml_end_element (file, "parameter");
|
||||
@ -607,7 +607,7 @@ write_function_info (const gchar *ns,
|
||||
else if (flags & GI_FUNCTION_IS_GETTER)
|
||||
xml_printf (file, " glib:get-property=\"%s\"", property_name);
|
||||
|
||||
gi_base_info_unref (property);
|
||||
gi_base_info_unref ((GIBaseInfo *) property);
|
||||
}
|
||||
}
|
||||
|
||||
@ -661,7 +661,7 @@ write_struct_info (const gchar *ns,
|
||||
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
||||
type_init = gi_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info);
|
||||
|
||||
if (gi_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_BOXED)
|
||||
if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_BOXED)
|
||||
{
|
||||
xml_start_element (file, "glib:boxed");
|
||||
xml_printf (file, " glib:name=\"%s\"", name);
|
||||
@ -813,7 +813,7 @@ write_constant_info (const gchar *ns,
|
||||
xml_start_element (file, "constant");
|
||||
xml_printf (file, " name=\"%s\"", name);
|
||||
|
||||
type = gi_constant_info_get_type (info);
|
||||
type = gi_constant_info_get_type_info (info);
|
||||
xml_printf (file, " value=\"");
|
||||
|
||||
gi_constant_info_get_value (info, &value);
|
||||
@ -849,7 +849,7 @@ write_enum_info (const gchar *ns,
|
||||
type_init = gi_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info);
|
||||
error_domain = gi_enum_info_get_error_domain (info);
|
||||
|
||||
if (gi_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_ENUM)
|
||||
if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_ENUM)
|
||||
xml_start_element (file, "enumeration");
|
||||
else
|
||||
xml_start_element (file, "bitfield");
|
||||
@ -1020,7 +1020,7 @@ write_property_info (const gchar *ns,
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
type = gi_property_info_get_type (info);
|
||||
type = gi_property_info_get_type_info (info);
|
||||
|
||||
write_type_info (ns, type, file);
|
||||
|
||||
@ -1414,7 +1414,7 @@ gi_ir_writer_write (const char *filename,
|
||||
for (j = 0; j < n_infos; j++)
|
||||
{
|
||||
GIBaseInfo *info = gi_repository_get_info (repository, cur_ns, j);
|
||||
switch (gi_base_info_get_type (info))
|
||||
switch (gi_base_info_get_info_type (info))
|
||||
{
|
||||
case GI_INFO_TYPE_FUNCTION:
|
||||
write_function_info (ns, (GIFunctionInfo *)info, xml);
|
||||
@ -1451,7 +1451,7 @@ gi_ir_writer_write (const char *filename,
|
||||
break;
|
||||
|
||||
default:
|
||||
g_error ("unknown info type %d\n", gi_base_info_get_type (info));
|
||||
g_error ("unknown info type %d\n", gi_base_info_get_info_type (info));
|
||||
}
|
||||
|
||||
gi_base_info_unref (info);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gisignalinfo.h"
|
||||
@ -141,3 +142,11 @@ gi_signal_info_true_stops_emit (GISignalInfo *info)
|
||||
return blob->true_stops_emit;
|
||||
}
|
||||
|
||||
void
|
||||
gi_signal_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_SIGNAL;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GISignalInfo.
|
||||
*/
|
||||
#define GI_IS_SIGNAL_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_SIGNAL)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_SIGNAL)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gistructinfo.h"
|
||||
@ -117,7 +118,7 @@ gi_struct_info_get_field (GIStructInfo *info,
|
||||
*
|
||||
* Obtain the type information for field named @name.
|
||||
*
|
||||
* Since: 1.46
|
||||
* Since: 2.80
|
||||
* Returns: (transfer full): the #GIFieldInfo or %NULL if not found,
|
||||
* free it with gi_base_info_unref() when done.
|
||||
*/
|
||||
@ -293,7 +294,7 @@ gi_struct_info_is_gtype_struct (GIStructInfo *info)
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the name of the copy function
|
||||
*
|
||||
* Since: 1.76
|
||||
* Since: 2.80
|
||||
*/
|
||||
const char *
|
||||
gi_struct_info_get_copy_function (GIStructInfo *info)
|
||||
@ -320,7 +321,7 @@ gi_struct_info_get_copy_function (GIStructInfo *info)
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the name of the free function
|
||||
*
|
||||
* Since: 1.76
|
||||
* Since: 2.80
|
||||
*/
|
||||
const char *
|
||||
gi_struct_info_get_free_function (GIStructInfo *info)
|
||||
@ -338,3 +339,12 @@ gi_struct_info_get_free_function (GIStructInfo *info)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gi_struct_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_STRUCT;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ G_BEGIN_DECLS
|
||||
* Checks if @info is a #GIStructInfo.
|
||||
*/
|
||||
#define GI_IS_STRUCT_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_STRUCT)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_STRUCT)
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -27,26 +27,31 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gitypeinfo.h"
|
||||
|
||||
/**
|
||||
* SECTION:gitypeinfo
|
||||
* @title: GITypeInfo
|
||||
* @short_description: Struct representing a type
|
||||
* GITypeInfo:
|
||||
*
|
||||
* GITypeInfo represents a type.
|
||||
* `GITypeInfo` represents a type, including information about direction and
|
||||
* transfer.
|
||||
*
|
||||
* You can retrieve a type info from an argument (see #GIArgInfo), a
|
||||
* functions return value (see #GIFunctionInfo), a field (see
|
||||
* #GIFieldInfo), a property (see #GIPropertyInfo), a constant
|
||||
* (see #GIConstantInfo) or for a union discriminator (see #GIUnionInfo).
|
||||
* You can retrieve a type info from an argument (see
|
||||
* [class@GIRepository.ArgInfo]), a function’s return value (see
|
||||
* [class@GIRepository.FunctionInfo]), a field (see
|
||||
* [class@GIRepository.FieldInfo]), a property (see
|
||||
* [class@GIRepository.PropertyInfo]), a constant (see
|
||||
* [class@GIRepository.ConstantInfo]) or for a union discriminator (see
|
||||
* [class@GIRepository.UnionInfo]).
|
||||
*
|
||||
* A type can either be a of a basic type which is a standard C primitive
|
||||
* type or an interface type. For interface types you need to call
|
||||
* gi_type_info_get_interface() to get a reference to the base info for that
|
||||
* interface.
|
||||
* [method@GIRepository.TypeInfo.get_interface] to get a reference to the base
|
||||
* info for that interface.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -55,12 +60,13 @@
|
||||
*
|
||||
* Obtain if the type is passed as a reference.
|
||||
*
|
||||
* Note that the types of %GI_DIRECTION_OUT and %GI_DIRECTION_INOUT parameters
|
||||
* Note that the types of `GI_DIRECTION_OUT` and `GI_DIRECTION_INOUT` parameters
|
||||
* will only be pointers if the underlying type being transferred is a pointer
|
||||
* (i.e. only if the type of the C function’s formal parameter is a pointer to a
|
||||
* pointer).
|
||||
*
|
||||
* Returns: %TRUE if it is a pointer
|
||||
* Returns: true if it is a pointer
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_type_info_is_pointer (GITypeInfo *info)
|
||||
@ -87,10 +93,12 @@ gi_type_info_is_pointer (GITypeInfo *info)
|
||||
* gi_type_info_get_tag:
|
||||
* @info: a #GITypeInfo
|
||||
*
|
||||
* Obtain the type tag for the type. See #GITypeTag for a list
|
||||
* of type tags.
|
||||
* Obtain the type tag for the type.
|
||||
*
|
||||
* See [type@GIRepository.TypeTag] for a list of type tags.
|
||||
*
|
||||
* Returns: the type tag
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypeTag
|
||||
gi_type_info_get_tag (GITypeInfo *info)
|
||||
@ -120,9 +128,10 @@ gi_type_info_get_tag (GITypeInfo *info)
|
||||
* @info: a #GITypeInfo
|
||||
* @n: index of the parameter
|
||||
*
|
||||
* Obtain the parameter type @n.
|
||||
* Obtain the parameter type @n, or `-1` if the type is not an array.
|
||||
*
|
||||
* Returns: (transfer full): the param type info
|
||||
* Returns: (transfer full) (nullable): the param type info
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypeInfo *
|
||||
gi_type_info_get_param_type (GITypeInfo *info,
|
||||
@ -162,13 +171,15 @@ gi_type_info_get_param_type (GITypeInfo *info,
|
||||
* gi_type_info_get_interface:
|
||||
* @info: a #GITypeInfo
|
||||
*
|
||||
* For types which have #GI_TYPE_TAG_INTERFACE such as GObjects and boxed values,
|
||||
* this function returns full information about the referenced type. You can then
|
||||
* inspect the type of the returned #GIBaseInfo to further query whether it is
|
||||
* a concrete GObject, a GInterface, a structure, etc. using gi_base_info_get_type().
|
||||
* For types which have `GI_TYPE_TAG_INTERFACE` such as [class@GObject.Object]s
|
||||
* and boxed values, this function returns full information about the referenced
|
||||
* type. You can then inspect the type of the returned
|
||||
* [class@GIRepository.BaseInfo] to further query whether it is a concrete
|
||||
* [class@GObject.Object], an interface, a structure, etc., using
|
||||
* [method@GIRepository.BaseInfo.get_info_type].
|
||||
*
|
||||
* Returns: (transfer full): the #GIBaseInfo, or %NULL. Free it with
|
||||
* gi_base_info_unref() when done.
|
||||
* Returns: (transfer full) (nullable): the [class@GIRepository.BaseInfo], or
|
||||
* `NULL`. Free it with gi_base_info_unref() when done.
|
||||
*/
|
||||
GIBaseInfo *
|
||||
gi_type_info_get_interface (GITypeInfo *info)
|
||||
@ -219,9 +230,10 @@ gi_type_info_get_interface (GITypeInfo *info)
|
||||
* @info: a #GITypeInfo
|
||||
*
|
||||
* Obtain the position of the argument which gives the array length of the type.
|
||||
* The type tag must be a #GI_TYPE_TAG_ARRAY or -1 will be returned.
|
||||
* The type tag must be a `GI_TYPE_TAG_ARRAY` or `-1` will be returned.
|
||||
*
|
||||
* Returns: the array length, or -1 if the type is not an array
|
||||
* Returns: the array length, or `-1` if the type is not an array
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_type_info_get_array_length (GITypeInfo *info)
|
||||
@ -253,9 +265,10 @@ gi_type_info_get_array_length (GITypeInfo *info)
|
||||
* @info: a #GITypeInfo
|
||||
*
|
||||
* Obtain the fixed array size of the type. The type tag must be a
|
||||
* #GI_TYPE_TAG_ARRAY or -1 will be returned.
|
||||
* `GI_TYPE_TAG_ARRAY` or `-1` will be returned.
|
||||
*
|
||||
* Returns: the size or -1 if it's not an array
|
||||
* Returns: the size or `-1` if the type is not an array
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_type_info_get_array_fixed_size (GITypeInfo *info)
|
||||
@ -286,10 +299,11 @@ gi_type_info_get_array_fixed_size (GITypeInfo *info)
|
||||
* gi_type_info_is_zero_terminated:
|
||||
* @info: a #GITypeInfo
|
||||
*
|
||||
* Obtain if the last element of the array is %NULL. The type tag must be a
|
||||
* #GI_TYPE_TAG_ARRAY or %FALSE will be returned.
|
||||
* Obtain if the last element of the array is `NULL`. The type tag must be a
|
||||
* `GI_TYPE_TAG_ARRAY` or false will be returned.
|
||||
*
|
||||
* Returns: %TRUE if zero terminated
|
||||
* Returns: true if zero terminated
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_type_info_is_zero_terminated (GITypeInfo *info)
|
||||
@ -317,11 +331,13 @@ gi_type_info_is_zero_terminated (GITypeInfo *info)
|
||||
* gi_type_info_get_array_type:
|
||||
* @info: a #GITypeInfo
|
||||
*
|
||||
* Obtain the array type for this type. See #GIArrayType for a list of
|
||||
* possible values. If the type tag of this type is not array, -1 will be
|
||||
* returned.
|
||||
* Obtain the array type for this type.
|
||||
*
|
||||
* Returns: the array type or -1
|
||||
* See [enum@GIRepository.ArrayType] for a list of possible values. If the type
|
||||
* tag of this type is not array, `-1` will be returned.
|
||||
*
|
||||
* Returns: the array type or `-1`
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIArrayType
|
||||
gi_type_info_get_array_type (GITypeInfo *info)
|
||||
@ -351,11 +367,11 @@ gi_type_info_get_array_type (GITypeInfo *info)
|
||||
*
|
||||
* Obtain the type tag corresponding to the underlying storage type in C for
|
||||
* the type.
|
||||
* See #GITypeTag for a list of type tags.
|
||||
*
|
||||
* See [type@GIRepository.TypeTag] for a list of type tags.
|
||||
*
|
||||
* Returns: the type tag
|
||||
*
|
||||
* Since: 1.66
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypeTag
|
||||
gi_type_info_get_storage_type (GITypeInfo *info)
|
||||
@ -365,9 +381,9 @@ gi_type_info_get_storage_type (GITypeInfo *info)
|
||||
if (type_tag == GI_TYPE_TAG_INTERFACE)
|
||||
{
|
||||
GIBaseInfo *interface = gi_type_info_get_interface (info);
|
||||
GIInfoType info_type = gi_base_info_get_type (interface);
|
||||
GIInfoType info_type = gi_base_info_get_info_type (interface);
|
||||
if (info_type == GI_INFO_TYPE_ENUM || info_type == GI_INFO_TYPE_FLAGS)
|
||||
type_tag = gi_enum_info_get_storage_type (interface);
|
||||
type_tag = gi_enum_info_get_storage_type ((GIEnumInfo *) interface);
|
||||
gi_base_info_unref (interface);
|
||||
}
|
||||
|
||||
@ -376,23 +392,25 @@ gi_type_info_get_storage_type (GITypeInfo *info)
|
||||
|
||||
/**
|
||||
* gi_type_tag_argument_from_hash_pointer:
|
||||
* @storage_type: a #GITypeTag obtained from gi_type_info_get_storage_type()
|
||||
* @hash_pointer: A pointer, such as a #GHashTable data pointer
|
||||
* @arg: A #GIArgument to fill in
|
||||
* @storage_type: a [type@GIRepository.TypeTag] obtained from
|
||||
* [method@GIRepository.TypeInfo.get_storage_type]
|
||||
* @hash_pointer: a pointer, such as a [struct@GLib.HashTable] data pointer
|
||||
* @arg: a [type@GIRepository.Argument] to fill in
|
||||
*
|
||||
* GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
|
||||
* [type@GLib.HashTable], all store data pointers.
|
||||
*
|
||||
* GLib data structures, such as #GList, #GSList, and #GHashTable, all store
|
||||
* data pointers.
|
||||
* In the case where the list or hash table is storing single types rather than
|
||||
* structs, these data pointers may have values stuffed into them via macros
|
||||
* such as %GPOINTER_TO_INT.
|
||||
* such as `GPOINTER_TO_INT`.
|
||||
*
|
||||
* Use this function to ensure that all values are correctly extracted from
|
||||
* stuffed pointers, regardless of the machine's architecture or endianness.
|
||||
* stuffed pointers, regardless of the machine’s architecture or endianness.
|
||||
*
|
||||
* This function fills in the appropriate field of @arg with the value extracted
|
||||
* from @hash_pointer, depending on @storage_type.
|
||||
*
|
||||
* Since: 1.72
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type,
|
||||
@ -450,22 +468,23 @@ gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type,
|
||||
/**
|
||||
* gi_type_info_argument_from_hash_pointer:
|
||||
* @info: a #GITypeInfo
|
||||
* @hash_pointer: A pointer, such as a #GHashTable data pointer
|
||||
* @arg: A #GIArgument to fill in
|
||||
* @hash_pointer: a pointer, such as a [struct@GLib.HashTable] data pointer
|
||||
* @arg: a [type@GIRepository.Argument] to fill in
|
||||
*
|
||||
* GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
|
||||
* [type@GLib.HashTable], all store data pointers.
|
||||
*
|
||||
* GLib data structures, such as #GList, #GSList, and #GHashTable, all store
|
||||
* data pointers.
|
||||
* In the case where the list or hash table is storing single types rather than
|
||||
* structs, these data pointers may have values stuffed into them via macros
|
||||
* such as %GPOINTER_TO_INT.
|
||||
* such as `GPOINTER_TO_INT`.
|
||||
*
|
||||
* Use this function to ensure that all values are correctly extracted from
|
||||
* stuffed pointers, regardless of the machine's architecture or endianness.
|
||||
* stuffed pointers, regardless of the machine’s architecture or endianness.
|
||||
*
|
||||
* This function fills in the appropriate field of @arg with the value extracted
|
||||
* from @hash_pointer, depending on the storage type of @info.
|
||||
*
|
||||
* Since: 1.66
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_type_info_argument_from_hash_pointer (GITypeInfo *info,
|
||||
@ -479,24 +498,26 @@ gi_type_info_argument_from_hash_pointer (GITypeInfo *info,
|
||||
|
||||
/**
|
||||
* gi_type_tag_hash_pointer_from_argument:
|
||||
* @storage_type: a #GITypeTag obtained from gi_get_storage_type()
|
||||
* @arg: A #GIArgument with the value to stuff into a pointer
|
||||
* @storage_type: a [type@GIRepository.TypeTag] obtained from
|
||||
* [method@GIRepository.TypeInfo.get_storage_type]
|
||||
* @arg: A [type@GIRepository.Argument] with the value to stuff into a pointer
|
||||
*
|
||||
* GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
|
||||
* [type@GLib.HashTable], all store data pointers.
|
||||
*
|
||||
* GLib data structures, such as #GList, #GSList, and #GHashTable, all store
|
||||
* data pointers.
|
||||
* In the case where the list or hash table is storing single types rather than
|
||||
* structs, these data pointers may have values stuffed into them via macros
|
||||
* such as %GPOINTER_TO_INT.
|
||||
* such as `GPOINTER_TO_INT`.
|
||||
*
|
||||
* Use this function to ensure that all values are correctly stuffed into
|
||||
* pointers, regardless of the machine's architecture or endianness.
|
||||
* pointers, regardless of the machine’s architecture or endianness.
|
||||
*
|
||||
* This function returns a pointer stuffed with the appropriate field of @arg,
|
||||
* depending on @storage_type.
|
||||
*
|
||||
* Returns: A stuffed pointer, that can be stored in a #GHashTable, for example
|
||||
*
|
||||
* Since: 1.72
|
||||
* Returns: A stuffed pointer, that can be stored in a [struct@GLib.HashTable],
|
||||
* for example
|
||||
* Since: 2.80
|
||||
*/
|
||||
gpointer
|
||||
gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type,
|
||||
@ -544,23 +565,24 @@ gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type,
|
||||
/**
|
||||
* gi_type_info_hash_pointer_from_argument:
|
||||
* @info: a #GITypeInfo
|
||||
* @arg: A #GIArgument with the value to stuff into a pointer
|
||||
* @arg: A [struct@GIRepository.Argument] with the value to stuff into a pointer
|
||||
*
|
||||
* GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
|
||||
* [type@GLib.HashTable], all store data pointers.
|
||||
*
|
||||
* GLib data structures, such as #GList, #GSList, and #GHashTable, all store
|
||||
* data pointers.
|
||||
* In the case where the list or hash table is storing single types rather than
|
||||
* structs, these data pointers may have values stuffed into them via macros
|
||||
* such as %GPOINTER_TO_INT.
|
||||
* such as `GPOINTER_TO_INT`.
|
||||
*
|
||||
* Use this function to ensure that all values are correctly stuffed into
|
||||
* pointers, regardless of the machine's architecture or endianness.
|
||||
* pointers, regardless of the machine’s architecture or endianness.
|
||||
*
|
||||
* This function returns a pointer stuffed with the appropriate field of @arg,
|
||||
* depending on the storage type of @info.
|
||||
*
|
||||
* Returns: A stuffed pointer, that can be stored in a #GHashTable, for example
|
||||
*
|
||||
* Since: 1.66
|
||||
* Returns: A stuffed pointer, that can be stored in a [struct@GLib.HashTable],
|
||||
* for example
|
||||
* Since: 2.80
|
||||
*/
|
||||
gpointer
|
||||
gi_type_info_hash_pointer_from_argument (GITypeInfo *info,
|
||||
@ -569,3 +591,12 @@ gi_type_info_hash_pointer_from_argument (GITypeInfo *info,
|
||||
GITypeTag storage_type = gi_type_info_get_storage_type (info);
|
||||
return gi_type_tag_hash_pointer_from_argument (storage_type, arg);
|
||||
}
|
||||
|
||||
void
|
||||
gi_type_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_TYPE;
|
||||
}
|
||||
|
@ -33,21 +33,23 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GI_IS_TYPE_INFO
|
||||
* GI_IS_TYPE_INFO:
|
||||
* @info: an info structure
|
||||
*
|
||||
* Checks if @info is a #GITypeInfo.
|
||||
* Checks if @info is a [alias@GIRepository.TypeInfo].
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_IS_TYPE_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_TYPE)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_TYPE)
|
||||
|
||||
/**
|
||||
* GI_TYPE_TAG_IS_BASIC
|
||||
* GI_TYPE_TAG_IS_BASIC:
|
||||
* @tag: a type tag
|
||||
*
|
||||
* Checks if @tag is a basic type.
|
||||
*
|
||||
* Since: 1.72
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_TYPE_TAG_IS_BASIC(tag) ((tag) < GI_TYPE_TAG_ARRAY || (tag) == GI_TYPE_TAG_UNICHAR)
|
||||
|
||||
@ -57,27 +59,7 @@ G_BEGIN_DECLS
|
||||
*
|
||||
* Checks if @tag is a numeric type. That is, integer or floating point.
|
||||
*
|
||||
* Since: 1.72
|
||||
*/
|
||||
#define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE)
|
||||
|
||||
/**
|
||||
* GI_TYPE_TAG_IS_NUMERIC:
|
||||
* @tag: a type tag
|
||||
*
|
||||
* Checks if @tag is a numeric type. That is, integer or floating point.
|
||||
*
|
||||
* Since: 1.72
|
||||
*/
|
||||
#define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE)
|
||||
|
||||
/**
|
||||
* GI_TYPE_TAG_IS_NUMERIC:
|
||||
* @tag: a type tag
|
||||
*
|
||||
* Checks if @tag is a numeric type. That is, integer or floating point.
|
||||
*
|
||||
* Since: 1.72
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE)
|
||||
|
||||
@ -86,9 +68,9 @@ G_BEGIN_DECLS
|
||||
* @tag: a type tag
|
||||
*
|
||||
* Checks if @tag is a container type. That is, a type which may have a nonnull
|
||||
* return from gi_type_info_get_param_type().
|
||||
* return from [method@GIRepository.TypeInfo.get_param_type].
|
||||
*
|
||||
* Since: 1.72
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_TYPE_TAG_IS_CONTAINER(tag) ((tag) == GI_TYPE_TAG_ARRAY || \
|
||||
((tag) >= GI_TYPE_TAG_GLIST && (tag) <= GI_TYPE_TAG_GHASH))
|
||||
|
@ -32,6 +32,15 @@
|
||||
#include "gitypelib-internal.h"
|
||||
#include "gitypelib.h"
|
||||
|
||||
/**
|
||||
* GITypelib:
|
||||
*
|
||||
* `GITypelib` represents a loaded `.typelib` file, which contains a description
|
||||
* of a single module’s API.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
GITypelib *typelib;
|
||||
GSList *context_stack;
|
||||
@ -2242,7 +2251,7 @@ static GSList *library_paths;
|
||||
* path (ie. LD_LIBRARY_PATH and DT_RPATH in ELF systems).
|
||||
* See the documentation of your dynamic linker for full details.
|
||||
*
|
||||
* Since: 1.36
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_repository_prepend_library_path (const char *directory)
|
||||
@ -2369,15 +2378,17 @@ gi_typelib_ensure_open (GITypelib *typelib)
|
||||
|
||||
/**
|
||||
* gi_typelib_new_from_memory: (skip)
|
||||
* @memory: address of memory chunk containing the typelib
|
||||
* @memory: (array length=len): address of memory chunk containing the typelib
|
||||
* @len: length of memory chunk containing the typelib
|
||||
* @error: a #GError
|
||||
*
|
||||
* Creates a new #GITypelib from a memory location. The memory block
|
||||
* pointed to by @typelib will be automatically g_free()d when the
|
||||
* Creates a new `GITypelib` from a memory location.
|
||||
*
|
||||
* The memory block pointed to by @typelib will be automatically freed when the
|
||||
* repository is destroyed.
|
||||
*
|
||||
* Returns: the new #GITypelib
|
||||
* Returns: (transfer full): the new #GITypelib
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypelib *
|
||||
gi_typelib_new_from_memory (guint8 *memory,
|
||||
@ -2400,13 +2411,14 @@ gi_typelib_new_from_memory (guint8 *memory,
|
||||
|
||||
/**
|
||||
* gi_typelib_new_from_const_memory: (skip)
|
||||
* @memory: address of memory chunk containing the typelib
|
||||
* @memory: (array length=len): address of memory chunk containing the typelib
|
||||
* @len: length of memory chunk containing the typelib
|
||||
* @error: A #GError
|
||||
* @error: a #GError
|
||||
*
|
||||
* Creates a new #GITypelib from a memory location.
|
||||
* Creates a new `GITypelib` from a memory location.
|
||||
*
|
||||
* Returns: the new #GITypelib
|
||||
* Returns: (transfer full): the new #GITypelib
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypelib *
|
||||
gi_typelib_new_from_const_memory (const guchar *memory,
|
||||
@ -2429,12 +2441,14 @@ gi_typelib_new_from_const_memory (const guchar *memory,
|
||||
|
||||
/**
|
||||
* gi_typelib_new_from_mapped_file: (skip)
|
||||
* @mfile: a #GMappedFile, that will be free'd when the repository is destroyed
|
||||
* @mfile: (transfer full): a [type@GLib.MappedFile], that will be freed when
|
||||
* the repository is destroyed
|
||||
* @error: a #GError
|
||||
*
|
||||
* Creates a new #GITypelib from a #GMappedFile.
|
||||
* Creates a new `GITypelib` from a [type@GLib.MappedFile].
|
||||
*
|
||||
* Returns: the new #GITypelib
|
||||
* Returns: (transfer full): the new #GITypelib
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypelib *
|
||||
gi_typelib_new_from_mapped_file (GMappedFile *mfile,
|
||||
@ -2458,9 +2472,11 @@ gi_typelib_new_from_mapped_file (GMappedFile *mfile,
|
||||
|
||||
/**
|
||||
* gi_typelib_free:
|
||||
* @typelib: a #GITypelib
|
||||
* @typelib: (transfer full): a #GITypelib
|
||||
*
|
||||
* Free a #GITypelib.
|
||||
* Free a `GITypelib`.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
gi_typelib_free (GITypelib *typelib)
|
||||
@ -2480,11 +2496,12 @@ gi_typelib_free (GITypelib *typelib)
|
||||
|
||||
/**
|
||||
* gi_typelib_get_namespace:
|
||||
* @typelib: TODO
|
||||
* @typelib: a #GITypelib
|
||||
*
|
||||
* TODO
|
||||
* Get the name of the namespace represented by @typelib.
|
||||
*
|
||||
* Returns: TODO
|
||||
* Returns: name of the namespace represented by @typelib
|
||||
* Since: 2.80
|
||||
*/
|
||||
const gchar *
|
||||
gi_typelib_get_namespace (GITypelib *typelib)
|
||||
@ -2496,11 +2513,13 @@ gi_typelib_get_namespace (GITypelib *typelib)
|
||||
* gi_typelib_symbol:
|
||||
* @typelib: the typelib
|
||||
* @symbol_name: name of symbol to be loaded
|
||||
* @symbol: returns a pointer to the symbol value
|
||||
* @symbol: (out) (nullable): returns a pointer to the symbol value, or `NULL`
|
||||
* on failure
|
||||
*
|
||||
* Loads a symbol from #GITypelib.
|
||||
* Loads a symbol from a `GITypelib`.
|
||||
*
|
||||
* Returns: #TRUE on success
|
||||
* Returns: true on success
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_typelib_symbol (GITypelib *typelib, const char *symbol_name, gpointer *symbol)
|
||||
|
@ -34,19 +34,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:gitypelib
|
||||
* @title: GITypelib
|
||||
* @short_description: TODO
|
||||
*
|
||||
* TODO
|
||||
*/
|
||||
|
||||
/**
|
||||
* GITypelib:
|
||||
*
|
||||
* TODO
|
||||
*/
|
||||
typedef struct _GITypelib GITypelib;
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
|
@ -28,162 +28,88 @@
|
||||
#error "Only <girepository.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "gi-visibility.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GIBaseInfoStub {
|
||||
/*< private >*/
|
||||
gint32 dummy1;
|
||||
gint32 dummy2;
|
||||
gpointer dummy3;
|
||||
gpointer dummy4;
|
||||
gpointer dummy5;
|
||||
guint32 dummy6;
|
||||
guint32 dummy7;
|
||||
gpointer padding[4];
|
||||
} GIBaseInfo;
|
||||
/* Documented in gibaseinfo.c */
|
||||
typedef struct _GIBaseInfo GIBaseInfo;
|
||||
typedef struct _GIBaseInfoClass GIBaseInfoClass;
|
||||
|
||||
/**
|
||||
* GICallableInfo:
|
||||
*
|
||||
* Represents a callable, either #GIFunctionInfo, #GICallbackInfo or
|
||||
* #GIVFuncInfo.
|
||||
*/
|
||||
typedef GIBaseInfo GICallableInfo;
|
||||
/* Documented in gicallableinfo.c */
|
||||
typedef struct _GICallableInfo GICallableInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_callable_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIFunctionInfo:
|
||||
*
|
||||
* Represents a function, eg arguments and return value.
|
||||
*/
|
||||
typedef GIBaseInfo GIFunctionInfo;
|
||||
/* Documented in gifunctioninfo.c */
|
||||
typedef struct _GIFunctionInfo GIFunctionInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_function_info_get_type (void);
|
||||
|
||||
/**
|
||||
* SECTION:gicallbackinfo
|
||||
* @title: GICallbackInfo
|
||||
* @short_description: Struct representing a callback
|
||||
*
|
||||
* GICallbackInfo represents a callback.
|
||||
*/
|
||||
/* Documented in gicallbackinfo.c */
|
||||
typedef struct _GICallbackInfo GICallbackInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_callback_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GICallbackInfo:
|
||||
*
|
||||
* Represents a callback, eg arguments and return value.
|
||||
*/
|
||||
typedef GIBaseInfo GICallbackInfo;
|
||||
/* Documented in giregisteredtypeinfo.c */
|
||||
typedef struct _GIRegisteredTypeInfo GIRegisteredTypeInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_registered_type_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIRegisteredTypeInfo:
|
||||
*
|
||||
* Represent a registered type.
|
||||
*/
|
||||
typedef GIBaseInfo GIRegisteredTypeInfo;
|
||||
/* Documented in gistructinfo.c */
|
||||
typedef struct _GIStructInfo GIStructInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_struct_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIStructInfo:
|
||||
*
|
||||
* Represents a struct.
|
||||
*/
|
||||
typedef GIBaseInfo GIStructInfo;
|
||||
/* Documented in giunioninfo.c */
|
||||
typedef struct _GIUnionInfo GIUnionInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_union_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIUnionInfo:
|
||||
*
|
||||
* Represents a union.
|
||||
*/
|
||||
typedef GIBaseInfo GIUnionInfo;
|
||||
/* Documented in gienuminfo.c */
|
||||
typedef struct _GIEnumInfo GIEnumInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_enum_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIEnumInfo:
|
||||
*
|
||||
* Represents an enum or a flag.
|
||||
*/
|
||||
typedef GIBaseInfo GIEnumInfo;
|
||||
/* Documented in giobjectinfo.c */
|
||||
typedef struct _GIObjectInfo GIObjectInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIObjectInfo:
|
||||
*
|
||||
* Represents an object.
|
||||
*/
|
||||
typedef GIBaseInfo GIObjectInfo;
|
||||
/* Documented in giinterfaceinfo.c */
|
||||
typedef struct _GIInterfaceInfo GIInterfaceInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_interface_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIInterfaceInfo:
|
||||
*
|
||||
* Represents an interface.
|
||||
*/
|
||||
typedef GIBaseInfo GIInterfaceInfo;
|
||||
/* Documented in giconstantinfo.c */
|
||||
typedef struct _GIConstantInfo GIConstantInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_constant_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIConstantInfo:
|
||||
*
|
||||
* Represents a constant.
|
||||
*/
|
||||
typedef GIBaseInfo GIConstantInfo;
|
||||
/* Documented in givalueinfo.c */
|
||||
typedef struct _GIValueInfo GIValueInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_value_info_get_type (void);
|
||||
|
||||
/**
|
||||
* SECTION:givalueinfo
|
||||
* @title: GIValueInfo
|
||||
* @short_description: Struct representing a value
|
||||
*
|
||||
* GIValueInfo represents a value.
|
||||
*/
|
||||
/* Documented in gisignalinfo.c */
|
||||
typedef struct _GISignalInfo GISignalInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_signal_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIValueInfo:
|
||||
*
|
||||
* Represents a enum value of a #GIEnumInfo.
|
||||
*/
|
||||
typedef GIBaseInfo GIValueInfo;
|
||||
/* Documented in givfuncinfo.c */
|
||||
typedef struct _GIVFuncInfo GIVFuncInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_vfunc_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GISignalInfo:
|
||||
*
|
||||
* Represents a signal.
|
||||
*/
|
||||
typedef GIBaseInfo GISignalInfo;
|
||||
/* Documented in gipropertyinfo.c */
|
||||
typedef struct _GIPropertyInfo GIPropertyInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_property_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIVFuncInfo:
|
||||
*
|
||||
* Represents a virtual function.
|
||||
*/
|
||||
typedef GIBaseInfo GIVFuncInfo;
|
||||
/* Documented in gifieldinfo.c */
|
||||
typedef struct _GIFieldInfo GIFieldInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_field_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIPropertyInfo:
|
||||
*
|
||||
* Represents a property of a #GIObjectInfo or a #GIInterfaceInfo.
|
||||
*/
|
||||
typedef GIBaseInfo GIPropertyInfo;
|
||||
/* Documented in giarginfo.c */
|
||||
typedef struct _GIArgInfo GIArgInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_arg_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIFieldInfo:
|
||||
*
|
||||
* Represents a field of a #GIStructInfo or a #GIUnionInfo.
|
||||
*/
|
||||
typedef GIBaseInfo GIFieldInfo;
|
||||
/* Documented in gitypeinfo.c */
|
||||
typedef struct _GITypeInfo GITypeInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_type_info_get_type (void);
|
||||
|
||||
/**
|
||||
* GIArgInfo:
|
||||
*
|
||||
* Represents an argument.
|
||||
*/
|
||||
typedef GIBaseInfo GIArgInfo;
|
||||
|
||||
/**
|
||||
* GITypeInfo:
|
||||
*
|
||||
* Represents type information, direction, transfer etc.
|
||||
*/
|
||||
typedef GIBaseInfo GITypeInfo;
|
||||
|
||||
/**
|
||||
* GIUnresolvedInfo:
|
||||
*
|
||||
* Represents a unresolved type in a typelib.
|
||||
*/
|
||||
/* Documented in giunresolvedinfo.c */
|
||||
typedef struct _GIUnresolvedInfo GIUnresolvedInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_unresolved_info_get_type (void);
|
||||
|
||||
union _GIArgument
|
||||
{
|
||||
@ -261,6 +187,10 @@ typedef union _GIArgument GIArgument;
|
||||
* @GI_INFO_TYPE_TYPE: type information, see #GITypeInfo
|
||||
* @GI_INFO_TYPE_UNRESOLVED: unresolved type, a type which is not present in
|
||||
* the typelib, or any of its dependencies.
|
||||
* @GI_INFO_TYPE_CALLABLE: an abstract type representing any callable (function,
|
||||
* callback, vfunc) (Since: 2.80)
|
||||
* @GI_INFO_TYPE_REGISTERED_TYPE: an abstract type representing any registered
|
||||
* type (enum, interface, object, struct, union) (Since: 2.80)
|
||||
*
|
||||
* The type of a GIBaseInfo struct.
|
||||
*/
|
||||
@ -285,7 +215,10 @@ typedef enum
|
||||
GI_INFO_TYPE_FIELD,
|
||||
GI_INFO_TYPE_ARG,
|
||||
GI_INFO_TYPE_TYPE,
|
||||
GI_INFO_TYPE_UNRESOLVED
|
||||
GI_INFO_TYPE_UNRESOLVED,
|
||||
GI_INFO_TYPE_CALLABLE, /* 20 */
|
||||
GI_INFO_TYPE_REGISTERED_TYPE,
|
||||
/* keep GI_INFO_TYPE_N_TYPES in sync with this */
|
||||
} GIInfoType;
|
||||
|
||||
/**
|
||||
@ -423,16 +356,6 @@ typedef enum {
|
||||
*/
|
||||
#define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_UNICHAR+1)
|
||||
|
||||
#ifndef __GTK_DOC_IGNORE__
|
||||
/* These were removed and no longer appear in the typelib;
|
||||
* instead, the machine-specific versions like INT32 are
|
||||
* always used.
|
||||
*/
|
||||
#define GI_TYPE_TAG_SHORT GI_TYPE_TAG_SHORT_WAS_REMOVED
|
||||
#define GI_TYPE_TAG_INT GI_TYPE_TAG_INT_WAS_REMOVED
|
||||
#define GI_TYPE_TAG_LONG GI_TYPE_TAG_LONG_WAS_REMOVED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GIArrayType:
|
||||
* @GI_ARRAY_TYPE_C: a C array, char[] for instance
|
||||
|
@ -27,20 +27,21 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "giunioninfo.h"
|
||||
|
||||
/**
|
||||
* SECTION:giunioninfo
|
||||
* @title: GIUnionInfo
|
||||
* @short_description: Struct representing a union.
|
||||
* GIUnionInfo:
|
||||
*
|
||||
* GIUnionInfo represents a union type.
|
||||
* `GIUnionInfo` represents a union type.
|
||||
*
|
||||
* A union has methods and fields. Unions can optionally have a
|
||||
* discriminator, which is a field deciding what type of real union
|
||||
* fields is valid for specified instance.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -50,6 +51,7 @@
|
||||
* Obtain the number of fields this union has.
|
||||
*
|
||||
* Returns: number of fields
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_union_info_get_n_fields (GIUnionInfo *info)
|
||||
@ -65,10 +67,11 @@ gi_union_info_get_n_fields (GIUnionInfo *info)
|
||||
* @info: a #GIUnionInfo
|
||||
* @n: a field index
|
||||
*
|
||||
* Obtain the type information for field with specified index.
|
||||
* Obtain the type information for the field with the specified index.
|
||||
*
|
||||
* Returns: (transfer full): the #GIFieldInfo, free it with gi_base_info_unref()
|
||||
* when done.
|
||||
* Returns: (transfer full): the [type@GIRepository.FieldInfo], free it with
|
||||
* [method@GIRepository.BaseInfo.unref] when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIFieldInfo *
|
||||
gi_union_info_get_field (GIUnionInfo *info,
|
||||
@ -89,6 +92,7 @@ gi_union_info_get_field (GIUnionInfo *info,
|
||||
* Obtain the number of methods this union has.
|
||||
*
|
||||
* Returns: number of methods
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_union_info_get_n_methods (GIUnionInfo *info)
|
||||
@ -104,10 +108,11 @@ gi_union_info_get_n_methods (GIUnionInfo *info)
|
||||
* @info: a #GIUnionInfo
|
||||
* @n: a method index
|
||||
*
|
||||
* Obtain the type information for method with specified index.
|
||||
* Obtain the type information for the method with the specified index.
|
||||
*
|
||||
* Returns: (transfer full): the #GIFunctionInfo, free it with gi_base_info_unref()
|
||||
* when done.
|
||||
* Returns: (transfer full): the [type@GIRepository.FunctionInfo], free it
|
||||
* with [method@GIRepository.BaseInfo.unref] when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIFunctionInfo *
|
||||
gi_union_info_get_method (GIUnionInfo *info,
|
||||
@ -129,9 +134,10 @@ gi_union_info_get_method (GIUnionInfo *info,
|
||||
* gi_union_info_is_discriminated:
|
||||
* @info: a #GIUnionInfo
|
||||
*
|
||||
* Return true if this union contains discriminator field.
|
||||
* Return true if this union contains a discriminator field.
|
||||
*
|
||||
* Returns: %TRUE if this is a discriminated union, %FALSE otherwise
|
||||
* Returns: true if this is a discriminated union, false otherwise
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_union_info_is_discriminated (GIUnionInfo *info)
|
||||
@ -146,9 +152,10 @@ gi_union_info_is_discriminated (GIUnionInfo *info)
|
||||
* gi_union_info_get_discriminator_offset:
|
||||
* @info: a #GIUnionInfo
|
||||
*
|
||||
* Returns offset of the discriminator field in the structure.
|
||||
* Returns the offset of the discriminator field in the structure.
|
||||
*
|
||||
* Returns: offset in bytes of the discriminator
|
||||
* Returns: offset, in bytes, of the discriminator
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_union_info_get_discriminator_offset (GIUnionInfo *info)
|
||||
@ -165,8 +172,9 @@ gi_union_info_get_discriminator_offset (GIUnionInfo *info)
|
||||
*
|
||||
* Obtain the type information of the union discriminator.
|
||||
*
|
||||
* Returns: (transfer full): the #GITypeInfo, free it with gi_base_info_unref()
|
||||
* when done.
|
||||
* Returns: (transfer full): the [type@GIRepository.TypeInfo], free it with
|
||||
* [method@GIRepository.BaseInfo.unref] when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
GITypeInfo *
|
||||
gi_union_info_get_discriminator_type (GIUnionInfo *info)
|
||||
@ -181,12 +189,15 @@ gi_union_info_get_discriminator_type (GIUnionInfo *info)
|
||||
* @info: a #GIUnionInfo
|
||||
* @n: a union field index
|
||||
*
|
||||
* Obtain discriminator value assigned for n-th union field, i.e. n-th
|
||||
* union field is the active one if discriminator contains this
|
||||
* Obtain the discriminator value assigned for n-th union field, i.e. the n-th
|
||||
* union field is the active one if the discriminator contains this
|
||||
* constant.
|
||||
*
|
||||
* Returns: (transfer full): the #GIConstantInfo, free it with gi_base_info_unref()
|
||||
* when done.
|
||||
* If the union is not discriminated, `NULL` is returned.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the [type@GIRepository.ConstantInfo],
|
||||
* free it with [method@GIRepository.BaseInfo.unref] when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIConstantInfo *
|
||||
gi_union_info_get_discriminator (GIUnionInfo *info,
|
||||
@ -217,10 +228,11 @@ gi_union_info_get_discriminator (GIUnionInfo *info,
|
||||
* @info: a #GIUnionInfo
|
||||
* @name: a method name
|
||||
*
|
||||
* Obtain the type information for method named @name.
|
||||
* Obtain the type information for the method named @name.
|
||||
*
|
||||
* Returns: (transfer full): the #GIFunctionInfo, free it with gi_base_info_unref()
|
||||
* when done.
|
||||
* Returns: (transfer full): the [type@GIRepository.FunctionInfo], free it
|
||||
* with [method@GIRepository.BaseInfo.unref] when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIFunctionInfo *
|
||||
gi_union_info_find_method (GIUnionInfo *info,
|
||||
@ -243,7 +255,8 @@ gi_union_info_find_method (GIUnionInfo *info,
|
||||
*
|
||||
* Obtain the total size of the union.
|
||||
*
|
||||
* Returns: size of the union in bytes
|
||||
* Returns: size of the union, in bytes
|
||||
* Since: 2.80
|
||||
*/
|
||||
gsize
|
||||
gi_union_info_get_size (GIUnionInfo *info)
|
||||
@ -260,7 +273,8 @@ gi_union_info_get_size (GIUnionInfo *info)
|
||||
*
|
||||
* Obtain the required alignment of the union.
|
||||
*
|
||||
* Returns: required alignment in bytes
|
||||
* Returns: required alignment, in bytes
|
||||
* Since: 2.80
|
||||
*/
|
||||
gsize
|
||||
gi_union_info_get_alignment (GIUnionInfo *info)
|
||||
@ -277,9 +291,9 @@ gi_union_info_get_alignment (GIUnionInfo *info)
|
||||
*
|
||||
* Retrieves the name of the copy function for @info, if any is set.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the name of the copy function
|
||||
*
|
||||
* Since: 1.76
|
||||
* Returns: (transfer none) (nullable): the name of the copy function, or `NULL`
|
||||
* if none is set
|
||||
* Since: 2.80
|
||||
*/
|
||||
const char *
|
||||
gi_union_info_get_copy_function (GIUnionInfo *info)
|
||||
@ -304,9 +318,9 @@ gi_union_info_get_copy_function (GIUnionInfo *info)
|
||||
*
|
||||
* Retrieves the name of the free function for @info, if any is set.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the name of the free function
|
||||
*
|
||||
* Since: 1.76
|
||||
* Returns: (transfer none) (nullable): the name of the free function, or `NULL`
|
||||
* if none is set
|
||||
* Since: 2.80
|
||||
*/
|
||||
const char *
|
||||
gi_union_info_get_free_function (GIUnionInfo *info)
|
||||
@ -324,3 +338,12 @@ gi_union_info_get_free_function (GIUnionInfo *info)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gi_union_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_UNION;
|
||||
}
|
||||
|
@ -33,13 +33,15 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GI_IS_UNION_INFO
|
||||
* GI_IS_UNION_INFO:
|
||||
* @info: an info structure
|
||||
*
|
||||
* Checks if @info is a #GIUnionInfo.
|
||||
* Checks if @info is a [struct@GIRepository.UnionInfo].
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_IS_UNION_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNION)
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
gint gi_union_info_get_n_fields (GIUnionInfo *info);
|
||||
|
52
girepository/giunresolvedinfo.c
Normal file
52
girepository/giunresolvedinfo.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
* GObject introspection: Callable implementation
|
||||
*
|
||||
* Copyright (C) 2005 Matthias Clasen
|
||||
* Copyright 2023 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 <stdlib.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "giunresolvedinfo.h"
|
||||
|
||||
/**
|
||||
* SECTION:giunresolved
|
||||
* @title: GIUnresolvedInfo
|
||||
* @short_description: Struct representing an unresolved symbol
|
||||
*
|
||||
* GIUnresolvedInfo represents an unresolved symbol.
|
||||
*/
|
||||
|
||||
void
|
||||
gi_unresolved_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_UNRESOLVED;
|
||||
}
|
43
girepository/giunresolvedinfo.h
Normal file
43
girepository/giunresolvedinfo.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
* GObject introspection: Callable
|
||||
*
|
||||
* Copyright 2023 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
|
||||
|
||||
/**
|
||||
* GI_IS_UNRESOLVED_INFO
|
||||
* @info: an info structure
|
||||
*
|
||||
* Checks if @info is a #GIUnresolvedInfo or derived from it.
|
||||
*/
|
||||
#define GI_IS_UNRESOLVED_INFO(info) \
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNRESOLVED)
|
||||
|
||||
G_END_DECLS
|
@ -29,19 +29,20 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository/girepository.h>
|
||||
#include "gibaseinfo-private.h"
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
#include "givfuncinfo.h"
|
||||
|
||||
/**
|
||||
* SECTION:givfuncinfo
|
||||
* @title: GIVFuncInfo
|
||||
* @short_description: Struct representing a virtual function
|
||||
* GIVFuncInfo:
|
||||
*
|
||||
* GIVfuncInfo represents a virtual function.
|
||||
* `GIVfuncInfo` represents a virtual function.
|
||||
*
|
||||
* A virtual function is a callable object that belongs to either a
|
||||
* #GIObjectInfo or a #GIInterfaceInfo.
|
||||
* [type@GIRepository.ObjectInfo] or a [type@GIRepository.InterfaceInfo].
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
|
||||
GIVFuncInfo *
|
||||
@ -73,10 +74,13 @@ gi_base_info_find_vfunc (GIRealInfo *rinfo,
|
||||
* gi_vfunc_info_get_flags:
|
||||
* @info: a #GIVFuncInfo
|
||||
*
|
||||
* Obtain the flags for this virtual function info. See #GIVFuncInfoFlags for
|
||||
* more information about possible flag values.
|
||||
* Obtain the flags for this virtual function info.
|
||||
*
|
||||
* See [flags@GIRepository.VFuncInfoFlags] for more information about possible
|
||||
* flag values.
|
||||
*
|
||||
* Returns: the flags
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIVFuncInfoFlags
|
||||
gi_vfunc_info_get_flags (GIVFuncInfo *info)
|
||||
@ -112,9 +116,10 @@ gi_vfunc_info_get_flags (GIVFuncInfo *info)
|
||||
* @info: a #GIVFuncInfo
|
||||
*
|
||||
* Obtain the offset of the function pointer in the class struct. The value
|
||||
* 0xFFFF indicates that the struct offset is unknown.
|
||||
* `0xFFFF` indicates that the struct offset is unknown.
|
||||
*
|
||||
* Returns: the struct offset or 0xFFFF if it's unknown
|
||||
* Returns: the struct offset or `0xFFFF` if it’s unknown
|
||||
* Since: 2.80
|
||||
*/
|
||||
gint
|
||||
gi_vfunc_info_get_offset (GIVFuncInfo *info)
|
||||
@ -135,10 +140,12 @@ gi_vfunc_info_get_offset (GIVFuncInfo *info)
|
||||
* @info: a #GIVFuncInfo
|
||||
*
|
||||
* Obtain the signal for the virtual function if one is set.
|
||||
*
|
||||
* The signal comes from the object or interface to which
|
||||
* this virtual function belongs.
|
||||
*
|
||||
* Returns: (transfer full): the signal or %NULL if none set
|
||||
* Returns: (transfer full) (nullable): the signal or `NULL` if none set
|
||||
* Since: 2.80
|
||||
*/
|
||||
GISignalInfo *
|
||||
gi_vfunc_info_get_signal (GIVFuncInfo *info)
|
||||
@ -166,8 +173,9 @@ gi_vfunc_info_get_signal (GIVFuncInfo *info)
|
||||
*
|
||||
* Not all virtuals will have invokers.
|
||||
*
|
||||
* Returns: (transfer full): the #GIVFuncInfo or %NULL. Free it with
|
||||
* gi_base_info_unref() when done.
|
||||
* Returns: (transfer full) (nullable): the [type@GIRepository.FunctionInfo] or
|
||||
* `NULL`. Free it with gi_base_info_unref() when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIFunctionInfo *
|
||||
gi_vfunc_info_get_invoker (GIVFuncInfo *info)
|
||||
@ -187,7 +195,7 @@ gi_vfunc_info_get_invoker (GIVFuncInfo *info)
|
||||
return NULL;
|
||||
|
||||
container = rinfo->container;
|
||||
parent_type = gi_base_info_get_type (container);
|
||||
parent_type = gi_base_info_get_info_type (container);
|
||||
if (parent_type == GI_INFO_TYPE_OBJECT)
|
||||
return gi_object_info_get_method ((GIObjectInfo*)container, blob->invoker);
|
||||
else if (parent_type == GI_INFO_TYPE_INTERFACE)
|
||||
@ -202,10 +210,11 @@ gi_vfunc_info_get_invoker (GIVFuncInfo *info)
|
||||
* @implementor_gtype: #GType implementing this virtual function
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* This method will look up where inside the type struct of @implementor_gtype
|
||||
* is the implementation for @info.
|
||||
* Looks up where inside the type struct of @implementor_gtype is the
|
||||
* implementation for @info.
|
||||
*
|
||||
* Returns: address to a function or %NULL if an error happened
|
||||
* Returns: address to a function or `NULL` if an error happened
|
||||
* Since: 2.80
|
||||
*/
|
||||
gpointer
|
||||
gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
|
||||
@ -221,8 +230,12 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
|
||||
gpointer implementor_class, implementor_vtable;
|
||||
gpointer func = NULL;
|
||||
|
||||
container_info = gi_base_info_get_container (vfunc_info);
|
||||
if (gi_base_info_get_type (container_info) == GI_INFO_TYPE_OBJECT)
|
||||
g_return_val_if_fail (vfunc_info != NULL, NULL);
|
||||
g_return_val_if_fail (GI_IS_VFUNC_INFO (vfunc_info), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
container_info = gi_base_info_get_container ((GIBaseInfo *) vfunc_info);
|
||||
if (gi_base_info_get_info_type (container_info) == GI_INFO_TYPE_OBJECT)
|
||||
{
|
||||
object_info = (GIObjectInfo*) container_info;
|
||||
interface_info = NULL;
|
||||
@ -242,7 +255,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
|
||||
|
||||
if (strcmp (gi_base_info_get_name ( (GIBaseInfo*) field_info),
|
||||
gi_base_info_get_name ( (GIBaseInfo*) vfunc_info)) != 0) {
|
||||
gi_base_info_unref (field_info);
|
||||
gi_base_info_unref ((GIBaseInfo *) field_info);
|
||||
field_info = NULL;
|
||||
continue;
|
||||
}
|
||||
@ -276,7 +289,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
|
||||
offset = gi_field_info_get_offset (field_info);
|
||||
func = *(gpointer*) G_STRUCT_MEMBER_P (implementor_vtable, offset);
|
||||
g_type_class_unref (implementor_class);
|
||||
gi_base_info_unref (field_info);
|
||||
gi_base_info_unref ((GIBaseInfo *) field_info);
|
||||
|
||||
if (func == NULL)
|
||||
{
|
||||
@ -299,25 +312,26 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
|
||||
* gi_vfunc_info_invoke: (skip)
|
||||
* @info: a #GIVFuncInfo describing the virtual function to invoke
|
||||
* @implementor: #GType of the type that implements this virtual function
|
||||
* @in_args: (array length=n_in_args): an array of #GIArgument<!-- -->s, one for each in
|
||||
* parameter of @info. If there are no in parameter, @in_args
|
||||
* can be %NULL
|
||||
* @in_args: (array length=n_in_args) (nullable): an array of
|
||||
* [struct@GIRepository.Argument]s, one for each in parameter of @info. If
|
||||
* there are no in parameter, @in_args can be `NULL`
|
||||
* @n_in_args: the length of the @in_args array
|
||||
* @out_args: (array length=n_out_args): an array of #GIArgument<!-- -->s, one for each out
|
||||
* parameter of @info. If there are no out parameters, @out_args
|
||||
* may be %NULL
|
||||
* @out_args: (array length=n_out_args) (nullable): an array of
|
||||
* [struct@GIRepository.Argument]s, one for each out parameter of @info. If
|
||||
* there are no out parameters, @out_args may be `NULL`
|
||||
* @n_out_args: the length of the @out_args array
|
||||
* @return_value: return location for the return value of the
|
||||
* @return_value: (nullable): return location for the return value of the
|
||||
* function. If the function returns void, @return_value may be
|
||||
* %NULL
|
||||
* @error: return location for detailed error information, or %NULL
|
||||
* `NULL`
|
||||
* @error: return location for detailed error information, or `NULL`
|
||||
*
|
||||
* Invokes the function described in @info with the given
|
||||
* arguments. Note that inout parameters must appear in both
|
||||
* argument lists.
|
||||
*
|
||||
* Returns: %TRUE if the function has been invoked, %FALSE if an
|
||||
* Returns: true if the function has been invoked, false if an
|
||||
* error occurred.
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
gi_vfunc_info_invoke (GIVFuncInfo *info,
|
||||
@ -330,10 +344,20 @@ gi_vfunc_info_invoke (GIVFuncInfo *info,
|
||||
GError **error)
|
||||
{
|
||||
gpointer func;
|
||||
GError *local_error = NULL;
|
||||
|
||||
func = gi_vfunc_info_get_address (info, implementor, error);
|
||||
if (*error != NULL)
|
||||
return FALSE;
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
g_return_val_if_fail (GI_IS_VFUNC_INFO (info), FALSE);
|
||||
g_return_val_if_fail (in_args != NULL || n_in_args == 0, FALSE);
|
||||
g_return_val_if_fail (out_args != NULL || n_out_args == 0, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
func = gi_vfunc_info_get_address (info, implementor, &local_error);
|
||||
if (local_error != NULL)
|
||||
{
|
||||
g_propagate_error (error, g_steal_pointer (&local_error));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return gi_callable_info_invoke ((GICallableInfo*) info,
|
||||
func,
|
||||
@ -346,3 +370,12 @@ gi_vfunc_info_invoke (GIVFuncInfo *info,
|
||||
FALSE,
|
||||
error);
|
||||
}
|
||||
|
||||
void
|
||||
gi_vfunc_info_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GIBaseInfoClass *info_class = g_class;
|
||||
|
||||
info_class->info_type = GI_INFO_TYPE_VFUNC;
|
||||
}
|
||||
|
@ -33,13 +33,15 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GI_IS_VFUNC_INFO
|
||||
* GI_IS_VFUNC_INFO:
|
||||
* @info: an info structure
|
||||
*
|
||||
* Checks if @info is a #GIVfuncInfo.
|
||||
* Checks if @info is a [struct@GIRepository.VFuncInfo].
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define GI_IS_VFUNC_INFO(info) \
|
||||
(gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VFUNC)
|
||||
(gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_VFUNC)
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIVFuncInfoFlags gi_vfunc_info_get_flags (GIVFuncInfo *info);
|
||||
|
@ -23,10 +23,10 @@ subdir('cmph')
|
||||
|
||||
gir_dir_prefix = get_option('gir_dir_prefix')
|
||||
if gir_dir_prefix == '' or gir_dir_prefix == get_option('datadir')
|
||||
gir_dir_prefix = get_option('datadir')
|
||||
gir_dir_pc_prefix = '${datadir}'
|
||||
gir_dir_prefix = get_option('datadir')
|
||||
gir_dir_pc_prefix = '${datadir}'
|
||||
else
|
||||
gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix)
|
||||
gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix)
|
||||
endif
|
||||
|
||||
glib_girdir = get_option('prefix') / gir_dir_prefix / 'gir-1.0'
|
||||
@ -45,6 +45,7 @@ girepo_headers = files(
|
||||
'giarginfo.h',
|
||||
'gibaseinfo.h',
|
||||
'gicallableinfo.h',
|
||||
'gicallbackinfo.h',
|
||||
'giconstantinfo.h',
|
||||
'gienuminfo.h',
|
||||
'gifieldinfo.h',
|
||||
@ -54,17 +55,25 @@ girepo_headers = files(
|
||||
'gipropertyinfo.h',
|
||||
'giregisteredtypeinfo.h',
|
||||
'girepository.h',
|
||||
'girffi.h',
|
||||
'gisignalinfo.h',
|
||||
'gistructinfo.h',
|
||||
'gitypeinfo.h',
|
||||
'gitypelib.h',
|
||||
'gitypes.h',
|
||||
'giunioninfo.h',
|
||||
'giunresolvedinfo.h',
|
||||
'givfuncinfo.h',
|
||||
)
|
||||
|
||||
install_headers(girepo_headers, install_dir: gir_includedir)
|
||||
girepo_ffi_headers = [
|
||||
'girffi.h',
|
||||
]
|
||||
|
||||
girepo_ffi_sources = files(
|
||||
'girffi.c',
|
||||
)
|
||||
|
||||
install_headers(girepo_headers + girepo_ffi_headers, install_dir: gir_includedir)
|
||||
|
||||
gir_c_args = [
|
||||
'-DGI_COMPILATION',
|
||||
@ -110,7 +119,7 @@ if cc.get_id() != 'msvc'
|
||||
])
|
||||
endif
|
||||
|
||||
libgirepo_internals = static_library('girepository-internals',
|
||||
libgirepository_internals = static_library('girepository-internals',
|
||||
sources: [
|
||||
'girmodule.c',
|
||||
'girnode.c',
|
||||
@ -124,8 +133,8 @@ libgirepo_internals = static_library('girepository-internals',
|
||||
dependencies: [girepo_gthash_dep, libffi_dep],
|
||||
)
|
||||
|
||||
libgirepo_internals_dep = declare_dependency(
|
||||
link_with: libgirepo_internals,
|
||||
libgirepository_internals_dep = declare_dependency(
|
||||
link_with: libgirepository_internals,
|
||||
dependencies: libffi_dep,
|
||||
include_directories: [girepoinc],
|
||||
)
|
||||
@ -135,6 +144,7 @@ girepo_sources = files(
|
||||
'giarginfo.c',
|
||||
'gibaseinfo.c',
|
||||
'gicallableinfo.c',
|
||||
'gicallbackinfo.c',
|
||||
'giconstantinfo.c',
|
||||
'gienuminfo.c',
|
||||
'gifieldinfo.c',
|
||||
@ -151,6 +161,7 @@ girepo_sources = files(
|
||||
'gitypeinfo.c',
|
||||
'gitypelib.c',
|
||||
'giunioninfo.c',
|
||||
'giunresolvedinfo.c',
|
||||
'givfuncinfo.c',
|
||||
)
|
||||
|
||||
@ -164,8 +175,8 @@ if cc.get_id() != 'msvc'
|
||||
])
|
||||
endif
|
||||
|
||||
libgirepo = shared_library('girepository-2.0',
|
||||
sources: girepo_sources + [gi_visibility_h],
|
||||
libgirepository = shared_library('girepository-2.0',
|
||||
sources: girepo_sources + girepo_ffi_sources + [gi_visibility_h],
|
||||
include_directories: [configinc, girepoinc],
|
||||
c_args: gir_c_args,
|
||||
version: library_version,
|
||||
@ -178,13 +189,13 @@ libgirepo = shared_library('girepository-2.0',
|
||||
libgobject_dep,
|
||||
libgmodule_dep,
|
||||
libgio_dep,
|
||||
libgirepo_internals_dep,
|
||||
libgirepository_internals_dep,
|
||||
],
|
||||
install: true,
|
||||
)
|
||||
|
||||
libgirepo_dep = declare_dependency(
|
||||
link_with: libgirepo,
|
||||
libgirepository_dep = declare_dependency(
|
||||
link_with: libgirepository,
|
||||
dependencies: [libglib_dep, libgobject_dep, libgio_dep, libgmodule_dep],
|
||||
include_directories: [girepoinc],
|
||||
)
|
||||
@ -192,7 +203,7 @@ libgirepo_dep = declare_dependency(
|
||||
executable('gi-dump-types',
|
||||
sources: 'gi-dump-types.c',
|
||||
dependencies: [
|
||||
libgirepo_dep,
|
||||
libgirepository_dep,
|
||||
libgiounix_dep,
|
||||
libgiowin32_dep
|
||||
],
|
||||
@ -204,7 +215,7 @@ pkgconfig_variables = [
|
||||
'typelibdir=${libdir}/girepository-1.0',
|
||||
]
|
||||
|
||||
pkg.generate(libgirepo,
|
||||
pkg.generate(libgirepository,
|
||||
name: 'girepository',
|
||||
version: glib_version,
|
||||
filebase: 'girepository-2.0',
|
||||
@ -214,3 +225,34 @@ pkg.generate(libgirepo,
|
||||
libraries: [libglib_dep, libgobject_dep],
|
||||
)
|
||||
|
||||
if enable_gir
|
||||
libgirepository_gir_sources = [
|
||||
gi_visibility_h,
|
||||
girepo_headers,
|
||||
girepo_sources,
|
||||
]
|
||||
libgirepository_gir_packages = [ 'girepository-2.0' ]
|
||||
libgirepository_gir_args = [
|
||||
'-DGI_COMPILATION',
|
||||
'--symbol-prefix=gi',
|
||||
'--identifier-prefix=GI',
|
||||
]
|
||||
|
||||
girepository_gir = gnome.generate_gir(libgirepository,
|
||||
sources: libgirepository_gir_sources,
|
||||
namespace: 'GIRepository',
|
||||
nsversion: '2.0',
|
||||
identifier_prefix: 'GI',
|
||||
symbol_prefix: 'gi',
|
||||
export_packages: libgirepository_gir_packages,
|
||||
header: 'girepository/girepository.h',
|
||||
includes: [ glib_gir[0], gmodule_gir[0], gobject_gir[0], gio_gir[0] ],
|
||||
install: true,
|
||||
dependencies: [ libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep ],
|
||||
extra_args: gir_args + libgirepository_gir_args,
|
||||
)
|
||||
endif
|
||||
|
||||
if build_tests
|
||||
subdir('tests')
|
||||
endif
|
85
girepository/tests/meson.build
Normal file
85
girepository/tests/meson.build
Normal file
@ -0,0 +1,85 @@
|
||||
girepository_tests = {}
|
||||
|
||||
# Some GIR files are needed to test against
|
||||
if enable_gir
|
||||
girepository_tests += {
|
||||
'repository' : {
|
||||
'depends': [glib_gir, gobject_gir],
|
||||
},
|
||||
}
|
||||
endif
|
||||
|
||||
test_env = environment()
|
||||
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
||||
test_deps = [libm, thread_dep, libgirepository_dep]
|
||||
test_cargs = ['-DG_LOG_DOMAIN="GIRepository"', '-UG_DISABLE_ASSERT']
|
||||
test_cpp_args = test_cargs
|
||||
|
||||
foreach test_name, extra_args : girepository_tests
|
||||
source = extra_args.get('source', test_name + '.c')
|
||||
install = installed_tests_enabled and extra_args.get('install', true)
|
||||
installed_tests_env = extra_args.get('installed_tests_env', {})
|
||||
|
||||
if install
|
||||
test_conf = configuration_data()
|
||||
test_conf.set('installed_tests_dir', installed_tests_execdir)
|
||||
test_conf.set('program', test_name)
|
||||
test_env_override = ''
|
||||
if installed_tests_env != {}
|
||||
envs = []
|
||||
foreach var, value : installed_tests_env
|
||||
envs += '@0@=@1@'.format(var, value)
|
||||
endforeach
|
||||
test_env_override = '@0@ @1@ '.format(env_program.full_path(), ' '.join(envs))
|
||||
endif
|
||||
test_conf.set('env', test_env_override)
|
||||
configure_file(
|
||||
input: installed_tests_template_tap,
|
||||
output: test_name + '.test',
|
||||
install_dir: installed_tests_metadir,
|
||||
install_tag: 'tests',
|
||||
configuration: test_conf
|
||||
)
|
||||
endif
|
||||
|
||||
exe = executable(test_name, source,
|
||||
c_args: test_cargs + extra_args.get('c_args', []),
|
||||
cpp_args: test_cpp_args + extra_args.get('cpp_args', []),
|
||||
link_args: extra_args.get('link_args', []),
|
||||
override_options: extra_args.get('override_options', []),
|
||||
dependencies: test_deps + extra_args.get('dependencies', []),
|
||||
link_with: extra_args.get('link_with', []),
|
||||
install_dir: installed_tests_execdir,
|
||||
install_tag: 'tests',
|
||||
install: install,
|
||||
)
|
||||
|
||||
depends = [extra_args.get('depends', [])]
|
||||
suite = ['girepository', 'core'] + extra_args.get('suite', [])
|
||||
timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
|
||||
|
||||
if extra_args.get('can_fail', false)
|
||||
suite += 'failing'
|
||||
endif
|
||||
|
||||
foreach program : extra_args.get('extra_programs', [])
|
||||
depends += test_extra_programs_targets[program]
|
||||
endforeach
|
||||
|
||||
local_test_env = test_env
|
||||
foreach var, value : extra_args.get('env', {})
|
||||
local_test_env.append(var, value)
|
||||
endforeach
|
||||
|
||||
test(test_name, exe,
|
||||
args: extra_args.get('args', []),
|
||||
protocol: extra_args.get('protocol', test_protocol),
|
||||
depends: depends,
|
||||
env: local_test_env,
|
||||
timeout: timeout,
|
||||
suite: suite,
|
||||
should_fail: extra_args.get('should_fail', false),
|
||||
)
|
||||
endforeach
|
117
girepository/tests/repository.c
Normal file
117
girepository/tests/repository.c
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2023 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.1 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Philip Withnall <pwithnall@gnome.org>
|
||||
*/
|
||||
|
||||
#include "glib.h"
|
||||
#include "girepository.h"
|
||||
|
||||
static void
|
||||
test_repository_basic (void)
|
||||
{
|
||||
GIRepository *repository;
|
||||
char *gobject_typelib_dir = NULL;
|
||||
GSList *search_path;
|
||||
GITypelib *typelib = NULL;
|
||||
char **namespaces = NULL;
|
||||
const char *expected_namespaces[] = { "GLib", NULL };
|
||||
GError *local_error = NULL;
|
||||
|
||||
g_test_summary ("Test basic opening of a repository and requiring a typelib");
|
||||
|
||||
gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "gobject", NULL);
|
||||
g_test_message ("Using GI_TYPELIB_DIR = %s", gobject_typelib_dir);
|
||||
gi_repository_prepend_search_path (gobject_typelib_dir);
|
||||
|
||||
repository = gi_repository_new ();
|
||||
g_assert_nonnull (repository);
|
||||
|
||||
search_path = gi_repository_get_search_path ();
|
||||
g_assert_nonnull (search_path);
|
||||
g_assert_cmpstr (search_path->data, ==, gobject_typelib_dir);
|
||||
|
||||
typelib = gi_repository_require (repository, "GLib", "2.0", 0, &local_error);
|
||||
g_assert_no_error (local_error);
|
||||
g_assert_nonnull (typelib);
|
||||
|
||||
namespaces = gi_repository_get_loaded_namespaces (repository);
|
||||
g_assert_cmpstrv (namespaces, expected_namespaces);
|
||||
g_strfreev (namespaces);
|
||||
|
||||
g_free (gobject_typelib_dir);
|
||||
g_clear_object (&repository);
|
||||
}
|
||||
|
||||
static void
|
||||
test_repository_info (void)
|
||||
{
|
||||
GIRepository *repository;
|
||||
char *gobject_typelib_dir = NULL;
|
||||
GITypelib *typelib = NULL;
|
||||
GIObjectInfo *object_info = NULL;
|
||||
GISignalInfo *signal_info = NULL;
|
||||
GError *local_error = NULL;
|
||||
|
||||
g_test_summary ("Test retrieving some basic info blobs from a typelib");
|
||||
|
||||
gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "gobject", NULL);
|
||||
g_test_message ("Using GI_TYPELIB_DIR = %s", gobject_typelib_dir);
|
||||
gi_repository_prepend_search_path (gobject_typelib_dir);
|
||||
g_free (gobject_typelib_dir);
|
||||
|
||||
repository = gi_repository_new ();
|
||||
g_assert_nonnull (repository);
|
||||
|
||||
typelib = gi_repository_require (repository, "GObject", "2.0", 0, &local_error);
|
||||
g_assert_no_error (local_error);
|
||||
g_assert_nonnull (typelib);
|
||||
|
||||
object_info = (GIObjectInfo *) gi_repository_find_by_name (repository, "GObject", "Object");
|
||||
g_assert_nonnull (object_info);
|
||||
|
||||
g_assert_cmpint (gi_base_info_get_info_type ((GIBaseInfo *) object_info), ==, GI_INFO_TYPE_OBJECT);
|
||||
g_assert_cmpstr (gi_base_info_get_name ((GIBaseInfo *) object_info), ==, "Object");
|
||||
g_assert_cmpstr (gi_base_info_get_namespace ((GIBaseInfo *) object_info), ==, "GObject");
|
||||
|
||||
signal_info = gi_object_info_find_signal (object_info, "notify");
|
||||
g_assert_nonnull (signal_info);
|
||||
|
||||
g_assert_cmpint (gi_signal_info_get_flags (signal_info), ==,
|
||||
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS | G_SIGNAL_ACTION);
|
||||
|
||||
gi_base_info_unref ((GIBaseInfo *) signal_info);
|
||||
gi_base_info_unref ((GIBaseInfo *) object_info);
|
||||
g_clear_object (&repository);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
/* Isolate from the system typelibs and GIRs. */
|
||||
g_setenv ("GI_TYPELIB_PATH", "/dev/null", TRUE);
|
||||
g_setenv ("GI_GIR_PATH", "/dev/null", TRUE);
|
||||
|
||||
g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
|
||||
|
||||
g_test_add_func ("/repository/basic", test_repository_basic);
|
||||
g_test_add_func ("/repository/info", test_repository_info);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user