update glib to 2.72.3

This commit is contained in:
alexey.lysiuk 2022-08-30 16:15:20 +03:00
parent fc54fd298e
commit a85315c9ad
58 changed files with 1190 additions and 344 deletions

View file

@ -22,7 +22,7 @@ import os
import re import re
import sys import sys
VERSION_STR = '''glib-genmarshal version 2.68.3 VERSION_STR = '''glib-genmarshal version 2.72.3
glib-genmarshal comes with ABSOLUTELY NO WARRANTY. glib-genmarshal comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of glib-genmarshal under the terms of You may redistribute copies of glib-genmarshal under the terms of
the GNU General Public License which can be found in the the GNU General Public License which can be found in the

View file

@ -19,7 +19,7 @@ import errno
import codecs import codecs
import locale import locale
VERSION_STR = '''glib-mkenums version 2.68.3 VERSION_STR = '''glib-mkenums version 2.72.3
glib-mkenums comes with ABSOLUTELY NO WARRANTY. glib-mkenums comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of glib-mkenums under the terms of You may redistribute copies of glib-mkenums under the terms of
the GNU General Public License which can be found in the the GNU General Public License which can be found in the

View file

@ -20,6 +20,7 @@
#define __GLIB_GOBJECT_H_INSIDE__ #define __GLIB_GOBJECT_H_INSIDE__
#include <gobject/gbinding.h> #include <gobject/gbinding.h>
#include <gobject/gbindinggroup.h>
#include <gobject/gboxed.h> #include <gobject/gboxed.h>
#include <gobject/genums.h> #include <gobject/genums.h>
#include <gobject/glib-enumtypes.h> #include <gobject/glib-enumtypes.h>
@ -27,6 +28,7 @@
#include <gobject/gparam.h> #include <gobject/gparam.h>
#include <gobject/gparamspecs.h> #include <gobject/gparamspecs.h>
#include <gobject/gsignal.h> #include <gobject/gsignal.h>
#include <gobject/gsignalgroup.h>
#include <gobject/gsourceclosure.h> #include <gobject/gsourceclosure.h>
#include <gobject/gtype.h> #include <gobject/gtype.h>
#include <gobject/gtypemodule.h> #include <gobject/gtypemodule.h>

View file

@ -43,7 +43,7 @@ G_BEGIN_DECLS
* *
* Error domain for API in the g_unix_ namespace. Note that there is no * Error domain for API in the g_unix_ namespace. Note that there is no
* exported enumeration mapping %errno. Instead, all functions ensure that * exported enumeration mapping %errno. Instead, all functions ensure that
* %errno is relevant. The code for all #G_UNIX_ERROR is always 0, and the * %errno is relevant. The code for all %G_UNIX_ERROR is always 0, and the
* error message is always generated via g_strerror(). * error message is always generated via g_strerror().
* *
* It is expected that most code will not look at %errno from these APIs. * It is expected that most code will not look at %errno from these APIs.

View file

@ -112,6 +112,7 @@
#include <glib/deprecated/gthread.h> #include <glib/deprecated/gthread.h>
#include <glib/glib-autocleanups.h> #include <glib/glib-autocleanups.h>
#include <glib/glib-typeof.h>
#undef __GLIB_H_INSIDE__ #undef __GLIB_H_INSIDE__

View file

@ -125,7 +125,11 @@ void g_thread_foreach (GFunc thread_func,
#endif #endif
#define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32 #define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32
#ifndef G_OS_WIN32
#define G_STATIC_MUTEX_INIT { NULL, PTHREAD_MUTEX_INITIALIZER } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init)
#else
#define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) #define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init)
#endif
typedef struct typedef struct
{ {
GMutex *mutex; GMutex *mutex;

View file

@ -30,6 +30,7 @@
#endif #endif
#include <glib/gtypes.h> #include <glib/gtypes.h>
#include <string.h>
#if defined(__BIONIC__) && defined (GLIB_HAVE_ALLOCA_H) #if defined(__BIONIC__) && defined (GLIB_HAVE_ALLOCA_H)
# include <alloca.h> # include <alloca.h>
@ -81,6 +82,11 @@ G_END_DECLS
* way as out of stack space situations from infinite function recursion, i.e. * way as out of stack space situations from infinite function recursion, i.e.
* with a segmentation fault. * with a segmentation fault.
* *
* - Allowing @size to be specified by an untrusted party would allow for them
* to trigger a segmentation fault by specifying a large size, leading to a
* denial of service vulnerability. @size must always be entirely under the
* control of the program.
*
* - Special care has to be taken when mixing alloca() with GNU C variable sized arrays. * - Special care has to be taken when mixing alloca() with GNU C variable sized arrays.
* Stack space allocated with alloca() in the same scope as a variable sized array * Stack space allocated with alloca() in the same scope as a variable sized array
* will be freed together with the variable sized array upon exit of that scope, and * will be freed together with the variable sized array upon exit of that scope, and
@ -89,6 +95,22 @@ G_END_DECLS
* Returns: space for @size bytes, allocated on the stack * Returns: space for @size bytes, allocated on the stack
*/ */
#define g_alloca(size) alloca (size) #define g_alloca(size) alloca (size)
/**
* g_alloca0:
* @size: number of bytes to allocate.
*
* Wraps g_alloca() and initializes allocated memory to zeroes.
* If @size is `0` it returns %NULL.
*
* Note that the @size argument will be evaluated multiple times.
*
* Returns: (nullable) (transfer full): space for @size bytes, allocated on the stack
*
* Since: 2.72
*/
#define g_alloca0(size) ((size) == 0 ? NULL : memset (g_alloca (size), 0, (size)))
/** /**
* g_newa: * g_newa:
* @struct_type: Type of memory chunks to be allocated * @struct_type: Type of memory chunks to be allocated
@ -96,8 +118,28 @@ G_END_DECLS
* *
* Wraps g_alloca() in a more typesafe manner. * Wraps g_alloca() in a more typesafe manner.
* *
* As mentioned in the documentation for g_alloca(), @n_structs must always be
* entirely under the control of the program, or you may introduce a denial of
* service vulnerability. In addition, the multiplication of @struct_type by
* @n_structs is not checked, so an overflow may lead to a remote code execution
* vulnerability.
*
* Returns: Pointer to stack space for @n_structs chunks of type @struct_type * Returns: Pointer to stack space for @n_structs chunks of type @struct_type
*/ */
#define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs))) #define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs)))
/**
* g_newa0:
* @struct_type: the type of the elements to allocate.
* @n_structs: the number of elements to allocate.
*
* Wraps g_alloca0() in a more typesafe manner.
*
* Returns: (nullable) (transfer full): Pointer to stack space for @n_structs
* chunks of type @struct_type
*
* Since: 2.72
*/
#define g_newa0(struct_type, n_structs) ((struct_type*) g_alloca0 (sizeof (struct_type) * (gsize) (n_structs)))
#endif /* __G_ALLOCA_H__ */ #endif /* __G_ALLOCA_H__ */

View file

@ -25,11 +25,7 @@
#endif #endif
#include <glib/gtypes.h> #include <glib/gtypes.h>
#include <glib/glib-typeof.h>
#if defined(glib_typeof_2_68) && GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
/* for glib_typeof */
#include <type_traits>
#endif
G_BEGIN_DECLS G_BEGIN_DECLS
@ -108,7 +104,7 @@ G_END_DECLS
__atomic_store ((gint *)(atomic), &gais_temp, __ATOMIC_SEQ_CST); \ __atomic_store ((gint *)(atomic), &gais_temp, __ATOMIC_SEQ_CST); \
})) }))
#if defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) #if defined(glib_typeof)
#define g_atomic_pointer_get(atomic) \ #define g_atomic_pointer_get(atomic) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
@ -125,7 +121,7 @@ G_END_DECLS
(void) (0 ? (gpointer) * (atomic) : NULL); \ (void) (0 ? (gpointer) * (atomic) : NULL); \
__atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \
})) }))
#else /* if !(defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68)) */ #else /* if !(defined(glib_typeof) */
#define g_atomic_pointer_get(atomic) \ #define g_atomic_pointer_get(atomic) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
@ -142,7 +138,7 @@ G_END_DECLS
(void) (0 ? (gpointer) *(atomic) : NULL); \ (void) (0 ? (gpointer) *(atomic) : NULL); \
__atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \
})) }))
#endif /* if defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) */ #endif /* if defined(glib_typeof) */
#define g_atomic_int_inc(atomic) \ #define g_atomic_int_inc(atomic) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
@ -156,13 +152,25 @@ G_END_DECLS
(void) (0 ? *(atomic) ^ *(atomic) : 1); \ (void) (0 ? *(atomic) ^ *(atomic) : 1); \
__atomic_fetch_sub ((atomic), 1, __ATOMIC_SEQ_CST) == 1; \ __atomic_fetch_sub ((atomic), 1, __ATOMIC_SEQ_CST) == 1; \
})) }))
#if defined(glib_typeof) && defined(__cplusplus) && __cplusplus >= 201103L
/* See comments below about equivalent g_atomic_pointer_compare_and_exchange()
* shenanigans for type-safety when compiling in C++ mode. */
#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \
(G_GNUC_EXTENSION ({ \
glib_typeof (*(atomic)) gaicae_oldval = (oldval); \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
(void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \
__atomic_compare_exchange_n ((atomic), &gaicae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
}))
#else /* if !(defined(glib_typeof) && defined(__cplusplus) && __cplusplus >= 201103L) */
#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ #define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
gint gaicae_oldval = (oldval); \ gint gaicae_oldval = (oldval); \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
(void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \
__atomic_compare_exchange_n ((atomic), &gaicae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ __atomic_compare_exchange_n ((atomic), (void *) (&(gaicae_oldval)), (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
})) }))
#endif /* defined(glib_typeof) */
#define g_atomic_int_add(atomic, val) \ #define g_atomic_int_add(atomic, val) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
@ -212,7 +220,7 @@ G_END_DECLS
gpointer gapcae_oldval = (gpointer)(oldval); \ gpointer gapcae_oldval = (gpointer)(oldval); \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
(void) (0 ? (gpointer) *(atomic) : NULL); \ (void) (0 ? (gpointer) *(atomic) : NULL); \
__atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ __atomic_compare_exchange_n ((atomic), (void *) (&(gapcae_oldval)), (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
})) }))
#endif /* defined(glib_typeof) */ #endif /* defined(glib_typeof) */
#define g_atomic_pointer_add(atomic, val) \ #define g_atomic_pointer_add(atomic, val) \
@ -307,7 +315,7 @@ G_END_DECLS
__asm__ __volatile__ ("" : : : "memory"); \ __asm__ __volatile__ ("" : : : "memory"); \
gapg_result; \ gapg_result; \
})) }))
#if defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) #if defined(glib_typeof)
#define g_atomic_pointer_set(atomic, newval) \ #define g_atomic_pointer_set(atomic, newval) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
@ -316,7 +324,7 @@ G_END_DECLS
__asm__ __volatile__ ("" : : : "memory"); \ __asm__ __volatile__ ("" : : : "memory"); \
*(atomic) = (glib_typeof (*(atomic))) (gsize) (newval); \ *(atomic) = (glib_typeof (*(atomic))) (gsize) (newval); \
})) }))
#else /* if !(defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68)) */ #else /* if !(defined(glib_typeof) */
#define g_atomic_pointer_set(atomic, newval) \ #define g_atomic_pointer_set(atomic, newval) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
@ -325,7 +333,7 @@ G_END_DECLS
__asm__ __volatile__ ("" : : : "memory"); \ __asm__ __volatile__ ("" : : : "memory"); \
*(atomic) = (gpointer) (gsize) (newval); \ *(atomic) = (gpointer) (gsize) (newval); \
})) }))
#endif /* if defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) */ #endif /* if defined(glib_typeof) */
#define g_atomic_int_inc(atomic) \ #define g_atomic_int_inc(atomic) \
(G_GNUC_EXTENSION ({ \ (G_GNUC_EXTENSION ({ \
@ -428,7 +436,7 @@ G_END_DECLS
#define g_atomic_int_dec_and_test(atomic) \ #define g_atomic_int_dec_and_test(atomic) \
(g_atomic_int_dec_and_test ((gint *) (atomic))) (g_atomic_int_dec_and_test ((gint *) (atomic)))
#if defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) #if defined(glib_typeof)
/* The (void *) cast in the middle *looks* redundant, because /* The (void *) cast in the middle *looks* redundant, because
* g_atomic_pointer_get returns void * already, but it's to silence * g_atomic_pointer_get returns void * already, but it's to silence
* -Werror=bad-function-cast when we're doing something like: * -Werror=bad-function-cast when we're doing something like:
@ -438,7 +446,7 @@ G_END_DECLS
* non-pointer-typed result. */ * non-pointer-typed result. */
#define g_atomic_pointer_get(atomic) \ #define g_atomic_pointer_get(atomic) \
(glib_typeof (*(atomic))) (void *) ((g_atomic_pointer_get) ((void *) atomic)) (glib_typeof (*(atomic))) (void *) ((g_atomic_pointer_get) ((void *) atomic))
#else /* !(defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68)) */ #else /* !(defined(glib_typeof) */
#define g_atomic_pointer_get(atomic) \ #define g_atomic_pointer_get(atomic) \
(g_atomic_pointer_get (atomic)) (g_atomic_pointer_get (atomic))
#endif #endif

View file

@ -33,6 +33,7 @@ G_BEGIN_DECLS
* G_BOOKMARK_FILE_ERROR: * G_BOOKMARK_FILE_ERROR:
* *
* Error domain for bookmark file parsing. * Error domain for bookmark file parsing.
*
* Errors in this domain will be from the #GBookmarkFileError * Errors in this domain will be from the #GBookmarkFileError
* enumeration. See #GError for information on error domains. * enumeration. See #GError for information on error domains.
*/ */
@ -72,8 +73,7 @@ GQuark g_bookmark_file_error_quark (void);
/** /**
* GBookmarkFile: * GBookmarkFile:
* *
* The `GBookmarkFile` structure contains only * An opaque data structure representing a set of bookmarks.
* private data and should not be directly accessed.
*/ */
typedef struct _GBookmarkFile GBookmarkFile; typedef struct _GBookmarkFile GBookmarkFile;

View file

@ -85,6 +85,13 @@ GLIB_AVAILABLE_IN_ALL
gint g_bytes_compare (gconstpointer bytes1, gint g_bytes_compare (gconstpointer bytes1,
gconstpointer bytes2); gconstpointer bytes2);
GLIB_AVAILABLE_IN_2_70
gconstpointer g_bytes_get_region (GBytes *bytes,
gsize element_size,
gsize offset,
gsize n_elements);
G_END_DECLS G_END_DECLS
#endif /* __G_BYTES_H__ */ #endif /* __G_BYTES_H__ */

View file

@ -56,6 +56,7 @@ typedef enum {
* GChecksum: * GChecksum:
* *
* An opaque structure representing a checksumming operation. * An opaque structure representing a checksumming operation.
*
* To create a new GChecksum, use g_checksum_new(). To free * To create a new GChecksum, use g_checksum_new(). To free
* a GChecksum, use g_checksum_free(). * a GChecksum, use g_checksum_free().
* *

View file

@ -89,8 +89,7 @@ typedef gint64 GTimeSpan;
/** /**
* GDateTime: * GDateTime:
* *
* `GDateTime` is an opaque structure whose members * An opaque structure that represents a date and time, including a time zone.
* cannot be accessed directly.
* *
* Since: 2.26 * Since: 2.26
*/ */

View file

@ -31,7 +31,7 @@ G_BEGIN_DECLS
/** /**
* GError: * GError:
* @domain: error domain, e.g. #G_FILE_ERROR * @domain: error domain, e.g. %G_FILE_ERROR
* @code: error code, e.g. %G_FILE_ERROR_NOENT * @code: error code, e.g. %G_FILE_ERROR_NOENT
* @message: human-readable informative error message * @message: human-readable informative error message
* *
@ -244,6 +244,11 @@ void g_prefix_error (GError **err,
const gchar *format, const gchar *format,
...) G_GNUC_PRINTF (2, 3); ...) G_GNUC_PRINTF (2, 3);
/* if (err) prefix the string to the ->message */
GLIB_AVAILABLE_IN_2_70
void g_prefix_error_literal (GError **err,
const gchar *prefix);
/* g_propagate_error then g_error_prefix on dest */ /* g_propagate_error then g_error_prefix on dest */
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_propagate_prefixed_error (GError **dest, void g_propagate_prefixed_error (GError **dest,

View file

@ -61,6 +61,8 @@ GHashTable* g_hash_table_new_full (GHashFunc hash_func,
GEqualFunc key_equal_func, GEqualFunc key_equal_func,
GDestroyNotify key_destroy_func, GDestroyNotify key_destroy_func,
GDestroyNotify value_destroy_func); GDestroyNotify value_destroy_func);
GLIB_AVAILABLE_IN_2_72
GHashTable *g_hash_table_new_similar (GHashTable *other_hash_table);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_hash_table_destroy (GHashTable *hash_table); void g_hash_table_destroy (GHashTable *hash_table);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL

View file

@ -0,0 +1,43 @@
/* GLIB - Library of useful routines for C programming
* Copyright (C) 2021 Iain Lane, Xavier Claessens
*
* 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/>.
*/
#ifndef __GLIB_TYPEOF_H__
#define __GLIB_TYPEOF_H__
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
#error "Only <glib.h> can be included directly."
#endif
#include <glib/gversionmacros.h>
/*
* We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since
* __typeof__ is used in a few places in GLib, provide a pre-processor symbol
* to factor the check out from callers.
*
* This symbol is private.
*/
#undef glib_typeof
#if !defined(__cplusplus) && (G_GNUC_CHECK_VERSION(4, 8) || defined(__clang__))
#define glib_typeof(t) __typeof__ (t)
#elif defined(__cplusplus) && __cplusplus >= 201103L && GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
/* C++11 decltype() is close enough for our usage */
#include <type_traits>
#define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
#endif
#endif /* __GLIB_TYPEOF_H__ */

View file

@ -37,6 +37,12 @@
*/ */
#include <stddef.h> #include <stddef.h>
/*
* Note: Clang (but not clang-cl) defines __GNUC__ and __GNUC_MINOR__.
* Both Clang 11.1 on current Arch Linux and Apple's Clang 12.0 define
* __GNUC__ = 4 and __GNUC_MINOR__ = 2. So G_GNUC_CHECK_VERSION(4, 2) on
* current Clang will be 1.
*/
#ifdef __GNUC__ #ifdef __GNUC__
#define G_GNUC_CHECK_VERSION(major, minor) \ #define G_GNUC_CHECK_VERSION(major, minor) \
((__GNUC__ > (major)) || \ ((__GNUC__ > (major)) || \
@ -50,7 +56,7 @@
* where this is valid. This allows for warningless compilation of * where this is valid. This allows for warningless compilation of
* "long long" types even in the presence of '-ansi -pedantic'. * "long long" types even in the presence of '-ansi -pedantic'.
*/ */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) #if G_GNUC_CHECK_VERSION(2, 8)
#define G_GNUC_EXTENSION __extension__ #define G_GNUC_EXTENSION __extension__
#else #else
#define G_GNUC_EXTENSION #define G_GNUC_EXTENSION
@ -106,6 +112,40 @@
# define G_INLINE_FUNC static inline GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) # define G_INLINE_FUNC static inline GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline)
#endif /* G_IMPLEMENT_INLINES */ #endif /* G_IMPLEMENT_INLINES */
/*
* Attribute support detection. Works on clang and GCC >= 5
* https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
* https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
*/
#ifdef __has_attribute
#define g_macro__has_attribute __has_attribute
#else
/*
* Fallback for GCC < 5 and other compilers not supporting __has_attribute.
*/
#define g_macro__has_attribute(x) g_macro__has_attribute_##x
#define g_macro__has_attribute___pure__ G_GNUC_CHECK_VERSION (2, 96)
#define g_macro__has_attribute___malloc__ G_GNUC_CHECK_VERSION (2, 96)
#define g_macro__has_attribute___noinline__ G_GNUC_CHECK_VERSION (2, 96)
#define g_macro__has_attribute___sentinel__ G_GNUC_CHECK_VERSION (4, 0)
#define g_macro__has_attribute___alloc_size__ G_GNUC_CHECK_VERSION (4, 3)
#define g_macro__has_attribute___format__ G_GNUC_CHECK_VERSION (2, 4)
#define g_macro__has_attribute___format_arg__ G_GNUC_CHECK_VERSION (2, 4)
#define g_macro__has_attribute___noreturn__ (G_GNUC_CHECK_VERSION (2, 8) || (0x5110 <= __SUNPRO_C))
#define g_macro__has_attribute___const__ G_GNUC_CHECK_VERSION (2, 4)
#define g_macro__has_attribute___unused__ G_GNUC_CHECK_VERSION (2, 4)
#define g_macro__has_attribute___no_instrument_function__ G_GNUC_CHECK_VERSION (2, 4)
#define g_macro__has_attribute_fallthrough G_GNUC_CHECK_VERSION (6, 0)
#define g_macro__has_attribute___deprecated__ G_GNUC_CHECK_VERSION (3, 1)
#define g_macro__has_attribute_may_alias G_GNUC_CHECK_VERSION (3, 3)
#define g_macro__has_attribute_warn_unused_result G_GNUC_CHECK_VERSION (3, 4)
#define g_macro__has_attribute_cleanup G_GNUC_CHECK_VERSION (3, 3)
#endif
/* Provide macros to feature the GCC function attribute. /* Provide macros to feature the GCC function attribute.
*/ */
@ -188,14 +228,27 @@
* *
* Since: 2.58 * Since: 2.58
*/ */
/* Note: We cant annotate this with GLIB_AVAILABLE_MACRO_IN_2_58 because its
* used within the GLib headers in function declarations which are always
* evaluated when a header is included. This results in warnings in third party
* code which includes glib.h, even if the third party code doesnt use the new
* macro itself. */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #if g_macro__has_attribute(__pure__)
#define G_GNUC_PURE __attribute__((__pure__)) #define G_GNUC_PURE __attribute__((__pure__))
#define G_GNUC_MALLOC __attribute__((__malloc__))
#define G_GNUC_NO_INLINE __attribute__((noinline))
#else #else
#define G_GNUC_PURE #define G_GNUC_PURE
#endif
#if g_macro__has_attribute(__malloc__)
#define G_GNUC_MALLOC __attribute__ ((__malloc__))
#else
#define G_GNUC_MALLOC #define G_GNUC_MALLOC
#endif
#if g_macro__has_attribute(__noinline__)
#define G_GNUC_NO_INLINE __attribute__ ((__noinline__))
#else
#define G_GNUC_NO_INLINE #define G_GNUC_NO_INLINE
#endif #endif
@ -218,36 +271,12 @@
* *
* Since: 2.8 * Since: 2.8
*/ */
#if __GNUC__ >= 4 #if g_macro__has_attribute(__sentinel__)
#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) #define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
#else #else
#define G_GNUC_NULL_TERMINATED #define G_GNUC_NULL_TERMINATED
#endif #endif
/*
* We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since
* __typeof__ is used in a few places in GLib, provide a pre-processor symbol
* to factor the check out from callers.
*
* This symbol is private.
*/
#undef glib_typeof
#if !defined(__cplusplus) && \
((defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
defined(__clang__))
#define glib_typeof(t) __typeof__ (t)
#elif defined(__cplusplus) && __cplusplus >= 201103L
/* C++11 decltype() is close enough for our usage */
/* This needs `#include <type_traits>`, but we have guarded this feature with a
* `GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68` check, and such a check
* cannot be enforced in this header due to include ordering requirements.
* Within GLib itself, which use `glib_typeof` need to add the include
* themselves. See other examples in GLib for how to do this.
*/
#define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
#define glib_typeof_2_68
#endif
/* /*
* Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html * Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html
* These are not available on GCC, but since the pre-processor doesn't do * These are not available on GCC, but since the pre-processor doesn't do
@ -258,12 +287,6 @@
* So we define it to 0 to satisfy the pre-processor. * So we define it to 0 to satisfy the pre-processor.
*/ */
#ifdef __has_attribute
#define g_macro__has_attribute __has_attribute
#else
#define g_macro__has_attribute(x) 0
#endif
#ifdef __has_feature #ifdef __has_feature
#define g_macro__has_feature __has_feature #define g_macro__has_feature __has_feature
#else #else
@ -276,6 +299,12 @@
#define g_macro__has_builtin(x) 0 #define g_macro__has_builtin(x) 0
#endif #endif
#ifdef __has_extension
#define g_macro__has_extension __has_extension
#else
#define g_macro__has_extension(x) 0
#endif
/** /**
* G_GNUC_ALLOC_SIZE: * G_GNUC_ALLOC_SIZE:
* @x: the index of the argument specifying the allocation size * @x: the index of the argument specifying the allocation size
@ -319,8 +348,7 @@
* *
* Since: 2.18 * Since: 2.18
*/ */
#if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ #if g_macro__has_attribute(__alloc_size__)
(defined(__clang__) && g_macro__has_attribute(__alloc_size__))
#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) #define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) #define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
#else #else
@ -506,46 +534,73 @@
* See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005finstrument_005ffunction-function-attribute) for more details. * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005finstrument_005ffunction-function-attribute) for more details.
*/ */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) #if g_macro__has_attribute(__format__)
#if !defined (__clang__) && G_GNUC_CHECK_VERSION (4, 4) #if !defined (__clang__) && G_GNUC_CHECK_VERSION (4, 4)
#define G_GNUC_PRINTF( format_idx, arg_idx ) \ #define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (gnu_printf, format_idx, arg_idx))) __attribute__((__format__ (gnu_printf, format_idx, arg_idx)))
#define G_GNUC_SCANF( format_idx, arg_idx ) \ #define G_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (gnu_scanf, format_idx, arg_idx))) __attribute__((__format__ (gnu_scanf, format_idx, arg_idx)))
#define G_GNUC_STRFTIME( format_idx ) \ #define G_GNUC_STRFTIME( format_idx ) \
__attribute__((__format__ (gnu_strftime, format_idx, 0))) __attribute__((__format__ (gnu_strftime, format_idx, 0))) \
GLIB_AVAILABLE_MACRO_IN_2_60
#else #else
#define G_GNUC_PRINTF( format_idx, arg_idx ) \ #define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx))) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
#define G_GNUC_SCANF( format_idx, arg_idx ) \ #define G_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (__scanf__, format_idx, arg_idx))) __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
#define G_GNUC_STRFTIME( format_idx ) \ #define G_GNUC_STRFTIME( format_idx ) \
__attribute__((__format__ (__strftime__, format_idx, 0))) __attribute__((__format__ (__strftime__, format_idx, 0))) \
GLIB_AVAILABLE_MACRO_IN_2_60
#endif #endif
#define G_GNUC_FORMAT( arg_idx ) \
__attribute__((__format_arg__ (arg_idx))) #else
#define G_GNUC_NORETURN \
__attribute__((__noreturn__))
#define G_GNUC_CONST \
__attribute__((__const__))
#define G_GNUC_UNUSED \
__attribute__((__unused__))
#define G_GNUC_NO_INSTRUMENT \
__attribute__((__no_instrument_function__))
#else /* !__GNUC__ */
#define G_GNUC_PRINTF( format_idx, arg_idx ) #define G_GNUC_PRINTF( format_idx, arg_idx )
#define G_GNUC_SCANF( format_idx, arg_idx ) #define G_GNUC_SCANF( format_idx, arg_idx )
#define G_GNUC_STRFTIME( format_idx ) #define G_GNUC_STRFTIME( format_idx ) \
GLIB_AVAILABLE_MACRO_IN_2_60
#endif
#if g_macro__has_attribute(__format_arg__)
#define G_GNUC_FORMAT(arg_idx) \
__attribute__ ((__format_arg__ (arg_idx)))
#else
#define G_GNUC_FORMAT( arg_idx ) #define G_GNUC_FORMAT( arg_idx )
#endif
#if g_macro__has_attribute(__noreturn__)
#define G_GNUC_NORETURN \
__attribute__ ((__noreturn__))
#else
/* NOTE: MSVC has __declspec(noreturn) but unlike GCC __attribute__, /* NOTE: MSVC has __declspec(noreturn) but unlike GCC __attribute__,
* __declspec can only be placed at the start of the function prototype * __declspec can only be placed at the start of the function prototype
* and not at the end, so we can't use it without breaking API. * and not at the end, so we can't use it without breaking API.
*/ */
#define G_GNUC_NORETURN #define G_GNUC_NORETURN
#endif
#if g_macro__has_attribute(__const__)
#define G_GNUC_CONST \
__attribute__ ((__const__))
#else
#define G_GNUC_CONST #define G_GNUC_CONST
#endif
#if g_macro__has_attribute(__unused__)
#define G_GNUC_UNUSED \
__attribute__ ((__unused__))
#else
#define G_GNUC_UNUSED #define G_GNUC_UNUSED
#endif
#if g_macro__has_attribute(__no_instrument_function__)
#define G_GNUC_NO_INSTRUMENT \
__attribute__ ((__no_instrument_function__))
#else
#define G_GNUC_NO_INSTRUMENT #define G_GNUC_NO_INSTRUMENT
#endif /* !__GNUC__ */ #endif
/** /**
* G_GNUC_FALLTHROUGH: * G_GNUC_FALLTHROUGH:
@ -575,13 +630,13 @@
* *
* Since: 2.60 * Since: 2.60
*/ */
#if __GNUC__ > 6 #if g_macro__has_attribute(fallthrough)
#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) #define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) \
#elif g_macro__has_attribute (fallthrough) GLIB_AVAILABLE_MACRO_IN_2_60
#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
#else #else
#define G_GNUC_FALLTHROUGH #define G_GNUC_FALLTHROUGH \
#endif /* __GNUC__ */ GLIB_AVAILABLE_MACRO_IN_2_60
#endif
/** /**
* G_GNUC_DEPRECATED: * G_GNUC_DEPRECATED:
@ -601,7 +656,7 @@
* *
* Since: 2.2 * Since: 2.2
*/ */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) #if g_macro__has_attribute(__deprecated__)
#define G_GNUC_DEPRECATED __attribute__((__deprecated__)) #define G_GNUC_DEPRECATED __attribute__((__deprecated__))
#else #else
#define G_GNUC_DEPRECATED #define G_GNUC_DEPRECATED
@ -630,11 +685,13 @@
* *
* Since: 2.26 * Since: 2.26
*/ */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) #if G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__)
#define G_GNUC_DEPRECATED_FOR(f) \ #define G_GNUC_DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead"))) __attribute__((deprecated("Use " #f " instead"))) \
GLIB_AVAILABLE_MACRO_IN_2_26
#else #else
#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED #define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED \
GLIB_AVAILABLE_MACRO_IN_2_26
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#ifdef __ICC #ifdef __ICC
@ -643,7 +700,7 @@
_Pragma ("warning (disable:1478)") _Pragma ("warning (disable:1478)")
#define G_GNUC_END_IGNORE_DEPRECATIONS \ #define G_GNUC_END_IGNORE_DEPRECATIONS \
_Pragma ("warning (pop)") _Pragma ("warning (pop)")
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #elif G_GNUC_CHECK_VERSION(4, 6)
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
@ -664,6 +721,7 @@
#else #else
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#define G_GNUC_END_IGNORE_DEPRECATIONS #define G_GNUC_END_IGNORE_DEPRECATIONS
#define GLIB_CANNOT_IGNORE_DEPRECATIONS
#endif #endif
/** /**
@ -677,7 +735,7 @@
* *
* Since: 2.14 * Since: 2.14
*/ */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) #if g_macro__has_attribute(may_alias)
#define G_GNUC_MAY_ALIAS __attribute__((may_alias)) #define G_GNUC_MAY_ALIAS __attribute__((may_alias))
#else #else
#define G_GNUC_MAY_ALIAS #define G_GNUC_MAY_ALIAS
@ -701,7 +759,7 @@
* *
* Since: 2.10 * Since: 2.10
*/ */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) #if g_macro__has_attribute(warn_unused_result)
#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else #else
#define G_GNUC_WARN_UNUSED_RESULT #define G_GNUC_WARN_UNUSED_RESULT
@ -743,6 +801,9 @@
#if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__) #if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__)
#define G_ANALYZER_ANALYZING 1 #define G_ANALYZER_ANALYZING 1
#define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) #define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
#elif defined(__COVERITY__)
#define G_ANALYZER_ANALYZING 1
#define G_ANALYZER_NORETURN __attribute__((noreturn))
#else #else
#define G_ANALYZER_ANALYZING 0 #define G_ANALYZER_ANALYZING 0
#define G_ANALYZER_NORETURN #define G_ANALYZER_NORETURN
@ -754,7 +815,8 @@
#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */ #ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2) #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #if !defined(__cplusplus) && defined(__STDC_VERSION__) && \
(__STDC_VERSION__ >= 201112L || g_macro__has_feature(c_static_assert) || g_macro__has_extension(c_static_assert))
#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false") #define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \ #elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
(defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \ (defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \
@ -848,7 +910,7 @@
* fields through their offsets. * fields through their offsets.
*/ */
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined (_MSC_VER) #if G_GNUC_CHECK_VERSION(4, 0) || defined(_MSC_VER)
#define G_STRUCT_OFFSET(struct_type, member) \ #define G_STRUCT_OFFSET(struct_type, member) \
((glong) offsetof (struct_type, member)) ((glong) offsetof (struct_type, member))
#else #else
@ -907,9 +969,11 @@
* Since: 2.60 * Since: 2.60
*/ */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
#define G_ALIGNOF(type) _Alignof (type) #define G_ALIGNOF(type) _Alignof (type) \
GLIB_AVAILABLE_MACRO_IN_2_60
#else #else
#define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b)) #define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b)) \
GLIB_AVAILABLE_MACRO_IN_2_60
#endif #endif
/** /**
@ -956,7 +1020,7 @@
* evaluated when a header is included. This results in warnings in third party * evaluated when a header is included. This results in warnings in third party
* code which includes glib.h, even if the third party code doesnt use the new * code which includes glib.h, even if the third party code doesnt use the new
* macro itself. */ * macro itself. */
#if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__)) || (0x5110 <= __SUNPRO_C) #if g_macro__has_attribute(__noreturn__)
/* For compatibility with G_NORETURN_FUNCPTR on clang, use /* For compatibility with G_NORETURN_FUNCPTR on clang, use
__attribute__((__noreturn__)), not _Noreturn. */ __attribute__((__noreturn__)), not _Noreturn. */
# define G_NORETURN __attribute__ ((__noreturn__)) # define G_NORETURN __attribute__ ((__noreturn__))
@ -964,10 +1028,10 @@
/* Use MSVC specific syntax. */ /* Use MSVC specific syntax. */
# define G_NORETURN __declspec (noreturn) # define G_NORETURN __declspec (noreturn)
/* Use ISO C++11 syntax when the compiler supports it. */ /* Use ISO C++11 syntax when the compiler supports it. */
#elif (defined (__cplusplus) && __cplusplus >= 201103 && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) || defined (_MSC_VER) && (_MSC_VER >= 1900) #elif defined (__cplusplus) && __cplusplus >= 201103
# define G_NORETURN [[noreturn]] # define G_NORETURN [[noreturn]]
/* Use ISO C11 syntax when the compiler supports it. */ /* Use ISO C11 syntax when the compiler supports it. */
#elif (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112
# define G_NORETURN _Noreturn # define G_NORETURN _Noreturn
#else #else
# define G_NORETURN /* empty */ # define G_NORETURN /* empty */
@ -995,7 +1059,7 @@
* *
* Since: 2.68 * Since: 2.68
*/ */
#if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__)) || (0x5110 <= __SUNPRO_C) #if g_macro__has_attribute(__noreturn__)
# define G_NORETURN_FUNCPTR __attribute__ ((__noreturn__)) \ # define G_NORETURN_FUNCPTR __attribute__ ((__noreturn__)) \
GLIB_AVAILABLE_MACRO_IN_2_68 GLIB_AVAILABLE_MACRO_IN_2_68
#else #else
@ -1011,7 +1075,7 @@
* The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
* putting assignments in g_return_if_fail (). * putting assignments in g_return_if_fail ().
*/ */
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) #if G_GNUC_CHECK_VERSION(2, 0) && defined(__OPTIMIZE__)
#define _G_BOOLEAN_EXPR(expr) \ #define _G_BOOLEAN_EXPR(expr) \
G_GNUC_EXTENSION ({ \ G_GNUC_EXTENSION ({ \
int _g_boolean_var_; \ int _g_boolean_var_; \
@ -1028,7 +1092,14 @@
#define G_UNLIKELY(expr) (expr) #define G_UNLIKELY(expr) (expr)
#endif #endif
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) /* GLIB_CANNOT_IGNORE_DEPRECATIONS is defined above for compilers that do not
* have a way to temporarily suppress deprecation warnings. In these cases,
* suppress the deprecated attribute altogether (otherwise a simple #include
* <glib.h> will emit a barrage of warnings).
*/
#if defined(GLIB_CANNOT_IGNORE_DEPRECATIONS)
#define G_DEPRECATED
#elif G_GNUC_CHECK_VERSION(3, 1) || defined(__clang__)
#define G_DEPRECATED __attribute__((__deprecated__)) #define G_DEPRECATED __attribute__((__deprecated__))
#elif defined(_MSC_VER) && (_MSC_VER >= 1300) #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
#define G_DEPRECATED __declspec(deprecated) #define G_DEPRECATED __declspec(deprecated)
@ -1036,7 +1107,9 @@
#define G_DEPRECATED #define G_DEPRECATED
#endif #endif
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) #if defined(GLIB_CANNOT_IGNORE_DEPRECATIONS)
#define G_DEPRECATED_FOR(f) G_DEPRECATED
#elif G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__)
#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) #define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
#define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) #define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
@ -1044,7 +1117,7 @@
#define G_DEPRECATED_FOR(f) G_DEPRECATED #define G_DEPRECATED_FOR(f) G_DEPRECATED
#endif #endif
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) #if G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__)
#define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min))) #define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min)))
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
#define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min)) #define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min))
@ -1075,12 +1148,14 @@
#endif #endif
#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ #if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || \ (G_GNUC_CHECK_VERSION(4, 6) || \
__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)) __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4))
#define _GLIB_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x)) #define _GLIB_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x))
#define GLIB_DEPRECATED_MACRO _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol") #define GLIB_DEPRECATED_MACRO _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol")
#define GLIB_DEPRECATED_MACRO_FOR(f) _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol, replace with " #f) #define GLIB_DEPRECATED_MACRO_FOR(f) \
#define GLIB_UNAVAILABLE_MACRO(maj,min) _GLIB_GNUC_DO_PRAGMA(GCC warning "Not available before " #maj "." #min) _GLIB_GNUC_DO_PRAGMA(GCC warning G_STRINGIFY (Deprecated pre-processor symbol: replace with #f))
#define GLIB_UNAVAILABLE_MACRO(maj,min) \
_GLIB_GNUC_DO_PRAGMA(GCC warning G_STRINGIFY (Not available before maj.min))
#else #else
#define GLIB_DEPRECATED_MACRO #define GLIB_DEPRECATED_MACRO
#define GLIB_DEPRECATED_MACRO_FOR(f) #define GLIB_DEPRECATED_MACRO_FOR(f)
@ -1088,7 +1163,7 @@
#endif #endif
#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ #if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \
((defined (__GNUC__) && (__GNUC__ > 6 || (__GNUC__ == 6 && __GNUC_MINOR__ >= 1))) || \ (G_GNUC_CHECK_VERSION(6, 1) || \
(defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0))))
#define GLIB_DEPRECATED_ENUMERATOR G_DEPRECATED #define GLIB_DEPRECATED_ENUMERATOR G_DEPRECATED
#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) G_DEPRECATED_FOR(f) #define GLIB_DEPRECATED_ENUMERATOR_FOR(f) G_DEPRECATED_FOR(f)
@ -1100,7 +1175,7 @@
#endif #endif
#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ #if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \
((defined (__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))) || \ (G_GNUC_CHECK_VERSION(3, 1) || \
(defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0))))
#define GLIB_DEPRECATED_TYPE G_DEPRECATED #define GLIB_DEPRECATED_TYPE G_DEPRECATED
#define GLIB_DEPRECATED_TYPE_FOR(f) G_DEPRECATED_FOR(f) #define GLIB_DEPRECATED_TYPE_FOR(f) G_DEPRECATED_FOR(f)
@ -1113,7 +1188,7 @@
#ifndef __GI_SCANNER__ #ifndef __GI_SCANNER__
#if defined (__GNUC__) || defined (__clang__) #if g_macro__has_attribute(cleanup)
/* these macros are private */ /* these macros are private */
#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName #define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName

View file

@ -38,6 +38,26 @@ typedef enum /*< flags >*/
G_IO_NVAL GLIB_SYSDEF_POLLNVAL G_IO_NVAL GLIB_SYSDEF_POLLNVAL
} GIOCondition; } GIOCondition;
/**
* GMainContextFlags:
* @G_MAIN_CONTEXT_FLAGS_NONE: Default behaviour.
* @G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING: Assume that polling for events will
* free the thread to process other jobs. That's useful if you're using
* `g_main_context_{prepare,query,check,dispatch}` to integrate GMainContext in
* other event loops.
*
* Flags to pass to g_main_context_new_with_flags() which affect the behaviour
* of a #GMainContext.
*
* Since: 2.72
*/
GLIB_AVAILABLE_TYPE_IN_2_72
typedef enum /*< flags >*/
{
G_MAIN_CONTEXT_FLAGS_NONE = 0,
G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING = 1
} GMainContextFlags;
/** /**
* GMainContext: * GMainContext:
@ -102,8 +122,8 @@ typedef struct _GSourceCallbackFuncs GSourceCallbackFuncs;
* connected to a callback using g_source_set_callback(). The @dispatch * connected to a callback using g_source_set_callback(). The @dispatch
* function should call the callback function with @user_data and whatever * function should call the callback function with @user_data and whatever
* additional parameters are needed for this type of event source. The * additional parameters are needed for this type of event source. The
* return value of the @dispatch function should be #G_SOURCE_REMOVE if the * return value of the @dispatch function should be %G_SOURCE_REMOVE if the
* source should be removed or #G_SOURCE_CONTINUE to keep it. * source should be removed or %G_SOURCE_CONTINUE to keep it.
* @finalize: Called when the source is finalized. At this point, the source * @finalize: Called when the source is finalized. At this point, the source
* will have been destroyed, had its callback cleared, and have been removed * will have been destroyed, had its callback cleared, and have been removed
* from its #GMainContext, but it will still have its final reference count, * from its #GMainContext, but it will still have its final reference count,
@ -167,8 +187,8 @@ typedef struct _GSourceFuncs GSourceFuncs;
* different type to this type. Use G_SOURCE_FUNC() to avoid warnings about * different type to this type. Use G_SOURCE_FUNC() to avoid warnings about
* incompatible function types. * incompatible function types.
* *
* Returns: %FALSE if the source should be removed. #G_SOURCE_CONTINUE and * Returns: %FALSE if the source should be removed. %G_SOURCE_CONTINUE and
* #G_SOURCE_REMOVE are more memorable names for the return value. * %G_SOURCE_REMOVE are more memorable names for the return value.
*/ */
typedef gboolean (*GSourceFunc) (gpointer user_data); typedef gboolean (*GSourceFunc) (gpointer user_data);
@ -193,16 +213,20 @@ typedef gboolean (*GSourceFunc) (gpointer user_data);
/** /**
* GChildWatchFunc: * GChildWatchFunc:
* @pid: the process id of the child process * @pid: the process id of the child process
* @status: Status information about the child process, encoded * @wait_status: Status information about the child process, encoded
* in a platform-specific manner * in a platform-specific manner
* @user_data: user data passed to g_child_watch_add() * @user_data: user data passed to g_child_watch_add()
* *
* Prototype of a #GChildWatchSource callback, called when a child * Prototype of a #GChildWatchSource callback, called when a child
* process has exited. To interpret @status, see the documentation * process has exited.
* for g_spawn_check_exit_status(). *
* To interpret @wait_status, see the documentation
* for g_spawn_check_wait_status(). In particular,
* on Unix platforms, note that it is usually not equal
* to the integer passed to `exit()` or returned from `main()`.
*/ */
typedef void (*GChildWatchFunc) (GPid pid, typedef void (*GChildWatchFunc) (GPid pid,
gint status, gint wait_status,
gpointer user_data); gpointer user_data);
@ -264,8 +288,8 @@ typedef void (*GSourceDummyMarshal) (void);
struct _GSourceFuncs struct _GSourceFuncs
{ {
gboolean (*prepare) (GSource *source, gboolean (*prepare) (GSource *source,
gint *timeout_); gint *timeout_);/* Can be NULL */
gboolean (*check) (GSource *source); gboolean (*check) (GSource *source);/* Can be NULL */
gboolean (*dispatch) (GSource *source, gboolean (*dispatch) (GSource *source,
GSourceFunc callback, GSourceFunc callback,
gpointer user_data); gpointer user_data);
@ -304,8 +328,8 @@ struct _GSourceFuncs
* *
* Use this for high priority idle functions. * Use this for high priority idle functions.
* *
* GTK+ uses #G_PRIORITY_HIGH_IDLE + 10 for resizing operations, * GTK+ uses %G_PRIORITY_HIGH_IDLE + 10 for resizing operations,
* and #G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is * and %G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is
* done to ensure that any pending resizes are processed before any * done to ensure that any pending resizes are processed before any
* pending redraws, so that widgets are not redrawn twice unnecessarily.) * pending redraws, so that widgets are not redrawn twice unnecessarily.)
*/ */
@ -354,6 +378,10 @@ struct _GSourceFuncs
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GMainContext *g_main_context_new (void); GMainContext *g_main_context_new (void);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GLIB_AVAILABLE_IN_2_72
GMainContext *g_main_context_new_with_flags (GMainContextFlags flags);
G_GNUC_END_IGNORE_DEPRECATIONS
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GMainContext *g_main_context_ref (GMainContext *context); GMainContext *g_main_context_ref (GMainContext *context);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
@ -601,6 +629,9 @@ gboolean g_source_is_destroyed (GSource *source);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_source_set_name (GSource *source, void g_source_set_name (GSource *source,
const char *name); const char *name);
GLIB_AVAILABLE_IN_2_70
void g_source_set_static_name (GSource *source,
const char *name);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
const char * g_source_get_name (GSource *source); const char * g_source_get_name (GSource *source);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
@ -781,6 +812,15 @@ void g_main_context_invoke (GMainContext *context,
GSourceFunc function, GSourceFunc function,
gpointer data); gpointer data);
GLIB_AVAILABLE_STATIC_INLINE_IN_2_70
static inline int
g_steal_fd (int *fd_ptr)
{
int fd = *fd_ptr;
*fd_ptr = -1;
return fd;
}
/* Hook for GClosure / GSource integration. Don't touch */ /* Hook for GClosure / GSource integration. Don't touch */
GLIB_VAR GSourceFuncs g_timeout_funcs; GLIB_VAR GSourceFuncs g_timeout_funcs;
GLIB_VAR GSourceFuncs g_child_watch_funcs; GLIB_VAR GSourceFuncs g_child_watch_funcs;

View file

@ -30,11 +30,7 @@
#endif #endif
#include <glib/gutils.h> #include <glib/gutils.h>
#include <glib/glib-typeof.h>
#if defined(glib_typeof_2_68) && GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
/* for glib_typeof */
#include <type_traits>
#endif
G_BEGIN_DECLS G_BEGIN_DECLS
@ -115,7 +111,18 @@ gpointer g_try_realloc_n (gpointer mem,
gsize n_blocks, gsize n_blocks,
gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT;
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) GLIB_AVAILABLE_IN_2_72
gpointer g_aligned_alloc (gsize n_blocks,
gsize n_block_bytes,
gsize alignment) G_GNUC_WARN_UNUSED_RESULT G_GNUC_ALLOC_SIZE2(1,2);
GLIB_AVAILABLE_IN_2_72
gpointer g_aligned_alloc0 (gsize n_blocks,
gsize n_block_bytes,
gsize alignment) G_GNUC_WARN_UNUSED_RESULT G_GNUC_ALLOC_SIZE2(1,2);
GLIB_AVAILABLE_IN_2_72
void g_aligned_free (gpointer mem);
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
#define g_clear_pointer(pp, destroy) \ #define g_clear_pointer(pp, destroy) \
G_STMT_START \ G_STMT_START \
{ \ { \
@ -218,7 +225,7 @@ g_steal_pointer (gpointer pp)
} }
/* type safety */ /* type safety */
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) #if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
#define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp)) #define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp))
#else /* __GNUC__ */ #else /* __GNUC__ */
/* This version does not depend on gcc extensions, but gcc does not warn /* This version does not depend on gcc extensions, but gcc does not warn

View file

@ -189,6 +189,7 @@ struct _GLogField
* *
* Returns: %G_LOG_WRITER_HANDLED if the log entry was handled successfully; * Returns: %G_LOG_WRITER_HANDLED if the log entry was handled successfully;
* %G_LOG_WRITER_UNHANDLED otherwise * %G_LOG_WRITER_UNHANDLED otherwise
*
* Since: 2.50 * Since: 2.50
*/ */
typedef GLogWriterOutput (*GLogWriterFunc) (GLogLevelFlags log_level, typedef GLogWriterOutput (*GLogWriterFunc) (GLogLevelFlags log_level,
@ -248,6 +249,12 @@ GLIB_AVAILABLE_IN_2_68
gboolean g_log_writer_default_would_drop (GLogLevelFlags log_level, gboolean g_log_writer_default_would_drop (GLogLevelFlags log_level,
const char *log_domain); const char *log_domain);
/* G_MESSAGES_DEBUG enablement */
GLIB_AVAILABLE_IN_2_72
gboolean g_log_get_debug_enabled (void);
GLIB_AVAILABLE_IN_2_72
void g_log_set_debug_enabled (gboolean enabled);
/** /**
* G_DEBUG_HERE: * G_DEBUG_HERE:
* *

View file

@ -278,7 +278,7 @@ struct _GOptionEntry
* or %G_OPTION_ARG_FILENAME_ARRAY. * or %G_OPTION_ARG_FILENAME_ARRAY.
* *
* *
* Using #G_OPTION_REMAINING instead of simply scanning `argv` * Using %G_OPTION_REMAINING instead of simply scanning `argv`
* for leftover arguments has the advantage that GOption takes care of * for leftover arguments has the advantage that GOption takes care of
* necessary encoding conversions for strings or filenames. * necessary encoding conversions for strings or filenames.
* *
@ -286,6 +286,24 @@ struct _GOptionEntry
*/ */
#define G_OPTION_REMAINING "" #define G_OPTION_REMAINING ""
/**
* G_OPTION_ENTRY_NULL:
*
* A #GOptionEntry array requires a %NULL terminator, this macro can
* be used as terminator instead of an explicit `{ 0 }` but it cannot
* be assigned to a variable.
*
* |[
* GOptionEntry option[] = { G_OPTION_ENTRY_NULL };
* ]|
*
* Since: 2.70
*/
#define G_OPTION_ENTRY_NULL \
GLIB_AVAILABLE_MACRO_IN_2_70 \
{ NULL, 0, 0, 0, NULL, NULL, NULL }
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GOptionContext *g_option_context_new (const gchar *parameter_string); GOptionContext *g_option_context_new (const gchar *parameter_string);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL

View file

@ -33,15 +33,25 @@ GLIB_AVAILABLE_IN_ALL
GPatternSpec* g_pattern_spec_new (const gchar *pattern); GPatternSpec* g_pattern_spec_new (const gchar *pattern);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_pattern_spec_free (GPatternSpec *pspec); void g_pattern_spec_free (GPatternSpec *pspec);
GLIB_AVAILABLE_IN_2_70
GPatternSpec *g_pattern_spec_copy (GPatternSpec *pspec);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_pattern_spec_equal (GPatternSpec *pspec1, gboolean g_pattern_spec_equal (GPatternSpec *pspec1,
GPatternSpec *pspec2); GPatternSpec *pspec2);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_2_70
gboolean g_pattern_spec_match (GPatternSpec *pspec,
gsize string_length,
const gchar *string,
const gchar *string_reversed);
GLIB_AVAILABLE_IN_2_70
gboolean g_pattern_spec_match_string (GPatternSpec *pspec,
const gchar *string);
GLIB_DEPRECATED_IN_2_70_FOR (g_pattern_spec_match)
gboolean g_pattern_match (GPatternSpec *pspec, gboolean g_pattern_match (GPatternSpec *pspec,
guint string_length, guint string_length,
const gchar *string, const gchar *string,
const gchar *string_reversed); const gchar *string_reversed);
GLIB_AVAILABLE_IN_ALL GLIB_DEPRECATED_IN_2_70_FOR (g_pattern_spec_match_string)
gboolean g_pattern_match_string (GPatternSpec *pspec, gboolean g_pattern_match_string (GPatternSpec *pspec,
const gchar *string); const gchar *string);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL

View file

@ -23,11 +23,7 @@
#endif #endif
#include <glib/gmem.h> #include <glib/gmem.h>
#include <glib/glib-typeof.h>
#if defined(glib_typeof_2_68) && GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
/* for glib_typeof */
#include <type_traits>
#endif
G_BEGIN_DECLS G_BEGIN_DECLS
@ -76,7 +72,7 @@ gsize g_atomic_rc_box_get_size (gpointer mem_block);
#define g_atomic_rc_box_new0(type) \ #define g_atomic_rc_box_new0(type) \
((type *) g_atomic_rc_box_alloc0 (sizeof (type))) ((type *) g_atomic_rc_box_alloc0 (sizeof (type)))
#if defined(glib_typeof) && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) #if defined(glib_typeof)
/* Type check to avoid assigning references to different types */ /* Type check to avoid assigning references to different types */
#define g_rc_box_acquire(mem_block) \ #define g_rc_box_acquire(mem_block) \
((glib_typeof (mem_block)) (g_rc_box_acquire) (mem_block)) ((glib_typeof (mem_block)) (g_rc_box_acquire) (mem_block))

View file

@ -224,8 +224,8 @@ GQuark g_regex_error_quark (void);
* newlines). The "start of line" metacharacter ("^") matches only * newlines). The "start of line" metacharacter ("^") matches only
* at the start of the string, while the "end of line" metacharacter * at the start of the string, while the "end of line" metacharacter
* ("$") matches only at the end of the string, or before a terminating * ("$") matches only at the end of the string, or before a terminating
* newline (unless #G_REGEX_DOLLAR_ENDONLY is set). When * newline (unless %G_REGEX_DOLLAR_ENDONLY is set). When
* #G_REGEX_MULTILINE is set, the "start of line" and "end of line" * %G_REGEX_MULTILINE is set, the "start of line" and "end of line"
* constructs match immediately following or immediately before any * constructs match immediately following or immediately before any
* newline in the string, respectively, as well as at the very start * newline in the string, respectively, as well as at the very start
* and end. This can be changed within a pattern by a "(?m)" option * and end. This can be changed within a pattern by a "(?m)" option
@ -248,7 +248,7 @@ GQuark g_regex_error_quark (void);
* matches only at the end of the string. Without this option, a * matches only at the end of the string. Without this option, a
* dollar also matches immediately before the final character if * dollar also matches immediately before the final character if
* it is a newline (but not before any other newlines). This option * it is a newline (but not before any other newlines). This option
* is ignored if #G_REGEX_MULTILINE is set. * is ignored if %G_REGEX_MULTILINE is set.
* @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that * @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that
* they are not greedy by default, but become greedy if followed by "?". * they are not greedy by default, but become greedy if followed by "?".
* It can also be set by a "(?U)" option setting within the pattern. * It can also be set by a "(?U)" option setting within the pattern.
@ -324,14 +324,14 @@ typedef enum
* metacharacter. * metacharacter.
* @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is * @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is
* not the beginning of a line, so the circumflex metacharacter should * not the beginning of a line, so the circumflex metacharacter should
* not match before it. Setting this without #G_REGEX_MULTILINE (at * not match before it. Setting this without %G_REGEX_MULTILINE (at
* compile time) causes circumflex never to match. This option affects * compile time) causes circumflex never to match. This option affects
* only the behaviour of the circumflex metacharacter, it does not * only the behaviour of the circumflex metacharacter, it does not
* affect "\A". * affect "\A".
* @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is * @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is
* not the end of a line, so the dollar metacharacter should not match * not the end of a line, so the dollar metacharacter should not match
* it nor (except in multiline mode) a newline immediately before it. * it nor (except in multiline mode) a newline immediately before it.
* Setting this without #G_REGEX_MULTILINE (at compile time) causes * Setting this without %G_REGEX_MULTILINE (at compile time) causes
* dollar never to match. This option affects only the behaviour of * dollar never to match. This option affects only the behaviour of
* the dollar metacharacter, it does not affect "\Z" or "\z". * the dollar metacharacter, it does not affect "\Z" or "\z".
* @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid * @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid
@ -368,12 +368,12 @@ typedef enum
* single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
* U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
* U+2029 PARAGRAPH SEPARATOR. Since: 2.34 * U+2029 PARAGRAPH SEPARATOR. Since: 2.34
* @G_REGEX_MATCH_PARTIAL_SOFT: An alias for #G_REGEX_MATCH_PARTIAL. Since: 2.34 * @G_REGEX_MATCH_PARTIAL_SOFT: An alias for %G_REGEX_MATCH_PARTIAL. Since: 2.34
* @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to * @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to
* to #G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match * to %G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match
* is found, without continuing to search for a possible complete match. See * is found, without continuing to search for a possible complete match. See
* g_match_info_is_partial_match() for more information. Since: 2.34 * g_match_info_is_partial_match() for more information. Since: 2.34
* @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like #G_REGEX_MATCH_NOTEMPTY, but only applied to * @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like %G_REGEX_MATCH_NOTEMPTY, but only applied to
* the start of the matched string. For anchored * the start of the matched string. For anchored
* patterns this can only happen for pattern containing "\K". Since: 2.34 * patterns this can only happen for pattern containing "\K". Since: 2.34
* *

View file

@ -95,7 +95,7 @@ typedef enum
/** /**
* G_SPAWN_EXIT_ERROR: * G_SPAWN_EXIT_ERROR:
* *
* Error domain used by g_spawn_check_exit_status(). The code * Error domain used by g_spawn_check_wait_status(). The code
* will be the program exit code. * will be the program exit code.
*/ */
#define G_SPAWN_EXIT_ERROR g_spawn_exit_error_quark () #define G_SPAWN_EXIT_ERROR g_spawn_exit_error_quark ()
@ -259,21 +259,25 @@ gboolean g_spawn_sync (const gchar *working_directory,
gpointer user_data, gpointer user_data,
gchar **standard_output, gchar **standard_output,
gchar **standard_error, gchar **standard_error,
gint *exit_status, gint *wait_status,
GError **error); GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_spawn_command_line_sync (const gchar *command_line, gboolean g_spawn_command_line_sync (const gchar *command_line,
gchar **standard_output, gchar **standard_output,
gchar **standard_error, gchar **standard_error,
gint *exit_status, gint *wait_status,
GError **error); GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_spawn_command_line_async (const gchar *command_line, gboolean g_spawn_command_line_async (const gchar *command_line,
GError **error); GError **error);
GLIB_AVAILABLE_IN_2_34 GLIB_AVAILABLE_IN_2_70
gboolean g_spawn_check_exit_status (gint exit_status, gboolean g_spawn_check_wait_status (gint wait_status,
GError **error);
GLIB_DEPRECATED_IN_2_70_FOR(g_spawn_check_wait_status)
gboolean g_spawn_check_exit_status (gint wait_status,
GError **error); GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL

View file

@ -61,7 +61,7 @@ typedef struct stat GStatBuf;
* A few functions can't be handled in this way, since they are not defined * A few functions can't be handled in this way, since they are not defined
* in a portable system header that we could include here. * in a portable system header that we could include here.
* *
* #G_STDIO_WRAP_ON_UNIX is not public API and its behaviour is not guaranteed * G_STDIO_WRAP_ON_UNIX is not public API and its behaviour is not guaranteed
* in future. * in future.
*/ */

View file

@ -1,5 +1,6 @@
/* /*
* Copyright © 2020 Canonical Ltd. * Copyright © 2020 Canonical Ltd.
* Copyright © 2021 Alexandros Theodotou
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -50,6 +51,14 @@ GLIB_AVAILABLE_IN_2_68
void g_strv_builder_add (GStrvBuilder *builder, void g_strv_builder_add (GStrvBuilder *builder,
const char *value); const char *value);
GLIB_AVAILABLE_IN_2_70
void g_strv_builder_addv (GStrvBuilder *builder,
const char **value);
GLIB_AVAILABLE_IN_2_70
void g_strv_builder_add_many (GStrvBuilder *builder,
...) G_GNUC_NULL_TERMINATED;
GLIB_AVAILABLE_IN_2_68 GLIB_AVAILABLE_IN_2_68
GStrv g_strv_builder_end (GStrvBuilder *builder); GStrv g_strv_builder_end (GStrvBuilder *builder);

View file

@ -275,6 +275,7 @@ void g_test_init (int *argc,
* - g_get_user_config_dir() * - g_get_user_config_dir()
* - g_get_system_data_dirs() * - g_get_system_data_dirs()
* - g_get_user_data_dir() * - g_get_user_data_dir()
* - g_get_user_state_dir()
* - g_get_user_runtime_dir() * - g_get_user_runtime_dir()
* *
* The subdirectories may not be created by the test harness; as with normal * The subdirectories may not be created by the test harness; as with normal
@ -345,10 +346,19 @@ const char * g_test_get_path (void);
/* tell about failure */ /* tell about failure */
GLIB_AVAILABLE_IN_2_30 GLIB_AVAILABLE_IN_2_30
void g_test_fail (void); void g_test_fail (void);
GLIB_AVAILABLE_IN_2_70
void g_test_fail_printf (const char *format,
...) G_GNUC_PRINTF (1, 2);
GLIB_AVAILABLE_IN_2_38 GLIB_AVAILABLE_IN_2_38
void g_test_incomplete (const gchar *msg); void g_test_incomplete (const gchar *msg);
GLIB_AVAILABLE_IN_2_70
void g_test_incomplete_printf (const char *format,
...) G_GNUC_PRINTF (1, 2);
GLIB_AVAILABLE_IN_2_38 GLIB_AVAILABLE_IN_2_38
void g_test_skip (const gchar *msg); void g_test_skip (const gchar *msg);
GLIB_AVAILABLE_IN_2_70
void g_test_skip_printf (const char *format,
...) G_GNUC_PRINTF (1, 2);
GLIB_AVAILABLE_IN_2_38 GLIB_AVAILABLE_IN_2_38
gboolean g_test_failed (void); gboolean g_test_failed (void);
GLIB_AVAILABLE_IN_2_38 GLIB_AVAILABLE_IN_2_38
@ -506,6 +516,12 @@ void g_test_suite_add_suite (GTestSuite *suite,
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
int g_test_run_suite (GTestSuite *suite); int g_test_run_suite (GTestSuite *suite);
GLIB_AVAILABLE_IN_2_70
void g_test_case_free (GTestCase *test_case);
GLIB_AVAILABLE_IN_2_70
void g_test_suite_free (GTestSuite *suite);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_test_trap_assertions (const char *domain, void g_test_trap_assertions (const char *domain,
const char *file, const char *file,

View file

@ -51,6 +51,13 @@ GThreadPool * g_thread_pool_new (GFunc func,
gint max_threads, gint max_threads,
gboolean exclusive, gboolean exclusive,
GError **error); GError **error);
GLIB_AVAILABLE_IN_2_70
GThreadPool * g_thread_pool_new_full (GFunc func,
gpointer user_data,
GDestroyNotify item_free_func,
gint max_threads,
gboolean exclusive,
GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_thread_pool_free (GThreadPool *pool, void g_thread_pool_free (GThreadPool *pool,
gboolean immediate, gboolean immediate,

View file

@ -111,6 +111,10 @@ void g_tree_replace (GTree *tree,
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_tree_remove (GTree *tree, gboolean g_tree_remove (GTree *tree,
gconstpointer key); gconstpointer key);
GLIB_AVAILABLE_IN_2_70
void g_tree_remove_all (GTree *tree);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_tree_steal (GTree *tree, gboolean g_tree_steal (GTree *tree,
gconstpointer key); gconstpointer key);

View file

@ -424,56 +424,62 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str,
/* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */ /* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */
#if __GNUC__ >= 5 && !defined(__INTEL_COMPILER) #if __GNUC__ >= 5 && !defined(__INTEL_COMPILER)
#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS #define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
#elif g_macro__has_builtin(__builtin_uadd_overflow) #elif g_macro__has_builtin(__builtin_add_overflow)
#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS #define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
#endif #endif
#endif #endif
#ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
#define g_uint_checked_add(dest, a, b) \ #define g_uint_checked_add(dest, a, b) \
_GLIB_CHECKED_ADD_U32(dest, a, b) (!__builtin_add_overflow(a, b, dest))
#define g_uint_checked_mul(dest, a, b) \ #define g_uint_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_U32(dest, a, b) (!__builtin_mul_overflow(a, b, dest))
#define g_uint64_checked_add(dest, a, b) \ #define g_uint64_checked_add(dest, a, b) \
_GLIB_CHECKED_ADD_U64(dest, a, b) (!__builtin_add_overflow(a, b, dest))
#define g_uint64_checked_mul(dest, a, b) \ #define g_uint64_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_U64(dest, a, b) (!__builtin_mul_overflow(a, b, dest))
#if GLIB_SIZEOF_SIZE_T == 8
#define g_size_checked_add(dest, a, b) \ #define g_size_checked_add(dest, a, b) \
_GLIB_CHECKED_ADD_U64(dest, a, b) (!__builtin_add_overflow(a, b, dest))
#define g_size_checked_mul(dest, a, b) \ #define g_size_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_U64(dest, a, b) (!__builtin_mul_overflow(a, b, dest))
#else
#define g_size_checked_add(dest, a, b) \ #else /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */
_GLIB_CHECKED_ADD_U32(dest, a, b)
#define g_size_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_U32(dest, a, b)
#endif
/* The names of the following inlines are private. Use the macro /* The names of the following inlines are private. Use the macro
* definitions above. * definitions above.
*/ */
#ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS static inline gboolean _GLIB_CHECKED_ADD_UINT (guint *dest, guint a, guint b) {
static inline gboolean _GLIB_CHECKED_ADD_U32 (guint32 *dest, guint32 a, guint32 b) {
return !__builtin_uadd_overflow(a, b, dest); }
static inline gboolean _GLIB_CHECKED_MUL_U32 (guint32 *dest, guint32 a, guint32 b) {
return !__builtin_umul_overflow(a, b, dest); }
static inline gboolean _GLIB_CHECKED_ADD_U64 (guint64 *dest, guint64 a, guint64 b) {
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
return !__builtin_uaddll_overflow(a, b, (unsigned long long *) dest); }
static inline gboolean _GLIB_CHECKED_MUL_U64 (guint64 *dest, guint64 a, guint64 b) {
return !__builtin_umulll_overflow(a, b, (unsigned long long *) dest); }
#else
static inline gboolean _GLIB_CHECKED_ADD_U32 (guint32 *dest, guint32 a, guint32 b) {
*dest = a + b; return *dest >= a; } *dest = a + b; return *dest >= a; }
static inline gboolean _GLIB_CHECKED_MUL_U32 (guint32 *dest, guint32 a, guint32 b) { static inline gboolean _GLIB_CHECKED_MUL_UINT (guint *dest, guint a, guint b) {
*dest = a * b; return !a || *dest / a == b; } *dest = a * b; return !a || *dest / a == b; }
static inline gboolean _GLIB_CHECKED_ADD_U64 (guint64 *dest, guint64 a, guint64 b) { static inline gboolean _GLIB_CHECKED_ADD_UINT64 (guint64 *dest, guint64 a, guint64 b) {
*dest = a + b; return *dest >= a; } *dest = a + b; return *dest >= a; }
static inline gboolean _GLIB_CHECKED_MUL_U64 (guint64 *dest, guint64 a, guint64 b) { static inline gboolean _GLIB_CHECKED_MUL_UINT64 (guint64 *dest, guint64 a, guint64 b) {
*dest = a * b; return !a || *dest / a == b; } *dest = a * b; return !a || *dest / a == b; }
#endif static inline gboolean _GLIB_CHECKED_ADD_SIZE (gsize *dest, gsize a, gsize b) {
*dest = a + b; return *dest >= a; }
static inline gboolean _GLIB_CHECKED_MUL_SIZE (gsize *dest, gsize a, gsize b) {
*dest = a * b; return !a || *dest / a == b; }
#define g_uint_checked_add(dest, a, b) \
_GLIB_CHECKED_ADD_UINT(dest, a, b)
#define g_uint_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_UINT(dest, a, b)
#define g_uint64_checked_add(dest, a, b) \
_GLIB_CHECKED_ADD_UINT64(dest, a, b)
#define g_uint64_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_UINT64(dest, a, b)
#define g_size_checked_add(dest, a, b) \
_GLIB_CHECKED_ADD_SIZE(dest, a, b)
#define g_size_checked_mul(dest, a, b) \
_GLIB_CHECKED_MUL_SIZE(dest, a, b)
#endif /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */
/* IEEE Standard 754 Single Precision Storage Format (gfloat): /* IEEE Standard 754 Single Precision Storage Format (gfloat):
* *

View file

@ -194,7 +194,8 @@ typedef enum
* @G_UNICODE_BREAK_HANGUL_T_JAMO: Hangul T Jamo (JT) * @G_UNICODE_BREAK_HANGUL_T_JAMO: Hangul T Jamo (JT)
* @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE: Hangul LV Syllable (H2) * @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE: Hangul LV Syllable (H2)
* @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE: Hangul LVT Syllable (H3) * @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE: Hangul LVT Syllable (H3)
* @G_UNICODE_BREAK_CLOSE_PARANTHESIS: Closing Parenthesis (CP). Since 2.28 * @G_UNICODE_BREAK_CLOSE_PARANTHESIS: Closing Parenthesis (CP). Since 2.28. Deprecated: 2.70: Use %G_UNICODE_BREAK_CLOSE_PARENTHESIS instead.
* @G_UNICODE_BREAK_CLOSE_PARENTHESIS: Closing Parenthesis (CP). Since 2.70
* @G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER: Conditional Japanese Starter (CJ). Since: 2.32 * @G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER: Conditional Japanese Starter (CJ). Since: 2.32
* @G_UNICODE_BREAK_HEBREW_LETTER: Hebrew Letter (HL). Since: 2.32 * @G_UNICODE_BREAK_HEBREW_LETTER: Hebrew Letter (HL). Since: 2.32
* @G_UNICODE_BREAK_REGIONAL_INDICATOR: Regional Indicator (RI). Since: 2.36 * @G_UNICODE_BREAK_REGIONAL_INDICATOR: Regional Indicator (RI). Since: 2.36
@ -248,6 +249,7 @@ typedef enum
G_UNICODE_BREAK_HANGUL_LV_SYLLABLE, G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE, G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE,
G_UNICODE_BREAK_CLOSE_PARANTHESIS, G_UNICODE_BREAK_CLOSE_PARANTHESIS,
G_UNICODE_BREAK_CLOSE_PARENTHESIS GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = G_UNICODE_BREAK_CLOSE_PARANTHESIS,
G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER, G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER,
G_UNICODE_BREAK_HEBREW_LETTER, G_UNICODE_BREAK_HEBREW_LETTER,
G_UNICODE_BREAK_REGIONAL_INDICATOR, G_UNICODE_BREAK_REGIONAL_INDICATOR,
@ -428,6 +430,12 @@ typedef enum
* @G_UNICODE_SCRIPT_DIVES_AKURU: Dives Akuru. Since: 2.66 * @G_UNICODE_SCRIPT_DIVES_AKURU: Dives Akuru. Since: 2.66
* @G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT: Khitan small script. Since: 2.66 * @G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT: Khitan small script. Since: 2.66
* @G_UNICODE_SCRIPT_YEZIDI: Yezidi. Since: 2.66 * @G_UNICODE_SCRIPT_YEZIDI: Yezidi. Since: 2.66
* @G_UNICODE_SCRIPT_CYPRO_MINOAN: Cypro-Minoan. Since: 2.72
* @G_UNICODE_SCRIPT_OLD_UYGHUR: Old Uyghur. Since: 2.72
* @G_UNICODE_SCRIPT_TANGSA: Tangsa. Since: 2.72
* @G_UNICODE_SCRIPT_TOTO: Toto. Since: 2.72
* @G_UNICODE_SCRIPT_VITHKUQI: Vithkuqi. Since: 2.72
* @G_UNICODE_SCRIPT_MATH: Mathematical notation. Since: 2.72
* *
* The #GUnicodeScript enumeration identifies different writing * The #GUnicodeScript enumeration identifies different writing
* systems. The values correspond to the names as defined in the * systems. The values correspond to the names as defined in the
@ -625,7 +633,17 @@ typedef enum
G_UNICODE_SCRIPT_CHORASMIAN, /* Chrs */ G_UNICODE_SCRIPT_CHORASMIAN, /* Chrs */
G_UNICODE_SCRIPT_DIVES_AKURU, /* Diak */ G_UNICODE_SCRIPT_DIVES_AKURU, /* Diak */
G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, /* Kits */ G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, /* Kits */
G_UNICODE_SCRIPT_YEZIDI /* Yezi */ G_UNICODE_SCRIPT_YEZIDI, /* Yezi */
/* Unicode 14.0 additions */
G_UNICODE_SCRIPT_CYPRO_MINOAN, /* Cpmn */
G_UNICODE_SCRIPT_OLD_UYGHUR, /* Ougr */
G_UNICODE_SCRIPT_TANGSA, /* Tnsa */
G_UNICODE_SCRIPT_TOTO, /* Toto */
G_UNICODE_SCRIPT_VITHKUQI, /* Vith */
/* not really a Unicode script, but part of ISO 15924 */
G_UNICODE_SCRIPT_MATH, /* Zmth */
} GUnicodeScript; } GUnicodeScript;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
@ -758,10 +776,15 @@ GLIB_VAR const gchar * const g_utf8_skip;
* g_utf8_next_char: * g_utf8_next_char:
* @p: Pointer to the start of a valid UTF-8 character * @p: Pointer to the start of a valid UTF-8 character
* *
* Skips to the next character in a UTF-8 string. The string must be * Skips to the next character in a UTF-8 string.
* valid; this macro is as fast as possible, and has no error-checking. *
* You would use this macro to iterate over a string character by * The string must be valid; this macro is as fast as possible, and has
* character. The macro returns the start of the next UTF-8 character. * no error-checking.
*
* You would use this macro to iterate over a string character by character.
*
* The macro returns the start of the next UTF-8 character.
*
* Before using this macro, use g_utf8_validate() to validate strings * Before using this macro, use g_utf8_validate() to validate strings
* that may contain invalid UTF-8. * that may contain invalid UTF-8.
*/ */

View file

@ -197,6 +197,8 @@ GLIB_AVAILABLE_IN_ALL
const gchar * g_get_user_config_dir (void); const gchar * g_get_user_config_dir (void);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
const gchar * g_get_user_cache_dir (void); const gchar * g_get_user_cache_dir (void);
GLIB_AVAILABLE_IN_2_72
const gchar * g_get_user_state_dir (void);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
const gchar * const * g_get_system_data_dirs (void); const gchar * const * g_get_system_data_dirs (void);

View file

@ -345,7 +345,9 @@ GQuark g_variant_parse_error_quark (void);
* A stack-allocated #GVariantBuilder must be initialized if it is * A stack-allocated #GVariantBuilder must be initialized if it is
* used together with g_auto() to avoid warnings or crashes if * used together with g_auto() to avoid warnings or crashes if
* function returns before g_variant_builder_init() is called on the * function returns before g_variant_builder_init() is called on the
* builder. This macro can be used as initializer instead of an * builder.
*
* This macro can be used as initializer instead of an
* explicit zeroing a variable when declaring it and a following * explicit zeroing a variable when declaring it and a following
* g_variant_builder_init(), but it cannot be assigned to a variable. * g_variant_builder_init(), but it cannot be assigned to a variable.
* *
@ -354,13 +356,20 @@ GQuark g_variant_parse_error_quark (void);
* the G_VARIANT_BUILDER_INIT() call, but rather in functions that * the G_VARIANT_BUILDER_INIT() call, but rather in functions that
* make sure that #GVariantBuilder is valid. * make sure that #GVariantBuilder is valid.
* *
* |[ * |[<!-- language="C" -->
* g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_BYTESTRING); * g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_BYTESTRING);
* ]| * ]|
* *
* Since: 2.50 * Since: 2.50
*/ */
#define G_VARIANT_BUILDER_INIT(variant_type) { { { 2942751021u, variant_type, { 0, } } } } #define G_VARIANT_BUILDER_INIT(variant_type) \
{ \
{ \
{ \
2942751021u /* == GVSB_MAGIC_PARTIAL, see gvariant.c */, variant_type, { 0, } \
} \
} \
}
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GVariantBuilder * g_variant_builder_new (const GVariantType *type); GVariantBuilder * g_variant_builder_new (const GVariantType *type);
@ -455,6 +464,7 @@ struct _GVariantDict {
* A stack-allocated #GVariantDict must be initialized if it is used * A stack-allocated #GVariantDict must be initialized if it is used
* together with g_auto() to avoid warnings or crashes if function * together with g_auto() to avoid warnings or crashes if function
* returns before g_variant_dict_init() is called on the builder. * returns before g_variant_dict_init() is called on the builder.
*
* This macro can be used as initializer instead of an explicit * This macro can be used as initializer instead of an explicit
* zeroing a variable when declaring it and a following * zeroing a variable when declaring it and a following
* g_variant_dict_init(), but it cannot be assigned to a variable. * g_variant_dict_init(), but it cannot be assigned to a variable.
@ -468,14 +478,21 @@ struct _GVariantDict {
* safely with a different @asv right after the variable was * safely with a different @asv right after the variable was
* initialized with G_VARIANT_DICT_INIT(). * initialized with G_VARIANT_DICT_INIT().
* *
* |[ * |[<!-- language="C" -->
* g_autoptr(GVariant) variant = get_asv_variant (); * g_autoptr(GVariant) variant = get_asv_variant ();
* g_auto(GVariantDict) dict = G_VARIANT_DICT_INIT (variant); * g_auto(GVariantDict) dict = G_VARIANT_DICT_INIT (variant);
* ]| * ]|
* *
* Since: 2.50 * Since: 2.50
*/ */
#define G_VARIANT_DICT_INIT(asv) { { { asv, 3488698669u, { 0, } } } } #define G_VARIANT_DICT_INIT(asv) \
{ \
{ \
{ \
asv, 3488698669u /* == GVSD_MAGIC_PARTIAL, see gvariant.c */, { 0, } \
} \
} \
}
GLIB_AVAILABLE_IN_2_40 GLIB_AVAILABLE_IN_2_40
GVariantDict * g_variant_dict_new (GVariant *from_asv); GVariantDict * g_variant_dict_new (GVariant *from_asv);

View file

@ -255,6 +255,26 @@
*/ */
#define GLIB_VERSION_2_68 (G_ENCODE_VERSION (2, 68)) #define GLIB_VERSION_2_68 (G_ENCODE_VERSION (2, 68))
/**
* GLIB_VERSION_2_70:
*
* A macro that evaluates to the 2.70 version of GLib, in a format
* that can be used by the C pre-processor.
*
* Since: 2.70
*/
#define GLIB_VERSION_2_70 (G_ENCODE_VERSION (2, 70))
/**
* GLIB_VERSION_2_72:
*
* A macro that evaluates to the 2.72 version of GLib, in a format
* that can be used by the C pre-processor.
*
* Since: 2.72
*/
#define GLIB_VERSION_2_72 (G_ENCODE_VERSION (2, 72))
/** /**
* GLIB_VERSION_CUR_STABLE: * GLIB_VERSION_CUR_STABLE:
* *
@ -1076,4 +1096,72 @@
# define GLIB_AVAILABLE_TYPE_IN_2_68 # define GLIB_AVAILABLE_TYPE_IN_2_68
#endif #endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_70
# define GLIB_DEPRECATED_IN_2_70 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_70_FOR(f) GLIB_DEPRECATED_FOR(f)
# define GLIB_DEPRECATED_MACRO_IN_2_70 GLIB_DEPRECATED_MACRO
# define GLIB_DEPRECATED_MACRO_IN_2_70_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f)
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_70 GLIB_DEPRECATED_ENUMERATOR
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f)
# define GLIB_DEPRECATED_TYPE_IN_2_70 GLIB_DEPRECATED_TYPE
# define GLIB_DEPRECATED_TYPE_IN_2_70_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_70 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_70_FOR(f) _GLIB_EXTERN
# define GLIB_DEPRECATED_MACRO_IN_2_70
# define GLIB_DEPRECATED_MACRO_IN_2_70_FOR(f)
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_70
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f)
# define GLIB_DEPRECATED_TYPE_IN_2_70
# define GLIB_DEPRECATED_TYPE_IN_2_70_FOR(f)
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_70
# define GLIB_AVAILABLE_IN_2_70 GLIB_UNAVAILABLE(2, 70)
# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_70 GLIB_UNAVAILABLE_STATIC_INLINE(2, 70)
# define GLIB_AVAILABLE_MACRO_IN_2_70 GLIB_UNAVAILABLE_MACRO(2, 70)
# define GLIB_AVAILABLE_ENUMERATOR_IN_2_70 GLIB_UNAVAILABLE_ENUMERATOR(2, 70)
# define GLIB_AVAILABLE_TYPE_IN_2_70 GLIB_UNAVAILABLE_TYPE(2, 70)
#else
# define GLIB_AVAILABLE_IN_2_70 _GLIB_EXTERN
# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_70
# define GLIB_AVAILABLE_MACRO_IN_2_70
# define GLIB_AVAILABLE_ENUMERATOR_IN_2_70
# define GLIB_AVAILABLE_TYPE_IN_2_70
#endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_72
# define GLIB_DEPRECATED_IN_2_72 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_72_FOR(f) GLIB_DEPRECATED_FOR(f)
# define GLIB_DEPRECATED_MACRO_IN_2_72 GLIB_DEPRECATED_MACRO
# define GLIB_DEPRECATED_MACRO_IN_2_72_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f)
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_72 GLIB_DEPRECATED_ENUMERATOR
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f)
# define GLIB_DEPRECATED_TYPE_IN_2_72 GLIB_DEPRECATED_TYPE
# define GLIB_DEPRECATED_TYPE_IN_2_72_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_72 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_72_FOR(f) _GLIB_EXTERN
# define GLIB_DEPRECATED_MACRO_IN_2_72
# define GLIB_DEPRECATED_MACRO_IN_2_72_FOR(f)
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_72
# define GLIB_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f)
# define GLIB_DEPRECATED_TYPE_IN_2_72
# define GLIB_DEPRECATED_TYPE_IN_2_72_FOR(f)
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_72
# define GLIB_AVAILABLE_IN_2_72 GLIB_UNAVAILABLE(2, 72)
# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_72 GLIB_UNAVAILABLE_STATIC_INLINE(2, 72)
# define GLIB_AVAILABLE_MACRO_IN_2_72 GLIB_UNAVAILABLE_MACRO(2, 72)
# define GLIB_AVAILABLE_ENUMERATOR_IN_2_72 GLIB_UNAVAILABLE_ENUMERATOR(2, 72)
# define GLIB_AVAILABLE_TYPE_IN_2_72 GLIB_UNAVAILABLE_TYPE(2, 72)
#else
# define GLIB_AVAILABLE_IN_2_72 _GLIB_EXTERN
# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_72
# define GLIB_AVAILABLE_MACRO_IN_2_72
# define GLIB_AVAILABLE_ENUMERATOR_IN_2_72
# define GLIB_AVAILABLE_TYPE_IN_2_72
#endif
#endif /* __G_VERSION_MACROS_H__ */ #endif /* __G_VERSION_MACROS_H__ */

View file

@ -53,8 +53,9 @@ typedef struct _GBinding GBinding;
* @to_value: the #GValue in which to store the transformed value * @to_value: the #GValue in which to store the transformed value
* @user_data: data passed to the transform function * @user_data: data passed to the transform function
* *
* A function to be called to transform @from_value to @to_value. If * A function to be called to transform @from_value to @to_value.
* this is the @transform_to function of a binding, then @from_value *
* If this is the @transform_to function of a binding, then @from_value
* is the @source_property on the @source object, and @to_value is the * is the @source_property on the @source object, and @to_value is the
* @target_property on the @target object. If this is the * @target_property on the @target object. If this is the
* @transform_from function of a %G_BINDING_BIDIRECTIONAL binding, * @transform_from function of a %G_BINDING_BIDIRECTIONAL binding,

View file

@ -0,0 +1,85 @@
/* GObject - GLib Type, Object, Parameter and Signal Library
*
* Copyright (C) 2015-2022 Christian Hergert <christian@hergert.me>
* Copyright (C) 2015 Garrett Regier <garrettregier@gmail.com>
*
* 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef __G_BINDING_GROUP_H__
#define __G_BINDING_GROUP_H__
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
#include <glib.h>
#include <gobject/gobject.h>
#include <gobject/gbinding.h>
G_BEGIN_DECLS
#define G_BINDING_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING_GROUP, GBindingGroup))
#define G_IS_BINDING_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING_GROUP))
#define G_TYPE_BINDING_GROUP (g_binding_group_get_type())
/**
* GBindingGroup:
*
* GBindingGroup is an opaque structure whose members
* cannot be accessed directly.
*
* Since: 2.72
*/
typedef struct _GBindingGroup GBindingGroup;
GLIB_AVAILABLE_IN_2_72
GType g_binding_group_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_2_72
GBindingGroup *g_binding_group_new (void);
GLIB_AVAILABLE_IN_2_72
gpointer g_binding_group_dup_source (GBindingGroup *self);
GLIB_AVAILABLE_IN_2_72
void g_binding_group_set_source (GBindingGroup *self,
gpointer source);
GLIB_AVAILABLE_IN_2_72
void g_binding_group_bind (GBindingGroup *self,
const gchar *source_property,
gpointer target,
const gchar *target_property,
GBindingFlags flags);
GLIB_AVAILABLE_IN_2_72
void g_binding_group_bind_full (GBindingGroup *self,
const gchar *source_property,
gpointer target,
const gchar *target_property,
GBindingFlags flags,
GBindingTransformFunc transform_to,
GBindingTransformFunc transform_from,
gpointer user_data,
GDestroyNotify user_data_destroy);
GLIB_AVAILABLE_IN_2_72
void g_binding_group_bind_with_closures (GBindingGroup *self,
const gchar *source_property,
gpointer target,
const gchar *target_property,
GBindingFlags flags,
GClosure *transform_to,
GClosure *transform_from);
G_END_DECLS
#endif /* __G_BINDING_GROUP_H__ */

View file

@ -42,6 +42,7 @@ G_BEGIN_DECLS
* @cl: a #GClosure * @cl: a #GClosure
* *
* Get the total number of notifiers connected with the closure @cl. * Get the total number of notifiers connected with the closure @cl.
*
* The count includes the meta marshaller, the finalize and invalidate notifiers * The count includes the meta marshaller, the finalize and invalidate notifiers
* and the marshal guards. Note that each guard counts as two notifiers. * and the marshal guards. Note that each guard counts as two notifiers.
* See g_closure_set_meta_marshal(), g_closure_add_finalize_notifier(), * See g_closure_set_meta_marshal(), g_closure_add_finalize_notifier(),
@ -78,10 +79,13 @@ typedef struct _GClosureNotifyData GClosureNotifyData;
* GCallback: * GCallback:
* *
* The type used for callback functions in structure definitions and function * The type used for callback functions in structure definitions and function
* signatures. This doesn't mean that all callback functions must take no * signatures.
* parameters and return void. The required signature of a callback function *
* is determined by the context in which is used (e.g. the signal to which it * This doesn't mean that all callback functions must take no parameters and
* is connected). Use G_CALLBACK() to cast the callback function to a #GCallback. * return void. The required signature of a callback function is determined by
* the context in which is used (e.g. the signal to which it is connected).
*
* Use G_CALLBACK() to cast the callback function to a #GCallback.
*/ */
typedef void (*GCallback) (void); typedef void (*GCallback) (void);
/** /**

View file

@ -8,7 +8,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
/* enumerations from "../../../../../source/glib/glib-2.68.3/gobject/../glib/gunicode.h" */ /* enumerations from "../../../../../source/glib/glib-2.72.3/gobject/../glib/gunicode.h" */
GLIB_AVAILABLE_IN_2_60 GType g_unicode_type_get_type (void) G_GNUC_CONST; GLIB_AVAILABLE_IN_2_60 GType g_unicode_type_get_type (void) G_GNUC_CONST;
#define G_TYPE_UNICODE_TYPE (g_unicode_type_get_type ()) #define G_TYPE_UNICODE_TYPE (g_unicode_type_get_type ())
GLIB_AVAILABLE_IN_2_60 GType g_unicode_break_type_get_type (void) G_GNUC_CONST; GLIB_AVAILABLE_IN_2_60 GType g_unicode_break_type_get_type (void) G_GNUC_CONST;

View file

@ -44,7 +44,7 @@ typedef gsize GType;
* The #GType for a boxed type holding a %NULL-terminated array of strings. * The #GType for a boxed type holding a %NULL-terminated array of strings.
* *
* The code fragments in the following example show the use of a property of * The code fragments in the following example show the use of a property of
* type #G_TYPE_STRV with g_object_class_install_property(), g_object_set() * type %G_TYPE_STRV with g_object_class_install_property(), g_object_set()
* and g_object_get(). * and g_object_get().
* *
* |[ * |[
@ -315,6 +315,15 @@ typedef gsize GType;
*/ */
#define G_TYPE_TREE (g_tree_get_type ()) #define G_TYPE_TREE (g_tree_get_type ())
/**
* G_TYPE_PATTERN_SPEC:
*
* The #GType for #GPatternSpec.
*
* Since: 2.70
*/
#define G_TYPE_PATTERN_SPEC (g_pattern_spec_get_type ())
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GType g_date_get_type (void) G_GNUC_CONST; GType g_date_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
@ -375,6 +384,8 @@ GLIB_AVAILABLE_IN_2_66
GType g_uri_get_type (void) G_GNUC_CONST; GType g_uri_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_2_68 GLIB_AVAILABLE_IN_2_68
GType g_tree_get_type (void) G_GNUC_CONST; GType g_tree_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_2_70
GType g_pattern_spec_get_type (void) G_GNUC_CONST;
GLIB_DEPRECATED_FOR('G_TYPE_VARIANT') GLIB_DEPRECATED_FOR('G_TYPE_VARIANT')
GType g_variant_get_gtype (void) G_GNUC_CONST; GType g_variant_get_gtype (void) G_GNUC_CONST;

View file

@ -28,11 +28,6 @@
#include <gobject/gsignal.h> #include <gobject/gsignal.h>
#include <gobject/gboxed.h> #include <gobject/gboxed.h>
#if defined(glib_typeof_2_68) && GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
/* for glib_typeof */
#include <type_traits>
#endif
G_BEGIN_DECLS G_BEGIN_DECLS
/* --- type macros --- */ /* --- type macros --- */
@ -50,6 +45,7 @@ G_BEGIN_DECLS
* @object: Object which is subject to casting. * @object: Object which is subject to casting.
* *
* Casts a #GObject or derived pointer into a (GObject*) pointer. * Casts a #GObject or derived pointer into a (GObject*) pointer.
*
* Depending on the current debugging level, this function may invoke * Depending on the current debugging level, this function may invoke
* certain runtime checks to identify invalid casts. * certain runtime checks to identify invalid casts.
*/ */
@ -149,7 +145,9 @@ G_BEGIN_DECLS
* @object: Object which is subject to casting. * @object: Object which is subject to casting.
* *
* Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*) * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*)
* pointer. Depending on the current debugging level, this function may invoke * pointer.
*
* Depending on the current debugging level, this function may invoke
* certain runtime checks to identify invalid casts. * certain runtime checks to identify invalid casts.
*/ */
#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned)) #define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))
@ -235,17 +233,34 @@ typedef void (*GObjectFinalizeFunc) (GObject *object);
* @where_the_object_was: the object being disposed * @where_the_object_was: the object being disposed
* *
* A #GWeakNotify function can be added to an object as a callback that gets * A #GWeakNotify function can be added to an object as a callback that gets
* triggered when the object is finalized. Since the object is already being * triggered when the object is finalized.
* disposed when the #GWeakNotify is called, there's not much you could do *
* with the object, apart from e.g. using its address as hash-index or the like. * Since the object is already being disposed when the #GWeakNotify is called,
* there's not much you could do with the object, apart from e.g. using its
* address as hash-index or the like.
*
* In particular, this means its invalid to call g_object_ref(),
* g_weak_ref_init(), g_weak_ref_set(), g_object_add_toggle_ref(),
* g_object_weak_ref(), g_object_add_weak_pointer() or any function which calls
* them on the object from this callback.
*/ */
typedef void (*GWeakNotify) (gpointer data, typedef void (*GWeakNotify) (gpointer data,
GObject *where_the_object_was); GObject *where_the_object_was);
/** /**
* GObject: * GObject:
* *
* All the fields in the GObject structure are private * The base object type.
* to the #GObject implementation and should never be accessed directly. *
* All the fields in the `GObject` structure are private to the implementation
* and should never be accessed directly.
*
* Since GLib 2.72, all #GObjects are guaranteed to be aligned to at least the
* alignment of the largest basic GLib type (typically this is #guint64 or
* #gdouble). If you need larger alignment for an element in a #GObject, you
* should allocate it on the heap (aligned), or arrange for your #GObject to be
* appropriately padded. This guarantee applies to the #GObject (or derived)
* struct, the #GObjectClass (or derived) struct, and any private data allocated
* by G_ADD_PRIVATE().
*/ */
struct _GObject struct _GObject
{ {
@ -357,14 +372,14 @@ struct _GObjectClass
/* padding */ /* padding */
gpointer pdummy[6]; gpointer pdummy[6];
}; };
/** /**
* GObjectConstructParam: * GObjectConstructParam:
* @pspec: the #GParamSpec of the construct parameter * @pspec: the #GParamSpec of the construct parameter
* @value: the value to set the parameter to * @value: the value to set the parameter to
* *
* The GObjectConstructParam struct is an auxiliary * The GObjectConstructParam struct is an auxiliary structure used to hand
* structure used to hand #GParamSpec/#GValue pairs to the @constructor of * #GParamSpec/#GValue pairs to the @constructor of a #GObjectClass.
* a #GObjectClass.
*/ */
struct _GObjectConstructParam struct _GObjectConstructParam
{ {
@ -375,9 +390,10 @@ struct _GObjectConstructParam
/** /**
* GInitiallyUnowned: * GInitiallyUnowned:
* *
* All the fields in the GInitiallyUnowned structure * A type for objects that have an initially floating reference.
* are private to the #GInitiallyUnowned implementation and should never be *
* accessed directly. * All the fields in the `GInitiallyUnowned` structure are private to the
* implementation and should never be accessed directly.
*/ */
/** /**
* GInitiallyUnownedClass: * GInitiallyUnownedClass:
@ -499,6 +515,8 @@ GLIB_AVAILABLE_IN_ALL
gboolean g_object_is_floating (gpointer object); gboolean g_object_is_floating (gpointer object);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gpointer g_object_ref_sink (gpointer object); gpointer g_object_ref_sink (gpointer object);
GLIB_AVAILABLE_IN_2_70
gpointer g_object_take_ref (gpointer object);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gpointer g_object_ref (gpointer object); gpointer g_object_ref (gpointer object);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
@ -518,7 +536,7 @@ GLIB_AVAILABLE_IN_ALL
void g_object_remove_weak_pointer (GObject *object, void g_object_remove_weak_pointer (GObject *object,
gpointer *weak_pointer_location); gpointer *weak_pointer_location);
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 && (!defined(glib_typeof_2_68) || GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68) #if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56
/* Make reference APIs type safe with macros */ /* Make reference APIs type safe with macros */
#define g_object_ref(Obj) ((glib_typeof (Obj)) (g_object_ref) (Obj)) #define g_object_ref(Obj) ((glib_typeof (Obj)) (g_object_ref) (Obj))
#define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (g_object_ref_sink) (Obj)) #define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (g_object_ref_sink) (Obj))
@ -534,7 +552,9 @@ void g_object_remove_weak_pointer (GObject *object,
* references. * references.
* *
* A callback function used for notification when the state * A callback function used for notification when the state
* of a toggle reference changes. See g_object_add_toggle_ref(). * of a toggle reference changes.
*
* See also: g_object_add_toggle_ref()
*/ */
typedef void (*GToggleNotify) (gpointer data, typedef void (*GToggleNotify) (gpointer data,
GObject *object, GObject *object,
@ -688,10 +708,11 @@ void g_clear_object (GObject **object_ptr);
* @new_object: (nullable) (transfer none): a pointer to the new #GObject to * @new_object: (nullable) (transfer none): a pointer to the new #GObject to
* assign to @object_ptr, or %NULL to clear the pointer * assign to @object_ptr, or %NULL to clear the pointer
* *
* Updates a #GObject pointer to refer to @new_object. It increments the * Updates a #GObject pointer to refer to @new_object.
* reference count of @new_object (if non-%NULL), decrements the reference *
* count of the current value of @object_ptr (if non-%NULL), and assigns * It increments the reference count of @new_object (if non-%NULL), decrements
* @new_object to @object_ptr. The assignment is not atomic. * the reference count of the current value of @object_ptr (if non-%NULL), and
* assigns @new_object to @object_ptr. The assignment is not atomic.
* *
* @object_ptr must not be %NULL, but can point to a %NULL value. * @object_ptr must not be %NULL, but can point to a %NULL value.
* *
@ -841,13 +862,15 @@ static inline void
* @new_object: (nullable) (transfer none): a pointer to the new #GObject to * @new_object: (nullable) (transfer none): a pointer to the new #GObject to
* assign to it, or %NULL to clear the pointer * assign to it, or %NULL to clear the pointer
* *
* Updates a pointer to weakly refer to @new_object. It assigns @new_object * Updates a pointer to weakly refer to @new_object.
* to @weak_pointer_location and ensures that @weak_pointer_location will
* automatically be set to %NULL if @new_object gets destroyed. The assignment
* is not atomic. The weak reference is not thread-safe, see
* g_object_add_weak_pointer() for details.
* *
* @weak_pointer_location must not be %NULL. * It assigns @new_object to @weak_pointer_location and ensures
* that @weak_pointer_location will automatically be set to %NULL
* if @new_object gets destroyed. The assignment is not atomic.
* The weak reference is not thread-safe, see g_object_add_weak_pointer()
* for details.
*
* The @weak_pointer_location argument must not be %NULL.
* *
* A macro is also included that allows this function to be used without * A macro is also included that allows this function to be used without
* pointer casts. The function itself is static inline, so its address may vary * pointer casts. The function itself is static inline, so its address may vary

View file

@ -145,7 +145,9 @@ G_BEGIN_DECLS
* Since 2.26 * Since 2.26
* *
* Through the #GParamFlags flag values, certain aspects of parameters * Through the #GParamFlags flag values, certain aspects of parameters
* can be configured. See also #G_PARAM_STATIC_STRINGS. * can be configured.
*
* See also: %G_PARAM_STATIC_STRINGS
*/ */
typedef enum typedef enum
{ {
@ -194,7 +196,7 @@ typedef struct _GParamSpecClass GParamSpecClass;
typedef struct _GParameter GParameter GLIB_DEPRECATED_TYPE_IN_2_54; typedef struct _GParameter GParameter GLIB_DEPRECATED_TYPE_IN_2_54;
typedef struct _GParamSpecPool GParamSpecPool; typedef struct _GParamSpecPool GParamSpecPool;
/** /**
* GParamSpec: (ref-func g_param_spec_ref_sink) (unref-func g_param_spec_uref) (set-value-func g_value_set_param) (get-value-func g_value_get_param) * GParamSpec: (ref-func g_param_spec_ref_sink) (unref-func g_param_spec_unref) (set-value-func g_value_set_param) (get-value-func g_value_get_param)
* @g_type_instance: private #GTypeInstance portion * @g_type_instance: private #GTypeInstance portion
* @name: name of this parameter: always an interned string * @name: name of this parameter: always an interned string
* @flags: #GParamFlags flags for this parameter * @flags: #GParamFlags flags for this parameter
@ -368,6 +370,7 @@ typedef struct _GParamSpecTypeInfo GParamSpecTypeInfo;
* This structure is used to provide the type system with the information * This structure is used to provide the type system with the information
* required to initialize and destruct (finalize) a parameter's class and * required to initialize and destruct (finalize) a parameter's class and
* instances thereof. * instances thereof.
*
* The initialized structure is passed to the g_param_type_register_static() * The initialized structure is passed to the g_param_type_register_static()
* The type system will perform a deep copy of this structure, so its memory * The type system will perform a deep copy of this structure, so its memory
* does not need to be persistent across invocation of * does not need to be persistent across invocation of

View file

@ -923,11 +923,14 @@ struct _GParamSpecObject
/** /**
* GParamSpecOverride: * GParamSpecOverride:
* *
* This is a type of #GParamSpec type that simply redirects operations to * A #GParamSpec derived structure that redirects operations to
* another paramspec. All operations other than getting or * other types of #GParamSpec.
* setting the value are redirected, including accessing the nick and *
* blurb, validating a value, and so forth. See * All operations other than getting or setting the value are redirected,
* g_param_spec_get_redirect_target() for retrieving the overridden * including accessing the nick and blurb, validating a value, and so
* forth.
*
* See g_param_spec_get_redirect_target() for retrieving the overridden
* property. #GParamSpecOverride is used in implementing * property. #GParamSpecOverride is used in implementing
* g_object_class_override_property(), and will not be directly useful * g_object_class_override_property(), and will not be directly useful
* unless you are implementing a new base type similar to GObject. * unless you are implementing a new base type similar to GObject.

View file

@ -36,9 +36,11 @@ typedef struct _GSignalInvocationHint GSignalInvocationHint;
* *
* This is the signature of marshaller functions, required to marshall * This is the signature of marshaller functions, required to marshall
* arrays of parameter values to signal emissions into C language callback * arrays of parameter values to signal emissions into C language callback
* invocations. It is merely an alias to #GClosureMarshal since the #GClosure * invocations.
* mechanism takes over responsibility of actual function invocation for the *
* signal system. * It is merely an alias to #GClosureMarshal since the #GClosure mechanism
* takes over responsibility of actual function invocation for the signal
* system.
*/ */
typedef GClosureMarshal GSignalCMarshaller; typedef GClosureMarshal GSignalCMarshaller;
/** /**
@ -58,11 +60,12 @@ typedef GVaClosureMarshal GSignalCVaMarshaller;
* the signal was emitted, followed by the parameters of the emission. * the signal was emitted, followed by the parameters of the emission.
* @data: user data associated with the hook. * @data: user data associated with the hook.
* *
* A simple function pointer to get invoked when the signal is emitted. This * A simple function pointer to get invoked when the signal is emitted.
* allows you to tie a hook to the signal type, so that it will trap all
* emissions of that signal, from any object.
* *
* You may not attach these to signals created with the #G_SIGNAL_NO_HOOKS flag. * Emission hooks allow you to tie a hook to the signal type, so that it will
* trap all emissions of that signal, from any object.
*
* You may not attach these to signals created with the %G_SIGNAL_NO_HOOKS flag.
* *
* Returns: whether it wants to stay connected. If it returns %FALSE, the signal * Returns: whether it wants to stay connected. If it returns %FALSE, the signal
* hook is disconnected (and destroyed). * hook is disconnected (and destroyed).
@ -81,14 +84,19 @@ typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint,
* *
* The signal accumulator is a special callback function that can be used * The signal accumulator is a special callback function that can be used
* to collect return values of the various callbacks that are called * to collect return values of the various callbacks that are called
* during a signal emission. The signal accumulator is specified at signal * during a signal emission.
* creation time, if it is left %NULL, no accumulation of callback return *
* values is performed. The return value of signal emissions is then the * The signal accumulator is specified at signal creation time, if it is
* value returned by the last callback. * left %NULL, no accumulation of callback return values is performed.
* The return value of signal emissions is then the value returned by the
* last callback.
* *
* Returns: The accumulator function returns whether the signal emission * Returns: The accumulator function returns whether the signal emission
* should be aborted. Returning %FALSE means to abort the * should be aborted. Returning %TRUE will continue with
* current emission and %TRUE is returned for continuation. * the signal emission. Returning %FALSE will abort the current emission.
* Since 2.62, returning %FALSE will skip to the CLEANUP stage. In this case,
* emission will occur as normal in the CLEANUP stage and the handler's
* return value will be accumulated.
*/ */
typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint, typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint,
GValue *return_accu, GValue *return_accu,
@ -123,9 +131,7 @@ typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint,
* functions for the #GSignalInvocationHint::run_type field to mark the first * functions for the #GSignalInvocationHint::run_type field to mark the first
* call to the accumulator function for a signal emission. Since 2.68. * call to the accumulator function for a signal emission. Since 2.68.
* *
* The signal flags are used to specify a signal's behaviour, the overall * The signal flags are used to specify a signal's behaviour.
* signal description outlines how especially the RUN flags control the
* stages of a signal emission.
*/ */
typedef enum typedef enum
{ {
@ -250,8 +256,9 @@ struct _GSignalInvocationHint
* gpointer data2); * gpointer data2);
* ]| * ]|
* *
* A structure holding in-depth information for a specific signal. It is * A structure holding in-depth information for a specific signal.
* filled in by the g_signal_query() function. *
* See also: g_signal_query()
*/ */
struct _GSignalQuery struct _GSignalQuery
{ {
@ -490,7 +497,7 @@ void g_signal_chain_from_overridden_handler (gpointer instance,
* *
* Connects a #GCallback function to a signal for a particular object. * Connects a #GCallback function to a signal for a particular object.
* *
* The handler will be called before the default handler of the signal. * The handler will be called synchronously, before the default handler of the signal. g_signal_emit() will not return control until all handlers are called.
* *
* See [memory management of signal handlers][signal-memory-management] for * See [memory management of signal handlers][signal-memory-management] for
* details on how to handle the return value and memory management of @data. * details on how to handle the return value and memory management of @data.
@ -508,7 +515,7 @@ void g_signal_chain_from_overridden_handler (gpointer instance,
* *
* Connects a #GCallback function to a signal for a particular object. * Connects a #GCallback function to a signal for a particular object.
* *
* The handler will be called after the default handler of the signal. * The handler will be called synchronously, after the default handler of the signal.
* *
* Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections)
*/ */

View file

@ -0,0 +1,93 @@
/* GObject - GLib Type, Object, Parameter and Signal Library
*
* Copyright (C) 2015-2022 Christian Hergert <christian@hergert.me>
* Copyright (C) 2015 Garrett Regier <garrettregier@gmail.com>
*
* 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef __G_SIGNAL_GROUP_H__
#define __G_SIGNAL_GROUP_H__
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
#include <glib.h>
#include <gobject/gobject.h>
#include <gobject/gsignal.h>
G_BEGIN_DECLS
#define G_SIGNAL_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SIGNAL_GROUP, GSignalGroup))
#define G_IS_SIGNAL_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SIGNAL_GROUP))
#define G_TYPE_SIGNAL_GROUP (g_signal_group_get_type())
/**
* GSignalGroup:
*
* #GSignalGroup is an opaque structure whose members
* cannot be accessed directly.
*
* Since: 2.72
*/
typedef struct _GSignalGroup GSignalGroup;
GLIB_AVAILABLE_IN_2_72
GType g_signal_group_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_2_72
GSignalGroup *g_signal_group_new (GType target_type);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_set_target (GSignalGroup *self,
gpointer target);
GLIB_AVAILABLE_IN_2_72
gpointer g_signal_group_dup_target (GSignalGroup *self);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_block (GSignalGroup *self);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_unblock (GSignalGroup *self);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_connect_object (GSignalGroup *self,
const gchar *detailed_signal,
GCallback c_handler,
gpointer object,
GConnectFlags flags);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_connect_data (GSignalGroup *self,
const gchar *detailed_signal,
GCallback c_handler,
gpointer data,
GClosureNotify notify,
GConnectFlags flags);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_connect (GSignalGroup *self,
const gchar *detailed_signal,
GCallback c_handler,
gpointer data);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_connect_after (GSignalGroup *self,
const gchar *detailed_signal,
GCallback c_handler,
gpointer data);
GLIB_AVAILABLE_IN_2_72
void g_signal_group_connect_swapped (GSignalGroup *self,
const gchar *detailed_signal,
GCallback c_handler,
gpointer data);
G_END_DECLS
#endif /* __G_SIGNAL_GROUP_H__ */

View file

@ -32,6 +32,7 @@ G_BEGIN_DECLS
* @type: A #GType value. * @type: A #GType value.
* *
* The fundamental type which is the ancestor of @type. * The fundamental type which is the ancestor of @type.
*
* Fundamental types are types that serve as ultimate bases for the derived types, * Fundamental types are types that serve as ultimate bases for the derived types,
* thus they are the roots of distinct inheritance hierarchies. * thus they are the roots of distinct inheritance hierarchies.
*/ */
@ -70,7 +71,8 @@ G_BEGIN_DECLS
* G_TYPE_CHAR: * G_TYPE_CHAR:
* *
* The fundamental type corresponding to #gchar. * The fundamental type corresponding to #gchar.
* The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. *
* The type designated by %G_TYPE_CHAR is unconditionally an 8-bit signed integer.
* This may or may not be the same type a the C type "gchar". * This may or may not be the same type a the C type "gchar".
*/ */
#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3) #define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3)
@ -213,6 +215,7 @@ G_BEGIN_DECLS
* @x: the fundamental type number. * @x: the fundamental type number.
* *
* Get the type ID for the fundamental type number @x. * Get the type ID for the fundamental type number @x.
*
* Use g_type_fundamental_next() instead of this macro to create new fundamental * Use g_type_fundamental_next() instead of this macro to create new fundamental
* types. * types.
* *
@ -281,6 +284,7 @@ G_BEGIN_DECLS
* @type: A #GType value * @type: A #GType value
* *
* Checks if @type is an interface type. * Checks if @type is an interface type.
*
* An interface type provides a pure API, the implementation * An interface type provides a pure API, the implementation
* of which is provided by another type (which is then said to conform * of which is provided by another type (which is then said to conform
* to the interface). GLib interfaces are somewhat analogous to Java * to the interface). GLib interfaces are somewhat analogous to Java
@ -370,6 +374,18 @@ G_BEGIN_DECLS
* Returns: %TRUE on success * Returns: %TRUE on success
*/ */
#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL) #define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL)
/**
* G_TYPE_IS_FINAL:
* @type: a #GType value
*
* Checks if @type is a final type. A final type cannot be derived any
* further.
*
* Returns: %TRUE on success
*
* Since: 2.70
*/
#define G_TYPE_IS_FINAL(type) (g_type_test_flags ((type), G_TYPE_FLAG_FINAL)) GLIB_AVAILABLE_MACRO_IN_2_70
/* Typedefs /* Typedefs
@ -439,7 +455,8 @@ struct _GTypeInterface
* @instance_size: the size of the instance structure * @instance_size: the size of the instance structure
* *
* A structure holding information for a specific type. * A structure holding information for a specific type.
* It is filled in by the g_type_query() function. *
* See also: g_type_query()
*/ */
struct _GTypeQuery struct _GTypeQuery
{ {
@ -630,13 +647,14 @@ struct _GTypeQuery
* @c_type: The C type for the private structure * @c_type: The C type for the private structure
* *
* Gets the private structure for a particular type. * Gets the private structure for a particular type.
*
* The private structure must have been registered in the * The private structure must have been registered in the
* class_init function with g_type_class_add_private(). * class_init function with g_type_class_add_private().
* *
* This macro should only be used in type implementations. * This macro should only be used in type implementations.
* *
* Since: 2.4 * Since: 2.4
* Deprecated: 2.58: Use %G_ADD_PRIVATE and the generated * Deprecated: 2.58: Use G_ADD_PRIVATE() and the generated
* `your_type_get_instance_private()` function instead * `your_type_get_instance_private()` function instead
* Returns: (not nullable): a pointer to the private data structure * Returns: (not nullable): a pointer to the private data structure
*/ */
@ -649,6 +667,7 @@ struct _GTypeQuery
* @c_type: The C type for the private structure * @c_type: The C type for the private structure
* *
* Gets the private class structure for a particular type. * Gets the private class structure for a particular type.
*
* The private structure must have been registered in the * The private structure must have been registered in the
* get_type() function with g_type_add_class_private(). * get_type() function with g_type_add_class_private().
* *
@ -761,9 +780,12 @@ int g_type_get_instance_count (GType type);
* @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize
* *
* A callback function used by the type system to do base initialization * A callback function used by the type system to do base initialization
* of the class structures of derived types. It is called as part of the * of the class structures of derived types.
* initialization process of all derived classes and should reallocate *
* or reset all dynamic class members copied over from the parent class. * This function is called as part of the initialization process of all derived
* classes and should reallocate or reset all dynamic class members copied over
* from the parent class.
*
* For example, class members (such as strings) that are not sufficiently * For example, class members (such as strings) that are not sufficiently
* handled by a plain memory copy of the parent class into the derived class * handled by a plain memory copy of the parent class into the derived class
* have to be altered. See GClassInitFunc() for a discussion of the class * have to be altered. See GClassInitFunc() for a discussion of the class
@ -776,8 +798,11 @@ typedef void (*GBaseInitFunc) (gpointer g_class);
* *
* A callback function used by the type system to finalize those portions * A callback function used by the type system to finalize those portions
* of a derived types class structure that were setup from the corresponding * of a derived types class structure that were setup from the corresponding
* GBaseInitFunc() function. Class finalization basically works the inverse * GBaseInitFunc() function.
* way in which class initialization is performed. *
* Class finalization basically works the inverse way in which class
* initialization is performed.
*
* See GClassInitFunc() for a discussion of the class initialization process. * See GClassInitFunc() for a discussion of the class initialization process.
*/ */
typedef void (*GBaseFinalizeFunc) (gpointer g_class); typedef void (*GBaseFinalizeFunc) (gpointer g_class);
@ -787,8 +812,9 @@ typedef void (*GBaseFinalizeFunc) (gpointer g_class);
* @class_data: The @class_data member supplied via the #GTypeInfo structure. * @class_data: The @class_data member supplied via the #GTypeInfo structure.
* *
* A callback function used by the type system to initialize the class * A callback function used by the type system to initialize the class
* of a specific type. This function should initialize all static class * of a specific type.
* members. *
* This function should initialize all static class members.
* *
* The initialization process of a class involves: * The initialization process of a class involves:
* *
@ -857,6 +883,7 @@ typedef void (*GBaseFinalizeFunc) (gpointer g_class);
* class->static_float = 3.14159265358979323846; * class->static_float = 3.14159265358979323846;
* } * }
* ]| * ]|
*
* Initialization of TypeBClass will first cause initialization of * Initialization of TypeBClass will first cause initialization of
* TypeAClass (derived classes reference their parent classes, see * TypeAClass (derived classes reference their parent classes, see
* g_type_class_ref() on this). * g_type_class_ref() on this).
@ -890,8 +917,10 @@ typedef void (*GClassInitFunc) (gpointer g_class,
* @class_data: The @class_data member supplied via the #GTypeInfo structure * @class_data: The @class_data member supplied via the #GTypeInfo structure
* *
* A callback function used by the type system to finalize a class. * A callback function used by the type system to finalize a class.
*
* This function is rarely needed, as dynamically allocated class resources * This function is rarely needed, as dynamically allocated class resources
* should be handled by GBaseInitFunc() and GBaseFinalizeFunc(). * should be handled by GBaseInitFunc() and GBaseFinalizeFunc().
*
* Also, specification of a GClassFinalizeFunc() in the #GTypeInfo * Also, specification of a GClassFinalizeFunc() in the #GTypeInfo
* structure of a static type is invalid, because classes of static types * structure of a static type is invalid, because classes of static types
* will never be finalized (they are artificially kept alive when their * will never be finalized (they are artificially kept alive when their
@ -906,8 +935,10 @@ typedef void (*GClassFinalizeFunc) (gpointer g_class,
* created for * created for
* *
* A callback function used by the type system to initialize a new * A callback function used by the type system to initialize a new
* instance of a type. This function initializes all instance members and * instance of a type.
* allocates any resources required by it. *
* This function initializes all instance members and allocates any resources
* required by it.
* *
* Initialization of a derived instance involves calling all its parent * Initialization of a derived instance involves calling all its parent
* types instance initializers, so the class member of the instance * types instance initializers, so the class member of the instance
@ -925,8 +956,10 @@ typedef void (*GInstanceInitFunc) (GTypeInstance *instance,
* @iface_data: The @interface_data supplied via the #GInterfaceInfo structure * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure
* *
* A callback function used by the type system to initialize a new * A callback function used by the type system to initialize a new
* interface. This function should initialize all internal data and * interface.
* allocate any resources required by the interface. *
* This function should initialize all internal data and* allocate any
* resources required by the interface.
* *
* The members of @iface_data are guaranteed to have been filled with * The members of @iface_data are guaranteed to have been filled with
* zeros before this function is called. * zeros before this function is called.
@ -939,6 +972,7 @@ typedef void (*GInterfaceInitFunc) (gpointer g_iface,
* @iface_data: The @interface_data supplied via the #GInterfaceInfo structure * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure
* *
* A callback function used by the type system to finalize an interface. * A callback function used by the type system to finalize an interface.
*
* This function should destroy any internal data and release any resources * This function should destroy any internal data and release any resources
* allocated by the corresponding GInterfaceInitFunc() function. * allocated by the corresponding GInterfaceInitFunc() function.
*/ */
@ -951,10 +985,11 @@ typedef void (*GInterfaceFinalizeFunc) (gpointer g_iface,
* unreferenced * unreferenced
* *
* A callback function which is called when the reference count of a class * A callback function which is called when the reference count of a class
* drops to zero. It may use g_type_class_ref() to prevent the class from * drops to zero.
* being freed. You should not call g_type_class_unref() from a *
* #GTypeClassCacheFunc function to prevent infinite recursion, use * It may use g_type_class_ref() to prevent the class from being freed. You
* g_type_class_unref_uncached() instead. * should not call g_type_class_unref() from a #GTypeClassCacheFunc function
* to prevent infinite recursion, use g_type_class_unref_uncached() instead.
* *
* The functions have to check the class id passed in to figure * The functions have to check the class id passed in to figure
* whether they actually want to cache the class of this type, since all * whether they actually want to cache the class of this type, since all
@ -972,6 +1007,7 @@ typedef gboolean (*GTypeClassCacheFunc) (gpointer cache_data,
* initialized * initialized
* *
* A callback called after an interface vtable is initialized. * A callback called after an interface vtable is initialized.
*
* See g_type_add_interface_check(). * See g_type_add_interface_check().
* *
* Since: 2.4 * Since: 2.4
@ -1002,13 +1038,16 @@ typedef enum /*< skip >*/
* @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type * @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type
* that introduces a value table, but can't be used for * that introduces a value table, but can't be used for
* g_value_init() * g_value_init()
* @G_TYPE_FLAG_FINAL: Indicates a final type. A final type is a non-derivable
* leaf node in a deep derivable type hierarchy tree. Since: 2.70
* *
* Bit masks used to check or determine characteristics of a type. * Bit masks used to check or determine characteristics of a type.
*/ */
typedef enum /*< skip >*/ typedef enum /*< skip >*/
{ {
G_TYPE_FLAG_ABSTRACT = (1 << 4), G_TYPE_FLAG_ABSTRACT = (1 << 4),
G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5) G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5),
G_TYPE_FLAG_FINAL GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6)
} GTypeFlags; } GTypeFlags;
/** /**
* GTypeInfo: * GTypeInfo:
@ -1171,7 +1210,7 @@ struct _GInterfaceInfo
* return NULL; * return NULL;
* ]| * ]|
* It should be noted, that it is generally a bad idea to follow the * It should be noted, that it is generally a bad idea to follow the
* #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to * %G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to
* reentrancy requirements and reference count assertions performed * reentrancy requirements and reference count assertions performed
* by the signal emission code, reference counts should always be * by the signal emission code, reference counts should always be
* incremented for reference counted contents stored in the value->data * incremented for reference counted contents stored in the value->data
@ -1341,12 +1380,12 @@ guint g_type_get_type_registration_serial (void);
* @OBJ_NAME: The bare name of the type, in all caps (like `WIDGET`) * @OBJ_NAME: The bare name of the type, in all caps (like `WIDGET`)
* @ParentName: the name of the parent type, in camel case (like `GtkWidget`) * @ParentName: the name of the parent type, in camel case (like `GtkWidget`)
* *
* A convenience macro for emitting the usual declarations in the header file for a type which is not (at the * A convenience macro for emitting the usual declarations in the header file
* present time) intended to be subclassed. * for a type which is not (at the present time) intended to be subclassed.
* *
* You might use it in a header as follows: * You might use it in a header as follows:
* *
* |[ * |[<!-- language="C" -->
* #ifndef _myapp_window_h_ * #ifndef _myapp_window_h_
* #define _myapp_window_h_ * #define _myapp_window_h_
* *
@ -1362,6 +1401,17 @@ guint g_type_get_type_registration_serial (void);
* #endif * #endif
* ]| * ]|
* *
* And use it as follow in your C file:
*
* |[<!-- language="C" -->
* struct _MyAppWindow
* {
* GtkWindow parent;
* ...
* };
* G_DEFINE_TYPE (MyAppWindow, my_app_window, GTK_TYPE_WINDOW)
* ]|
*
* This results in the following things happening: * This results in the following things happening:
* *
* - the usual `my_app_window_get_type()` function is declared with a return type of #GType * - the usual `my_app_window_get_type()` function is declared with a return type of #GType
@ -1427,7 +1477,7 @@ guint g_type_get_type_registration_serial (void);
* *
* You might use it in a header as follows: * You might use it in a header as follows:
* *
* |[ * |[<!-- language="C" -->
* #ifndef _gtk_frobber_h_ * #ifndef _gtk_frobber_h_
* #define _gtk_frobber_h_ * #define _gtk_frobber_h_
* *
@ -1452,6 +1502,18 @@ guint g_type_get_type_registration_serial (void);
* #endif * #endif
* ]| * ]|
* *
* Since the instance structure is public it is often needed to declare a
* private struct as follow in your C file:
*
* |[<!-- language="C" -->
* typedef struct _GtkFrobberPrivate GtkFrobberPrivate;
* struct _GtkFrobberPrivate
* {
* ...
* };
* G_DEFINE_TYPE_WITH_PRIVATE (GtkFrobber, gtk_frobber, GTK_TYPE_WIDGET)
* ]|
*
* This results in the following things happening: * This results in the following things happening:
* *
* - the usual `gtk_frobber_get_type()` function is declared with a return type of #GType * - the usual `gtk_frobber_get_type()` function is declared with a return type of #GType
@ -1524,7 +1586,7 @@ guint g_type_get_type_registration_serial (void);
* *
* You might use it in a header as follows: * You might use it in a header as follows:
* *
* |[ * |[<!-- language="C" -->
* #ifndef _my_model_h_ * #ifndef _my_model_h_
* #define _my_model_h_ * #define _my_model_h_
* *
@ -1546,6 +1608,18 @@ guint g_type_get_type_registration_serial (void);
* #endif * #endif
* ]| * ]|
* *
* And use it as follow in your C file:
*
* |[<!-- language="C" -->
* G_DEFINE_INTERFACE (MyModel, my_model, G_TYPE_OBJECT);
*
* static void
* my_model_default_init (MyModelInterface *iface)
* {
* ...
* }
* ]|
*
* This results in the following things happening: * This results in the following things happening:
* *
* - the usual `my_model_get_type()` function is declared with a return type of #GType * - the usual `my_model_get_type()` function is declared with a return type of #GType
@ -1609,6 +1683,7 @@ guint g_type_get_type_registration_serial (void);
* @_C_: Custom code that gets inserted in the `*_get_type()` function. * @_C_: Custom code that gets inserted in the `*_get_type()` function.
* *
* A convenience macro for type implementations. * A convenience macro for type implementations.
*
* Similar to G_DEFINE_TYPE(), but allows you to insert custom code into the * Similar to G_DEFINE_TYPE(), but allows you to insert custom code into the
* `*_get_type()` function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). * `*_get_type()` function, e.g. interface implementations via G_IMPLEMENT_INTERFACE().
* See G_DEFINE_TYPE_EXTENDED() for an example. * See G_DEFINE_TYPE_EXTENDED() for an example.
@ -1627,6 +1702,7 @@ guint g_type_get_type_registration_serial (void);
* initialization function, an instance initialization function (see #GTypeInfo * initialization function, an instance initialization function (see #GTypeInfo
* for information about these), a static variable named `t_n_parent_class` * for information about these), a static variable named `t_n_parent_class`
* pointing to the parent class, and adds private instance data to the type. * pointing to the parent class, and adds private instance data to the type.
*
* Furthermore, it defines a `*_get_type()` function. See G_DEFINE_TYPE_EXTENDED() * Furthermore, it defines a `*_get_type()` function. See G_DEFINE_TYPE_EXTENDED()
* for an example. * for an example.
* *
@ -1649,6 +1725,7 @@ guint g_type_get_type_registration_serial (void);
* @T_P: The #GType of the parent type. * @T_P: The #GType of the parent type.
* *
* A convenience macro for type implementations. * A convenience macro for type implementations.
*
* Similar to G_DEFINE_TYPE(), but defines an abstract type. * Similar to G_DEFINE_TYPE(), but defines an abstract type.
* See G_DEFINE_TYPE_EXTENDED() for an example. * See G_DEFINE_TYPE_EXTENDED() for an example.
* *
@ -1664,9 +1741,11 @@ guint g_type_get_type_registration_serial (void);
* @_C_: Custom code that gets inserted in the `type_name_get_type()` function. * @_C_: Custom code that gets inserted in the `type_name_get_type()` function.
* *
* A convenience macro for type implementations. * A convenience macro for type implementations.
*
* Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and * Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and
* allows you to insert custom code into the `*_get_type()` function, e.g. * allows you to insert custom code into the `*_get_type()` function, e.g.
* interface implementations via G_IMPLEMENT_INTERFACE(). * interface implementations via G_IMPLEMENT_INTERFACE().
*
* See G_DEFINE_TYPE_EXTENDED() for an example. * See G_DEFINE_TYPE_EXTENDED() for an example.
* *
* Since: 2.4 * Since: 2.4
@ -1680,11 +1759,63 @@ guint g_type_get_type_registration_serial (void);
* @T_P: The #GType of the parent type. * @T_P: The #GType of the parent type.
* *
* Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type. * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type.
*
* See G_DEFINE_TYPE_EXTENDED() for an example. * See G_DEFINE_TYPE_EXTENDED() for an example.
* *
* Since: 2.38 * Since: 2.38
*/ */
#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN)) #define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN))
/**
* G_DEFINE_FINAL_TYPE:
* @TN: the name of the new type, in Camel case
* @t_n: the name of the new type, in lower case, with words
* separated by `_` (snake case)
* @T_P: the #GType of the parent type
*
* A convenience macro for type implementations.
*
* Similar to G_DEFINE_TYPE(), but defines a final type.
*
* See G_DEFINE_TYPE_EXTENDED() for an example.
*
* Since: 2.70
*/
#define G_DEFINE_FINAL_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_FINAL, {}) GLIB_AVAILABLE_MACRO_IN_2_70
/**
* G_DEFINE_FINAL_TYPE_WITH_CODE:
* @TN: the name of the new type, in Camel case
* @t_n: the name of the new type, in lower case, with words
* separated by `_` (snake case)
* @T_P: the #GType of the parent type
* @_C_: Custom code that gets inserted in the `type_name_get_type()` function.
*
* A convenience macro for type implementations.
*
* Similar to G_DEFINE_TYPE_WITH_CODE(), but defines a final type and
* allows you to insert custom code into the `*_get_type()` function, e.g.
* interface implementations via G_IMPLEMENT_INTERFACE().
*
* See G_DEFINE_TYPE_EXTENDED() for an example.
*
* Since: 2.70
*/
#define G_DEFINE_FINAL_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_FINAL) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() GLIB_AVAILABLE_MACRO_IN_2_70
/**
* G_DEFINE_FINAL_TYPE_WITH_PRIVATE:
* @TN: the name of the new type, in Camel case
* @t_n: the name of the new type, in lower case, with words
* separated by `_` (snake case)
* @T_P: the #GType of the parent type
*
* A convenience macro for type implementations.
*
* Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines a final type.
*
* See G_DEFINE_TYPE_EXTENDED() for an example.
*
* Since: 2.70
*/
#define G_DEFINE_FINAL_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_FINAL, G_ADD_PRIVATE (TN)) GLIB_AVAILABLE_MACRO_IN_2_70
/** /**
* G_DEFINE_TYPE_EXTENDED: * G_DEFINE_TYPE_EXTENDED:
* @TN: The name of the new type, in Camel case. * @TN: The name of the new type, in Camel case.
@ -1706,7 +1837,9 @@ guint g_type_get_type_registration_serial (void);
* G_IMPLEMENT_INTERFACE (TYPE_GIZMO, * G_IMPLEMENT_INTERFACE (TYPE_GIZMO,
* gtk_gadget_gizmo_init)); * gtk_gadget_gizmo_init));
* ]| * ]|
*
* expands to * expands to
*
* |[<!-- language="C" --> * |[<!-- language="C" -->
* static void gtk_gadget_init (GtkGadget *self); * static void gtk_gadget_init (GtkGadget *self);
* static void gtk_gadget_class_init (GtkGadgetClass *klass); * static void gtk_gadget_class_init (GtkGadgetClass *klass);
@ -1753,6 +1886,7 @@ guint g_type_get_type_registration_serial (void);
* return static_g_define_type_id; * return static_g_define_type_id;
* } * }
* ]| * ]|
*
* The only pieces which have to be manually provided are the definitions of * The only pieces which have to be manually provided are the definitions of
* the instance and class structure and the definitions of the instance and * the instance and class structure and the definitions of the instance and
* class init functions. * class init functions.
@ -1794,11 +1928,13 @@ guint g_type_get_type_registration_serial (void);
* for no prerequisite type. * for no prerequisite type.
* @_C_: Custom code that gets inserted in the `*_get_type()` function. * @_C_: Custom code that gets inserted in the `*_get_type()` function.
* *
* A convenience macro for #GTypeInterface definitions. Similar to * A convenience macro for #GTypeInterface definitions.
* G_DEFINE_INTERFACE(), but allows you to insert custom code into the *
* `*_get_type()` function, e.g. additional interface implementations * Similar to G_DEFINE_INTERFACE(), but allows you to insert custom code
* via G_IMPLEMENT_INTERFACE(), or additional prerequisite types. See * into the `*_get_type()` function, e.g. additional interface implementations
* G_DEFINE_TYPE_EXTENDED() for a similar example using * via G_IMPLEMENT_INTERFACE(), or additional prerequisite types.
*
* See G_DEFINE_TYPE_EXTENDED() for a similar example using
* G_DEFINE_TYPE_WITH_CODE(). * G_DEFINE_TYPE_WITH_CODE().
* *
* Since: 2.24 * Since: 2.24
@ -1880,6 +2016,12 @@ guint g_type_get_type_registration_serial (void);
* } * }
* ]| * ]|
* *
* Since GLib 2.72, the returned `MyObjectPrivate` pointer is guaranteed to be
* aligned to at least the alignment of the largest basic GLib type (typically
* this is #guint64 or #gdouble). If you need larger alignment for an element in
* the struct, you should allocate it on the heap (aligned), or arrange for your
* `MyObjectPrivate` struct to be appropriately padded.
*
* Note that this macro can only be used together with the `G_DEFINE_TYPE_*` * Note that this macro can only be used together with the `G_DEFINE_TYPE_*`
* macros, since it depends on variable names from those macros. * macros, since it depends on variable names from those macros.
* *
@ -2071,8 +2213,23 @@ type_name##_get_type (void) \
* @copy_func: the #GBoxedCopyFunc for the new type * @copy_func: the #GBoxedCopyFunc for the new type
* @free_func: the #GBoxedFreeFunc for the new type * @free_func: the #GBoxedFreeFunc for the new type
* *
* A convenience macro for boxed type implementations, which defines a * A convenience macro for defining a new custom boxed type.
* type_name_get_type() function registering the boxed type. *
* Using this macro is the recommended way of defining new custom boxed
* types, over calling g_boxed_type_register_static() directly. It defines
* a `type_name_get_type()` function which will return the newly defined
* #GType, enabling lazy instantiation.
*
* |[<!-- language="C" -->
* G_DEFINE_BOXED_TYPE (MyStruct, my_struct, my_struct_copy, my_struct_free)
*
* void
* foo ()
* {
* GType type = my_struct_get_type ();
* // ... your code ...
* }
* ]|
* *
* Since: 2.26 * Since: 2.26
*/ */
@ -2087,6 +2244,7 @@ type_name##_get_type (void) \
* @_C_: Custom code that gets inserted in the `*_get_type()` function * @_C_: Custom code that gets inserted in the `*_get_type()` function
* *
* A convenience macro for boxed type implementations. * A convenience macro for boxed type implementations.
*
* Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the * Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the
* `type_name_get_type()` function, e.g. to register value transformations with * `type_name_get_type()` function, e.g. to register value transformations with
* g_value_register_transform_func(), for instance: * g_value_register_transform_func(), for instance:
@ -2098,7 +2256,7 @@ type_name##_get_type (void) \
* register_rectangle_transform_funcs (g_define_type_id)) * register_rectangle_transform_funcs (g_define_type_id))
* ]| * ]|
* *
* Similarly to the %G_DEFINE_TYPE family of macros, the #GType of the newly * Similarly to the `G_DEFINE_TYPE_*` family of macros, the #GType of the newly
* defined boxed type is exposed in the `g_define_type_id` variable. * defined boxed type is exposed in the `g_define_type_id` variable.
* *
* Since: 2.26 * Since: 2.26
@ -2108,7 +2266,7 @@ type_name##_get_type (void) \
/* Only use this in non-C++ on GCC >= 2.7, except for Darwin/ppc64. /* Only use this in non-C++ on GCC >= 2.7, except for Darwin/ppc64.
* See https://bugzilla.gnome.org/show_bug.cgi?id=647145 * See https://bugzilla.gnome.org/show_bug.cgi?id=647145
*/ */
#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !(defined (__APPLE__) && defined (__ppc64__)) #if !defined (__cplusplus) && (G_GNUC_CHECK_VERSION(2, 7)) && !(defined (__APPLE__) && defined (__ppc64__))
#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ #define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
static GType type_name##_get_type_once (void); \ static GType type_name##_get_type_once (void); \
\ \
@ -2297,9 +2455,9 @@ const gchar * g_type_name_from_class (GTypeClass *g_class);
/* --- implementation bits --- */ /* --- implementation bits --- */
#ifndef G_DISABLE_CAST_CHECKS #ifndef G_DISABLE_CAST_CHECKS
# define _G_TYPE_CIC(ip, gt, ct) \ # define _G_TYPE_CIC(ip, gt, ct) \
((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) ((ct*) (void *) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
# define _G_TYPE_CCC(cp, gt, ct) \ # define _G_TYPE_CCC(cp, gt, ct) \
((ct*) g_type_check_class_cast ((GTypeClass*) cp, gt)) ((ct*) (void *) g_type_check_class_cast ((GTypeClass*) cp, gt))
#else /* G_DISABLE_CAST_CHECKS */ #else /* G_DISABLE_CAST_CHECKS */
# define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip) # define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip)
# define _G_TYPE_CCC(cp, gt, ct) ((ct*) cp) # define _G_TYPE_CCC(cp, gt, ct) ((ct*) cp)

View file

@ -93,9 +93,10 @@ struct _GTypeModuleClass
* A convenience macro for dynamic type implementations, which declares a * A convenience macro for dynamic type implementations, which declares a
* class initialization function, an instance initialization function (see * class initialization function, an instance initialization function (see
* #GTypeInfo for information about these) and a static variable named * #GTypeInfo for information about these) and a static variable named
* `t_n`_parent_class pointing to the parent class. Furthermore, * `t_n`_parent_class pointing to the parent class.
* it defines a `*_get_type()` and a static `*_register_type()` functions *
* for use in your `module_init()`. * Furthermore, it defines a `*_get_type()` and a static `*_register_type()`
* functions for use in your `module_init()`.
* *
* See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example. * See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example.
* *
@ -114,7 +115,7 @@ struct _GTypeModuleClass
* A more general version of G_DEFINE_DYNAMIC_TYPE() which * A more general version of G_DEFINE_DYNAMIC_TYPE() which
* allows to specify #GTypeFlags and custom code. * allows to specify #GTypeFlags and custom code.
* *
* |[ * |[<!-- language="C" -->
* G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget, * G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget,
* gtk_gadget, * gtk_gadget,
* GTK_TYPE_THING, * GTK_TYPE_THING,
@ -122,8 +123,10 @@ struct _GTypeModuleClass
* G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO, * G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO,
* gtk_gadget_gizmo_init)); * gtk_gadget_gizmo_init));
* ]| * ]|
*
* expands to * expands to
* |[ *
* |[<!-- language="C" -->
* static void gtk_gadget_init (GtkGadget *self); * static void gtk_gadget_init (GtkGadget *self);
* static void gtk_gadget_class_init (GtkGadgetClass *klass); * static void gtk_gadget_class_init (GtkGadgetClass *klass);
* static void gtk_gadget_class_finalize (GtkGadgetClass *klass); * static void gtk_gadget_class_finalize (GtkGadgetClass *klass);
@ -227,8 +230,9 @@ type_name##_register_type (GTypeModule *type_module) \
* @iface_init: The interface init function * @iface_init: The interface init function
* *
* A convenience macro to ease interface addition in the @_C_ section * A convenience macro to ease interface addition in the @_C_ section
* of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See G_DEFINE_DYNAMIC_TYPE_EXTENDED() * of G_DEFINE_DYNAMIC_TYPE_EXTENDED().
* for an example. *
* See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example.
* *
* Note that this macro can only be used together with the * Note that this macro can only be used together with the
* G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable
@ -248,8 +252,9 @@ type_name##_register_type (GTypeModule *type_module) \
* @TypeName: the name of the type in CamelCase * @TypeName: the name of the type in CamelCase
* *
* A convenience macro to ease adding private data to instances of a new dynamic * A convenience macro to ease adding private data to instances of a new dynamic
* type in the @_C_ section of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See * type in the @_C_ section of G_DEFINE_DYNAMIC_TYPE_EXTENDED().
* G_ADD_PRIVATE() for details, it is similar but for static types. *
* See G_ADD_PRIVATE() for details, it is similar but for static types.
* *
* Note that this macro can only be used together with the * Note that this macro can only be used together with the
* G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable

View file

@ -33,6 +33,7 @@ G_BEGIN_DECLS
* @type: A #GType value. * @type: A #GType value.
* *
* Checks whether the passed in type ID can be used for g_value_init(). * Checks whether the passed in type ID can be used for g_value_init().
*
* That is, this macro checks whether this type provides an implementation * That is, this macro checks whether this type provides an implementation
* of the #GTypeValueTable functions required for a type to create a #GValue of. * of the #GTypeValueTable functions required for a type to create a #GValue of.
* *
@ -97,10 +98,12 @@ typedef void (*GValueTransform) (const GValue *src_value,
* GValue: * GValue:
* *
* An opaque structure used to hold different types of values. * An opaque structure used to hold different types of values.
*
* The data within the structure has protected scope: it is accessible only * The data within the structure has protected scope: it is accessible only
* to functions within a #GTypeValueTable structure, or implementations of * to functions within a #GTypeValueTable structure, or implementations of
* the g_value_*() API. That is, code portions which implement new fundamental * the g_value_*() API. That is, code portions which implement new fundamental
* types. * types.
*
* #GValue users cannot make any assumptions about how data is stored * #GValue users cannot make any assumptions about how data is stored
* within the 2 element @data union, and the @g_type member should * within the 2 element @data union, and the @g_type member should
* only be accessed through the G_VALUE_TYPE() macro. * only be accessed through the G_VALUE_TYPE() macro.
@ -193,7 +196,7 @@ void g_value_register_transform_func (GType src_type,
* be used as initializer instead of an explicit `{ 0 }` when declaring * be used as initializer instead of an explicit `{ 0 }` when declaring
* a variable, but it cannot be assigned to a variable. * a variable, but it cannot be assigned to a variable.
* *
* |[ * |[<!-- language="C" -->
* GValue value = G_VALUE_INIT; * GValue value = G_VALUE_INIT;
* ]| * ]|
* *

View file

@ -23,6 +23,7 @@
* *
* The macros in this section provide the varargs parsing support needed * The macros in this section provide the varargs parsing support needed
* in variadic GObject functions such as g_object_new() or g_object_set(). * in variadic GObject functions such as g_object_new() or g_object_set().
*
* They currently support the collection of integral types, floating point * They currently support the collection of integral types, floating point
* types and pointers. * types and pointers.
*/ */
@ -79,9 +80,10 @@ union _GTypeCValue
* @__error: a #gchar** variable that will be modified to hold a g_new() * @__error: a #gchar** variable that will be modified to hold a g_new()
* allocated error messages if something fails * allocated error messages if something fails
* *
* Collects a variable argument value from a va_list. We have to * Collects a variable argument value from a `va_list`.
* implement the varargs collection as a macro, because on some systems *
* va_list variables cannot be passed by reference. * We have to implement the varargs collection as a macro, because on some
* systems `va_list` variables cannot be passed by reference.
* *
* Since: 2.24 * Since: 2.24
*/ */
@ -136,13 +138,14 @@ G_STMT_START { \
* @__error: a #gchar** variable that will be modified to hold a g_new() * @__error: a #gchar** variable that will be modified to hold a g_new()
* allocated error messages if something fails * allocated error messages if something fails
* *
* Collects a variable argument value from a va_list. We have to * Collects a variable argument value from a `va_list`.
* implement the varargs collection as a macro, because on some systems *
* va_list variables cannot be passed by reference. * We have to implement the varargs collection as a macro, because on some systems
* `va_list` variables cannot be passed by reference.
* *
* Note: If you are creating the @value argument just before calling this macro, * Note: If you are creating the @value argument just before calling this macro,
* you should use the #G_VALUE_COLLECT_INIT variant and pass the uninitialized * you should use the G_VALUE_COLLECT_INIT() variant and pass the uninitialized
* #GValue. That variant is faster than #G_VALUE_COLLECT. * #GValue. That variant is faster than G_VALUE_COLLECT().
*/ */
#define G_VALUE_COLLECT(value, var_args, flags, __error) G_STMT_START { \ #define G_VALUE_COLLECT(value, var_args, flags, __error) G_STMT_START { \
GValue *g_vc_value = (value); \ GValue *g_vc_value = (value); \
@ -203,7 +206,8 @@ G_STMT_START { \
* @__error: a #gchar** variable that will be modified to hold a g_new() * @__error: a #gchar** variable that will be modified to hold a g_new()
* allocated error message if something fails * allocated error message if something fails
* *
* Stores a values value into one or more argument locations from a va_list. * Stores a values value into one or more argument locations from a `va_list`.
*
* This is the inverse of G_VALUE_COLLECT(). * This is the inverse of G_VALUE_COLLECT().
*/ */
#define G_VALUE_LCOPY(value, var_args, flags, __error) \ #define G_VALUE_LCOPY(value, var_args, flags, __error) \

View file

@ -306,7 +306,7 @@ void g_value_set_string_take_ownership (GValue *value,
/** /**
* gchararray: * gchararray:
* *
* A C representable type name for #G_TYPE_STRING. * A C representable type name for %G_TYPE_STRING.
*/ */
typedef gchar* gchararray; typedef gchar* gchararray;

View file

@ -20,6 +20,8 @@
#define GLIB_STATIC_COMPILATION 1 #define GLIB_STATIC_COMPILATION 1
#define GOBJECT_STATIC_COMPILATION 1 #define GOBJECT_STATIC_COMPILATION 1
#define G_INTL_STATIC_COMPILATION 1
#define FFI_STATIC_BUILD 1
G_BEGIN_DECLS G_BEGIN_DECLS
@ -109,7 +111,7 @@ typedef unsigned long guintptr;
#define G_GUINTPTR_FORMAT "lu" #define G_GUINTPTR_FORMAT "lu"
#define GLIB_MAJOR_VERSION 2 #define GLIB_MAJOR_VERSION 2
#define GLIB_MINOR_VERSION 68 #define GLIB_MINOR_VERSION 72
#define GLIB_MICRO_VERSION 3 #define GLIB_MICRO_VERSION 3
#define G_OS_UNIX #define G_OS_UNIX

View file

@ -16,10 +16,12 @@
* system printf functions. This is useful to know, for example, * system printf functions. This is useful to know, for example,
* when using glibc's register_printf_function(). * when using glibc's register_printf_function().
*/ */
#undef GLIB_USING_SYSTEM_PRINTF #define GLIB_USING_SYSTEM_PRINTF
#define GLIB_STATIC_COMPILATION 1 #define GLIB_STATIC_COMPILATION 1
#define GOBJECT_STATIC_COMPILATION 1 #define GOBJECT_STATIC_COMPILATION 1
#define G_INTL_STATIC_COMPILATION 1
#define FFI_STATIC_BUILD 1
G_BEGIN_DECLS G_BEGIN_DECLS
@ -109,7 +111,7 @@ typedef unsigned long guintptr;
#define G_GUINTPTR_FORMAT "lu" #define G_GUINTPTR_FORMAT "lu"
#define GLIB_MAJOR_VERSION 2 #define GLIB_MAJOR_VERSION 2
#define GLIB_MINOR_VERSION 68 #define GLIB_MINOR_VERSION 72
#define GLIB_MICRO_VERSION 3 #define GLIB_MICRO_VERSION 3
#define G_OS_UNIX #define G_OS_UNIX

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +1,7 @@
prefix= prefix=
includedir=${prefix}/include
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/lib libdir=${exec_prefix}/lib
includedir=${prefix}/include
bindir=${prefix}/bin bindir=${prefix}/bin
glib_genmarshal=${bindir}/glib-genmarshal glib_genmarshal=${bindir}/glib-genmarshal
@ -10,8 +10,7 @@ glib_mkenums=${bindir}/glib-mkenums
Name: GLib Name: GLib
Description: C Utility Library Description: C Utility Library
Version: 2.68.3 Version: 2.72.3
Requires: libpcre >= 8.31 Requires: libpcre >= 8.31
Libs: -L${libdir} -lglib-2.0 -lintl -liconv -lm Libs: -L${libdir} -lglib-2.0 -lintl -liconv -framework Foundation -framework CoreFoundation -framework AppKit -framework Carbon -lm
Libs.private: -Wl,-framework,CoreFoundation -Wl,-framework,Carbon -Wl,-framework,Foundation -Wl,-framework,AppKit
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include

View file

@ -1,11 +1,11 @@
prefix= prefix=
includedir=${prefix}/include
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/lib libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: GObject Name: GObject
Description: GLib Type, Object, Parameter and Signal Library Description: GLib Type, Object, Parameter and Signal Library
Version: 2.68.3 Version: 2.72.3
Requires: glib-2.0, libffi >= 3.0.0 Requires: glib-2.0, libffi >= 3.0.0
Libs: -L${libdir} -lgobject-2.0 -lintl -liconv Libs: -L${libdir} -lgobject-2.0 -lintl -liconv
Cflags: -I${includedir} Cflags: -I${includedir}

View file

@ -1,11 +1,11 @@
prefix= prefix=
includedir=${prefix}/include
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/lib libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: GThread Name: GThread
Description: Thread support for GLib Description: Thread support for GLib
Version: 2.68.3 Version: 2.72.3
Requires: glib-2.0 Requires: glib-2.0
Libs: -L${libdir} -lgthread-2.0 -lintl -liconv Libs: -L${libdir} -lgthread-2.0 -lintl -liconv
Cflags: -I${includedir} Cflags: -I${includedir}