Add a G_DEFINE_QUARK macro

https://bugzilla.gnome.org/show_bug.cgi?id=627240
This commit is contained in:
Matthias Clasen 2012-08-27 23:34:30 -04:00
parent a1ff18582d
commit 702b448865
3 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -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.

View File

@ -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);