mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-19 07:08:54 +02:00
Move the GLib type system into libglib
The type system should have never been relegated to libgobject: it's a low level API to register types at run time. Having GType inside libglib allows us to use the type system information everywhere: - generic but type safe storage data types - explicit memory management semantics for all data types - enumeration types for all flags Having the type system inside libglib also allows us to create new and better fundamental types in the future, like sum types, option types, tuples, and generic types. Moved: - gatomicarray - gboxed - genums - gtype - gtypeplugin - gvalue The move is mostly Git surgery, but given the amount of internal API surface, it results in a single commit to avoid breaking bisectability. We need to maintain `gobject/gvaluecollector.h` as a publicly installed header but, to avoid issues in case of excessive inclusions, we make it conflict with `glib/gvaluecollector.h`. See: #2370 See: https://discourse.gnome.org/t/straw-man-moving-the-gtype-api-down-to-libglib-2-0/11169
This commit is contained in:
@@ -1,182 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2009 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "../glib/gvalgrind.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "gatomicarray.h"
|
||||
|
||||
/* A GAtomicArray is a growable, mutable array of data
|
||||
* generally of the form of a header of a specific size and
|
||||
* then an array of items of a fixed size.
|
||||
*
|
||||
* It is possible to do lock-less read transactions from the
|
||||
* array without any protection against other reads or writes,
|
||||
* but such read operation must be aware that the data in the
|
||||
* atomic array can change at any time during the transaction,
|
||||
* and only at the end can we verify if the transaction succeeded
|
||||
* or not. Thus the reading transaction cannot for instance
|
||||
* dereference a pointer in the array inside the transaction.
|
||||
*
|
||||
* The size of an array however cannot change during a read
|
||||
* transaction.
|
||||
*
|
||||
* Writes to the array is done in a copy-update style, but there
|
||||
* is no real protection against multiple writers overwriting each
|
||||
* others updates, so writes must be protected by an external lock.
|
||||
*/
|
||||
|
||||
G_LOCK_DEFINE_STATIC (array);
|
||||
|
||||
typedef struct _FreeListNode FreeListNode;
|
||||
struct _FreeListNode {
|
||||
FreeListNode *next;
|
||||
};
|
||||
|
||||
/* This is really a list of array memory blocks, using the
|
||||
* first item as the next pointer to chain them together.
|
||||
* Protected by array lock */
|
||||
static FreeListNode *freelist = NULL;
|
||||
|
||||
/* must hold array lock */
|
||||
static gpointer
|
||||
freelist_alloc (gsize size, gboolean reuse)
|
||||
{
|
||||
gpointer mem;
|
||||
FreeListNode *free, **prev;
|
||||
gsize real_size;
|
||||
|
||||
if (reuse)
|
||||
{
|
||||
for (free = freelist, prev = &freelist; free != NULL; prev = &free->next, free = free->next)
|
||||
{
|
||||
if (G_ATOMIC_ARRAY_DATA_SIZE (free) == size)
|
||||
{
|
||||
*prev = free->next;
|
||||
return (gpointer)free;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
real_size = sizeof (GAtomicArrayMetadata) + MAX (size, sizeof (FreeListNode));
|
||||
mem = g_slice_alloc (real_size);
|
||||
mem = ((char *) mem) + sizeof (GAtomicArrayMetadata);
|
||||
G_ATOMIC_ARRAY_DATA_SIZE (mem) = size;
|
||||
|
||||
#if ENABLE_VALGRIND
|
||||
VALGRIND_MALLOCLIKE_BLOCK (mem, real_size - sizeof (GAtomicArrayMetadata),
|
||||
FALSE, FALSE);
|
||||
#endif
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
/* must hold array lock */
|
||||
static void
|
||||
freelist_free (gpointer mem)
|
||||
{
|
||||
FreeListNode *free;
|
||||
|
||||
free = mem;
|
||||
free->next = freelist;
|
||||
freelist = free;
|
||||
}
|
||||
|
||||
void
|
||||
_g_atomic_array_init (GAtomicArray *array)
|
||||
{
|
||||
array->data = NULL;
|
||||
}
|
||||
|
||||
/* Get a copy of the data (if non-NULL) that
|
||||
* can be changed and then re-applied with
|
||||
* g_atomic_array_update().
|
||||
*
|
||||
* If additional_element_size is > 0 then
|
||||
* then the new memory chunk is that much
|
||||
* larger, or there were no data we return
|
||||
* a chunk of header_size + additional_element_size.
|
||||
* This means you can use this to grow the
|
||||
* array part and it handles the first element
|
||||
* being added automatically.
|
||||
*
|
||||
* We don't support shrinking arrays, as if
|
||||
* we then re-grow we may reuse an old pointer
|
||||
* value and confuse the transaction check.
|
||||
*/
|
||||
gpointer
|
||||
_g_atomic_array_copy (GAtomicArray *array,
|
||||
gsize header_size,
|
||||
gsize additional_element_size)
|
||||
{
|
||||
guint8 *new, *old;
|
||||
gsize old_size, new_size;
|
||||
|
||||
G_LOCK (array);
|
||||
old = g_atomic_pointer_get (&array->data);
|
||||
if (old)
|
||||
{
|
||||
old_size = G_ATOMIC_ARRAY_DATA_SIZE (old);
|
||||
new_size = old_size + additional_element_size;
|
||||
/* Don't reuse if copying to same size, as this may end
|
||||
up reusing the same pointer for the same array thus
|
||||
confusing the transaction check */
|
||||
new = freelist_alloc (new_size, additional_element_size != 0);
|
||||
memcpy (new, old, old_size);
|
||||
}
|
||||
else if (additional_element_size != 0)
|
||||
{
|
||||
new_size = header_size + additional_element_size;
|
||||
new = freelist_alloc (new_size, TRUE);
|
||||
}
|
||||
else
|
||||
new = NULL;
|
||||
G_UNLOCK (array);
|
||||
return new;
|
||||
}
|
||||
|
||||
/* Replace the data in the array with the new data,
|
||||
* freeing the old data (for reuse). The new data may
|
||||
* not be smaller than the current data.
|
||||
*/
|
||||
void
|
||||
_g_atomic_array_update (GAtomicArray *array,
|
||||
gpointer new_data)
|
||||
{
|
||||
guint8 *old;
|
||||
|
||||
G_LOCK (array);
|
||||
old = g_atomic_pointer_exchange (&array->data, new_data);
|
||||
|
||||
#ifdef G_DISABLE_ASSERT
|
||||
if (old && G_ATOMIC_ARRAY_DATA_SIZE (new_data) < G_ATOMIC_ARRAY_DATA_SIZE (old))
|
||||
{
|
||||
g_atomic_pointer_set (&array->data, old);
|
||||
g_return_if_reached ();
|
||||
}
|
||||
#else
|
||||
g_assert (old == NULL || G_ATOMIC_ARRAY_DATA_SIZE (old) <= G_ATOMIC_ARRAY_DATA_SIZE (new_data));
|
||||
#endif
|
||||
|
||||
if (old)
|
||||
freelist_free (old);
|
||||
G_UNLOCK (array);
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2009 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __G_ATOMIC_ARRAY_H__
|
||||
#define __G_ATOMIC_ARRAY_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib/glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef union _GAtomicArrayMetadata
|
||||
{
|
||||
gsize size;
|
||||
/* We have to ensure that the memory location is sufficiently aligned to
|
||||
* store any object. With C11 this would be max_align_t, but in practise
|
||||
* gpointer is sufficient for all known architectures. We could change
|
||||
* this to `_Alignas(max_align_t) char pad` once we depend on C11. */
|
||||
gpointer _alignment_padding;
|
||||
} GAtomicArrayMetadata;
|
||||
#define G_ATOMIC_ARRAY_DATA_SIZE(mem) (((GAtomicArrayMetadata *) (mem) - 1)->size)
|
||||
|
||||
typedef struct _GAtomicArray GAtomicArray;
|
||||
struct _GAtomicArray {
|
||||
gpointer data; /* elements - atomic */
|
||||
};
|
||||
|
||||
void _g_atomic_array_init (GAtomicArray *array);
|
||||
gpointer _g_atomic_array_copy (GAtomicArray *array,
|
||||
gsize header_size,
|
||||
gsize additional_element_size);
|
||||
void _g_atomic_array_update (GAtomicArray *array,
|
||||
gpointer new_data);
|
||||
|
||||
#define G_ATOMIC_ARRAY_GET_LOCKED(_array, _type) ((_type *)((_array)->data))
|
||||
|
||||
#define G_ATOMIC_ARRAY_DO_TRANSACTION(_array, _type, _C_) G_STMT_START { \
|
||||
gpointer *_datap = &(_array)->data; \
|
||||
_type *transaction_data, *__check; \
|
||||
\
|
||||
__check = g_atomic_pointer_get (_datap); \
|
||||
do { \
|
||||
transaction_data = __check; \
|
||||
{_C_;} \
|
||||
__check = g_atomic_pointer_get (_datap); \
|
||||
} while (transaction_data != __check); \
|
||||
} G_STMT_END
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_ATOMIC_ARRAY_H__ */
|
544
gobject/gboxed.c
544
gobject/gboxed.c
@@ -1,544 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2000-2001 Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* for GValueArray */
|
||||
#ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
|
||||
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "gboxed.h"
|
||||
#include "gclosure.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gvalue.h"
|
||||
#include "gvaluearray.h"
|
||||
#include "gvaluecollector.h"
|
||||
|
||||
static inline void /* keep this function in sync with gvalue.c */
|
||||
value_meminit (GValue *value,
|
||||
GType value_type)
|
||||
{
|
||||
value->g_type = value_type;
|
||||
memset (value->data, 0, sizeof (value->data));
|
||||
}
|
||||
|
||||
static GValue *
|
||||
value_copy (GValue *src_value)
|
||||
{
|
||||
GValue *dest_value = g_new0 (GValue, 1);
|
||||
|
||||
if (G_VALUE_TYPE (src_value))
|
||||
{
|
||||
g_value_init (dest_value, G_VALUE_TYPE (src_value));
|
||||
g_value_copy (src_value, dest_value);
|
||||
}
|
||||
return dest_value;
|
||||
}
|
||||
|
||||
static void
|
||||
value_free (GValue *value)
|
||||
{
|
||||
if (G_VALUE_TYPE (value))
|
||||
g_value_unset (value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static GPollFD *
|
||||
pollfd_copy (GPollFD *src)
|
||||
{
|
||||
GPollFD *dest = g_new0 (GPollFD, 1);
|
||||
/* just a couple of integers */
|
||||
memcpy (dest, src, sizeof (GPollFD));
|
||||
return dest;
|
||||
}
|
||||
|
||||
void
|
||||
_g_boxed_type_init (void)
|
||||
{
|
||||
const GTypeInfo info = {
|
||||
0, /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_destroy */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_destroy */
|
||||
NULL, /* class_data */
|
||||
0, /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
NULL, /* instance_init */
|
||||
NULL, /* value_table */
|
||||
};
|
||||
const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
|
||||
GType type G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
|
||||
|
||||
/* G_TYPE_BOXED
|
||||
*/
|
||||
type = g_type_register_fundamental (G_TYPE_BOXED, g_intern_static_string ("GBoxed"), &info, &finfo,
|
||||
G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
|
||||
g_assert (type == G_TYPE_BOXED);
|
||||
}
|
||||
|
||||
static GString *
|
||||
gstring_copy (GString *src_gstring)
|
||||
{
|
||||
return g_string_new_len (src_gstring->str, src_gstring->len);
|
||||
}
|
||||
|
||||
static void
|
||||
gstring_free (GString *gstring)
|
||||
{
|
||||
g_string_free (gstring, TRUE);
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GClosure, g_closure, g_closure_ref, g_closure_unref)
|
||||
G_DEFINE_BOXED_TYPE (GValue, g_value, value_copy, value_free)
|
||||
G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free)
|
||||
G_DEFINE_BOXED_TYPE (GDate, g_date, g_date_copy, g_date_free)
|
||||
/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
|
||||
G_DEFINE_BOXED_TYPE (GString, g_gstring, gstring_copy, gstring_free)
|
||||
G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_unref)
|
||||
G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
|
||||
G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)
|
||||
G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_unref)
|
||||
G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref)
|
||||
G_DEFINE_BOXED_TYPE (GTree, g_tree, g_tree_ref, g_tree_unref)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)
|
||||
G_DEFINE_BOXED_TYPE (GMatchInfo, g_match_info, g_match_info_ref, g_match_info_unref)
|
||||
|
||||
#define g_variant_type_get_type g_variant_type_get_gtype
|
||||
G_DEFINE_BOXED_TYPE (GVariantType, g_variant_type, g_variant_type_copy, g_variant_type_free)
|
||||
#undef g_variant_type_get_type
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GVariantBuilder, g_variant_builder, g_variant_builder_ref, g_variant_builder_unref)
|
||||
G_DEFINE_BOXED_TYPE (GVariantDict, g_variant_dict, g_variant_dict_ref, g_variant_dict_unref)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GError, g_error, g_error_copy, g_error_free)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GDateTime, g_date_time, g_date_time_ref, g_date_time_unref)
|
||||
G_DEFINE_BOXED_TYPE (GTimeZone, g_time_zone, g_time_zone_ref, g_time_zone_unref)
|
||||
G_DEFINE_BOXED_TYPE (GKeyFile, g_key_file, g_key_file_ref, g_key_file_unref)
|
||||
G_DEFINE_BOXED_TYPE (GMappedFile, g_mapped_file, g_mapped_file_ref, g_mapped_file_unref)
|
||||
G_DEFINE_BOXED_TYPE (GBookmarkFile, g_bookmark_file, g_bookmark_file_copy, g_bookmark_file_free)
|
||||
G_DEFINE_BOXED_TYPE (GHmac, g_hmac, g_hmac_ref, g_hmac_unref)
|
||||
G_DEFINE_BOXED_TYPE (GDir, g_dir, g_dir_ref, g_dir_unref)
|
||||
G_DEFINE_BOXED_TYPE (GRand, g_rand, g_rand_copy, g_rand_free)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GMainLoop, g_main_loop, g_main_loop_ref, g_main_loop_unref)
|
||||
G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref)
|
||||
G_DEFINE_BOXED_TYPE (GSource, g_source, g_source_ref, g_source_unref)
|
||||
G_DEFINE_BOXED_TYPE (GPollFD, g_pollfd, pollfd_copy, g_free)
|
||||
G_DEFINE_BOXED_TYPE (GMarkupParseContext, g_markup_parse_context, g_markup_parse_context_ref, g_markup_parse_context_unref)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GThread, g_thread, g_thread_ref, g_thread_unref)
|
||||
G_DEFINE_BOXED_TYPE (GChecksum, g_checksum, g_checksum_copy, g_checksum_free)
|
||||
G_DEFINE_BOXED_TYPE (GUri, g_uri, g_uri_ref, g_uri_unref)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GOptionGroup, g_option_group, g_option_group_ref, g_option_group_unref)
|
||||
G_DEFINE_BOXED_TYPE (GPatternSpec, g_pattern_spec, g_pattern_spec_copy, g_pattern_spec_free);
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GStrvBuilder, g_strv_builder, g_strv_builder_ref, g_strv_builder_unref);
|
||||
|
||||
/* This one can't use G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev) */
|
||||
GType
|
||||
g_strv_get_type (void)
|
||||
{
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
GType g_define_type_id =
|
||||
g_boxed_type_register_static (g_intern_static_string ("GStrv"),
|
||||
(GBoxedCopyFunc) g_strdupv,
|
||||
(GBoxedFreeFunc) g_strfreev);
|
||||
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
GType
|
||||
g_variant_get_gtype (void)
|
||||
{
|
||||
return G_TYPE_VARIANT;
|
||||
}
|
||||
|
||||
static void
|
||||
boxed_proxy_value_init (GValue *value)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
boxed_proxy_value_free (GValue *value)
|
||||
{
|
||||
if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
|
||||
_g_type_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
static void
|
||||
boxed_proxy_value_copy (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
if (src_value->data[0].v_pointer)
|
||||
dest_value->data[0].v_pointer = _g_type_boxed_copy (G_VALUE_TYPE (src_value), src_value->data[0].v_pointer);
|
||||
else
|
||||
dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
boxed_proxy_value_peek_pointer (const GValue *value)
|
||||
{
|
||||
return value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
boxed_proxy_collect_value (GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
if (!collect_values[0].v_pointer)
|
||||
value->data[0].v_pointer = NULL;
|
||||
else
|
||||
{
|
||||
if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
|
||||
{
|
||||
value->data[0].v_pointer = collect_values[0].v_pointer;
|
||||
value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
|
||||
}
|
||||
else
|
||||
value->data[0].v_pointer = _g_type_boxed_copy (G_VALUE_TYPE (value), collect_values[0].v_pointer);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
boxed_proxy_lcopy_value (const GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
gpointer *boxed_p = collect_values[0].v_pointer;
|
||||
|
||||
g_return_val_if_fail (boxed_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
|
||||
|
||||
if (!value->data[0].v_pointer)
|
||||
*boxed_p = NULL;
|
||||
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
|
||||
*boxed_p = value->data[0].v_pointer;
|
||||
else
|
||||
*boxed_p = _g_type_boxed_copy (G_VALUE_TYPE (value), value->data[0].v_pointer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_boxed_type_register_static:
|
||||
* @name: Name of the new boxed type.
|
||||
* @boxed_copy: (scope forever): Boxed structure copy function.
|
||||
* @boxed_free: (scope forever): Boxed structure free function.
|
||||
*
|
||||
* This function creates a new %G_TYPE_BOXED derived type id for a new
|
||||
* boxed type with name @name.
|
||||
*
|
||||
* Boxed type handling functions have to be provided to copy and free
|
||||
* opaque boxed structures of this type.
|
||||
*
|
||||
* For the general case, it is recommended to use G_DEFINE_BOXED_TYPE()
|
||||
* instead of calling g_boxed_type_register_static() directly. The macro
|
||||
* will create the appropriate `*_get_type()` function for the boxed type.
|
||||
*
|
||||
* Returns: New %G_TYPE_BOXED derived type id for @name.
|
||||
*/
|
||||
GType
|
||||
g_boxed_type_register_static (const gchar *name,
|
||||
GBoxedCopyFunc boxed_copy,
|
||||
GBoxedFreeFunc boxed_free)
|
||||
{
|
||||
static const GTypeValueTable vtable = {
|
||||
boxed_proxy_value_init,
|
||||
boxed_proxy_value_free,
|
||||
boxed_proxy_value_copy,
|
||||
boxed_proxy_value_peek_pointer,
|
||||
"p",
|
||||
boxed_proxy_collect_value,
|
||||
"p",
|
||||
boxed_proxy_lcopy_value,
|
||||
};
|
||||
GTypeInfo type_info = {
|
||||
0, /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0, /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
NULL, /* instance_init */
|
||||
&vtable, /* value_table */
|
||||
};
|
||||
GType type;
|
||||
|
||||
g_return_val_if_fail (name != NULL, 0);
|
||||
g_return_val_if_fail (boxed_copy != NULL, 0);
|
||||
g_return_val_if_fail (boxed_free != NULL, 0);
|
||||
g_return_val_if_fail (g_type_from_name (name) == 0, 0);
|
||||
|
||||
type = g_type_register_static (G_TYPE_BOXED, name, &type_info, 0);
|
||||
|
||||
/* install proxy functions upon successful registration */
|
||||
if (type)
|
||||
_g_type_boxed_init (type, boxed_copy, boxed_free);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_boxed_copy:
|
||||
* @boxed_type: The type of @src_boxed.
|
||||
* @src_boxed: (not nullable): The boxed structure to be copied.
|
||||
*
|
||||
* Provide a copy of a boxed structure @src_boxed which is of type @boxed_type.
|
||||
*
|
||||
* Returns: (transfer full) (not nullable): The newly created copy of the boxed
|
||||
* structure.
|
||||
*/
|
||||
gpointer
|
||||
g_boxed_copy (GType boxed_type,
|
||||
gconstpointer src_boxed)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
gpointer dest_boxed;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE, NULL);
|
||||
g_return_val_if_fail (src_boxed != NULL, NULL);
|
||||
|
||||
value_table = g_type_value_table_peek (boxed_type);
|
||||
g_assert (value_table != NULL);
|
||||
|
||||
/* check if our proxying implementation is used, we can short-cut here */
|
||||
if (value_table->value_copy == boxed_proxy_value_copy)
|
||||
dest_boxed = _g_type_boxed_copy (boxed_type, (gpointer) src_boxed);
|
||||
else
|
||||
{
|
||||
GValue src_value, dest_value;
|
||||
|
||||
/* we heavily rely on third-party boxed type value vtable
|
||||
* implementations to follow normal boxed value storage
|
||||
* (data[0].v_pointer is the boxed struct, and
|
||||
* data[1].v_uint holds the G_VALUE_NOCOPY_CONTENTS flag,
|
||||
* rest zero).
|
||||
* but then, we can expect that since we laid out the
|
||||
* g_boxed_*() API.
|
||||
* data[1].v_uint&G_VALUE_NOCOPY_CONTENTS shouldn't be set
|
||||
* after a copy.
|
||||
*/
|
||||
/* equiv. to g_value_set_static_boxed() */
|
||||
value_meminit (&src_value, boxed_type);
|
||||
src_value.data[0].v_pointer = (gpointer) src_boxed;
|
||||
src_value.data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
|
||||
|
||||
/* call third-party code copy function, fingers-crossed */
|
||||
value_meminit (&dest_value, boxed_type);
|
||||
value_table->value_copy (&src_value, &dest_value);
|
||||
|
||||
/* double check and grouse if things went wrong */
|
||||
if (dest_value.data[1].v_ulong)
|
||||
g_warning ("the copy_value() implementation of type '%s' seems to make use of reserved GValue fields",
|
||||
g_type_name (boxed_type));
|
||||
|
||||
dest_boxed = dest_value.data[0].v_pointer;
|
||||
}
|
||||
|
||||
return dest_boxed;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_boxed_free:
|
||||
* @boxed_type: The type of @boxed.
|
||||
* @boxed: (not nullable): The boxed structure to be freed.
|
||||
*
|
||||
* Free the boxed structure @boxed which is of type @boxed_type.
|
||||
*/
|
||||
void
|
||||
g_boxed_free (GType boxed_type,
|
||||
gpointer boxed)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
|
||||
g_return_if_fail (G_TYPE_IS_BOXED (boxed_type));
|
||||
g_return_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE);
|
||||
g_return_if_fail (boxed != NULL);
|
||||
|
||||
value_table = g_type_value_table_peek (boxed_type);
|
||||
g_assert (value_table != NULL);
|
||||
|
||||
/* check if our proxying implementation is used, we can short-cut here */
|
||||
if (value_table->value_free == boxed_proxy_value_free)
|
||||
_g_type_boxed_free (boxed_type, boxed);
|
||||
else
|
||||
{
|
||||
GValue value;
|
||||
|
||||
/* see g_boxed_copy() on why we think we can do this */
|
||||
value_meminit (&value, boxed_type);
|
||||
value.data[0].v_pointer = boxed;
|
||||
value_table->value_free (&value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_get_boxed:
|
||||
* @value: a valid #GValue of %G_TYPE_BOXED derived type
|
||||
*
|
||||
* Get the contents of a %G_TYPE_BOXED derived #GValue.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): boxed contents of @value
|
||||
*/
|
||||
gpointer
|
||||
g_value_get_boxed (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
|
||||
|
||||
return value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_dup_boxed: (skip)
|
||||
* @value: a valid #GValue of %G_TYPE_BOXED derived type
|
||||
*
|
||||
* Get the contents of a %G_TYPE_BOXED derived #GValue. Upon getting,
|
||||
* the boxed value is duplicated and needs to be later freed with
|
||||
* g_boxed_free(), e.g. like: g_boxed_free (G_VALUE_TYPE (@value),
|
||||
* return_value);
|
||||
*
|
||||
* Returns: (transfer full) (nullable): boxed contents of @value
|
||||
*/
|
||||
gpointer
|
||||
g_value_dup_boxed (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
|
||||
|
||||
return value->data[0].v_pointer ? g_boxed_copy (G_VALUE_TYPE (value), value->data[0].v_pointer) : NULL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
value_set_boxed_internal (GValue *value,
|
||||
gconstpointer boxed,
|
||||
gboolean need_copy,
|
||||
gboolean need_free)
|
||||
{
|
||||
if (!boxed)
|
||||
{
|
||||
/* just resetting to NULL might not be desired, need to
|
||||
* have value reinitialized also (for values defaulting
|
||||
* to other default value states than a NULL data pointer),
|
||||
* g_value_reset() will handle this
|
||||
*/
|
||||
g_value_reset (value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
|
||||
g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
|
||||
value->data[1].v_uint = need_free ? 0 : G_VALUE_NOCOPY_CONTENTS;
|
||||
value->data[0].v_pointer = need_copy ? g_boxed_copy (G_VALUE_TYPE (value), boxed) : (gpointer) boxed;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_set_boxed:
|
||||
* @value: a valid #GValue of %G_TYPE_BOXED derived type
|
||||
* @v_boxed: (nullable): boxed value to be set
|
||||
*
|
||||
* Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
|
||||
*/
|
||||
void
|
||||
g_value_set_boxed (GValue *value,
|
||||
gconstpointer boxed)
|
||||
{
|
||||
g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
|
||||
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
|
||||
|
||||
value_set_boxed_internal (value, boxed, TRUE, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_set_static_boxed:
|
||||
* @value: a valid #GValue of %G_TYPE_BOXED derived type
|
||||
* @v_boxed: (nullable): static boxed value to be set
|
||||
*
|
||||
* Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
|
||||
*
|
||||
* The boxed value is assumed to be static, and is thus not duplicated
|
||||
* when setting the #GValue.
|
||||
*/
|
||||
void
|
||||
g_value_set_static_boxed (GValue *value,
|
||||
gconstpointer boxed)
|
||||
{
|
||||
g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
|
||||
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
|
||||
|
||||
value_set_boxed_internal (value, boxed, FALSE, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_set_boxed_take_ownership:
|
||||
* @value: a valid #GValue of %G_TYPE_BOXED derived type
|
||||
* @v_boxed: (nullable): duplicated unowned boxed value to be set
|
||||
*
|
||||
* This is an internal function introduced mainly for C marshallers.
|
||||
*
|
||||
* Deprecated: 2.4: Use g_value_take_boxed() instead.
|
||||
*/
|
||||
void
|
||||
g_value_set_boxed_take_ownership (GValue *value,
|
||||
gconstpointer boxed)
|
||||
{
|
||||
g_value_take_boxed (value, boxed);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_take_boxed:
|
||||
* @value: a valid #GValue of %G_TYPE_BOXED derived type
|
||||
* @v_boxed: (nullable): duplicated unowned boxed value to be set
|
||||
*
|
||||
* Sets the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed
|
||||
* and takes over the ownership of the caller’s reference to @v_boxed;
|
||||
* the caller doesn’t have to unref it any more.
|
||||
*
|
||||
* Since: 2.4
|
||||
*/
|
||||
void
|
||||
g_value_take_boxed (GValue *value,
|
||||
gconstpointer boxed)
|
||||
{
|
||||
g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
|
||||
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
|
||||
|
||||
value_set_boxed_internal (value, boxed, FALSE, TRUE);
|
||||
}
|
124
gobject/gboxed.h
124
gobject/gboxed.h
@@ -1,124 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2000-2001 Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __G_BOXED_H__
|
||||
#define __G_BOXED_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gtype.h>
|
||||
|
||||
#ifndef __GI_SCANNER__
|
||||
#include <gobject/glib-types.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- type macros --- */
|
||||
#define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
|
||||
/**
|
||||
* G_VALUE_HOLDS_BOXED:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values derived
|
||||
* from type %G_TYPE_BOXED.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
|
||||
|
||||
|
||||
/* --- typedefs --- */
|
||||
/**
|
||||
* GBoxedCopyFunc:
|
||||
* @boxed: (not nullable): The boxed structure to be copied.
|
||||
*
|
||||
* This function is provided by the user and should produce a copy
|
||||
* of the passed in boxed structure.
|
||||
*
|
||||
* Returns: (not nullable): The newly created copy of the boxed structure.
|
||||
*/
|
||||
typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
|
||||
|
||||
/**
|
||||
* GBoxedFreeFunc:
|
||||
* @boxed: (not nullable): The boxed structure to be freed.
|
||||
*
|
||||
* This function is provided by the user and should free the boxed
|
||||
* structure passed.
|
||||
*/
|
||||
typedef void (*GBoxedFreeFunc) (gpointer boxed);
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gpointer g_boxed_copy (GType boxed_type,
|
||||
gconstpointer src_boxed);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_boxed_free (GType boxed_type,
|
||||
gpointer boxed);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_boxed (GValue *value,
|
||||
gconstpointer v_boxed);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_static_boxed (GValue *value,
|
||||
gconstpointer v_boxed);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_take_boxed (GValue *value,
|
||||
gconstpointer v_boxed);
|
||||
GOBJECT_DEPRECATED_FOR(g_value_take_boxed)
|
||||
void g_value_set_boxed_take_ownership (GValue *value,
|
||||
gconstpointer v_boxed);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gpointer g_value_get_boxed (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gpointer g_value_dup_boxed (const GValue *value);
|
||||
|
||||
|
||||
/* --- convenience --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_boxed_type_register_static (const gchar *name,
|
||||
GBoxedCopyFunc boxed_copy,
|
||||
GBoxedFreeFunc boxed_free);
|
||||
|
||||
/* --- GObject boxed types --- */
|
||||
/**
|
||||
* G_TYPE_CLOSURE:
|
||||
*
|
||||
* The #GType for #GClosure.
|
||||
*/
|
||||
#define G_TYPE_CLOSURE (g_closure_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_VALUE:
|
||||
*
|
||||
* The type ID of the "GValue" type which is a boxed type,
|
||||
* used to pass around pointers to GValues.
|
||||
*/
|
||||
#define G_TYPE_VALUE (g_value_get_type ())
|
||||
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_closure_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_value_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_BOXED_H__ */
|
@@ -26,16 +26,15 @@
|
||||
|
||||
#include "../glib/gvalgrind.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <ffi.h>
|
||||
|
||||
#include "gclosure.h"
|
||||
|
||||
#include "gboxed.h"
|
||||
#include "gobject.h"
|
||||
#include "genums.h"
|
||||
#include "gobject-private.h"
|
||||
#include "gvalue.h"
|
||||
#include "gvaluetypes.h"
|
||||
#include "gtype-private.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,6 +90,8 @@
|
||||
* automatically removed when the objects they point to go away.
|
||||
*/
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GClosure, g_closure, g_closure_ref, g_closure_unref)
|
||||
|
||||
#define CLOSURE_MAX_REF_COUNT ((1 << 15) - 1)
|
||||
#define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
|
||||
#define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
|
||||
|
@@ -24,7 +24,8 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gtype.h>
|
||||
#include <glib.h>
|
||||
#include <gobject/gobject-visibility.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -72,6 +73,13 @@ G_BEGIN_DECLS
|
||||
*/
|
||||
#define G_CALLBACK(f) ((GCallback) (f))
|
||||
|
||||
/**
|
||||
* G_TYPE_CLOSURE:
|
||||
*
|
||||
* The #GType for #GClosure.
|
||||
*/
|
||||
#define G_TYPE_CLOSURE (g_closure_get_type ())
|
||||
|
||||
|
||||
/* -- typedefs --- */
|
||||
typedef struct _GClosure GClosure;
|
||||
@@ -219,6 +227,9 @@ struct _GCClosure
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_closure_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GClosure* g_cclosure_new (GCallback callback_func,
|
||||
gpointer user_data,
|
||||
|
726
gobject/genums.c
726
gobject/genums.c
@@ -1,726 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MT safe
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "genums.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gvalue.h"
|
||||
#include "gvaluecollector.h"
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static void g_enum_class_init (GEnumClass *class,
|
||||
gpointer class_data);
|
||||
static void g_flags_class_init (GFlagsClass *class,
|
||||
gpointer class_data);
|
||||
static void value_flags_enum_init (GValue *value);
|
||||
static void value_flags_enum_copy_value (const GValue *src_value,
|
||||
GValue *dest_value);
|
||||
static gchar* value_flags_enum_collect_value (GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags);
|
||||
static gchar* value_flags_enum_lcopy_value (const GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags);
|
||||
|
||||
/* --- functions --- */
|
||||
void
|
||||
_g_enum_types_init (void)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
static const GTypeValueTable flags_enum_value_table = {
|
||||
value_flags_enum_init, /* value_init */
|
||||
NULL, /* value_free */
|
||||
value_flags_enum_copy_value, /* value_copy */
|
||||
NULL, /* value_peek_pointer */
|
||||
"i", /* collect_format */
|
||||
value_flags_enum_collect_value, /* collect_value */
|
||||
"p", /* lcopy_format */
|
||||
value_flags_enum_lcopy_value, /* lcopy_value */
|
||||
};
|
||||
GTypeInfo info = {
|
||||
0, /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_destroy */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_destroy */
|
||||
NULL, /* class_data */
|
||||
0, /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
NULL, /* instance_init */
|
||||
&flags_enum_value_table, /* value_table */
|
||||
};
|
||||
static const GTypeFundamentalInfo finfo = {
|
||||
G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_DERIVABLE,
|
||||
};
|
||||
GType type G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
|
||||
|
||||
g_return_if_fail (initialized == FALSE);
|
||||
initialized = TRUE;
|
||||
|
||||
/* G_TYPE_ENUM
|
||||
*/
|
||||
info.class_size = sizeof (GEnumClass);
|
||||
type = g_type_register_fundamental (G_TYPE_ENUM, g_intern_static_string ("GEnum"), &info, &finfo,
|
||||
G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
|
||||
g_assert (type == G_TYPE_ENUM);
|
||||
|
||||
/* G_TYPE_FLAGS
|
||||
*/
|
||||
info.class_size = sizeof (GFlagsClass);
|
||||
type = g_type_register_fundamental (G_TYPE_FLAGS, g_intern_static_string ("GFlags"), &info, &finfo,
|
||||
G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
|
||||
g_assert (type == G_TYPE_FLAGS);
|
||||
}
|
||||
|
||||
static void
|
||||
value_flags_enum_init (GValue *value)
|
||||
{
|
||||
value->data[0].v_long = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
value_flags_enum_copy_value (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
dest_value->data[0].v_long = src_value->data[0].v_long;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
value_flags_enum_collect_value (GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
if (G_VALUE_HOLDS_ENUM (value))
|
||||
value->data[0].v_long = collect_values[0].v_int;
|
||||
else
|
||||
value->data[0].v_ulong = (guint) collect_values[0].v_int;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
value_flags_enum_lcopy_value (const GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
gint *int_p = collect_values[0].v_pointer;
|
||||
|
||||
g_return_val_if_fail (int_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
|
||||
|
||||
*int_p = value->data[0].v_long;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_enum_register_static:
|
||||
* @name: A nul-terminated string used as the name of the new type.
|
||||
* @const_static_values: (array zero-terminated=1): An array of
|
||||
* #GEnumValue structs for the possible enumeration values. The array is
|
||||
* terminated by a struct with all members being 0. GObject keeps a
|
||||
* reference to the data, so it cannot be stack-allocated.
|
||||
*
|
||||
* Registers a new static enumeration type with the name @name.
|
||||
*
|
||||
* It is normally more convenient to let [glib-mkenums][glib-mkenums],
|
||||
* generate a my_enum_get_type() function from a usual C enumeration
|
||||
* definition than to write one yourself using g_enum_register_static().
|
||||
*
|
||||
* Returns: The new type identifier.
|
||||
*/
|
||||
GType
|
||||
g_enum_register_static (const gchar *name,
|
||||
const GEnumValue *const_static_values)
|
||||
{
|
||||
GTypeInfo enum_type_info = {
|
||||
sizeof (GEnumClass), /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) g_enum_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0, /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
NULL, /* instance_init */
|
||||
NULL, /* value_table */
|
||||
};
|
||||
GType type;
|
||||
|
||||
g_return_val_if_fail (name != NULL, 0);
|
||||
g_return_val_if_fail (const_static_values != NULL, 0);
|
||||
|
||||
enum_type_info.class_data = const_static_values;
|
||||
|
||||
type = g_type_register_static (G_TYPE_ENUM, name, &enum_type_info, 0);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_flags_register_static:
|
||||
* @name: A nul-terminated string used as the name of the new type.
|
||||
* @const_static_values: (array zero-terminated=1): An array of
|
||||
* #GFlagsValue structs for the possible flags values. The array is
|
||||
* terminated by a struct with all members being 0. GObject keeps a
|
||||
* reference to the data, so it cannot be stack-allocated.
|
||||
*
|
||||
* Registers a new static flags type with the name @name.
|
||||
*
|
||||
* It is normally more convenient to let [glib-mkenums][glib-mkenums]
|
||||
* generate a my_flags_get_type() function from a usual C enumeration
|
||||
* definition than to write one yourself using g_flags_register_static().
|
||||
*
|
||||
* Returns: The new type identifier.
|
||||
*/
|
||||
GType
|
||||
g_flags_register_static (const gchar *name,
|
||||
const GFlagsValue *const_static_values)
|
||||
{
|
||||
GTypeInfo flags_type_info = {
|
||||
sizeof (GFlagsClass), /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) g_flags_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0, /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
NULL, /* instance_init */
|
||||
NULL, /* value_table */
|
||||
};
|
||||
GType type;
|
||||
|
||||
g_return_val_if_fail (name != NULL, 0);
|
||||
g_return_val_if_fail (const_static_values != NULL, 0);
|
||||
|
||||
flags_type_info.class_data = const_static_values;
|
||||
|
||||
type = g_type_register_static (G_TYPE_FLAGS, name, &flags_type_info, 0);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_enum_complete_type_info:
|
||||
* @g_enum_type: the type identifier of the type being completed
|
||||
* @info: (out callee-allocates): the #GTypeInfo struct to be filled in
|
||||
* @const_values: An array of #GEnumValue structs for the possible
|
||||
* enumeration values. The array is terminated by a struct with all
|
||||
* members being 0.
|
||||
*
|
||||
* This function is meant to be called from the `complete_type_info`
|
||||
* function of a #GTypePlugin implementation, as in the following
|
||||
* example:
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* static void
|
||||
* my_enum_complete_type_info (GTypePlugin *plugin,
|
||||
* GType g_type,
|
||||
* GTypeInfo *info,
|
||||
* GTypeValueTable *value_table)
|
||||
* {
|
||||
* static const GEnumValue values[] = {
|
||||
* { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" },
|
||||
* { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" },
|
||||
* { 0, NULL, NULL }
|
||||
* };
|
||||
*
|
||||
* g_enum_complete_type_info (type, info, values);
|
||||
* }
|
||||
* ]|
|
||||
*/
|
||||
void
|
||||
g_enum_complete_type_info (GType g_enum_type,
|
||||
GTypeInfo *info,
|
||||
const GEnumValue *const_values)
|
||||
{
|
||||
g_return_if_fail (G_TYPE_IS_ENUM (g_enum_type));
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (const_values != NULL);
|
||||
|
||||
info->class_size = sizeof (GEnumClass);
|
||||
info->base_init = NULL;
|
||||
info->base_finalize = NULL;
|
||||
info->class_init = (GClassInitFunc) g_enum_class_init;
|
||||
info->class_finalize = NULL;
|
||||
info->class_data = const_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_flags_complete_type_info:
|
||||
* @g_flags_type: the type identifier of the type being completed
|
||||
* @info: (out callee-allocates): the #GTypeInfo struct to be filled in
|
||||
* @const_values: An array of #GFlagsValue structs for the possible
|
||||
* enumeration values. The array is terminated by a struct with all
|
||||
* members being 0.
|
||||
*
|
||||
* This function is meant to be called from the complete_type_info()
|
||||
* function of a #GTypePlugin implementation, see the example for
|
||||
* g_enum_complete_type_info() above.
|
||||
*/
|
||||
void
|
||||
g_flags_complete_type_info (GType g_flags_type,
|
||||
GTypeInfo *info,
|
||||
const GFlagsValue *const_values)
|
||||
{
|
||||
g_return_if_fail (G_TYPE_IS_FLAGS (g_flags_type));
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (const_values != NULL);
|
||||
|
||||
info->class_size = sizeof (GFlagsClass);
|
||||
info->base_init = NULL;
|
||||
info->base_finalize = NULL;
|
||||
info->class_init = (GClassInitFunc) g_flags_class_init;
|
||||
info->class_finalize = NULL;
|
||||
info->class_data = const_values;
|
||||
}
|
||||
|
||||
static void
|
||||
g_enum_class_init (GEnumClass *class,
|
||||
gpointer class_data)
|
||||
{
|
||||
g_return_if_fail (G_IS_ENUM_CLASS (class));
|
||||
|
||||
class->minimum = 0;
|
||||
class->maximum = 0;
|
||||
class->n_values = 0;
|
||||
class->values = class_data;
|
||||
|
||||
if (class->values)
|
||||
{
|
||||
GEnumValue *values;
|
||||
|
||||
class->minimum = class->values->value;
|
||||
class->maximum = class->values->value;
|
||||
for (values = class->values; values->value_name; values++)
|
||||
{
|
||||
class->minimum = MIN (class->minimum, values->value);
|
||||
class->maximum = MAX (class->maximum, values->value);
|
||||
class->n_values++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
g_flags_class_init (GFlagsClass *class,
|
||||
gpointer class_data)
|
||||
{
|
||||
g_return_if_fail (G_IS_FLAGS_CLASS (class));
|
||||
|
||||
class->mask = 0;
|
||||
class->n_values = 0;
|
||||
class->values = class_data;
|
||||
|
||||
if (class->values)
|
||||
{
|
||||
GFlagsValue *values;
|
||||
|
||||
for (values = class->values; values->value_name; values++)
|
||||
{
|
||||
class->mask |= values->value;
|
||||
class->n_values++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* g_enum_get_value_by_name:
|
||||
* @enum_class: a #GEnumClass
|
||||
* @name: the name to look up
|
||||
*
|
||||
* Looks up a #GEnumValue by name.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the #GEnumValue with name @name,
|
||||
* or %NULL if the enumeration doesn't have a member
|
||||
* with that name
|
||||
*/
|
||||
GEnumValue*
|
||||
g_enum_get_value_by_name (GEnumClass *enum_class,
|
||||
const gchar *name)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if (enum_class->n_values)
|
||||
{
|
||||
GEnumValue *enum_value;
|
||||
|
||||
for (enum_value = enum_class->values; enum_value->value_name; enum_value++)
|
||||
if (strcmp (name, enum_value->value_name) == 0)
|
||||
return enum_value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_flags_get_value_by_name:
|
||||
* @flags_class: a #GFlagsClass
|
||||
* @name: the name to look up
|
||||
*
|
||||
* Looks up a #GFlagsValue by name.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the #GFlagsValue with name @name,
|
||||
* or %NULL if there is no flag with that name
|
||||
*/
|
||||
GFlagsValue*
|
||||
g_flags_get_value_by_name (GFlagsClass *flags_class,
|
||||
const gchar *name)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_FLAGS_CLASS (flags_class), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if (flags_class->n_values)
|
||||
{
|
||||
GFlagsValue *flags_value;
|
||||
|
||||
for (flags_value = flags_class->values; flags_value->value_name; flags_value++)
|
||||
if (strcmp (name, flags_value->value_name) == 0)
|
||||
return flags_value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_enum_get_value_by_nick:
|
||||
* @enum_class: a #GEnumClass
|
||||
* @nick: the nickname to look up
|
||||
*
|
||||
* Looks up a #GEnumValue by nickname.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the #GEnumValue with nickname @nick,
|
||||
* or %NULL if the enumeration doesn't have a member
|
||||
* with that nickname
|
||||
*/
|
||||
GEnumValue*
|
||||
g_enum_get_value_by_nick (GEnumClass *enum_class,
|
||||
const gchar *nick)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), NULL);
|
||||
g_return_val_if_fail (nick != NULL, NULL);
|
||||
|
||||
if (enum_class->n_values)
|
||||
{
|
||||
GEnumValue *enum_value;
|
||||
|
||||
for (enum_value = enum_class->values; enum_value->value_name; enum_value++)
|
||||
if (enum_value->value_nick && strcmp (nick, enum_value->value_nick) == 0)
|
||||
return enum_value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_flags_get_value_by_nick:
|
||||
* @flags_class: a #GFlagsClass
|
||||
* @nick: the nickname to look up
|
||||
*
|
||||
* Looks up a #GFlagsValue by nickname.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the #GFlagsValue with nickname @nick,
|
||||
* or %NULL if there is no flag with that nickname
|
||||
*/
|
||||
GFlagsValue*
|
||||
g_flags_get_value_by_nick (GFlagsClass *flags_class,
|
||||
const gchar *nick)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_FLAGS_CLASS (flags_class), NULL);
|
||||
g_return_val_if_fail (nick != NULL, NULL);
|
||||
|
||||
if (flags_class->n_values)
|
||||
{
|
||||
GFlagsValue *flags_value;
|
||||
|
||||
for (flags_value = flags_class->values; flags_value->value_nick; flags_value++)
|
||||
if (flags_value->value_nick && strcmp (nick, flags_value->value_nick) == 0)
|
||||
return flags_value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_enum_get_value:
|
||||
* @enum_class: a #GEnumClass
|
||||
* @value: the value to look up
|
||||
*
|
||||
* Returns the #GEnumValue for a value.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the #GEnumValue for @value, or %NULL
|
||||
* if @value is not a member of the enumeration
|
||||
*/
|
||||
GEnumValue*
|
||||
g_enum_get_value (GEnumClass *enum_class,
|
||||
gint value)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), NULL);
|
||||
|
||||
if (enum_class->n_values)
|
||||
{
|
||||
GEnumValue *enum_value;
|
||||
|
||||
for (enum_value = enum_class->values; enum_value->value_name; enum_value++)
|
||||
if (enum_value->value == value)
|
||||
return enum_value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_flags_get_first_value:
|
||||
* @flags_class: a #GFlagsClass
|
||||
* @value: the value
|
||||
*
|
||||
* Returns the first #GFlagsValue which is set in @value.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the first #GFlagsValue which is set in
|
||||
* @value, or %NULL if none is set
|
||||
*/
|
||||
GFlagsValue*
|
||||
g_flags_get_first_value (GFlagsClass *flags_class,
|
||||
guint value)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_FLAGS_CLASS (flags_class), NULL);
|
||||
|
||||
if (flags_class->n_values)
|
||||
{
|
||||
GFlagsValue *flags_value;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
for (flags_value = flags_class->values; flags_value->value_name; flags_value++)
|
||||
if (flags_value->value == 0)
|
||||
return flags_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (flags_value = flags_class->values; flags_value->value_name; flags_value++)
|
||||
if (flags_value->value != 0 && (flags_value->value & value) == flags_value->value)
|
||||
return flags_value;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_enum_to_string:
|
||||
* @g_enum_type: the type identifier of a #GEnumClass type
|
||||
* @value: the value
|
||||
*
|
||||
* Pretty-prints @value in the form of the enum’s name.
|
||||
*
|
||||
* This is intended to be used for debugging purposes. The format of the output
|
||||
* may change in the future.
|
||||
*
|
||||
* Returns: (transfer full): a newly-allocated text string
|
||||
*
|
||||
* Since: 2.54
|
||||
*/
|
||||
gchar *
|
||||
g_enum_to_string (GType g_enum_type,
|
||||
gint value)
|
||||
{
|
||||
gchar *result;
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_ENUM (g_enum_type), NULL);
|
||||
|
||||
enum_class = g_type_class_ref (g_enum_type);
|
||||
|
||||
/* Already warned */
|
||||
if (enum_class == NULL)
|
||||
return g_strdup_printf ("%d", value);
|
||||
|
||||
enum_value = g_enum_get_value (enum_class, value);
|
||||
|
||||
if (enum_value == NULL)
|
||||
result = g_strdup_printf ("%d", value);
|
||||
else
|
||||
result = g_strdup (enum_value->value_name);
|
||||
|
||||
g_type_class_unref (enum_class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* g_flags_get_value_string:
|
||||
* @flags_class: a #GFlagsClass
|
||||
* @value: the value
|
||||
*
|
||||
* Pretty-prints @value in the form of the flag names separated by ` | ` and
|
||||
* sorted. Any extra bits will be shown at the end as a hexadecimal number.
|
||||
*
|
||||
* This is intended to be used for debugging purposes. The format of the output
|
||||
* may change in the future.
|
||||
*
|
||||
* Returns: (transfer full): a newly-allocated text string
|
||||
*
|
||||
* Since: 2.54
|
||||
*/
|
||||
static gchar *
|
||||
g_flags_get_value_string (GFlagsClass *flags_class,
|
||||
guint value)
|
||||
{
|
||||
GString *str;
|
||||
GFlagsValue *flags_value;
|
||||
|
||||
g_return_val_if_fail (G_IS_FLAGS_CLASS (flags_class), NULL);
|
||||
|
||||
str = g_string_new (NULL);
|
||||
|
||||
while ((str->len == 0 || value != 0) &&
|
||||
(flags_value = g_flags_get_first_value (flags_class, value)) != NULL)
|
||||
{
|
||||
if (str->len > 0)
|
||||
g_string_append (str, " | ");
|
||||
|
||||
g_string_append (str, flags_value->value_name);
|
||||
|
||||
value &= ~flags_value->value;
|
||||
}
|
||||
|
||||
/* Show the extra bits */
|
||||
if (value != 0 || str->len == 0)
|
||||
{
|
||||
if (str->len > 0)
|
||||
g_string_append (str, " | ");
|
||||
|
||||
g_string_append_printf (str, "0x%x", value);
|
||||
}
|
||||
|
||||
return g_string_free (str, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_flags_to_string:
|
||||
* @flags_type: the type identifier of a #GFlagsClass type
|
||||
* @value: the value
|
||||
*
|
||||
* Pretty-prints @value in the form of the flag names separated by ` | ` and
|
||||
* sorted. Any extra bits will be shown at the end as a hexadecimal number.
|
||||
*
|
||||
* This is intended to be used for debugging purposes. The format of the output
|
||||
* may change in the future.
|
||||
*
|
||||
* Returns: (transfer full): a newly-allocated text string
|
||||
*
|
||||
* Since: 2.54
|
||||
*/
|
||||
gchar *
|
||||
g_flags_to_string (GType flags_type,
|
||||
guint value)
|
||||
{
|
||||
gchar *result;
|
||||
GFlagsClass *flags_class;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
|
||||
|
||||
flags_class = g_type_class_ref (flags_type);
|
||||
|
||||
/* Already warned */
|
||||
if (flags_class == NULL)
|
||||
return NULL;
|
||||
|
||||
result = g_flags_get_value_string (flags_class, value);
|
||||
|
||||
g_type_class_unref (flags_class);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_value_set_enum:
|
||||
* @value: a valid #GValue whose type is derived from %G_TYPE_ENUM
|
||||
* @v_enum: enum value to be set
|
||||
*
|
||||
* Set the contents of a %G_TYPE_ENUM #GValue to @v_enum.
|
||||
*/
|
||||
void
|
||||
g_value_set_enum (GValue *value,
|
||||
gint v_enum)
|
||||
{
|
||||
g_return_if_fail (G_VALUE_HOLDS_ENUM (value));
|
||||
|
||||
value->data[0].v_long = v_enum;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_get_enum:
|
||||
* @value: a valid #GValue whose type is derived from %G_TYPE_ENUM
|
||||
*
|
||||
* Get the contents of a %G_TYPE_ENUM #GValue.
|
||||
*
|
||||
* Returns: enum contents of @value
|
||||
*/
|
||||
gint
|
||||
g_value_get_enum (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_VALUE_HOLDS_ENUM (value), 0);
|
||||
|
||||
return value->data[0].v_long;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_set_flags:
|
||||
* @value: a valid #GValue whose type is derived from %G_TYPE_FLAGS
|
||||
* @v_flags: flags value to be set
|
||||
*
|
||||
* Set the contents of a %G_TYPE_FLAGS #GValue to @v_flags.
|
||||
*/
|
||||
void
|
||||
g_value_set_flags (GValue *value,
|
||||
guint v_flags)
|
||||
{
|
||||
g_return_if_fail (G_VALUE_HOLDS_FLAGS (value));
|
||||
|
||||
value->data[0].v_ulong = v_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_get_flags:
|
||||
* @value: a valid #GValue whose type is derived from %G_TYPE_FLAGS
|
||||
*
|
||||
* Get the contents of a %G_TYPE_FLAGS #GValue.
|
||||
*
|
||||
* Returns: flags contents of @value
|
||||
*/
|
||||
guint
|
||||
g_value_get_flags (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_VALUE_HOLDS_FLAGS (value), 0);
|
||||
|
||||
return value->data[0].v_ulong;
|
||||
}
|
381
gobject/genums.h
381
gobject/genums.h
@@ -1,381 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __G_ENUMS_H__
|
||||
#define __G_ENUMS_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gtype.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- type macros --- */
|
||||
/**
|
||||
* G_TYPE_IS_ENUM:
|
||||
* @type: a #GType ID.
|
||||
*
|
||||
* Checks whether @type "is a" %G_TYPE_ENUM.
|
||||
*
|
||||
* Returns: %TRUE if @type "is a" %G_TYPE_ENUM.
|
||||
*/
|
||||
#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)
|
||||
/**
|
||||
* G_ENUM_CLASS:
|
||||
* @class: a valid #GEnumClass
|
||||
*
|
||||
* Casts a derived #GEnumClass structure into a #GEnumClass structure.
|
||||
*/
|
||||
#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
|
||||
/**
|
||||
* G_IS_ENUM_CLASS:
|
||||
* @class: a #GEnumClass
|
||||
*
|
||||
* Checks whether @class "is a" valid #GEnumClass structure of type %G_TYPE_ENUM
|
||||
* or derived.
|
||||
*/
|
||||
#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
|
||||
/**
|
||||
* G_ENUM_CLASS_TYPE:
|
||||
* @class: a #GEnumClass
|
||||
*
|
||||
* Get the type identifier from a given #GEnumClass structure.
|
||||
*
|
||||
* Returns: the #GType
|
||||
*/
|
||||
#define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
||||
/**
|
||||
* G_ENUM_CLASS_TYPE_NAME:
|
||||
* @class: a #GEnumClass
|
||||
*
|
||||
* Get the static type name from a given #GEnumClass structure.
|
||||
*
|
||||
* Returns: the type name.
|
||||
*/
|
||||
#define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class)))
|
||||
|
||||
|
||||
/**
|
||||
* G_TYPE_IS_FLAGS:
|
||||
* @type: a #GType ID.
|
||||
*
|
||||
* Checks whether @type "is a" %G_TYPE_FLAGS.
|
||||
*
|
||||
* Returns: %TRUE if @type "is a" %G_TYPE_FLAGS.
|
||||
*/
|
||||
#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
|
||||
/**
|
||||
* G_FLAGS_CLASS:
|
||||
* @class: a valid #GFlagsClass
|
||||
*
|
||||
* Casts a derived #GFlagsClass structure into a #GFlagsClass structure.
|
||||
*/
|
||||
#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
|
||||
/**
|
||||
* G_IS_FLAGS_CLASS:
|
||||
* @class: a #GFlagsClass
|
||||
*
|
||||
* Checks whether @class "is a" valid #GFlagsClass structure of type %G_TYPE_FLAGS
|
||||
* or derived.
|
||||
*/
|
||||
#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
|
||||
/**
|
||||
* G_FLAGS_CLASS_TYPE:
|
||||
* @class: a #GFlagsClass
|
||||
*
|
||||
* Get the type identifier from a given #GFlagsClass structure.
|
||||
*
|
||||
* Returns: the #GType
|
||||
*/
|
||||
#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
||||
/**
|
||||
* G_FLAGS_CLASS_TYPE_NAME:
|
||||
* @class: a #GFlagsClass
|
||||
*
|
||||
* Get the static type name from a given #GFlagsClass structure.
|
||||
*
|
||||
* Returns: the type name.
|
||||
*/
|
||||
#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class)))
|
||||
|
||||
|
||||
/**
|
||||
* G_VALUE_HOLDS_ENUM:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values derived from type %G_TYPE_ENUM.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM))
|
||||
/**
|
||||
* G_VALUE_HOLDS_FLAGS:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values derived from type %G_TYPE_FLAGS.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS))
|
||||
|
||||
|
||||
/* --- enum/flag values & classes --- */
|
||||
typedef struct _GEnumClass GEnumClass;
|
||||
typedef struct _GFlagsClass GFlagsClass;
|
||||
typedef struct _GEnumValue GEnumValue;
|
||||
typedef struct _GFlagsValue GFlagsValue;
|
||||
|
||||
/**
|
||||
* GEnumClass:
|
||||
* @g_type_class: the parent class
|
||||
* @minimum: the smallest possible value.
|
||||
* @maximum: the largest possible value.
|
||||
* @n_values: the number of possible values.
|
||||
* @values: an array of #GEnumValue structs describing the
|
||||
* individual values.
|
||||
*
|
||||
* The class of an enumeration type holds information about its
|
||||
* possible values.
|
||||
*/
|
||||
struct _GEnumClass
|
||||
{
|
||||
GTypeClass g_type_class;
|
||||
|
||||
/*< public >*/
|
||||
gint minimum;
|
||||
gint maximum;
|
||||
guint n_values;
|
||||
GEnumValue *values;
|
||||
};
|
||||
/**
|
||||
* GFlagsClass:
|
||||
* @g_type_class: the parent class
|
||||
* @mask: a mask covering all possible values.
|
||||
* @n_values: the number of possible values.
|
||||
* @values: an array of #GFlagsValue structs describing the
|
||||
* individual values.
|
||||
*
|
||||
* The class of a flags type holds information about its
|
||||
* possible values.
|
||||
*/
|
||||
struct _GFlagsClass
|
||||
{
|
||||
GTypeClass g_type_class;
|
||||
|
||||
/*< public >*/
|
||||
guint mask;
|
||||
guint n_values;
|
||||
GFlagsValue *values;
|
||||
};
|
||||
/**
|
||||
* GEnumValue:
|
||||
* @value: the enum value
|
||||
* @value_name: the name of the value
|
||||
* @value_nick: the nickname of the value
|
||||
*
|
||||
* A structure which contains a single enum value, its name, and its
|
||||
* nickname.
|
||||
*/
|
||||
struct _GEnumValue
|
||||
{
|
||||
gint value;
|
||||
const gchar *value_name;
|
||||
const gchar *value_nick;
|
||||
};
|
||||
/**
|
||||
* GFlagsValue:
|
||||
* @value: the flags value
|
||||
* @value_name: the name of the value
|
||||
* @value_nick: the nickname of the value
|
||||
*
|
||||
* A structure which contains a single flags value, its name, and its
|
||||
* nickname.
|
||||
*/
|
||||
struct _GFlagsValue
|
||||
{
|
||||
guint value;
|
||||
const gchar *value_name;
|
||||
const gchar *value_nick;
|
||||
};
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GEnumValue* g_enum_get_value (GEnumClass *enum_class,
|
||||
gint value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class,
|
||||
const gchar *name);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class,
|
||||
const gchar *nick);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class,
|
||||
guint value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class,
|
||||
const gchar *name);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class,
|
||||
const gchar *nick);
|
||||
GOBJECT_AVAILABLE_IN_2_54
|
||||
gchar *g_enum_to_string (GType g_enum_type,
|
||||
gint value);
|
||||
GOBJECT_AVAILABLE_IN_2_54
|
||||
gchar *g_flags_to_string (GType flags_type,
|
||||
guint value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_enum (GValue *value,
|
||||
gint v_enum);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gint g_value_get_enum (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_flags (GValue *value,
|
||||
guint v_flags);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
guint g_value_get_flags (const GValue *value);
|
||||
|
||||
|
||||
|
||||
/* --- registration functions --- */
|
||||
/* const_static_values is a NULL terminated array of enum/flags
|
||||
* values that is taken over!
|
||||
*/
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_enum_register_static (const gchar *name,
|
||||
const GEnumValue *const_static_values);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_flags_register_static (const gchar *name,
|
||||
const GFlagsValue *const_static_values);
|
||||
/* functions to complete the type information
|
||||
* for enums/flags implemented by plugins
|
||||
*/
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_enum_complete_type_info (GType g_enum_type,
|
||||
GTypeInfo *info,
|
||||
const GEnumValue *const_values);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_flags_complete_type_info (GType g_flags_type,
|
||||
GTypeInfo *info,
|
||||
const GFlagsValue *const_values);
|
||||
|
||||
/* {{{ Macros */
|
||||
|
||||
/**
|
||||
* G_DEFINE_ENUM_VALUE:
|
||||
* @EnumValue: an enumeration value
|
||||
* @EnumNick: a short string representing the enumeration value
|
||||
*
|
||||
* Defines an enumeration value, and maps it to a "nickname".
|
||||
*
|
||||
* This macro can only be used with G_DEFINE_ENUM_TYPE() and
|
||||
* G_DEFINE_FLAGS_TYPE().
|
||||
*
|
||||
* Since: 2.74
|
||||
*/
|
||||
#define G_DEFINE_ENUM_VALUE(EnumValue, EnumNick) \
|
||||
{ EnumValue, #EnumValue, EnumNick } \
|
||||
GOBJECT_AVAILABLE_MACRO_IN_2_74
|
||||
|
||||
/**
|
||||
* G_DEFINE_ENUM_TYPE:
|
||||
* @TypeName: the enumeration type, in `CamelCase`
|
||||
* @type_name: the enumeration type prefixed, in `snake_case`
|
||||
* @...: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()
|
||||
*
|
||||
* A convenience macro for defining enumeration types.
|
||||
*
|
||||
* This macro will generate a `*_get_type()` function for the
|
||||
* given @TypeName, using @type_name as the function prefix.
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* G_DEFINE_ENUM_TYPE (GtkOrientation, gtk_orientation,
|
||||
* G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_HORIZONTAL, "horizontal"),
|
||||
* G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_VERTICAL, "vertical"))
|
||||
* ]|
|
||||
*
|
||||
* For projects that have multiple enumeration types, or enumeration
|
||||
* types with many values, you should consider using glib-mkenums to
|
||||
* generate the type function.
|
||||
*
|
||||
* Since: 2.74
|
||||
*/
|
||||
#define G_DEFINE_ENUM_TYPE(TypeName, type_name, ...) \
|
||||
GType \
|
||||
type_name ## _get_type (void) { \
|
||||
static _g_type_once_init_type g_define_type__static = 0; \
|
||||
if (_g_type_once_init_enter (&g_define_type__static)) { \
|
||||
static const GEnumValue enum_values[] = { \
|
||||
__VA_ARGS__ , \
|
||||
{ 0, NULL, NULL }, \
|
||||
}; \
|
||||
GType g_define_type = g_enum_register_static (g_intern_static_string (#TypeName), enum_values); \
|
||||
_g_type_once_init_leave (&g_define_type__static, g_define_type); \
|
||||
} \
|
||||
return g_define_type__static; \
|
||||
} \
|
||||
GOBJECT_AVAILABLE_MACRO_IN_2_74
|
||||
|
||||
/**
|
||||
* G_DEFINE_FLAGS_TYPE:
|
||||
* @TypeName: the enumeration type, in `CamelCase`
|
||||
* @type_name: the enumeration type prefixed, in `snake_case`
|
||||
* @...: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()
|
||||
*
|
||||
* A convenience macro for defining flag types.
|
||||
*
|
||||
* This macro will generate a `*_get_type()` function for the
|
||||
* given @TypeName, using @type_name as the function prefix.
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* G_DEFINE_FLAGS_TYPE (GSettingsBindFlags, g_settings_bind_flags,
|
||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_DEFAULT, "default"),
|
||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET, "get"),
|
||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_SET, "set"),
|
||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_NO_SENSITIVITY, "no-sensitivity"),
|
||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET_NO_CHANGES, "get-no-changes"),
|
||||
* G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_INVERT_BOOLEAN, "invert-boolean"))
|
||||
* ]|
|
||||
*
|
||||
* For projects that have multiple enumeration types, or enumeration
|
||||
* types with many values, you should consider using glib-mkenums to
|
||||
* generate the type function.
|
||||
*
|
||||
* Since: 2.74
|
||||
*/
|
||||
#define G_DEFINE_FLAGS_TYPE(TypeName, type_name, ...) \
|
||||
GType \
|
||||
type_name ## _get_type (void) { \
|
||||
static _g_type_once_init_type g_define_type__static = 0; \
|
||||
if (_g_type_once_init_enter (&g_define_type__static)) { \
|
||||
static const GFlagsValue flags_values[] = { \
|
||||
__VA_ARGS__ , \
|
||||
{ 0, NULL, NULL }, \
|
||||
}; \
|
||||
GType g_define_type = g_flags_register_static (g_intern_static_string (#TypeName), flags_values); \
|
||||
_g_type_once_init_leave (&g_define_type__static, g_define_type); \
|
||||
} \
|
||||
return g_define_type__static; \
|
||||
} \
|
||||
GOBJECT_AVAILABLE_MACRO_IN_2_74
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_ENUMS_H__ */
|
@@ -1,453 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2000-2001 Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __GLIB_TYPES_H__
|
||||
#define __GLIB_TYPES_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) && !defined(GLIB_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <gobject/gobject-visibility.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* A hack necesssary to preprocess this file with g-ir-scanner */
|
||||
#ifdef __GI_SCANNER__
|
||||
typedef gsize GType;
|
||||
#endif
|
||||
|
||||
/* --- GLib boxed types --- */
|
||||
/**
|
||||
* G_TYPE_DATE:
|
||||
*
|
||||
* The #GType for #GDate.
|
||||
*/
|
||||
#define G_TYPE_DATE (g_date_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_STRV:
|
||||
*
|
||||
* 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
|
||||
* type %G_TYPE_STRV with g_object_class_install_property(), g_object_set()
|
||||
* and g_object_get().
|
||||
*
|
||||
* |[
|
||||
* g_object_class_install_property (object_class,
|
||||
* PROP_AUTHORS,
|
||||
* g_param_spec_boxed ("authors",
|
||||
* _("Authors"),
|
||||
* _("List of authors"),
|
||||
* G_TYPE_STRV,
|
||||
* G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
*
|
||||
* gchar *authors[] = { "Owen", "Tim", NULL };
|
||||
* g_object_set (obj, "authors", authors, NULL);
|
||||
*
|
||||
* gchar *writers[];
|
||||
* g_object_get (obj, "authors", &writers, NULL);
|
||||
* /* do something with writers */
|
||||
* g_strfreev (writers);
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.4
|
||||
*/
|
||||
#define G_TYPE_STRV (g_strv_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_GSTRING:
|
||||
*
|
||||
* The #GType for #GString.
|
||||
*/
|
||||
#define G_TYPE_GSTRING (g_gstring_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_HASH_TABLE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GHashTable reference.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
#define G_TYPE_HASH_TABLE (g_hash_table_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_REGEX:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GRegex reference.
|
||||
*
|
||||
* Since: 2.14
|
||||
*/
|
||||
#define G_TYPE_REGEX (g_regex_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_MATCH_INFO:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GMatchInfo reference.
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
#define G_TYPE_MATCH_INFO (g_match_info_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_ARRAY:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GArray reference.
|
||||
*
|
||||
* Since: 2.22
|
||||
*/
|
||||
#define G_TYPE_ARRAY (g_array_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_BYTE_ARRAY:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GByteArray reference.
|
||||
*
|
||||
* Since: 2.22
|
||||
*/
|
||||
#define G_TYPE_BYTE_ARRAY (g_byte_array_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_PTR_ARRAY:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GPtrArray reference.
|
||||
*
|
||||
* Since: 2.22
|
||||
*/
|
||||
#define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_BYTES:
|
||||
*
|
||||
* The #GType for #GBytes.
|
||||
*
|
||||
* Since: 2.32
|
||||
*/
|
||||
#define G_TYPE_BYTES (g_bytes_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_VARIANT_TYPE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GVariantType.
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
#define G_TYPE_VARIANT_TYPE (g_variant_type_get_gtype ())
|
||||
|
||||
/**
|
||||
* G_TYPE_ERROR:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GError.
|
||||
*
|
||||
* Since: 2.26
|
||||
*/
|
||||
#define G_TYPE_ERROR (g_error_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_DATE_TIME:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GDateTime.
|
||||
*
|
||||
* Since: 2.26
|
||||
*/
|
||||
#define G_TYPE_DATE_TIME (g_date_time_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_TIME_ZONE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GTimeZone.
|
||||
*
|
||||
* Since: 2.34
|
||||
*/
|
||||
#define G_TYPE_TIME_ZONE (g_time_zone_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_IO_CHANNEL:
|
||||
*
|
||||
* The #GType for #GIOChannel.
|
||||
*/
|
||||
#define G_TYPE_IO_CHANNEL (g_io_channel_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_IO_CONDITION:
|
||||
*
|
||||
* The #GType for #GIOCondition.
|
||||
*/
|
||||
#define G_TYPE_IO_CONDITION (g_io_condition_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_VARIANT_BUILDER:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GVariantBuilder.
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
#define G_TYPE_VARIANT_BUILDER (g_variant_builder_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_VARIANT_DICT:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GVariantDict.
|
||||
*
|
||||
* Since: 2.40
|
||||
*/
|
||||
#define G_TYPE_VARIANT_DICT (g_variant_dict_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_MAIN_LOOP:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GMainLoop.
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
#define G_TYPE_MAIN_LOOP (g_main_loop_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_MAIN_CONTEXT:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GMainContext.
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
#define G_TYPE_MAIN_CONTEXT (g_main_context_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_SOURCE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GSource.
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
#define G_TYPE_SOURCE (g_source_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_POLLFD:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GPollFD.
|
||||
*
|
||||
* Since: 2.36
|
||||
*/
|
||||
#define G_TYPE_POLLFD (g_pollfd_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_MARKUP_PARSE_CONTEXT:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GMarkupParseContext.
|
||||
*
|
||||
* Since: 2.36
|
||||
*/
|
||||
#define G_TYPE_MARKUP_PARSE_CONTEXT (g_markup_parse_context_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_KEY_FILE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GKeyFile.
|
||||
*
|
||||
* Since: 2.32
|
||||
*/
|
||||
#define G_TYPE_KEY_FILE (g_key_file_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_MAPPED_FILE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GMappedFile.
|
||||
*
|
||||
* Since: 2.40
|
||||
*/
|
||||
#define G_TYPE_MAPPED_FILE (g_mapped_file_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_THREAD:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GThread.
|
||||
*
|
||||
* Since: 2.36
|
||||
*/
|
||||
#define G_TYPE_THREAD (g_thread_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_CHECKSUM:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GChecksum.
|
||||
*
|
||||
* Since: 2.36
|
||||
*/
|
||||
#define G_TYPE_CHECKSUM (g_checksum_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_OPTION_GROUP:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GOptionGroup.
|
||||
*
|
||||
* Since: 2.44
|
||||
*/
|
||||
#define G_TYPE_OPTION_GROUP (g_option_group_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_URI:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GUri.
|
||||
*
|
||||
* Since: 2.66
|
||||
*/
|
||||
#define G_TYPE_URI (g_uri_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_TREE:
|
||||
*
|
||||
* The #GType for #GTree.
|
||||
*
|
||||
* Since: 2.68
|
||||
*/
|
||||
#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 ())
|
||||
|
||||
/**
|
||||
* G_TYPE_BOOKMARK_FILE:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GBookmarkFile.
|
||||
*
|
||||
* Since: 2.76
|
||||
*/
|
||||
#define G_TYPE_BOOKMARK_FILE (g_bookmark_file_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_HMAC:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GHmac.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define G_TYPE_HMAC (g_hmac_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_DIR:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GDir.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define G_TYPE_DIR (g_dir_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_RAND:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GRand.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define G_TYPE_RAND (g_rand_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_STRV_BUILDER:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GStrvBuilder.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define G_TYPE_STRV_BUILDER (g_strv_builder_get_type ())
|
||||
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_date_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_strv_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_gstring_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_hash_table_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_array_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_byte_array_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_ptr_array_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_bytes_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_variant_type_get_gtype (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_regex_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_30
|
||||
GType g_match_info_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_error_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_date_time_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_time_zone_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_io_channel_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_io_condition_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_variant_builder_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_40
|
||||
GType g_variant_dict_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_key_file_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_30
|
||||
GType g_main_loop_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_30
|
||||
GType g_main_context_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_30
|
||||
GType g_source_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_36
|
||||
GType g_pollfd_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_36
|
||||
GType g_thread_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_36
|
||||
GType g_checksum_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_36
|
||||
GType g_markup_parse_context_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_40
|
||||
GType g_mapped_file_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_44
|
||||
GType g_option_group_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_66
|
||||
GType g_uri_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_68
|
||||
GType g_tree_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_70
|
||||
GType g_pattern_spec_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_76
|
||||
GType g_bookmark_file_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_hmac_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_dir_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_rand_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_strv_builder_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GOBJECT_DEPRECATED_FOR('G_TYPE_VARIANT')
|
||||
GType g_variant_get_gtype (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLIB_TYPES_H__ */
|
@@ -23,7 +23,8 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "gboxed.h"
|
||||
#include "../glib/gtype-private.h"
|
||||
|
||||
#include "gclosure.h"
|
||||
#include "gobject.h"
|
||||
|
||||
@@ -38,7 +39,7 @@
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
#define GOBJECT_IF_DEBUG(debug_type, code_block) \
|
||||
G_STMT_START { \
|
||||
if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type) \
|
||||
if (GLIB_PRIVATE_CALL (g_type_has_debug_flag) (G_TYPE_DEBUG_ ## debug_type)) \
|
||||
{ code_block; } \
|
||||
} G_STMT_END
|
||||
#else /* !G_ENABLE_DEBUG */
|
||||
@@ -47,10 +48,6 @@ G_STMT_START { \
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
extern GTypeDebugFlags _g_type_debug_flags;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct _GRealClosure GRealClosure;
|
||||
struct _GRealClosure
|
||||
{
|
||||
@@ -64,25 +61,11 @@ struct _GRealClosure
|
||||
#define G_REAL_CLOSURE(_c) \
|
||||
((GRealClosure *)G_STRUCT_MEMBER_P ((_c), -G_STRUCT_OFFSET (GRealClosure, closure)))
|
||||
|
||||
void _g_value_c_init (void); /* sync with gvalue.c */
|
||||
void _g_value_types_init (void); /* sync with gvaluetypes.c */
|
||||
void _g_enum_types_init (void); /* sync with genums.c */
|
||||
void _g_param_type_init (void); /* sync with gparam.c */
|
||||
void _g_boxed_type_init (void); /* sync with gboxed.c */
|
||||
void _g_object_type_init (void); /* sync with gobject.c */
|
||||
void _g_param_spec_types_init (void); /* sync with gparamspecs.c */
|
||||
void _g_value_transforms_init (void); /* sync with gvaluetransform.c */
|
||||
void _g_signal_init (void); /* sync with gsignal.c */
|
||||
|
||||
/* for gboxed.c */
|
||||
gpointer _g_type_boxed_copy (GType type,
|
||||
gpointer value);
|
||||
void _g_type_boxed_free (GType type,
|
||||
gpointer value);
|
||||
void _g_type_boxed_init (GType type,
|
||||
GBoxedCopyFunc copy_func,
|
||||
GBoxedFreeFunc free_func);
|
||||
|
||||
gboolean _g_closure_is_void (GClosure *closure,
|
||||
gpointer instance);
|
||||
gboolean _g_closure_supports_invoke_va (GClosure *closure);
|
@@ -27,9 +27,9 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "../glib/glib-private.h"
|
||||
#include "../glib/gtype-private.h"
|
||||
|
||||
#include "gobject.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gobject-private.h"
|
||||
#include "gvaluecollector.h"
|
||||
#include "gsignal.h"
|
||||
#include "gparamspecs.h"
|
||||
@@ -895,7 +895,7 @@ _g_object_type_init (void)
|
||||
*
|
||||
* See: https://bugzilla.gnome.org/show_bug.cgi?id=769504
|
||||
*/
|
||||
if (_g_type_debug_flags & G_TYPE_DEBUG_OBJECTS) \
|
||||
if (GLIB_PRIVATE_CALL (g_type_has_debug_flag) (G_TYPE_DEBUG_OBJECTS))
|
||||
{
|
||||
debug_objects_ht = g_hash_table_new (g_direct_hash, NULL);
|
||||
# ifndef G_HAS_CONSTRUCTORS
|
||||
@@ -2666,6 +2666,8 @@ g_object_new_internal (GObjectClass *class,
|
||||
if (nqueue)
|
||||
g_object_notify_queue_thaw (object, nqueue, FALSE);
|
||||
|
||||
TRACE(GOBJECT_OBJECT_NEW(object, class->g_type_class.g_type));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -5825,3 +5827,110 @@ g_weak_ref_set (GWeakRef *weak_ref,
|
||||
|
||||
_weak_ref_set (weak_ref, object, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gobject_init (void)
|
||||
{
|
||||
/* G_TYPE_PARAM */
|
||||
_g_param_type_init ();
|
||||
|
||||
/* G_TYPE_OBJECT */
|
||||
_g_object_type_init ();
|
||||
|
||||
/* G_TYPE_PARAM_* pspec types */
|
||||
_g_param_spec_types_init ();
|
||||
|
||||
/* Signal system */
|
||||
_g_signal_init ();
|
||||
}
|
||||
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
|
||||
void gobject_win32_init (void);
|
||||
|
||||
void
|
||||
gobject_win32_init (void)
|
||||
{
|
||||
/* May be called more than once in static compilation mode */
|
||||
static gboolean win32_already_init = FALSE;
|
||||
if (!win32_already_init)
|
||||
{
|
||||
win32_already_init = TRUE;
|
||||
gobject_init ();
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef GLIB_STATIC_COMPILATION
|
||||
|
||||
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved);
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved)
|
||||
{
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
gobject_win32_init ();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* do nothing */
|
||||
;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#elif defined(G_HAS_CONSTRUCTORS) /* && G_PLATFORM_WIN32 && GLIB_STATIC_COMPILATION */
|
||||
extern void glib_win32_init (void);
|
||||
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(gobject_init_ctor)
|
||||
#endif
|
||||
|
||||
G_DEFINE_CONSTRUCTOR(gobject_init_ctor)
|
||||
|
||||
static void
|
||||
gobject_init_ctor (void)
|
||||
{
|
||||
/* When built dynamically, module initialization is done through DllMain
|
||||
* function which is called when the dynamic library is loaded by the glib
|
||||
* module. So, in dynamic configuration glib is always initialized BEFORE
|
||||
* gobject.
|
||||
*
|
||||
* When built statically, initialization mechanism relies on hooking
|
||||
* functions to the CRT section directly at compilation time. As we don't
|
||||
* control how each compilation unit will be built and in which order, we
|
||||
* obtain the same kind of issue as the "static initialization order fiasco".
|
||||
* In this case, we must ensure explicitly that glib is always well
|
||||
* initialized BEFORE gobject.
|
||||
*/
|
||||
glib_win32_init ();
|
||||
gobject_win32_init ();
|
||||
}
|
||||
|
||||
#else /* G_PLATFORM_WIN32 && GLIB_STATIC_COMPILATION && !G_HAS_CONSTRUCTORS */
|
||||
# error Your platform/compiler is missing constructor support
|
||||
#endif /* GLIB_STATIC_COMPILATION */
|
||||
|
||||
#elif defined(G_HAS_CONSTRUCTORS) /* && !G_PLATFORM_WIN32 */
|
||||
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(gobject_init_ctor)
|
||||
#endif
|
||||
|
||||
G_DEFINE_CONSTRUCTOR (gobject_init_ctor)
|
||||
|
||||
static void
|
||||
gobject_init_ctor (void)
|
||||
{
|
||||
gobject_init ();
|
||||
}
|
||||
|
||||
#else /* !G_PLATFORM_WIN32 && !G_HAS_CONSTRUCTORS */
|
||||
#error Your platform/compiler is missing constructor support
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
|
@@ -23,16 +23,24 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gtype.h>
|
||||
#include <gobject/gvalue.h>
|
||||
#include <gobject/gparam.h>
|
||||
#include <gobject/gclosure.h>
|
||||
#include <gobject/gsignal.h>
|
||||
#include <gobject/gboxed.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <gobject/gobject-visibility.h>
|
||||
#include <gobject/gparam.h>
|
||||
#include <gobject/gclosure.h>
|
||||
#include <gobject/gsignal.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- type macros --- */
|
||||
|
||||
/**
|
||||
* G_TYPE_OBJECT:
|
||||
*
|
||||
* The fundamental type for #GObject.
|
||||
*/
|
||||
#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
|
||||
|
||||
/**
|
||||
* G_TYPE_IS_OBJECT:
|
||||
* @type: Type id to check
|
||||
|
@@ -1,5 +1,4 @@
|
||||
provider gobject {
|
||||
probe type__new(char *, unsigned long, unsigned long);
|
||||
probe object__new(void*, unsigned long);
|
||||
probe object__ref(void*, unsigned long, unsigned int);
|
||||
probe object__unref(void*, unsigned long, unsigned int);
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "gparam.h"
|
||||
#include "gparamspecs.h"
|
||||
#include "gvaluecollector.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gobject-private.h"
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
@@ -25,11 +25,18 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gvalue.h>
|
||||
#include <glib.h>
|
||||
#include <gobject/gobject-visibility.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- standard type macros --- */
|
||||
/**
|
||||
* G_TYPE_PARAM:
|
||||
*
|
||||
* The fundamental type from which all #GParamSpec types are derived.
|
||||
*/
|
||||
#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19)
|
||||
/**
|
||||
* G_TYPE_IS_PARAM:
|
||||
* @type: a #GType ID
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
|
||||
#include "gparamspecs.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gobject-private.h"
|
||||
#include "gvaluecollector.h"
|
||||
|
||||
#include "gvaluearray.h"
|
||||
|
@@ -25,10 +25,7 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gvalue.h>
|
||||
#include <gobject/genums.h>
|
||||
#include <gobject/gboxed.h>
|
||||
#include <gobject/gobject.h>
|
||||
#include <gobject/gobject.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -29,13 +29,13 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define GLIB_COMPILATION
|
||||
#include "../glib/gvaluecollector.h"
|
||||
|
||||
#include "gsignal.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gobject-private.h"
|
||||
#include "gbsearcharray.h"
|
||||
#include "gvaluecollector.h"
|
||||
#include "gvaluetypes.h"
|
||||
#include "gobject.h"
|
||||
#include "genums.h"
|
||||
#include "gobject_trace.h"
|
||||
|
||||
|
||||
|
@@ -23,10 +23,12 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gclosure.h>
|
||||
#include <gobject/gvalue.h>
|
||||
#include <gobject/gparam.h>
|
||||
#include <gobject/gmarshal.h>
|
||||
#include <glib.h>
|
||||
#include <gobject/gobject-visibility.h>
|
||||
|
||||
#include <gobject/gclosure.h>
|
||||
#include <gobject/gmarshal.h>
|
||||
#include <gobject/gparam.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -24,10 +24,27 @@
|
||||
#endif
|
||||
|
||||
#include <gobject/gclosure.h>
|
||||
#include <gobject/glib-types.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* G_TYPE_IO_CHANNEL:
|
||||
*
|
||||
* The #GType for #GIOChannel.
|
||||
*/
|
||||
#define G_TYPE_IO_CHANNEL (g_io_channel_get_type ())
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_io_channel_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/**
|
||||
* G_TYPE_IO_CONDITION:
|
||||
*
|
||||
* The #GType for #GIOCondition.
|
||||
*/
|
||||
#define G_TYPE_IO_CONDITION (g_io_condition_get_type ())
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_io_condition_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_source_set_closure (GSource *source,
|
||||
GClosure *closure);
|
||||
|
5084
gobject/gtype.c
5084
gobject/gtype.c
File diff suppressed because it is too large
Load Diff
2736
gobject/gtype.h
2736
gobject/gtype.h
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gtypeplugin.h"
|
||||
#include "gtypemodule.h"
|
||||
|
||||
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#endif
|
||||
|
||||
#include <gobject/gobject.h>
|
||||
#include <gobject/genums.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -1,202 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtypeplugin.h"
|
||||
|
||||
|
||||
/**
|
||||
* GTypePlugin:
|
||||
*
|
||||
* An interface that handles the lifecycle of dynamically loaded types.
|
||||
*
|
||||
* The GObject type system supports dynamic loading of types.
|
||||
* It goes as follows:
|
||||
*
|
||||
* 1. The type is initially introduced (usually upon loading the module
|
||||
* the first time, or by your main application that knows what modules
|
||||
* introduces what types), like this:
|
||||
* ```c
|
||||
* new_type_id = g_type_register_dynamic (parent_type_id,
|
||||
* "TypeName",
|
||||
* new_type_plugin,
|
||||
* type_flags);
|
||||
* ```
|
||||
* where `new_type_plugin` is an implementation of the
|
||||
* `GTypePlugin` interface.
|
||||
*
|
||||
* 2. The type's implementation is referenced, e.g. through
|
||||
* [func@GObject.TypeClass.ref] or through [func@GObject.type_create_instance]
|
||||
* (this is being called by [ctor@GObject.Object.new]) or through one of the above
|
||||
* done on a type derived from `new_type_id`.
|
||||
*
|
||||
* 3. This causes the type system to load the type's implementation by calling
|
||||
* [method@GObject.TypePlugin.use] and [method@GObject.TypePlugin.complete_type_info]
|
||||
* on `new_type_plugin`.
|
||||
*
|
||||
* 4. At some point the type's implementation isn't required anymore, e.g. after
|
||||
* [method@GObject.TypeClass.unref] or [func@GObject.type_free_instance]
|
||||
* (called when the reference count of an instance drops to zero).
|
||||
*
|
||||
* 5. This causes the type system to throw away the information retrieved
|
||||
* from [method@GObject.TypePlugin.complete_type_info] and then it calls
|
||||
* [method@GObject.TypePlugin.unuse] on `new_type_plugin`.
|
||||
*
|
||||
* 6. Things may repeat from the second step.
|
||||
*
|
||||
* So basically, you need to implement a `GTypePlugin` type that
|
||||
* carries a use_count, once use_count goes from zero to one, you need
|
||||
* to load the implementation to successfully handle the upcoming
|
||||
* [method@GObject.TypePlugin.complete_type_info] call. Later, maybe after
|
||||
* succeeding use/unuse calls, once use_count drops to zero, you can
|
||||
* unload the implementation again. The type system makes sure to call
|
||||
* [method@GObject.TypePlugin.use] and [method@GObject.TypePlugin.complete_type_info]
|
||||
* again when the type is needed again.
|
||||
*
|
||||
* [class@GObject.TypeModule] is an implementation of `GTypePlugin` that
|
||||
* already implements most of this except for the actual module loading and
|
||||
* unloading. It even handles multiple registered types per module.
|
||||
*/
|
||||
|
||||
|
||||
/* --- functions --- */
|
||||
GType
|
||||
g_type_plugin_get_type (void)
|
||||
{
|
||||
static GType type_plugin_type = 0;
|
||||
|
||||
if (!type_plugin_type)
|
||||
{
|
||||
const GTypeInfo type_plugin_info = {
|
||||
sizeof (GTypePluginClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
0, /* class_init */
|
||||
NULL, /* class_destroy */
|
||||
NULL, /* class_data */
|
||||
0, /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
NULL, /* instance_init */
|
||||
NULL, /* value_table */
|
||||
};
|
||||
|
||||
type_plugin_type = g_type_register_static (G_TYPE_INTERFACE, g_intern_static_string ("GTypePlugin"), &type_plugin_info, 0);
|
||||
}
|
||||
|
||||
return type_plugin_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_type_plugin_use:
|
||||
* @plugin: a #GTypePlugin
|
||||
*
|
||||
* Calls the @use_plugin function from the #GTypePluginClass of
|
||||
* @plugin. There should be no need to use this function outside of
|
||||
* the GObject type system itself.
|
||||
*/
|
||||
void
|
||||
g_type_plugin_use (GTypePlugin *plugin)
|
||||
{
|
||||
GTypePluginClass *iface;
|
||||
|
||||
g_return_if_fail (G_IS_TYPE_PLUGIN (plugin));
|
||||
|
||||
iface = G_TYPE_PLUGIN_GET_CLASS (plugin);
|
||||
iface->use_plugin (plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_type_plugin_unuse:
|
||||
* @plugin: a #GTypePlugin
|
||||
*
|
||||
* Calls the @unuse_plugin function from the #GTypePluginClass of
|
||||
* @plugin. There should be no need to use this function outside of
|
||||
* the GObject type system itself.
|
||||
*/
|
||||
void
|
||||
g_type_plugin_unuse (GTypePlugin *plugin)
|
||||
{
|
||||
GTypePluginClass *iface;
|
||||
|
||||
g_return_if_fail (G_IS_TYPE_PLUGIN (plugin));
|
||||
|
||||
iface = G_TYPE_PLUGIN_GET_CLASS (plugin);
|
||||
iface->unuse_plugin (plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_type_plugin_complete_type_info:
|
||||
* @plugin: a #GTypePlugin
|
||||
* @g_type: the #GType whose info is completed
|
||||
* @info: the #GTypeInfo struct to fill in
|
||||
* @value_table: the #GTypeValueTable to fill in
|
||||
*
|
||||
* Calls the @complete_type_info function from the #GTypePluginClass of @plugin.
|
||||
* There should be no need to use this function outside of the GObject
|
||||
* type system itself.
|
||||
*/
|
||||
void
|
||||
g_type_plugin_complete_type_info (GTypePlugin *plugin,
|
||||
GType g_type,
|
||||
GTypeInfo *info,
|
||||
GTypeValueTable *value_table)
|
||||
{
|
||||
GTypePluginClass *iface;
|
||||
|
||||
g_return_if_fail (G_IS_TYPE_PLUGIN (plugin));
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (value_table != NULL);
|
||||
|
||||
iface = G_TYPE_PLUGIN_GET_CLASS (plugin);
|
||||
iface->complete_type_info (plugin,
|
||||
g_type,
|
||||
info,
|
||||
value_table);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_type_plugin_complete_interface_info:
|
||||
* @plugin: the #GTypePlugin
|
||||
* @instance_type: the #GType of an instantiatable type to which the interface
|
||||
* is added
|
||||
* @interface_type: the #GType of the interface whose info is completed
|
||||
* @info: the #GInterfaceInfo to fill in
|
||||
*
|
||||
* Calls the @complete_interface_info function from the
|
||||
* #GTypePluginClass of @plugin. There should be no need to use this
|
||||
* function outside of the GObject type system itself.
|
||||
*/
|
||||
void
|
||||
g_type_plugin_complete_interface_info (GTypePlugin *plugin,
|
||||
GType instance_type,
|
||||
GType interface_type,
|
||||
GInterfaceInfo *info)
|
||||
{
|
||||
GTypePluginClass *iface;
|
||||
|
||||
g_return_if_fail (G_IS_TYPE_PLUGIN (plugin));
|
||||
g_return_if_fail (info != NULL);
|
||||
|
||||
iface = G_TYPE_PLUGIN_GET_CLASS (plugin);
|
||||
iface->complete_interface_info (plugin,
|
||||
instance_type,
|
||||
interface_type,
|
||||
info);
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __G_TYPE_PLUGIN_H__
|
||||
#define __G_TYPE_PLUGIN_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gtype.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- type macros --- */
|
||||
#define G_TYPE_TYPE_PLUGIN (g_type_plugin_get_type ())
|
||||
#define G_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TYPE_PLUGIN, GTypePlugin))
|
||||
#define G_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), G_TYPE_TYPE_PLUGIN, GTypePluginClass))
|
||||
#define G_IS_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TYPE_PLUGIN))
|
||||
#define G_IS_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), G_TYPE_TYPE_PLUGIN))
|
||||
#define G_TYPE_PLUGIN_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TYPE_PLUGIN, GTypePluginClass))
|
||||
|
||||
|
||||
/* --- typedefs & structures --- */
|
||||
typedef struct _GTypePluginClass GTypePluginClass;
|
||||
/**
|
||||
* GTypePluginUse:
|
||||
* @plugin: the #GTypePlugin whose use count should be increased
|
||||
*
|
||||
* The type of the @use_plugin function of #GTypePluginClass, which gets called
|
||||
* to increase the use count of @plugin.
|
||||
*/
|
||||
typedef void (*GTypePluginUse) (GTypePlugin *plugin);
|
||||
/**
|
||||
* GTypePluginUnuse:
|
||||
* @plugin: the #GTypePlugin whose use count should be decreased
|
||||
*
|
||||
* The type of the @unuse_plugin function of #GTypePluginClass.
|
||||
*/
|
||||
typedef void (*GTypePluginUnuse) (GTypePlugin *plugin);
|
||||
/**
|
||||
* GTypePluginCompleteTypeInfo:
|
||||
* @plugin: the #GTypePlugin
|
||||
* @g_type: the #GType whose info is completed
|
||||
* @info: the #GTypeInfo struct to fill in
|
||||
* @value_table: the #GTypeValueTable to fill in
|
||||
*
|
||||
* The type of the @complete_type_info function of #GTypePluginClass.
|
||||
*/
|
||||
typedef void (*GTypePluginCompleteTypeInfo) (GTypePlugin *plugin,
|
||||
GType g_type,
|
||||
GTypeInfo *info,
|
||||
GTypeValueTable *value_table);
|
||||
/**
|
||||
* GTypePluginCompleteInterfaceInfo:
|
||||
* @plugin: the #GTypePlugin
|
||||
* @instance_type: the #GType of an instantiatable type to which the interface
|
||||
* is added
|
||||
* @interface_type: the #GType of the interface whose info is completed
|
||||
* @info: the #GInterfaceInfo to fill in
|
||||
*
|
||||
* The type of the @complete_interface_info function of #GTypePluginClass.
|
||||
*/
|
||||
typedef void (*GTypePluginCompleteInterfaceInfo) (GTypePlugin *plugin,
|
||||
GType instance_type,
|
||||
GType interface_type,
|
||||
GInterfaceInfo *info);
|
||||
/**
|
||||
* GTypePluginClass:
|
||||
* @use_plugin: Increases the use count of the plugin.
|
||||
* @unuse_plugin: Decreases the use count of the plugin.
|
||||
* @complete_type_info: Fills in the #GTypeInfo and
|
||||
* #GTypeValueTable structs for the type. The structs are initialized
|
||||
* with `memset(s, 0, sizeof (s))` before calling this function.
|
||||
* @complete_interface_info: Fills in missing parts of the #GInterfaceInfo
|
||||
* for the interface. The structs is initialized with
|
||||
* `memset(s, 0, sizeof (s))` before calling this function.
|
||||
*
|
||||
* The #GTypePlugin interface is used by the type system in order to handle
|
||||
* the lifecycle of dynamically loaded types.
|
||||
*/
|
||||
struct _GTypePluginClass
|
||||
{
|
||||
/*< private >*/
|
||||
GTypeInterface base_iface;
|
||||
|
||||
/*< public >*/
|
||||
GTypePluginUse use_plugin;
|
||||
GTypePluginUnuse unuse_plugin;
|
||||
GTypePluginCompleteTypeInfo complete_type_info;
|
||||
GTypePluginCompleteInterfaceInfo complete_interface_info;
|
||||
};
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_type_plugin_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_type_plugin_use (GTypePlugin *plugin);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_type_plugin_unuse (GTypePlugin *plugin);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_type_plugin_complete_type_info (GTypePlugin *plugin,
|
||||
GType g_type,
|
||||
GTypeInfo *info,
|
||||
GTypeValueTable *value_table);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_type_plugin_complete_interface_info (GTypePlugin *plugin,
|
||||
GType instance_type,
|
||||
GType interface_type,
|
||||
GInterfaceInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_TYPE_PLUGIN_H__ */
|
561
gobject/gvalue.c
561
gobject/gvalue.c
@@ -1,561 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FIXME: MT-safety
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gvalue.h"
|
||||
#include "gvaluecollector.h"
|
||||
#include "gbsearcharray.h"
|
||||
#include "gtype-private.h"
|
||||
|
||||
|
||||
/* --- typedefs & structures --- */
|
||||
typedef struct {
|
||||
GType src_type;
|
||||
GType dest_type;
|
||||
GValueTransform func;
|
||||
} TransformEntry;
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static gint transform_entries_cmp (gconstpointer bsearch_node1,
|
||||
gconstpointer bsearch_node2);
|
||||
|
||||
|
||||
/* --- variables --- */
|
||||
static GBSearchArray *transform_array = NULL;
|
||||
static GBSearchConfig transform_bconfig = {
|
||||
sizeof (TransformEntry),
|
||||
transform_entries_cmp,
|
||||
G_BSEARCH_ARRAY_ALIGN_POWER2,
|
||||
};
|
||||
|
||||
|
||||
/* --- functions --- */
|
||||
void
|
||||
_g_value_c_init (void)
|
||||
{
|
||||
transform_array = g_bsearch_array_create (&transform_bconfig);
|
||||
}
|
||||
|
||||
static inline void /* keep this function in sync with gvaluecollector.h and gboxed.c */
|
||||
value_meminit (GValue *value,
|
||||
GType value_type)
|
||||
{
|
||||
value->g_type = value_type;
|
||||
memset (value->data, 0, sizeof (value->data));
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_init:
|
||||
* @value: A zero-filled (uninitialized) #GValue structure.
|
||||
* @g_type: Type the #GValue should hold values of.
|
||||
*
|
||||
* Initializes @value with the default value of @type.
|
||||
*
|
||||
* Returns: (transfer none): the #GValue structure that has been passed in
|
||||
*/
|
||||
GValue*
|
||||
g_value_init (GValue *value,
|
||||
GType g_type)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
/* g_return_val_if_fail (G_TYPE_IS_VALUE (g_type), NULL); be more elaborate below */
|
||||
g_return_val_if_fail (value != NULL, NULL);
|
||||
/* g_return_val_if_fail (G_VALUE_TYPE (value) == 0, NULL); be more elaborate below */
|
||||
|
||||
value_table = g_type_value_table_peek (g_type);
|
||||
|
||||
if (value_table && G_VALUE_TYPE (value) == 0)
|
||||
{
|
||||
/* setup and init */
|
||||
value_meminit (value, g_type);
|
||||
value_table->value_init (value);
|
||||
}
|
||||
else if (G_VALUE_TYPE (value))
|
||||
g_critical ("%s: cannot initialize GValue with type '%s', the value has already been initialized as '%s'",
|
||||
G_STRLOC,
|
||||
g_type_name (g_type),
|
||||
g_type_name (G_VALUE_TYPE (value)));
|
||||
else /* !G_TYPE_IS_VALUE (g_type) */
|
||||
g_critical ("%s: cannot initialize GValue with type '%s', %s",
|
||||
G_STRLOC,
|
||||
g_type_name (g_type),
|
||||
value_table ? "this type is abstract with regards to GValue use, use a more specific (derived) type" : "this type has no GTypeValueTable implementation");
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_copy:
|
||||
* @src_value: An initialized #GValue structure.
|
||||
* @dest_value: An initialized #GValue structure of the same type as @src_value.
|
||||
*
|
||||
* Copies the value of @src_value into @dest_value.
|
||||
*/
|
||||
void
|
||||
g_value_copy (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
g_return_if_fail (src_value);
|
||||
g_return_if_fail (dest_value);
|
||||
g_return_if_fail (g_value_type_compatible (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value)));
|
||||
|
||||
if (src_value != dest_value)
|
||||
{
|
||||
GType dest_type = G_VALUE_TYPE (dest_value);
|
||||
GTypeValueTable *value_table = g_type_value_table_peek (dest_type);
|
||||
|
||||
g_return_if_fail (value_table);
|
||||
|
||||
/* make sure dest_value's value is free()d */
|
||||
if (value_table->value_free)
|
||||
value_table->value_free (dest_value);
|
||||
|
||||
/* setup and copy */
|
||||
value_meminit (dest_value, dest_type);
|
||||
value_table->value_copy (src_value, dest_value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_reset:
|
||||
* @value: An initialized #GValue structure.
|
||||
*
|
||||
* Clears the current value in @value and resets it to the default value
|
||||
* (as if the value had just been initialized).
|
||||
*
|
||||
* Returns: the #GValue structure that has been passed in
|
||||
*/
|
||||
GValue*
|
||||
g_value_reset (GValue *value)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
GType g_type;
|
||||
|
||||
g_return_val_if_fail (value, NULL);
|
||||
g_type = G_VALUE_TYPE (value);
|
||||
|
||||
value_table = g_type_value_table_peek (g_type);
|
||||
g_return_val_if_fail (value_table, NULL);
|
||||
|
||||
/* make sure value's value is free()d */
|
||||
if (value_table->value_free)
|
||||
value_table->value_free (value);
|
||||
|
||||
/* setup and init */
|
||||
value_meminit (value, g_type);
|
||||
value_table->value_init (value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_unset:
|
||||
* @value: An initialized #GValue structure.
|
||||
*
|
||||
* Clears the current value in @value (if any) and "unsets" the type,
|
||||
* this releases all resources associated with this GValue. An unset
|
||||
* value is the same as an uninitialized (zero-filled) #GValue
|
||||
* structure.
|
||||
*/
|
||||
void
|
||||
g_value_unset (GValue *value)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
|
||||
if (value->g_type == 0)
|
||||
return;
|
||||
|
||||
g_return_if_fail (value);
|
||||
|
||||
value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
|
||||
g_return_if_fail (value_table);
|
||||
|
||||
if (value_table->value_free)
|
||||
value_table->value_free (value);
|
||||
memset (value, 0, sizeof (*value));
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_fits_pointer:
|
||||
* @value: An initialized #GValue structure.
|
||||
*
|
||||
* Determines if @value will fit inside the size of a pointer value.
|
||||
* This is an internal function introduced mainly for C marshallers.
|
||||
*
|
||||
* Returns: %TRUE if @value will fit inside a pointer value.
|
||||
*/
|
||||
gboolean
|
||||
g_value_fits_pointer (const GValue *value)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
|
||||
g_return_val_if_fail (value, FALSE);
|
||||
|
||||
value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
|
||||
g_return_val_if_fail (value_table, FALSE);
|
||||
|
||||
return value_table->value_peek_pointer != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_peek_pointer:
|
||||
* @value: An initialized #GValue structure
|
||||
*
|
||||
* Returns the value contents as pointer. This function asserts that
|
||||
* g_value_fits_pointer() returned %TRUE for the passed in value.
|
||||
* This is an internal function introduced mainly for C marshallers.
|
||||
*
|
||||
* Returns: (transfer none): the value contents as pointer
|
||||
*/
|
||||
gpointer
|
||||
g_value_peek_pointer (const GValue *value)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
|
||||
g_return_val_if_fail (value, NULL);
|
||||
|
||||
value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
|
||||
g_return_val_if_fail (value_table, NULL);
|
||||
|
||||
if (!value_table->value_peek_pointer)
|
||||
{
|
||||
g_return_val_if_fail (g_value_fits_pointer (value) == TRUE, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value_table->value_peek_pointer (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_set_instance:
|
||||
* @value: An initialized #GValue structure.
|
||||
* @instance: (nullable): the instance
|
||||
*
|
||||
* Sets @value from an instantiatable type via the
|
||||
* value_table's collect_value() function.
|
||||
*/
|
||||
void
|
||||
g_value_set_instance (GValue *value,
|
||||
gpointer instance)
|
||||
{
|
||||
GType g_type;
|
||||
GTypeValueTable *value_table;
|
||||
GTypeCValue cvalue;
|
||||
gchar *error_msg;
|
||||
|
||||
g_return_if_fail (value);
|
||||
g_type = G_VALUE_TYPE (value);
|
||||
value_table = g_type_value_table_peek (g_type);
|
||||
g_return_if_fail (value_table);
|
||||
|
||||
if (instance)
|
||||
{
|
||||
g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
|
||||
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (instance), G_VALUE_TYPE (value)));
|
||||
}
|
||||
|
||||
g_return_if_fail (strcmp (value_table->collect_format, "p") == 0);
|
||||
|
||||
memset (&cvalue, 0, sizeof (cvalue));
|
||||
cvalue.v_pointer = instance;
|
||||
|
||||
/* make sure value's value is free()d */
|
||||
if (value_table->value_free)
|
||||
value_table->value_free (value);
|
||||
|
||||
/* setup and collect */
|
||||
value_meminit (value, g_type);
|
||||
error_msg = value_table->collect_value (value, 1, &cvalue, 0);
|
||||
if (error_msg)
|
||||
{
|
||||
g_critical ("%s: %s", G_STRLOC, error_msg);
|
||||
g_free (error_msg);
|
||||
|
||||
/* we purposely leak the value here, it might not be
|
||||
* in a correct state if an error condition occurred
|
||||
*/
|
||||
value_meminit (value, g_type);
|
||||
value_table->value_init (value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_init_from_instance:
|
||||
* @value: An uninitialized #GValue structure.
|
||||
* @instance: (type GObject.TypeInstance): the instance
|
||||
*
|
||||
* Initializes and sets @value from an instantiatable type via the
|
||||
* value_table's collect_value() function.
|
||||
*
|
||||
* Note: The @value will be initialised with the exact type of
|
||||
* @instance. If you wish to set the @value's type to a different GType
|
||||
* (such as a parent class GType), you need to manually call
|
||||
* g_value_init() and g_value_set_instance().
|
||||
*
|
||||
* Since: 2.42
|
||||
*/
|
||||
void
|
||||
g_value_init_from_instance (GValue *value,
|
||||
gpointer instance)
|
||||
{
|
||||
g_return_if_fail (value != NULL && G_VALUE_TYPE(value) == 0);
|
||||
|
||||
if (G_IS_OBJECT (instance))
|
||||
{
|
||||
/* Fast-path.
|
||||
* If G_IS_OBJECT() succeeds we know:
|
||||
* * that instance is present and valid
|
||||
* * that it is a GObject, and therefore we can directly
|
||||
* use the collect implementation (g_object_ref) */
|
||||
value_meminit (value, G_TYPE_FROM_INSTANCE (instance));
|
||||
value->data[0].v_pointer = g_object_ref (instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
GType g_type;
|
||||
GTypeValueTable *value_table;
|
||||
GTypeCValue cvalue;
|
||||
gchar *error_msg;
|
||||
|
||||
g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
|
||||
|
||||
g_type = G_TYPE_FROM_INSTANCE (instance);
|
||||
value_table = g_type_value_table_peek (g_type);
|
||||
g_return_if_fail (strcmp (value_table->collect_format, "p") == 0);
|
||||
|
||||
memset (&cvalue, 0, sizeof (cvalue));
|
||||
cvalue.v_pointer = instance;
|
||||
|
||||
/* setup and collect */
|
||||
value_meminit (value, g_type);
|
||||
value_table->value_init (value);
|
||||
error_msg = value_table->collect_value (value, 1, &cvalue, 0);
|
||||
if (error_msg)
|
||||
{
|
||||
g_critical ("%s: %s", G_STRLOC, error_msg);
|
||||
g_free (error_msg);
|
||||
|
||||
/* we purposely leak the value here, it might not be
|
||||
* in a correct state if an error condition occurred
|
||||
*/
|
||||
value_meminit (value, g_type);
|
||||
value_table->value_init (value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GType
|
||||
transform_lookup_get_parent_type (GType type)
|
||||
{
|
||||
if (g_type_fundamental (type) == G_TYPE_INTERFACE)
|
||||
return g_type_interface_instantiatable_prerequisite (type);
|
||||
|
||||
return g_type_parent (type);
|
||||
}
|
||||
|
||||
static GValueTransform
|
||||
transform_func_lookup (GType src_type,
|
||||
GType dest_type)
|
||||
{
|
||||
TransformEntry entry;
|
||||
|
||||
entry.src_type = src_type;
|
||||
do
|
||||
{
|
||||
entry.dest_type = dest_type;
|
||||
do
|
||||
{
|
||||
TransformEntry *e;
|
||||
|
||||
e = g_bsearch_array_lookup (transform_array, &transform_bconfig, &entry);
|
||||
if (e)
|
||||
{
|
||||
/* need to check that there hasn't been a change in value handling */
|
||||
if (g_type_value_table_peek (entry.dest_type) == g_type_value_table_peek (dest_type) &&
|
||||
g_type_value_table_peek (entry.src_type) == g_type_value_table_peek (src_type))
|
||||
return e->func;
|
||||
}
|
||||
entry.dest_type = transform_lookup_get_parent_type (entry.dest_type);
|
||||
}
|
||||
while (entry.dest_type);
|
||||
|
||||
entry.src_type = transform_lookup_get_parent_type (entry.src_type);
|
||||
}
|
||||
while (entry.src_type);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
transform_entries_cmp (gconstpointer bsearch_node1,
|
||||
gconstpointer bsearch_node2)
|
||||
{
|
||||
const TransformEntry *e1 = bsearch_node1;
|
||||
const TransformEntry *e2 = bsearch_node2;
|
||||
gint cmp = G_BSEARCH_ARRAY_CMP (e1->src_type, e2->src_type);
|
||||
|
||||
if (cmp)
|
||||
return cmp;
|
||||
else
|
||||
return G_BSEARCH_ARRAY_CMP (e1->dest_type, e2->dest_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_register_transform_func: (skip)
|
||||
* @src_type: Source type.
|
||||
* @dest_type: Target type.
|
||||
* @transform_func: a function which transforms values of type @src_type
|
||||
* into value of type @dest_type
|
||||
*
|
||||
* Registers a value transformation function for use in g_value_transform().
|
||||
* A previously registered transformation function for @src_type and @dest_type
|
||||
* will be replaced.
|
||||
*/
|
||||
void
|
||||
g_value_register_transform_func (GType src_type,
|
||||
GType dest_type,
|
||||
GValueTransform transform_func)
|
||||
{
|
||||
TransformEntry entry;
|
||||
|
||||
/* these checks won't pass for dynamic types.
|
||||
* g_return_if_fail (G_TYPE_HAS_VALUE_TABLE (src_type));
|
||||
* g_return_if_fail (G_TYPE_HAS_VALUE_TABLE (dest_type));
|
||||
*/
|
||||
g_return_if_fail (transform_func != NULL);
|
||||
|
||||
entry.src_type = src_type;
|
||||
entry.dest_type = dest_type;
|
||||
|
||||
#if 0 /* let transform function replacement be a valid operation */
|
||||
if (g_bsearch_array_lookup (transform_array, &transform_bconfig, &entry))
|
||||
g_warning ("reregistering value transformation function (%p) for '%s' to '%s'",
|
||||
transform_func,
|
||||
g_type_name (src_type),
|
||||
g_type_name (dest_type));
|
||||
#endif
|
||||
|
||||
entry.func = transform_func;
|
||||
transform_array = g_bsearch_array_replace (transform_array, &transform_bconfig, &entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_type_transformable:
|
||||
* @src_type: Source type.
|
||||
* @dest_type: Target type.
|
||||
*
|
||||
* Check whether g_value_transform() is able to transform values
|
||||
* of type @src_type into values of type @dest_type. Note that for
|
||||
* the types to be transformable, they must be compatible or a
|
||||
* transformation function must be registered.
|
||||
*
|
||||
* Returns: %TRUE if the transformation is possible, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
g_value_type_transformable (GType src_type,
|
||||
GType dest_type)
|
||||
{
|
||||
g_return_val_if_fail (src_type, FALSE);
|
||||
g_return_val_if_fail (dest_type, FALSE);
|
||||
|
||||
return (g_value_type_compatible (src_type, dest_type) ||
|
||||
transform_func_lookup (src_type, dest_type) != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_type_compatible:
|
||||
* @src_type: source type to be copied.
|
||||
* @dest_type: destination type for copying.
|
||||
*
|
||||
* Returns whether a #GValue of type @src_type can be copied into
|
||||
* a #GValue of type @dest_type.
|
||||
*
|
||||
* Returns: %TRUE if g_value_copy() is possible with @src_type and @dest_type.
|
||||
*/
|
||||
gboolean
|
||||
g_value_type_compatible (GType src_type,
|
||||
GType dest_type)
|
||||
{
|
||||
g_return_val_if_fail (src_type, FALSE);
|
||||
g_return_val_if_fail (dest_type, FALSE);
|
||||
|
||||
/* Fast path */
|
||||
if (src_type == dest_type)
|
||||
return TRUE;
|
||||
|
||||
return (g_type_is_a (src_type, dest_type) &&
|
||||
g_type_value_table_peek (dest_type) == g_type_value_table_peek (src_type));
|
||||
}
|
||||
|
||||
/**
|
||||
* g_value_transform:
|
||||
* @src_value: Source value.
|
||||
* @dest_value: Target value.
|
||||
*
|
||||
* Tries to cast the contents of @src_value into a type appropriate
|
||||
* to store in @dest_value, e.g. to transform a %G_TYPE_INT value
|
||||
* into a %G_TYPE_FLOAT value. Performing transformations between
|
||||
* value types might incur precision lossage. Especially
|
||||
* transformations into strings might reveal seemingly arbitrary
|
||||
* results and shouldn't be relied upon for production code (such
|
||||
* as rcfile value or object property serialization).
|
||||
*
|
||||
* Returns: Whether a transformation rule was found and could be applied.
|
||||
* Upon failing transformations, @dest_value is left untouched.
|
||||
*/
|
||||
gboolean
|
||||
g_value_transform (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
GType dest_type;
|
||||
|
||||
g_return_val_if_fail (src_value, FALSE);
|
||||
g_return_val_if_fail (dest_value, FALSE);
|
||||
|
||||
dest_type = G_VALUE_TYPE (dest_value);
|
||||
if (g_value_type_compatible (G_VALUE_TYPE (src_value), dest_type))
|
||||
{
|
||||
g_value_copy (src_value, dest_value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
GValueTransform transform = transform_func_lookup (G_VALUE_TYPE (src_value), dest_type);
|
||||
|
||||
if (transform)
|
||||
{
|
||||
g_value_unset (dest_value);
|
||||
|
||||
/* setup and transform */
|
||||
value_meminit (dest_value, dest_type);
|
||||
transform (src_value, dest_value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
212
gobject/gvalue.h
212
gobject/gvalue.h
@@ -1,212 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* gvalue.h: generic GValue functions
|
||||
*/
|
||||
#ifndef __G_VALUE_H__
|
||||
#define __G_VALUE_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gtype.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- type macros --- */
|
||||
/**
|
||||
* G_TYPE_IS_VALUE:
|
||||
* @type: A #GType value.
|
||||
*
|
||||
* 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
|
||||
* of the #GTypeValueTable functions required for a type to create a #GValue of.
|
||||
*
|
||||
* Returns: Whether @type is suitable as a #GValue type.
|
||||
*/
|
||||
#define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type))
|
||||
/**
|
||||
* G_IS_VALUE:
|
||||
* @value: A #GValue structure.
|
||||
*
|
||||
* Checks if @value is a valid and initialized #GValue structure.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value))
|
||||
/**
|
||||
* G_VALUE_TYPE:
|
||||
* @value: A #GValue structure.
|
||||
*
|
||||
* Get the type identifier of @value.
|
||||
*
|
||||
* Returns: the #GType.
|
||||
*/
|
||||
#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type)
|
||||
/**
|
||||
* G_VALUE_TYPE_NAME:
|
||||
* @value: A #GValue structure.
|
||||
*
|
||||
* Gets the type name of @value.
|
||||
*
|
||||
* Returns: the type name.
|
||||
*/
|
||||
#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
|
||||
/**
|
||||
* G_VALUE_HOLDS:
|
||||
* @value: A #GValue structure.
|
||||
* @type: A #GType value.
|
||||
*
|
||||
* Checks if @value holds (or contains) a value of @type.
|
||||
* This macro will also check for @value != %NULL and issue a
|
||||
* warning if the check fails.
|
||||
*
|
||||
* Returns: %TRUE if @value holds the @type.
|
||||
*/
|
||||
#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
|
||||
|
||||
|
||||
/* --- typedefs & structures --- */
|
||||
/**
|
||||
* GValueTransform:
|
||||
* @src_value: Source value.
|
||||
* @dest_value: Target value.
|
||||
*
|
||||
* The type of value transformation functions which can be registered with
|
||||
* g_value_register_transform_func().
|
||||
*
|
||||
* @dest_value will be initialized to the correct destination type.
|
||||
*/
|
||||
typedef void (*GValueTransform) (const GValue *src_value,
|
||||
GValue *dest_value);
|
||||
/**
|
||||
* GValue:
|
||||
*
|
||||
* An opaque structure used to hold different types of values.
|
||||
*
|
||||
* The data within the structure has protected scope: it is accessible only
|
||||
* to functions within a #GTypeValueTable structure, or implementations of
|
||||
* the g_value_*() API. That is, code portions which implement new fundamental
|
||||
* types.
|
||||
*
|
||||
* #GValue users cannot make any assumptions about how data is stored
|
||||
* within the 2 element @data union, and the @g_type member should
|
||||
* only be accessed through the G_VALUE_TYPE() macro.
|
||||
*/
|
||||
struct _GValue
|
||||
{
|
||||
/*< private >*/
|
||||
GType g_type;
|
||||
|
||||
/* public for GTypeValueTable methods */
|
||||
union {
|
||||
gint v_int;
|
||||
guint v_uint;
|
||||
glong v_long;
|
||||
gulong v_ulong;
|
||||
gint64 v_int64;
|
||||
guint64 v_uint64;
|
||||
gfloat v_float;
|
||||
gdouble v_double;
|
||||
gpointer v_pointer;
|
||||
} data[2];
|
||||
};
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GValue* g_value_init (GValue *value,
|
||||
GType g_type);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_copy (const GValue *src_value,
|
||||
GValue *dest_value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GValue* g_value_reset (GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_unset (GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_instance (GValue *value,
|
||||
gpointer instance);
|
||||
GOBJECT_AVAILABLE_IN_2_42
|
||||
void g_value_init_from_instance (GValue *value,
|
||||
gpointer instance);
|
||||
|
||||
|
||||
/* --- private --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gboolean g_value_fits_pointer (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gpointer g_value_peek_pointer (const GValue *value);
|
||||
|
||||
|
||||
/* --- implementation details --- */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gboolean g_value_type_compatible (GType src_type,
|
||||
GType dest_type);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gboolean g_value_type_transformable (GType src_type,
|
||||
GType dest_type);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gboolean g_value_transform (const GValue *src_value,
|
||||
GValue *dest_value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_register_transform_func (GType src_type,
|
||||
GType dest_type,
|
||||
GValueTransform transform_func);
|
||||
|
||||
/**
|
||||
* G_VALUE_NOCOPY_CONTENTS:
|
||||
*
|
||||
* If passed to G_VALUE_COLLECT(), allocated data won't be copied
|
||||
* but used verbatim. This does not affect ref-counted types like
|
||||
* objects. This does not affect usage of g_value_copy(), the data will
|
||||
* be copied if it is not ref-counted.
|
||||
*/
|
||||
#define G_VALUE_NOCOPY_CONTENTS (1 << 27)
|
||||
|
||||
/**
|
||||
* G_VALUE_INTERNED_STRING:
|
||||
*
|
||||
* For string values, indicates that the string contained is canonical and will
|
||||
* exist for the duration of the process. See g_value_set_interned_string().
|
||||
*
|
||||
* Since: 2.66
|
||||
*/
|
||||
#define G_VALUE_INTERNED_STRING (1 << 28) GOBJECT_AVAILABLE_MACRO_IN_2_66
|
||||
|
||||
/**
|
||||
* G_VALUE_INIT:
|
||||
*
|
||||
* A #GValue must be initialized before it can be used. This macro can
|
||||
* be used as initializer instead of an explicit `{ 0 }` when declaring
|
||||
* a variable, but it cannot be assigned to a variable.
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* GValue value = G_VALUE_INIT;
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
#define G_VALUE_INIT { 0, { { 0 } } }
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_VALUE_H__ */
|
@@ -26,8 +26,15 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h> /* qsort() */
|
||||
|
||||
#ifndef GOBJECT_DISABLE_DEPRECATION_WARNINGS
|
||||
#define GOBJECT_DISABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "gvaluearray.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free)
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GValueArray:
|
||||
|
@@ -25,7 +25,8 @@
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gvalue.h>
|
||||
#include <glib.h>
|
||||
#include <gobject/gobject-visibility.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -19,10 +19,18 @@
|
||||
* gvaluecollector.h: GValue varargs stubs
|
||||
*/
|
||||
|
||||
#ifndef __G_VALUE_COLLECTOR_H__
|
||||
#define __G_VALUE_COLLECTOR_H__
|
||||
#ifndef __GOBJECT_G_VALUE_COLLECTOR_H__
|
||||
#define __GOBJECT_G_VALUE_COLLECTOR_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
/* Sadly, this file is part of the API but it's not included in
|
||||
* glib.h or glib-object.h, which means we need to retain a copy inside GObject,
|
||||
* even if GLib has its own header file, in order to maintain source compatibility.
|
||||
*/
|
||||
#ifdef GLIB_GVALUECOLLECTOR_H
|
||||
#error "You cannot include glib/gvaluecollector.h and gobject/gvaluecollector.h at the same time"
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -277,4 +285,4 @@ G_STMT_START { \
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_VALUE_COLLECTOR_H__ */
|
||||
#endif /* __GOBJECT_G_VALUE_COLLECTOR_H__ */
|
||||
|
@@ -1,430 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gvalue.h"
|
||||
#include "gtype-private.h"
|
||||
#include "genums.h"
|
||||
|
||||
|
||||
/* same type transforms
|
||||
*/
|
||||
static void
|
||||
value_transform_memcpy_data0 (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
memcpy (&dest_value->data[0], &src_value->data[0], sizeof (src_value->data[0]));
|
||||
}
|
||||
#define value_transform_int_int value_transform_memcpy_data0
|
||||
#define value_transform_uint_uint value_transform_memcpy_data0
|
||||
#define value_transform_long_long value_transform_memcpy_data0
|
||||
#define value_transform_ulong_ulong value_transform_memcpy_data0
|
||||
#define value_transform_int64_int64 value_transform_memcpy_data0
|
||||
#define value_transform_uint64_uint64 value_transform_memcpy_data0
|
||||
#define value_transform_float_float value_transform_memcpy_data0
|
||||
#define value_transform_double_double value_transform_memcpy_data0
|
||||
|
||||
|
||||
/* numeric casts
|
||||
*/
|
||||
#define DEFINE_CAST(func_name, from_member, ctype, to_member) \
|
||||
static void \
|
||||
value_transform_##func_name (const GValue *src_value, \
|
||||
GValue *dest_value) \
|
||||
{ \
|
||||
ctype c_value = (ctype) src_value->data[0].from_member; \
|
||||
dest_value->data[0].to_member = c_value; \
|
||||
} extern void glib_dummy_decl (void)
|
||||
DEFINE_CAST (int_s8, v_int, gint8, v_int);
|
||||
DEFINE_CAST (int_u8, v_int, guint8, v_uint);
|
||||
DEFINE_CAST (int_uint, v_int, guint, v_uint);
|
||||
DEFINE_CAST (int_long, v_int, glong, v_long);
|
||||
DEFINE_CAST (int_ulong, v_int, gulong, v_ulong);
|
||||
DEFINE_CAST (int_int64, v_int, gint64, v_int64);
|
||||
DEFINE_CAST (int_uint64, v_int, guint64, v_uint64);
|
||||
DEFINE_CAST (int_float, v_int, gfloat, v_float);
|
||||
DEFINE_CAST (int_double, v_int, gdouble, v_double);
|
||||
DEFINE_CAST (uint_s8, v_uint, gint8, v_int);
|
||||
DEFINE_CAST (uint_u8, v_uint, guint8, v_uint);
|
||||
DEFINE_CAST (uint_int, v_uint, gint, v_int);
|
||||
DEFINE_CAST (uint_long, v_uint, glong, v_long);
|
||||
DEFINE_CAST (uint_ulong, v_uint, gulong, v_ulong);
|
||||
DEFINE_CAST (uint_int64, v_uint, gint64, v_int64);
|
||||
DEFINE_CAST (uint_uint64, v_uint, guint64, v_uint64);
|
||||
DEFINE_CAST (uint_float, v_uint, gfloat, v_float);
|
||||
DEFINE_CAST (uint_double, v_uint, gdouble, v_double);
|
||||
DEFINE_CAST (long_s8, v_long, gint8, v_int);
|
||||
DEFINE_CAST (long_u8, v_long, guint8, v_uint);
|
||||
DEFINE_CAST (long_int, v_long, gint, v_int);
|
||||
DEFINE_CAST (long_uint, v_long, guint, v_uint);
|
||||
DEFINE_CAST (long_ulong, v_long, gulong, v_ulong);
|
||||
DEFINE_CAST (long_int64, v_long, gint64, v_int64);
|
||||
DEFINE_CAST (long_uint64, v_long, guint64, v_uint64);
|
||||
DEFINE_CAST (long_float, v_long, gfloat, v_float);
|
||||
DEFINE_CAST (long_double, v_long, gdouble, v_double);
|
||||
DEFINE_CAST (ulong_s8, v_ulong, gint8, v_int);
|
||||
DEFINE_CAST (ulong_u8, v_ulong, guint8, v_uint);
|
||||
DEFINE_CAST (ulong_int, v_ulong, gint, v_int);
|
||||
DEFINE_CAST (ulong_uint, v_ulong, guint, v_uint);
|
||||
DEFINE_CAST (ulong_int64, v_ulong, gint64, v_int64);
|
||||
DEFINE_CAST (ulong_uint64, v_ulong, guint64, v_uint64);
|
||||
DEFINE_CAST (ulong_long, v_ulong, glong, v_long);
|
||||
DEFINE_CAST (ulong_float, v_ulong, gfloat, v_float);
|
||||
DEFINE_CAST (ulong_double, v_ulong, gdouble, v_double);
|
||||
DEFINE_CAST (int64_s8, v_int64, gint8, v_int);
|
||||
DEFINE_CAST (int64_u8, v_int64, guint8, v_uint);
|
||||
DEFINE_CAST (int64_int, v_int64, gint, v_int);
|
||||
DEFINE_CAST (int64_uint, v_int64, guint, v_uint);
|
||||
DEFINE_CAST (int64_long, v_int64, glong, v_long);
|
||||
DEFINE_CAST (int64_uint64, v_int64, guint64, v_uint64);
|
||||
DEFINE_CAST (int64_ulong, v_int64, gulong, v_ulong);
|
||||
DEFINE_CAST (int64_float, v_int64, gfloat, v_float);
|
||||
DEFINE_CAST (int64_double, v_int64, gdouble, v_double);
|
||||
DEFINE_CAST (uint64_s8, v_uint64, gint8, v_int);
|
||||
DEFINE_CAST (uint64_u8, v_uint64, guint8, v_uint);
|
||||
DEFINE_CAST (uint64_int, v_uint64, gint, v_int);
|
||||
DEFINE_CAST (uint64_uint, v_uint64, guint, v_uint);
|
||||
DEFINE_CAST (uint64_long, v_uint64, glong, v_long);
|
||||
DEFINE_CAST (uint64_ulong, v_uint64, gulong, v_ulong);
|
||||
DEFINE_CAST (uint64_int64, v_uint64, gint64, v_int64);
|
||||
DEFINE_CAST (uint64_float, v_uint64, gfloat, v_float);
|
||||
DEFINE_CAST (uint64_double, v_uint64, gdouble, v_double);
|
||||
DEFINE_CAST (float_s8, v_float, gint8, v_int);
|
||||
DEFINE_CAST (float_u8, v_float, guint8, v_uint);
|
||||
DEFINE_CAST (float_int, v_float, gint, v_int);
|
||||
DEFINE_CAST (float_uint, v_float, guint, v_uint);
|
||||
DEFINE_CAST (float_long, v_float, glong, v_long);
|
||||
DEFINE_CAST (float_ulong, v_float, gulong, v_ulong);
|
||||
DEFINE_CAST (float_int64, v_float, gint64, v_int64);
|
||||
DEFINE_CAST (float_uint64, v_float, guint64, v_uint64);
|
||||
DEFINE_CAST (float_double, v_float, gdouble, v_double);
|
||||
DEFINE_CAST (double_s8, v_double, gint8, v_int);
|
||||
DEFINE_CAST (double_u8, v_double, guint8, v_uint);
|
||||
DEFINE_CAST (double_int, v_double, gint, v_int);
|
||||
DEFINE_CAST (double_uint, v_double, guint, v_uint);
|
||||
DEFINE_CAST (double_long, v_double, glong, v_long);
|
||||
DEFINE_CAST (double_ulong, v_double, gulong, v_ulong);
|
||||
DEFINE_CAST (double_int64, v_double, gint64, v_int64);
|
||||
DEFINE_CAST (double_uint64, v_double, guint64, v_uint64);
|
||||
DEFINE_CAST (double_float, v_double, gfloat, v_float);
|
||||
|
||||
|
||||
/* boolean assignments
|
||||
*/
|
||||
#define DEFINE_BOOL_CHECK(func_name, from_member) \
|
||||
static void \
|
||||
value_transform_##func_name (const GValue *src_value, \
|
||||
GValue *dest_value) \
|
||||
{ \
|
||||
dest_value->data[0].v_int = src_value->data[0].from_member != 0; \
|
||||
} extern void glib_dummy_decl (void)
|
||||
DEFINE_BOOL_CHECK (int_bool, v_int);
|
||||
DEFINE_BOOL_CHECK (uint_bool, v_uint);
|
||||
DEFINE_BOOL_CHECK (long_bool, v_long);
|
||||
DEFINE_BOOL_CHECK (ulong_bool, v_ulong);
|
||||
DEFINE_BOOL_CHECK (int64_bool, v_int64);
|
||||
DEFINE_BOOL_CHECK (uint64_bool, v_uint64);
|
||||
|
||||
|
||||
/* string printouts
|
||||
*/
|
||||
#define DEFINE_SPRINTF(func_name, from_member, format) \
|
||||
static void \
|
||||
value_transform_##func_name (const GValue *src_value, \
|
||||
GValue *dest_value) \
|
||||
{ \
|
||||
dest_value->data[0].v_pointer = g_strdup_printf ((format), \
|
||||
src_value->data[0].from_member); \
|
||||
} extern void glib_dummy_decl (void)
|
||||
DEFINE_SPRINTF (int_string, v_int, "%d");
|
||||
DEFINE_SPRINTF (uint_string, v_uint, "%u");
|
||||
DEFINE_SPRINTF (long_string, v_long, "%ld");
|
||||
DEFINE_SPRINTF (ulong_string, v_ulong, "%lu");
|
||||
DEFINE_SPRINTF (int64_string, v_int64, "%" G_GINT64_FORMAT);
|
||||
DEFINE_SPRINTF (uint64_string, v_uint64, "%" G_GUINT64_FORMAT);
|
||||
DEFINE_SPRINTF (float_string, v_float, "%f");
|
||||
DEFINE_SPRINTF (double_string, v_double, "%f");
|
||||
|
||||
|
||||
/* special cases
|
||||
*/
|
||||
static void
|
||||
value_transform_bool_string (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
dest_value->data[0].v_pointer = g_strdup_printf ("%s",
|
||||
src_value->data[0].v_int ?
|
||||
"TRUE" : "FALSE");
|
||||
}
|
||||
static void
|
||||
value_transform_string_string (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);
|
||||
}
|
||||
static void
|
||||
value_transform_enum_string (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
gint v_enum = src_value->data[0].v_long;
|
||||
gchar *str = g_enum_to_string (G_VALUE_TYPE (src_value), v_enum);
|
||||
|
||||
dest_value->data[0].v_pointer = str;
|
||||
}
|
||||
static void
|
||||
value_transform_flags_string (const GValue *src_value,
|
||||
GValue *dest_value)
|
||||
{
|
||||
GFlagsClass *class = g_type_class_ref (G_VALUE_TYPE (src_value));
|
||||
GFlagsValue *flags_value = g_flags_get_first_value (class, src_value->data[0].v_ulong);
|
||||
|
||||
/* Note: this does not use g_flags_to_string()
|
||||
* to keep backwards compatibility.
|
||||
*/
|
||||
if (flags_value)
|
||||
{
|
||||
GString *gstring = g_string_new (NULL);
|
||||
guint v_flags = src_value->data[0].v_ulong;
|
||||
|
||||
do
|
||||
{
|
||||
v_flags &= ~flags_value->value;
|
||||
|
||||
if (gstring->str[0])
|
||||
g_string_append (gstring, " | ");
|
||||
g_string_append (gstring, flags_value->value_name);
|
||||
flags_value = g_flags_get_first_value (class, v_flags);
|
||||
}
|
||||
while (flags_value && v_flags);
|
||||
|
||||
if (v_flags)
|
||||
dest_value->data[0].v_pointer = g_strdup_printf ("%s | %u",
|
||||
gstring->str,
|
||||
v_flags);
|
||||
else
|
||||
dest_value->data[0].v_pointer = g_strdup (gstring->str);
|
||||
g_string_free (gstring, TRUE);
|
||||
}
|
||||
else
|
||||
dest_value->data[0].v_pointer = g_strdup_printf ("%lu", src_value->data[0].v_ulong);
|
||||
|
||||
g_type_class_unref (class);
|
||||
}
|
||||
|
||||
|
||||
/* registration
|
||||
*/
|
||||
void
|
||||
_g_value_transforms_init (void)
|
||||
{
|
||||
/* some transformations are a bit questionable,
|
||||
* we currently skip those
|
||||
*/
|
||||
#define SKIP____register_transform_func(type1,type2,transform_func) /* skip questionable transforms */ \
|
||||
(void)0
|
||||
|
||||
/* numeric types (plus to string) */
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_CHAR, value_transform_int_int);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_UCHAR, value_transform_int_u8);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_BOOLEAN, value_transform_int_bool);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_INT, value_transform_int_int);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_UINT, value_transform_int_uint);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_LONG, value_transform_int_long);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_ULONG, value_transform_int_ulong);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_INT64, value_transform_int_int64);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_UINT64, value_transform_int_uint64);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_ENUM, value_transform_int_long);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_FLAGS, value_transform_int_ulong);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_FLOAT, value_transform_int_float);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_DOUBLE, value_transform_int_double);
|
||||
g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_STRING, value_transform_int_string);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_CHAR, value_transform_uint_s8);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_UCHAR, value_transform_uint_uint);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_BOOLEAN, value_transform_uint_bool);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_INT, value_transform_uint_int);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_UINT, value_transform_uint_uint);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_LONG, value_transform_uint_long);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_ULONG, value_transform_uint_ulong);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_INT64, value_transform_uint_int64);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_UINT64, value_transform_uint_uint64);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_ENUM, value_transform_uint_long);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_FLAGS, value_transform_uint_ulong);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_FLOAT, value_transform_uint_float);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_DOUBLE, value_transform_uint_double);
|
||||
g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_STRING, value_transform_uint_string);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_CHAR, value_transform_int_s8);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_UCHAR, value_transform_int_u8);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, value_transform_int_int);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_INT, value_transform_int_int);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_UINT, value_transform_int_uint);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_LONG, value_transform_int_long);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_ULONG, value_transform_int_ulong);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_INT64, value_transform_int_int64);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_UINT64, value_transform_int_uint64);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_ENUM, value_transform_int_long);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_FLAGS, value_transform_int_ulong);
|
||||
SKIP____register_transform_func (G_TYPE_BOOLEAN, G_TYPE_FLOAT, value_transform_int_float);
|
||||
SKIP____register_transform_func (G_TYPE_BOOLEAN, G_TYPE_DOUBLE, value_transform_int_double);
|
||||
g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_STRING, value_transform_bool_string);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_CHAR, value_transform_int_s8);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_UCHAR, value_transform_int_u8);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_BOOLEAN, value_transform_int_bool);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_INT, value_transform_int_int);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_UINT, value_transform_int_uint);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_LONG, value_transform_int_long);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_ULONG, value_transform_int_ulong);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_INT64, value_transform_int_int64);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_UINT64, value_transform_int_uint64);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_ENUM, value_transform_int_long);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_FLAGS, value_transform_int_ulong);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_FLOAT, value_transform_int_float);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_DOUBLE, value_transform_int_double);
|
||||
g_value_register_transform_func (G_TYPE_INT, G_TYPE_STRING, value_transform_int_string);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_CHAR, value_transform_uint_s8);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_UCHAR, value_transform_uint_u8);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_BOOLEAN, value_transform_uint_bool);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_INT, value_transform_uint_int);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_UINT, value_transform_uint_uint);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_LONG, value_transform_uint_long);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_ULONG, value_transform_uint_ulong);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_INT64, value_transform_uint_int64);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_UINT64, value_transform_uint_uint64);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_ENUM, value_transform_uint_long);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_FLAGS, value_transform_uint_ulong);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_FLOAT, value_transform_uint_float);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_DOUBLE, value_transform_uint_double);
|
||||
g_value_register_transform_func (G_TYPE_UINT, G_TYPE_STRING, value_transform_uint_string);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_CHAR, value_transform_long_s8);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_UCHAR, value_transform_long_u8);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_BOOLEAN, value_transform_long_bool);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_INT, value_transform_long_int);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_UINT, value_transform_long_uint);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_LONG, value_transform_long_long);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_ULONG, value_transform_long_ulong);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_INT64, value_transform_long_int64);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_UINT64, value_transform_long_uint64);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_ENUM, value_transform_long_long);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_FLAGS, value_transform_long_ulong);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_FLOAT, value_transform_long_float);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_DOUBLE, value_transform_long_double);
|
||||
g_value_register_transform_func (G_TYPE_LONG, G_TYPE_STRING, value_transform_long_string);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_CHAR, value_transform_ulong_s8);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_UCHAR, value_transform_ulong_u8);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_BOOLEAN, value_transform_ulong_bool);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_INT, value_transform_ulong_int);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_UINT, value_transform_ulong_uint);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_LONG, value_transform_ulong_long);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_ULONG, value_transform_ulong_ulong);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_INT64, value_transform_ulong_int64);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_UINT64, value_transform_ulong_uint64);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_ENUM, value_transform_ulong_long);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_FLAGS, value_transform_ulong_ulong);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_FLOAT, value_transform_ulong_float);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_DOUBLE, value_transform_ulong_double);
|
||||
g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_STRING, value_transform_ulong_string);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_CHAR, value_transform_int64_s8);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_UCHAR, value_transform_int64_u8);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_BOOLEAN, value_transform_int64_bool);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_INT, value_transform_int64_int);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_UINT, value_transform_int64_uint);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_LONG, value_transform_int64_long);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_ULONG, value_transform_int64_ulong);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_INT64, value_transform_int64_int64);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_UINT64, value_transform_int64_uint64);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_ENUM, value_transform_int64_long);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_FLAGS, value_transform_int64_ulong);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_FLOAT, value_transform_int64_float);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_DOUBLE, value_transform_int64_double);
|
||||
g_value_register_transform_func (G_TYPE_INT64, G_TYPE_STRING, value_transform_int64_string);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_CHAR, value_transform_uint64_s8);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_UCHAR, value_transform_uint64_u8);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_BOOLEAN, value_transform_uint64_bool);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_INT, value_transform_uint64_int);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_UINT, value_transform_uint64_uint);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_LONG, value_transform_uint64_long);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_ULONG, value_transform_uint64_ulong);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_INT64, value_transform_uint64_int64);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_UINT64, value_transform_uint64_uint64);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_ENUM, value_transform_uint64_long);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_FLAGS, value_transform_uint64_ulong);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_FLOAT, value_transform_uint64_float);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_DOUBLE, value_transform_uint64_double);
|
||||
g_value_register_transform_func (G_TYPE_UINT64, G_TYPE_STRING, value_transform_uint64_string);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_CHAR, value_transform_long_s8);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_UCHAR, value_transform_long_u8);
|
||||
SKIP____register_transform_func (G_TYPE_ENUM, G_TYPE_BOOLEAN, value_transform_long_bool);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_INT, value_transform_long_int);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_UINT, value_transform_long_uint);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_LONG, value_transform_long_long);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_ULONG, value_transform_long_ulong);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_INT64, value_transform_long_int64);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_UINT64, value_transform_long_uint64);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_ENUM, value_transform_long_long);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_FLAGS, value_transform_long_ulong);
|
||||
SKIP____register_transform_func (G_TYPE_ENUM, G_TYPE_FLOAT, value_transform_long_float);
|
||||
SKIP____register_transform_func (G_TYPE_ENUM, G_TYPE_DOUBLE, value_transform_long_double);
|
||||
g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_STRING, value_transform_enum_string);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_CHAR, value_transform_ulong_s8);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_UCHAR, value_transform_ulong_u8);
|
||||
SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_BOOLEAN, value_transform_ulong_bool);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_INT, value_transform_ulong_int);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_UINT, value_transform_ulong_uint);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_LONG, value_transform_ulong_long);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_ULONG, value_transform_ulong_ulong);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_INT64, value_transform_ulong_int64);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_UINT64, value_transform_ulong_uint64);
|
||||
SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_ENUM, value_transform_ulong_long);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_FLAGS, value_transform_ulong_ulong);
|
||||
SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_FLOAT, value_transform_ulong_float);
|
||||
SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_DOUBLE, value_transform_ulong_double);
|
||||
g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_STRING, value_transform_flags_string);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_CHAR, value_transform_float_s8);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_UCHAR, value_transform_float_u8);
|
||||
SKIP____register_transform_func (G_TYPE_FLOAT, G_TYPE_BOOLEAN, value_transform_float_bool);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_INT, value_transform_float_int);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_UINT, value_transform_float_uint);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_LONG, value_transform_float_long);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_ULONG, value_transform_float_ulong);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_INT64, value_transform_float_int64);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_UINT64, value_transform_float_uint64);
|
||||
SKIP____register_transform_func (G_TYPE_FLOAT, G_TYPE_ENUM, value_transform_float_long);
|
||||
SKIP____register_transform_func (G_TYPE_FLOAT, G_TYPE_FLAGS, value_transform_float_ulong);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_FLOAT, value_transform_float_float);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_DOUBLE, value_transform_float_double);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_STRING, value_transform_float_string);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_CHAR, value_transform_double_s8);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_UCHAR, value_transform_double_u8);
|
||||
SKIP____register_transform_func (G_TYPE_DOUBLE, G_TYPE_BOOLEAN, value_transform_double_bool);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_INT, value_transform_double_int);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_UINT, value_transform_double_uint);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_LONG, value_transform_double_long);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_ULONG, value_transform_double_ulong);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_INT64, value_transform_double_int64);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_UINT64, value_transform_double_uint64);
|
||||
SKIP____register_transform_func (G_TYPE_DOUBLE, G_TYPE_ENUM, value_transform_double_long);
|
||||
SKIP____register_transform_func (G_TYPE_DOUBLE, G_TYPE_FLAGS, value_transform_double_ulong);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_FLOAT, value_transform_double_float);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_DOUBLE, value_transform_double_double);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_STRING, value_transform_double_string);
|
||||
/* string types */
|
||||
g_value_register_transform_func (G_TYPE_STRING, G_TYPE_STRING, value_transform_string_string);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,320 +0,0 @@
|
||||
/* GObject - GLib Type, Object, Parameter and Signal Library
|
||||
* Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* gvaluetypes.h: GLib default values
|
||||
*/
|
||||
#ifndef __G_VALUETYPES_H__
|
||||
#define __G_VALUETYPES_H__
|
||||
|
||||
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
||||
#error "Only <glib-object.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gobject/gvalue.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- type macros --- */
|
||||
/**
|
||||
* G_VALUE_HOLDS_CHAR:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
|
||||
/**
|
||||
* G_VALUE_HOLDS_UCHAR:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
|
||||
/**
|
||||
* G_VALUE_HOLDS_BOOLEAN:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
|
||||
/**
|
||||
* G_VALUE_HOLDS_INT:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_INT.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
|
||||
/**
|
||||
* G_VALUE_HOLDS_UINT:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
|
||||
/**
|
||||
* G_VALUE_HOLDS_LONG:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
|
||||
/**
|
||||
* G_VALUE_HOLDS_ULONG:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
|
||||
/**
|
||||
* G_VALUE_HOLDS_INT64:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
|
||||
/**
|
||||
* G_VALUE_HOLDS_UINT64:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
|
||||
/**
|
||||
* G_VALUE_HOLDS_FLOAT:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
|
||||
/**
|
||||
* G_VALUE_HOLDS_DOUBLE:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
|
||||
/**
|
||||
* G_VALUE_HOLDS_STRING:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
|
||||
/**
|
||||
* G_VALUE_IS_INTERNED_STRING:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether @value contains a string which is canonical.
|
||||
*
|
||||
* Returns: %TRUE if the value contains a string in its canonical
|
||||
* representation, as returned by g_intern_string(). See also
|
||||
* g_value_set_interned_string().
|
||||
*
|
||||
* Since: 2.66
|
||||
*/
|
||||
#define G_VALUE_IS_INTERNED_STRING(value) (G_VALUE_HOLDS_STRING (value) && ((value)->data[1].v_uint & G_VALUE_INTERNED_STRING)) GOBJECT_AVAILABLE_MACRO_IN_2_66
|
||||
/**
|
||||
* G_VALUE_HOLDS_POINTER:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
|
||||
/**
|
||||
* G_TYPE_GTYPE:
|
||||
*
|
||||
* The type for #GType.
|
||||
*/
|
||||
#define G_TYPE_GTYPE (g_gtype_get_type())
|
||||
/**
|
||||
* G_VALUE_HOLDS_GTYPE:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
|
||||
*
|
||||
* Since: 2.12
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
#define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
|
||||
/**
|
||||
* G_VALUE_HOLDS_VARIANT:
|
||||
* @value: a valid #GValue structure
|
||||
*
|
||||
* Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*
|
||||
* Since: 2.26
|
||||
*/
|
||||
#define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GOBJECT_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
|
||||
void g_value_set_char (GValue *value,
|
||||
gchar v_char);
|
||||
GOBJECT_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
|
||||
gchar g_value_get_char (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_schar (GValue *value,
|
||||
gint8 v_char);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gint8 g_value_get_schar (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_uchar (GValue *value,
|
||||
guchar v_uchar);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
guchar g_value_get_uchar (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_boolean (GValue *value,
|
||||
gboolean v_boolean);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gboolean g_value_get_boolean (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_int (GValue *value,
|
||||
gint v_int);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gint g_value_get_int (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_uint (GValue *value,
|
||||
guint v_uint);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
guint g_value_get_uint (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_long (GValue *value,
|
||||
glong v_long);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
glong g_value_get_long (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_ulong (GValue *value,
|
||||
gulong v_ulong);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gulong g_value_get_ulong (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_int64 (GValue *value,
|
||||
gint64 v_int64);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gint64 g_value_get_int64 (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_uint64 (GValue *value,
|
||||
guint64 v_uint64);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
guint64 g_value_get_uint64 (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_float (GValue *value,
|
||||
gfloat v_float);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gfloat g_value_get_float (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_double (GValue *value,
|
||||
gdouble v_double);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gdouble g_value_get_double (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_string (GValue *value,
|
||||
const gchar *v_string);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_static_string (GValue *value,
|
||||
const gchar *v_string);
|
||||
GOBJECT_AVAILABLE_IN_2_66
|
||||
void g_value_set_interned_string (GValue *value,
|
||||
const gchar *v_string);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
const gchar * g_value_get_string (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gchar* g_value_dup_string (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
gchar* g_value_steal_string (GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_pointer (GValue *value,
|
||||
gpointer v_pointer);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gpointer g_value_get_pointer (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_gtype_get_type (void);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_gtype (GValue *value,
|
||||
GType v_gtype);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_value_get_gtype (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_set_variant (GValue *value,
|
||||
GVariant *variant);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_take_variant (GValue *value,
|
||||
GVariant *variant);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GVariant* g_value_get_variant (const GValue *value);
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GVariant* g_value_dup_variant (const GValue *value);
|
||||
|
||||
|
||||
/* Convenience for registering new pointer types */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
GType g_pointer_type_register_static (const gchar *name);
|
||||
|
||||
/* debugging aid, describe value contents as string */
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
gchar* g_strdup_value_contents (const GValue *value);
|
||||
|
||||
|
||||
GOBJECT_AVAILABLE_IN_ALL
|
||||
void g_value_take_string (GValue *value,
|
||||
gchar *v_string);
|
||||
GOBJECT_DEPRECATED_FOR(g_value_take_string)
|
||||
void g_value_set_string_take_ownership (GValue *value,
|
||||
gchar *v_string);
|
||||
|
||||
|
||||
/* humpf, need a C representable type name for G_TYPE_STRING */
|
||||
/**
|
||||
* gchararray:
|
||||
*
|
||||
* A C representable type name for %G_TYPE_STRING.
|
||||
*/
|
||||
typedef gchar* gchararray;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_VALUETYPES_H__ */
|
@@ -2,12 +2,9 @@ gobject_includedir = glib_includedir / 'gobject'
|
||||
|
||||
gobject_install_headers = files(
|
||||
'gobject-autocleanups.h',
|
||||
'glib-types.h',
|
||||
'gbinding.h',
|
||||
'gbindinggroup.h',
|
||||
'gboxed.h',
|
||||
'gclosure.h',
|
||||
'genums.h',
|
||||
'gmarshal.h',
|
||||
'gobject.h',
|
||||
'gparam.h',
|
||||
@@ -15,13 +12,9 @@ gobject_install_headers = files(
|
||||
'gsignal.h',
|
||||
'gsignalgroup.h',
|
||||
'gsourceclosure.h',
|
||||
'gtype.h',
|
||||
'gtypemodule.h',
|
||||
'gtypeplugin.h',
|
||||
'gvalue.h',
|
||||
'gvaluearray.h',
|
||||
'gvaluecollector.h',
|
||||
'gvaluetypes.h',
|
||||
'gobjectnotifyqueue.c', # sic
|
||||
)
|
||||
|
||||
@@ -38,12 +31,9 @@ gobject_sources += gobject_visibility_h
|
||||
install_headers(gobject_install_headers, install_dir : gobject_includedir)
|
||||
|
||||
gobject_sources += files(
|
||||
'gatomicarray.c',
|
||||
'gbinding.c',
|
||||
'gbindinggroup.c',
|
||||
'gboxed.c',
|
||||
'gclosure.c',
|
||||
'genums.c',
|
||||
'gmarshal.c',
|
||||
'gobject.c',
|
||||
'gparam.c',
|
||||
@@ -51,13 +41,8 @@ gobject_sources += files(
|
||||
'gsignal.c',
|
||||
'gsignalgroup.c',
|
||||
'gsourceclosure.c',
|
||||
'gtype.c',
|
||||
'gtypemodule.c',
|
||||
'gtypeplugin.c',
|
||||
'gvalue.c',
|
||||
'gvaluearray.c',
|
||||
'gvaluetransform.c',
|
||||
'gvaluetypes.c',
|
||||
)
|
||||
|
||||
if host_system == 'windows' and glib_build_shared
|
||||
@@ -134,10 +119,6 @@ glib_enumtypes_c = custom_target('glib_enumtypes_c',
|
||||
'--template', files('glib-enumtypes.c.template'),
|
||||
'@INPUT@'])
|
||||
|
||||
# Expose as variable to be used by gobject-introspection
|
||||
# when it includes GLib as a subproject
|
||||
glib_types_h = files('glib-types.h')
|
||||
|
||||
libgobject = library('gobject-2.0',
|
||||
gobject_dtrace_obj, gobject_dtrace_hdr, glib_enumtypes_h, glib_enumtypes_c,
|
||||
sources : gobject_sources,
|
||||
|
Reference in New Issue
Block a user