[glib] Add examples for G_STRINGIFY and G_PASTE
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add examples for G_STRINGIFY and G_PASTE
- Date: Sun, 6 Jun 2010 16:50:13 +0000 (UTC)
commit 157116b8dd58429335a16c4d0d2c8ee4ef287302
Author: Will Thompson <will thompson collabora co uk>
Date: Thu Jun 3 14:50:19 2010 +0100
Add examples for G_STRINGIFY and G_PASTE
docs/reference/glib/tmpl/macros_misc.sgml | 37 ++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/glib/tmpl/macros_misc.sgml b/docs/reference/glib/tmpl/macros_misc.sgml
index 2396e5d..b8f229d 100644
--- a/docs/reference/glib/tmpl/macros_misc.sgml
+++ b/docs/reference/glib/tmpl/macros_misc.sgml
@@ -100,18 +100,49 @@ does not include <function>string.h</function> for you.
<!-- ##### MACRO G_STRINGIFY ##### -->
<para>
Accepts a macro or a string and converts it into a string after
-preprocessor argument expansion.
+preprocessor argument expansion. For example, the following code:
</para>
+<informalexample><programlisting>
+#define AGE 27
+const gchar *greeting = G_STRINGIFY (AGE) " today!";
+</programlisting></informalexample>
+
+<para>
+is transformed by the preprocessor into (code equivalent to):
+</para>
+
+<informalexample><programlisting>
+const gchar *greeting = "27 today!";
+</programlisting></informalexample>
+
@macro_or_string: a macro or a string.
<!-- ##### MACRO G_PASTE ##### -->
<para>
-Yields a new preprocessor pasted identifier 'identifier1identifier2'
-from its expanded arguments 'identifier1' and 'identifier2'.
+Yields a new preprocessor pasted identifier <code>identifier1identifier2</code>
+from its expanded arguments @identifier1 and @identifier2. For example, the
+following code:
</para>
+<informalexample><programlisting>
+#define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
+const gchar *name = GET (traveller, name);
+const gchar *quest = GET (traveller, quest);
+GdkColor *favourite = GET (traveller, favourite_colour);
+</programlisting></informalexample>
+
+<para>
+is transformed by the preprocessor into:
+</para>
+
+<informalexample><programlisting>
+const gchar *name = traveller_get_name (traveller);
+const gchar *quest = traveller_get_quest (traveller);
+GdkColor *favourite = traveller_get_favourite_colour (traveller);
+</programlisting></informalexample>
+
@identifier1: an identifier
@identifier2: an identifier
@Since: 2.20
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]