mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
Add a G_DEFINE_QUARK macro
https://bugzilla.gnome.org/show_bug.cgi?id=627240
This commit is contained in:
parent
a1ff18582d
commit
702b448865
@ -2538,6 +2538,7 @@ g_node_destroy
|
||||
<TITLE>Quarks</TITLE>
|
||||
<FILE>quarks</FILE>
|
||||
GQuark
|
||||
G_DEFINE_QUARK
|
||||
g_quark_from_string
|
||||
g_quark_from_static_string
|
||||
g_quark_to_string
|
||||
|
@ -92,6 +92,18 @@ static gint quark_block_offset = 0;
|
||||
* particular string. A GQuark value of zero is associated to %NULL.
|
||||
**/
|
||||
|
||||
/**
|
||||
* G_DEFINE_QUARK:
|
||||
* @QN: the string to return a #GQuark for
|
||||
* @q_n: prefix for the function name
|
||||
*
|
||||
* A convenience macro which defines a function returning the
|
||||
* #GQuark for the string @QN. The function will be named
|
||||
* @q_n<!-- -->_quark().
|
||||
*
|
||||
* Since: 2.34
|
||||
*/
|
||||
|
||||
/**
|
||||
* g_quark_try_string:
|
||||
* @string: (allow-none): a string.
|
||||
|
@ -44,6 +44,19 @@ GQuark g_quark_from_static_string (const gchar *string);
|
||||
GQuark g_quark_from_string (const gchar *string);
|
||||
const gchar * g_quark_to_string (GQuark quark) G_GNUC_CONST;
|
||||
|
||||
#define G_DEFINE_QUARK(QN, q_n) \
|
||||
GQuark \
|
||||
q_n##_quark (void) \
|
||||
{ \
|
||||
static volatile gsize g_define_quark__volatile = 0; \
|
||||
if (g_once_init_enter (&g_define_quark__volatile)) \
|
||||
{ \
|
||||
GQuark g_define_quark = g_quark_from_string (#QN); \
|
||||
g_once_init_leave (&g_define_quark__volatile, g_define_quark); \
|
||||
} \
|
||||
return g_define_quark__volatile; \
|
||||
}
|
||||
|
||||
const gchar * g_intern_string (const gchar *string);
|
||||
const gchar * g_intern_static_string (const gchar *string);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user