summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-07-07 18:18:37 -0400
committerColin Walters <walters@verbum.org>2010-07-08 14:42:54 -0400
commit017727630d09a854b1c1a4767066fb675b139de9 (patch)
tree015b9692d2225f1dbe6c6bacb37aae7ff8c54f82
parentcb268efadd68c0d67965e683a26966d760cd33ca (diff)
downloadgobject-introspection-017727630d09a854b1c1a4767066fb675b139de9.tar.gz
Move doc to toplevel element, write <any> for unknown containers
Moving to <doc> allows us to better preserve whitespace. XML has no facility for whitespace-preserving attributes. Second, for arrays and lists, both types with unknown element_type can occur in the current scanner; it's least wrong if we write out an <any> type.
-rw-r--r--gir/Everything-1.0-expected.gir218
-rw-r--r--gir/GIMarshallingTests-1.0-expected.gir8
-rw-r--r--girepository/girparser.c27
-rw-r--r--giscanner/girwriter.py66
-rw-r--r--giscanner/xmlwriter.py4
-rw-r--r--tests/scanner/annotation-1.0-expected.gir406
-rw-r--r--tests/scanner/foo-1.0-expected.gir62
7 files changed, 402 insertions, 389 deletions
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index 36c1153c..7fe9d1dc 100644
--- a/gir/Everything-1.0-expected.gir
+++ b/gir/Everything-1.0-expected.gir
@@ -236,18 +236,16 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</function>
- <virtual-method name="matrix"
- invoker="do_matrix"
- doc="This method is virtual. Notably its name differs from the virtual
+ <virtual-method name="matrix" invoker="do_matrix">
+ <doc xml:whitespace="preserve">This method is virtual. Notably its name differs from the virtual
slot name, which makes it useful for testing bindings handle this
-case.">
+case.</doc>
<return-value transfer-ownership="none">
<type name="int" c:type="int"/>
</return-value>
<parameters>
- <parameter name="somestr"
- transfer-ownership="none"
- doc="Meaningless string">
+ <parameter name="somestr" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Meaningless string</doc>
<type name="utf8" c:type="char*"/>
</parameter>
</parameters>
@@ -304,8 +302,8 @@ case.">
</method>
<method name="torture_signature_1"
c:identifier="test_obj_torture_signature_1"
- doc="This function throws an error if m is odd."
throws="1">
+ <doc xml:whitespace="preserve">This function throws an error if m is odd.</doc>
<return-value transfer-ownership="none">
<type name="boolean" c:type="gboolean"/>
</return-value>
@@ -339,18 +337,16 @@ case.">
</parameter>
</parameters>
</method>
- <method name="do_matrix"
- c:identifier="test_obj_do_matrix"
- doc="This method is virtual. Notably its name differs from the virtual
+ <method name="do_matrix" c:identifier="test_obj_do_matrix">
+ <doc xml:whitespace="preserve">This method is virtual. Notably its name differs from the virtual
slot name, which makes it useful for testing bindings handle this
-case.">
+case.</doc>
<return-value transfer-ownership="none">
<type name="int" c:type="int"/>
</return-value>
<parameters>
- <parameter name="somestr"
- transfer-ownership="none"
- doc="Meaningless string">
+ <parameter name="somestr" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Meaningless string</doc>
<type name="utf8" c:type="char*"/>
</parameter>
</parameters>
@@ -399,7 +395,9 @@ case.">
<type name="GLib.HashTable" c:type="GHashTable*"/>
</field>
<field name="list">
- <type name="GLib.List" c:type="GList*"/>
+ <type name="GLib.List" c:type="GList*">
+ <type name="any" c:type="gpointer"/>
+ </type>
</field>
<glib:signal name="test">
<return-value transfer-ownership="full">
@@ -432,9 +430,8 @@ case.">
<parameter name="obj" transfer-ownership="none">
<type name="TestObj" c:type="TestObj*"/>
</parameter>
- <parameter name="somestr"
- transfer-ownership="none"
- doc="Meaningless string">
+ <parameter name="somestr" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Meaningless string</doc>
<type name="utf8" c:type="char*"/>
</parameter>
</parameters>
@@ -513,9 +510,8 @@ case.">
<field name="some_enum" writable="1">
<type name="TestEnum" c:type="TestEnum"/>
</field>
- <method name="clone"
- c:identifier="test_struct_a_clone"
- doc="Make a copy of a TestStructA">
+ <method name="clone" c:identifier="test_struct_a_clone">
+ <doc xml:whitespace="preserve">Make a copy of a TestStructA</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -523,8 +519,8 @@ case.">
<parameter name="a_out"
direction="out"
caller-allocates="1"
- transfer-ownership="none"
- doc="the cloned structure">
+ transfer-ownership="none">
+ <doc xml:whitespace="preserve">the cloned structure</doc>
<type name="TestStructA" c:type="TestStructA*"/>
</parameter>
</parameters>
@@ -537,9 +533,8 @@ case.">
<field name="nested_a" writable="1">
<type name="TestStructA" c:type="TestStructA"/>
</field>
- <method name="clone"
- c:identifier="test_struct_b_clone"
- doc="Make a copy of a TestStructB">
+ <method name="clone" c:identifier="test_struct_b_clone">
+ <doc xml:whitespace="preserve">Make a copy of a TestStructB</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -547,8 +542,8 @@ case.">
<parameter name="b_out"
direction="out"
caller-allocates="1"
- transfer-ownership="none"
- doc="the cloned structure">
+ transfer-ownership="none">
+ <doc xml:whitespace="preserve">the cloned structure</doc>
<type name="TestStructB" c:type="TestStructB*"/>
</parameter>
</parameters>
@@ -661,14 +656,13 @@ case.">
</function>
<function name="test_array_fixed_size_int_in"
c:identifier="test_array_fixed_size_int_in">
- <return-value transfer-ownership="none"
- doc="the sum of the items in @ints">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">the sum of the items in @ints</doc>
<type name="int" c:type="int"/>
</return-value>
<parameters>
- <parameter name="ints"
- transfer-ownership="none"
- doc="a list of 5 integers">
+ <parameter name="ints" transfer-ownership="none">
+ <doc xml:whitespace="preserve">a list of 5 integers</doc>
<array c:type="int*" fixed-size="5">
<type name="int"/>
</array>
@@ -684,8 +678,8 @@ case.">
<parameter name="ints"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a list of 5 integers ranging from 0 to 4">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a list of 5 integers ranging from 0 to 4</doc>
<array c:type="int**" fixed-size="5">
<type name="int"/>
</array>
@@ -694,8 +688,8 @@ case.">
</function>
<function name="test_array_fixed_size_int_return"
c:identifier="test_array_fixed_size_int_return">
- <return-value transfer-ownership="full"
- doc="a list of 5 integers ranging from 0 to 4">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">a list of 5 integers ranging from 0 to 4</doc>
<array c:type="int*" fixed-size="5">
<type name="int"/>
</array>
@@ -709,7 +703,8 @@ case.">
<parameter name="n_ints" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="ints" transfer-ownership="none" doc="List of ints">
+ <parameter name="ints" transfer-ownership="none">
+ <doc xml:whitespace="preserve">List of ints</doc>
<array length="0" c:type="gint16*">
<type name="int16"/>
</array>
@@ -724,7 +719,8 @@ case.">
<parameter name="n_ints" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="ints" transfer-ownership="none" doc="List of ints">
+ <parameter name="ints" transfer-ownership="none">
+ <doc xml:whitespace="preserve">List of ints</doc>
<array length="0" c:type="gint32*">
<type name="int32"/>
</array>
@@ -739,7 +735,8 @@ case.">
<parameter name="n_ints" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="ints" transfer-ownership="none" doc="List of ints">
+ <parameter name="ints" transfer-ownership="none">
+ <doc xml:whitespace="preserve">List of ints</doc>
<array length="0" c:type="gint64*">
<type name="int64"/>
</array>
@@ -754,7 +751,8 @@ case.">
<parameter name="n_ints" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="ints" transfer-ownership="none" doc="List of ints">
+ <parameter name="ints" transfer-ownership="none">
+ <doc xml:whitespace="preserve">List of ints</doc>
<array length="0" c:type="gint8*">
<type name="int8"/>
</array>
@@ -762,15 +760,16 @@ case.">
</parameters>
</function>
<function name="test_array_gtype_in" c:identifier="test_array_gtype_in">
- <return-value transfer-ownership="full"
- doc="string representation of provided types">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">string representation of provided types</doc>
<type name="utf8" c:type="char*"/>
</return-value>
<parameters>
<parameter name="n_types" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="types" transfer-ownership="none" doc="List of types">
+ <parameter name="types" transfer-ownership="none">
+ <doc xml:whitespace="preserve">List of types</doc>
<array length="0" c:type="GType*">
<type name="GType"/>
</array>
@@ -779,7 +778,8 @@ case.">
</function>
<function name="test_array_int_full_out"
c:identifier="test_array_int_full_out">
- <return-value transfer-ownership="full" doc="a new array of integers.">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">a new array of integers.</doc>
<array length="0" c:type="int*">
<type name="int"/>
</array>
@@ -788,8 +788,8 @@ case.">
<parameter name="len"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="length of the returned array.">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">length of the returned array.</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
@@ -802,7 +802,8 @@ case.">
<parameter name="n_ints" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="ints" transfer-ownership="none" doc="List of ints">
+ <parameter name="ints" transfer-ownership="none">
+ <doc xml:whitespace="preserve">List of ints</doc>
<array length="0" c:type="int*">
<type name="int"/>
</array>
@@ -818,7 +819,8 @@ case.">
<parameter name="n_ints" transfer-ownership="none">
<type name="int" c:type="int"/>
</parameter>
- <parameter name="ints" transfer-ownership="full" doc="List of ints">
+ <parameter name="ints" transfer-ownership="full">
+ <doc xml:whitespace="preserve">List of ints</doc>
<array length="0" c:type="int*">
<type name="int"/>
</array>
@@ -833,15 +835,15 @@ case.">
<parameter name="n_ints"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="the length of @ints">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">the length of @ints</doc>
<type name="int" c:type="int*"/>
</parameter>
<parameter name="ints"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="a list of integers whose items will be increased by 1, except the first that will be dropped">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a list of integers whose items will be increased by 1, except the first that will be dropped</doc>
<array length="0" c:type="int**">
<type name="int"/>
</array>
@@ -850,8 +852,8 @@ case.">
</function>
<function name="test_array_int_none_out"
c:identifier="test_array_int_none_out">
- <return-value transfer-ownership="none"
- doc="a static array of integers.">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">a static array of integers.</doc>
<array length="0" c:type="int*">
<type name="int"/>
</array>
@@ -860,8 +862,8 @@ case.">
<parameter name="len"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="length of the returned array.">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">length of the returned array.</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
@@ -877,7 +879,8 @@ case.">
<type name="int"/>
</array>
</parameter>
- <parameter name="len" transfer-ownership="none" doc="length">
+ <parameter name="len" transfer-ownership="none">
+ <doc xml:whitespace="preserve">length</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
@@ -900,8 +903,8 @@ case.">
<parameter name="len"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="length">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">length</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
@@ -914,15 +917,15 @@ case.">
<parameter name="n_ints"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="the length of @ints">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">the length of @ints</doc>
<type name="int" c:type="int*"/>
</parameter>
<parameter name="ints"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a list of 5 integers, from 0 to 4 in consecutive order">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a list of 5 integers, from 0 to 4 in consecutive order</doc>
<array length="0" c:type="int**">
<type name="int"/>
</array>
@@ -1054,9 +1057,9 @@ case.">
</parameters>
</function>
<function name="test_callback_destroy_notify"
- c:identifier="test_callback_destroy_notify"
- doc="Notified - callback persists until a DestroyNotify delegate
-is invoked.">
+ c:identifier="test_callback_destroy_notify">
+ <doc xml:whitespace="preserve">Notified - callback persists until a DestroyNotify delegate
+is invoked.</doc>
<return-value transfer-ownership="none">
<type name="int" c:type="int"/>
</return-value>
@@ -1083,19 +1086,19 @@ is invoked.">
</return-value>
</function>
<function name="test_callback_thaw_notifications"
- c:identifier="test_callback_thaw_notifications"
- doc="Invokes all callbacks installed by #test_callback_destroy_notify(),
+ c:identifier="test_callback_thaw_notifications">
+ <doc xml:whitespace="preserve">Invokes all callbacks installed by #test_callback_destroy_notify(),
adding up their return values, and removes them, invoking the
-corresponding destroy notfications.">
- <return-value transfer-ownership="none"
- doc="Sum of the return values of the invoked callbacks.">
+corresponding destroy notfications.</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">Sum of the return values of the invoked callbacks.</doc>
<type name="int" c:type="int"/>
</return-value>
</function>
<function name="test_callback_user_data"
- c:identifier="test_callback_user_data"
- doc="Call - callback parameter persists for the duration of the method
-call and can be released on return.">
+ c:identifier="test_callback_user_data">
+ <doc xml:whitespace="preserve">Call - callback parameter persists for the duration of the method
+call and can be released on return.</doc>
<return-value transfer-ownership="none">
<type name="int" c:type="int"/>
</return-value>
@@ -1160,7 +1163,8 @@ call and can be released on return.">
</parameters>
</function>
<function name="test_filename_return" c:identifier="test_filename_return">
- <return-value transfer-ownership="full" doc="list of strings">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">list of strings</doc>
<type name="GLib.SList" c:type="GSList*">
<type name="filename"/>
</type>
@@ -1236,8 +1240,8 @@ call and can be released on return.">
</parameters>
</function>
<function name="test_ghash_nested_everything_return"
- c:identifier="test_ghash_nested_everything_return"
- doc="Specify nested parameterized types directly with the (type ) annotation.">
+ c:identifier="test_ghash_nested_everything_return">
+ <doc xml:whitespace="preserve">Specify nested parameterized types directly with the (type ) annotation.</doc>
<return-value transfer-ownership="full">
<type name="GLib.HashTable" c:type="GHashTable*">
<type name="utf8"/>
@@ -1249,8 +1253,8 @@ call and can be released on return.">
</return-value>
</function>
<function name="test_ghash_nested_everything_return2"
- c:identifier="test_ghash_nested_everything_return2"
- doc="element-type annotation.">
+ c:identifier="test_ghash_nested_everything_return2">
+ <doc xml:whitespace="preserve">element-type annotation.</doc>
<return-value transfer-ownership="full">
<type name="GLib.HashTable" c:type="GHashTable*">
<type name="utf8"/>
@@ -1731,10 +1735,8 @@ call and can be released on return.">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="obj"
- transfer-ownership="none"
- allow-none="1"
- doc="A #TestObj">
+ <parameter name="obj" transfer-ownership="none" allow-none="1">
+ <doc xml:whitespace="preserve">A #TestObj</doc>
<type name="TestObj" c:type="TestObj*"/>
</parameter>
</parameters>
@@ -1748,8 +1750,8 @@ call and can be released on return.">
direction="out"
caller-allocates="0"
transfer-ownership="full"
- allow-none="1"
- doc="A #TestObj">
+ allow-none="1">
+ <doc xml:whitespace="preserve">A #TestObj</doc>
<type name="TestObj" c:type="TestObj**"/>
</parameter>
</parameters>
@@ -1833,18 +1835,16 @@ call and can be released on return.">
<type name="GObject.Value" c:type="GValue*"/>
</return-value>
</function>
- <function name="test_strv_out"
- c:identifier="test_strv_out"
- doc="No annotations here. We want the default to Do The Right Thing.">
+ <function name="test_strv_out" c:identifier="test_strv_out">
+ <doc xml:whitespace="preserve">No annotations here. We want the default to Do The Right Thing.</doc>
<return-value transfer-ownership="full">
<array c:type="char**">
<type name="utf8"/>
</array>
</return-value>
</function>
- <function name="test_strv_out_c"
- c:identifier="test_strv_out_c"
- doc="No annotations here. We want the default to Do The Right Thing.">
+ <function name="test_strv_out_c" c:identifier="test_strv_out_c">
+ <doc xml:whitespace="preserve">No annotations here. We want the default to Do The Right Thing.</doc>
<return-value transfer-ownership="full">
<array c:type="char**">
<type name="utf8"/>
@@ -1921,8 +1921,8 @@ call and can be released on return.">
</function>
<function name="test_torture_signature_1"
c:identifier="test_torture_signature_1"
- doc="This function throws an error if m is odd."
throws="1">
+ <doc xml:whitespace="preserve">This function throws an error if m is odd.</doc>
<return-value transfer-ownership="none">
<type name="boolean" c:type="gboolean"/>
</return-value>
@@ -2086,8 +2086,8 @@ call and can be released on return.">
</function>
<function name="test_utf8_const_return"
c:identifier="test_utf8_const_return">
- <return-value transfer-ownership="none"
- doc="&lt;const char*&gt; UTF-8 string">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">&lt;const char*&gt; UTF-8 string</doc>
<type name="utf8" c:type="char*"/>
</return-value>
</function>
@@ -2117,7 +2117,8 @@ call and can be released on return.">
</function>
<function name="test_utf8_nonconst_return"
c:identifier="test_utf8_nonconst_return">
- <return-value transfer-ownership="full" doc="&lt;char*&gt; UTF-8 string">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">&lt;char*&gt; UTF-8 string</doc>
<type name="utf8" c:type="char*"/>
</return-value>
</function>
@@ -2160,16 +2161,16 @@ call and can be released on return.">
</function>
<function name="test_utf8_out_nonconst_return"
c:identifier="test_utf8_out_nonconst_return">
- <return-value transfer-ownership="full"
- doc="a copy of &quot;first&quot;">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">a copy of "first"</doc>
<type name="utf8" c:type="char*"/>
</return-value>
<parameters>
<parameter name="out"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a copy of &quot;second&quot;">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a copy of "second"</doc>
<type name="utf8" c:type="char**"/>
</parameter>
</parameters>
@@ -2182,26 +2183,27 @@ call and can be released on return.">
<parameter name="out0"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a copy of &quot;first&quot;">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a copy of "first"</doc>
<type name="utf8" c:type="char**"/>
</parameter>
<parameter name="out1"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a copy of &quot;second&quot;">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a copy of "second"</doc>
<type name="utf8" c:type="char**"/>
</parameter>
</parameters>
</function>
<function name="test_value_return" c:identifier="test_value_return">
- <return-value transfer-ownership="none"
- doc="the int wrapped in a GValue.">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">the int wrapped in a GValue.</doc>
<type name="GObject.Value" c:type="GValue*"/>
</return-value>
<parameters>
- <parameter name="i" transfer-ownership="none" doc="an int">
+ <parameter name="i" transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
diff --git a/gir/GIMarshallingTests-1.0-expected.gir b/gir/GIMarshallingTests-1.0-expected.gir
index 4069d1eb..798ecc75 100644
--- a/gir/GIMarshallingTests-1.0-expected.gir
+++ b/gir/GIMarshallingTests-1.0-expected.gir
@@ -864,6 +864,7 @@ and/or use gtk-doc annotations. -->
c:identifier="g_i_marshalling_tests_bytearray_full_return">
<return-value transfer-ownership="full">
<array name="GLib.ByteArray" c:type="GByteArray*">
+ <type name="any" c:type="gpointer"/>
</array>
</return-value>
</function>
@@ -970,7 +971,9 @@ and/or use gtk-doc annotations. -->
<function name="filename_list_return"
c:identifier="g_i_marshalling_tests_filename_list_return">
<return-value transfer-ownership="full">
- <type name="GLib.SList" c:type="GSList*"/>
+ <type name="GLib.SList" c:type="GSList*">
+ <type name="any" c:type="gpointer"/>
+ </type>
</return-value>
</function>
<function name="flags_in" c:identifier="g_i_marshalling_tests_flags_in">
@@ -1903,7 +1906,8 @@ and/or use gtk-doc annotations. -->
</function>
<function name="gstrv_return"
c:identifier="g_i_marshalling_tests_gstrv_return">
- <return-value transfer-ownership="full" doc="an array of strings">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">an array of strings</doc>
<array c:type="GStrv">
<type name="utf8"/>
</array>
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 5efe7fde..678edcc3 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -76,6 +76,7 @@ typedef enum
STATE_ALIAS, /* 30 */
STATE_TYPE,
STATE_ATTRIBUTE,
+ STATE_DOC,
STATE_PASSTHROUGH
} ParseState;
@@ -1958,6 +1959,22 @@ end_type (ParseContext *ctx)
}
static gboolean
+start_doc (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseContext *ctx,
+ GError **error)
+{
+ if (strcmp (element_name, "doc") != 0 || ctx->node_stack == NULL)
+ return FALSE;
+
+ state_switch (ctx, STATE_DOC);
+
+ return TRUE;
+}
+
+static gboolean
start_attribute (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -2570,6 +2587,9 @@ start_element_handler (GMarkupParseContext *context,
attribute_names, attribute_values,
ctx, error))
goto out;
+ else if (start_doc (context, element_name, attribute_names,
+ attribute_values, ctx, error))
+ goto out;
break;
case 'e':
@@ -3207,6 +3227,13 @@ end_element_handler (GMarkupParseContext *context,
}
break;
+ case STATE_DOC:
+ if (strcmp ("doc", element_name) == 0)
+ {
+ state_switch (ctx, ctx->prev_state);
+ }
+ break;
+
case STATE_PASSTHROUGH:
ctx->unknown_depth -= 1;
if (ctx->unknown_depth == 0)
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 59b4b495..5e29d067 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -23,7 +23,7 @@ from __future__ import with_statement
from .ast import (Alias, Array, Bitfield, Callback, Class, Constant, Enum,
Function, Interface, List, Map, Member, Struct, Union,
- Varargs)
+ Varargs, Type)
from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember,
GLibFlags, GLibObject, GLibInterface,
GLibRecord)
@@ -132,9 +132,12 @@ and/or use gtk-doc annotations. ''')
if node.version:
attrs.append(('version', node.version))
- def _write_attributes(self, node):
+ def _write_generic(self, node):
for key, value in node.attributes:
self.write_tag('attribute', [('name', key), ('value', value)])
+ if hasattr(node, 'doc') and node.doc:
+ self.write_tag('doc', [('xml:whitespace', 'preserve')],
+ node.doc.strip())
def _append_node_generic(self, node, attrs):
if node.skip or not node.introspectable:
@@ -158,13 +161,11 @@ and/or use gtk-doc annotations. ''')
def _write_callable(self, callable, tag_name, extra_attrs):
attrs = [('name', callable.name)]
attrs.extend(extra_attrs)
- if callable.doc:
- attrs.append(('doc', callable.doc))
self._append_version(callable, attrs)
self._append_node_generic(callable, attrs)
self._append_throws(callable, attrs)
with self.tagcontext(tag_name, attrs):
- self._write_attributes(callable)
+ self._write_generic(callable)
self._write_return_type(callable.retval)
self._write_parameters(callable.parameters)
@@ -189,10 +190,8 @@ and/or use gtk-doc annotations. ''')
attrs = []
attrs.append(('transfer-ownership', return_.transfer))
- if return_.doc:
- attrs.append(('doc', return_.doc))
with self.tagcontext('return-value', attrs):
- self._write_attributes(return_)
+ self._write_generic(return_)
self._write_type(return_.type)
def _write_parameters(self, parameters):
@@ -222,10 +221,8 @@ and/or use gtk-doc annotations. ''')
attrs.append(('closure', '%d' % parameter.closure_index))
if parameter.destroy_index >= 0:
attrs.append(('destroy', '%d' % parameter.destroy_index))
- if parameter.doc:
- attrs.append(('doc', parameter.doc))
with self.tagcontext('parameter', attrs):
- self._write_attributes(parameter)
+ self._write_generic(parameter)
self._write_type(parameter.type)
def _type_to_string(self, ntype):
@@ -259,6 +256,8 @@ and/or use gtk-doc annotations. ''')
with self.tagcontext('array', attrs):
if ntype.element_type is not None:
self._write_type(ntype.element_type)
+ else:
+ self._write_type(Type('any', ctype='gpointer'))
return
attrs = [('name', self._type_to_string(ntype))]
# FIXME: figure out if type references a basic type
@@ -266,9 +265,14 @@ and/or use gtk-doc annotations. ''')
# writing the ctype if the latter.
if type_cname is not None:
attrs.append(('c:type', type_cname))
- if isinstance(ntype, List) and ntype.element_type:
+ if (isinstance(ntype, List)
+ or typename in ('GLib.List',
+ 'GLib.SList')):
with self.tagcontext('type', attrs):
- self._write_type(ntype.element_type)
+ if isinstance(ntype, List) and ntype.element_type:
+ self._write_type(ntype.element_type)
+ else:
+ self._write_type(Type('any', ctype='gpointer'))
return
if isinstance(ntype, Map) and ntype.key_type:
with self.tagcontext('type', attrs):
@@ -280,8 +284,6 @@ and/or use gtk-doc annotations. ''')
def _write_enum(self, enum):
attrs = [('name', enum.name)]
- if enum.doc:
- attrs.append(('doc', enum.doc))
self._append_version(enum, attrs)
self._append_node_generic(enum, attrs)
if isinstance(enum, GLibEnum):
@@ -294,14 +296,12 @@ and/or use gtk-doc annotations. ''')
attrs.append(('glib:error-quark', enum.error_quark))
with self.tagcontext('enumeration', attrs):
- self._write_attributes(enum)
+ self._write_generic(enum)
for member in enum.members:
self._write_member(member)
def _write_bitfield(self, bitfield):
attrs = [('name', bitfield.name)]
- if bitfield.doc:
- attrs.append(('doc', bitfield.doc))
self._append_version(bitfield, attrs)
self._append_node_generic(bitfield, attrs)
if isinstance(bitfield, GLibFlags):
@@ -311,7 +311,7 @@ and/or use gtk-doc annotations. ''')
else:
attrs.append(('c:type', bitfield.symbol))
with self.tagcontext('bitfield', attrs):
- self._write_attributes(bitfield)
+ self._write_generic(bitfield)
for member in bitfield.members:
self._write_member(member)
@@ -332,8 +332,6 @@ and/or use gtk-doc annotations. ''')
def _write_class(self, node):
attrs = [('name', node.name),
('c:type', node.ctype)]
- if node.doc:
- attrs.append(('doc', node.doc))
self._append_version(node, attrs)
self._append_node_generic(node, attrs)
if isinstance(node, Class):
@@ -351,7 +349,7 @@ and/or use gtk-doc annotations. ''')
if node.glib_type_struct:
attrs.append(('glib:type-struct', node.glib_type_struct.name))
with self.tagcontext(tag_name, attrs):
- self._write_attributes(node)
+ self._write_generic(node)
if isinstance(node, GLibObject):
for iface in node.interfaces:
self.write_tag('implements', [('name', iface)])
@@ -377,11 +375,9 @@ and/or use gtk-doc annotations. ''')
def _write_boxed(self, boxed):
attrs = [('c:type', boxed.ctype),
('glib:name', boxed.name)]
- if boxed.doc:
- attrs.append(('doc', boxed.doc))
attrs.extend(self._boxed_attrs(boxed))
with self.tagcontext('glib:boxed', attrs):
- self._write_attributes(boxed)
+ self._write_generic(boxed)
for method in boxed.constructors:
self._write_constructor(method)
for method in boxed.methods:
@@ -401,10 +397,8 @@ and/or use gtk-doc annotations. ''')
if prop.construct_only:
attrs.append(('construct-only', '1'))
attrs.append(('transfer-ownership', prop.transfer))
- if prop.doc:
- attrs.append(('doc', prop.doc))
with self.tagcontext('property', attrs):
- self._write_attributes(prop)
+ self._write_generic(prop)
self._write_type(prop.type)
def _write_vfunc(self, vf):
@@ -437,14 +431,12 @@ and/or use gtk-doc annotations. ''')
is_gtype_struct = True
attrs.append(('glib:is-gtype-struct-for',
record.is_gtype_struct_for))
- if record.doc:
- attrs.append(('doc', record.doc))
self._append_version(record, attrs)
self._append_node_generic(record, attrs)
if isinstance(record, GLibBoxed):
attrs.extend(self._boxed_attrs(record))
with self.tagcontext('record', attrs):
- self._write_attributes(record)
+ self._write_generic(record)
if record.fields:
for field in record.fields:
self._write_field(field, is_gtype_struct)
@@ -459,14 +451,12 @@ and/or use gtk-doc annotations. ''')
attrs.append(('name', union.name))
if union.symbol is not None: # the union might be anonymous
attrs.append(('c:type', union.symbol))
- if union.doc:
- attrs.append(('doc', union.doc))
self._append_version(union, attrs)
self._append_node_generic(union, attrs)
if isinstance(union, GLibBoxed):
attrs.extend(self._boxed_attrs(union))
with self.tagcontext('union', attrs):
- self._write_attributes(union)
+ self._write_generic(union)
if union.fields:
for field in union.fields:
self._write_field(field)
@@ -483,7 +473,7 @@ and/or use gtk-doc annotations. ''')
if isinstance(field, Callback):
attrs = [('name', field.name)]
with self.tagcontext('field', attrs):
- self._write_attributes(field)
+ self._write_generic(field)
if is_gtype_struct:
self._write_callback(field)
else:
@@ -504,16 +494,14 @@ and/or use gtk-doc annotations. ''')
if field.bits:
attrs.append(('bits', str(field.bits)))
with self.tagcontext('field', attrs):
- self._write_attributes(field)
+ self._write_generic(field)
self._write_type(field.type)
def _write_signal(self, signal):
attrs = [('name', signal.name)]
- if signal.doc:
- attrs.append(('doc', signal.doc))
self._append_version(signal, attrs)
self._append_node_generic(signal, attrs)
with self.tagcontext('glib:signal', attrs):
- self._write_attributes(signal)
+ self._write_generic(signal)
self._write_return_type(signal.retval)
self._write_parameters(signal.parameters)
diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py
index 3068e62e..0db286bb 100644
--- a/giscanner/xmlwriter.py
+++ b/giscanner/xmlwriter.py
@@ -22,7 +22,7 @@ from __future__ import with_statement
from contextlib import contextmanager
from cStringIO import StringIO
-from xml.sax.saxutils import quoteattr
+from xml.sax.saxutils import escape, quoteattr
from .libtoolimporter import LibtoolImporter
@@ -111,7 +111,7 @@ class XMLWriter(object):
attributes = []
prefix = '<%s' % (tag_name, )
if data is not None:
- suffix = '>%s</%s>' % (data, tag_name)
+ suffix = '>%s</%s>' % (escape(data), tag_name)
else:
suffix = '/>'
attrs = collect_attributes(
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index cf974f5e..61003ad1 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -14,14 +14,15 @@ and/or use gtk-doc annotations. -->
version="1.0"
shared-library="libannotation.so"
c:prefix="annotation">
- <callback name="Callback"
- c:type="AnnotationCallback"
- doc="This is a callback.">
- <return-value transfer-ownership="none" doc="array of ints">
+ <callback name="Callback" c:type="AnnotationCallback">
+ <doc xml:whitespace="preserve">This is a callback.</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">array of ints</doc>
<type name="int" c:type="gint*"/>
</return-value>
<parameters>
- <parameter name="in" transfer-ownership="none" doc="array of ints">
+ <parameter name="in" transfer-ownership="none">
+ <doc xml:whitespace="preserve">array of ints</doc>
<type name="int" c:type="gint*"/>
</parameter>
</parameters>
@@ -42,71 +43,71 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</callback>
- <callback name="ListCallback"
- c:type="AnnotationListCallback"
- doc="This is a callback taking a list.">
- <return-value transfer-ownership="container" doc="list of strings">
+ <callback name="ListCallback" c:type="AnnotationListCallback">
+ <doc xml:whitespace="preserve">This is a callback taking a list.</doc>
+ <return-value transfer-ownership="container">
+ <doc xml:whitespace="preserve">list of strings</doc>
<type name="GLib.List" c:type="GList*">
<type name="utf8"/>
</type>
</return-value>
<parameters>
- <parameter name="in" transfer-ownership="none" doc="list of strings">
+ <parameter name="in" transfer-ownership="none">
+ <doc xml:whitespace="preserve">list of strings</doc>
<type name="GLib.List" c:type="GList*">
<type name="utf8"/>
</type>
</parameter>
</parameters>
</callback>
- <callback name="NotifyFunc"
- c:type="AnnotationNotifyFunc"
- doc="This is a callback with a &apos;closure&apos; argument that is not named
-&apos;user_data&apos; and hence has to be annotated.">
+ <callback name="NotifyFunc" c:type="AnnotationNotifyFunc">
+ <doc xml:whitespace="preserve">This is a callback with a 'closure' argument that is not named
+'user_data' and hence has to be annotated.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="data"
- transfer-ownership="none"
- closure="0"
- doc="The user data">
+ <parameter name="data" transfer-ownership="none" closure="0">
+ <doc xml:whitespace="preserve">The user data</doc>
<type name="any" c:type="gpointer"/>
</parameter>
</parameters>
</callback>
<class name="Object"
c:type="AnnotationObject"
- doc="This is an object used to test annotations."
parent="GObject.Object"
glib:type-name="AnnotationObject"
glib:get-type="annotation_object_get_type"
glib:type-struct="ObjectClass">
<attribute name="org.example.Test" value="cows"/>
+ <doc xml:whitespace="preserve">This is an object used to test annotations.</doc>
<method name="method" c:identifier="annotation_object_method">
- <return-value transfer-ownership="none" doc="an int">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
</method>
- <method name="out"
- c:identifier="annotation_object_out"
- doc="This is a test for out arguments">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="out" c:identifier="annotation_object_out">
+ <doc xml:whitespace="preserve">This is a test for out arguments</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
<parameter name="outarg"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="This is an argument test">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">This is an argument test</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
</method>
<method name="create_object"
- c:identifier="annotation_object_create_object"
- doc="Test returning a caller-owned object">
- <return-value transfer-ownership="full" doc="The object">
+ c:identifier="annotation_object_create_object">
+ <doc xml:whitespace="preserve">Test returning a caller-owned object</doc>
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">The object</doc>
<type name="GObject.Object" c:type="GObject*"/>
</return-value>
</method>
@@ -121,47 +122,47 @@ and/or use gtk-doc annotations. -->
</parameters>
</method>
<method name="notrans" c:identifier="annotation_object_notrans">
- <return-value transfer-ownership="none"
- doc="An object, not referenced">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">An object, not referenced</doc>
<type name="GObject.Object" c:type="GObject*"/>
</return-value>
</method>
- <method name="inout"
- c:identifier="annotation_object_inout"
- doc="This is a test for out arguments">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="inout" c:identifier="annotation_object_inout">
+ <doc xml:whitespace="preserve">This is a test for out arguments</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
<parameter name="inoutarg"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="This is an argument test">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">This is an argument test</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
</method>
- <method name="inout2"
- c:identifier="annotation_object_inout2"
- doc="This is a second test for out arguments">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="inout2" c:identifier="annotation_object_inout2">
+ <doc xml:whitespace="preserve">This is a second test for out arguments</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
<parameter name="inoutarg"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="This is an argument test">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">This is an argument test</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
</method>
- <method name="inout3"
- c:identifier="annotation_object_inout3"
- doc="This is a 3th test for out arguments">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="inout3" c:identifier="annotation_object_inout3">
+ <doc xml:whitespace="preserve">This is a 3th test for out arguments</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
@@ -169,80 +170,79 @@ and/or use gtk-doc annotations. -->
direction="inout"
caller-allocates="0"
transfer-ownership="full"
- allow-none="1"
- doc="This is an argument test">
+ allow-none="1">
+ <doc xml:whitespace="preserve">This is an argument test</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
</method>
- <method name="in"
- c:identifier="annotation_object_in"
- doc="This is a test for in arguments">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="in" c:identifier="annotation_object_in">
+ <doc xml:whitespace="preserve">This is a test for in arguments</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
- <parameter name="inarg"
- transfer-ownership="none"
- doc="This is an argument test">
+ <parameter name="inarg" transfer-ownership="none">
+ <doc xml:whitespace="preserve">This is an argument test</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
</method>
- <method name="calleeowns"
- c:identifier="annotation_object_calleeowns"
- doc="This is a test for out arguments; GObject defaults to transfer">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="calleeowns" c:identifier="annotation_object_calleeowns">
+ <doc xml:whitespace="preserve">This is a test for out arguments; GObject defaults to transfer</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
<parameter name="toown"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a #GObject">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a #GObject</doc>
<type name="GObject.Object" c:type="GObject**"/>
</parameter>
</parameters>
</method>
- <method name="calleesowns"
- c:identifier="annotation_object_calleesowns"
- doc="This is a test for out arguments, one transferred, other not">
- <return-value transfer-ownership="none" doc="an int">
+ <method name="calleesowns" c:identifier="annotation_object_calleesowns">
+ <doc xml:whitespace="preserve">This is a test for out arguments, one transferred, other not</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">an int</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
<parameter name="toown1"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="a #GObject">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">a #GObject</doc>
<type name="GObject.Object" c:type="GObject**"/>
</parameter>
<parameter name="toown2"
direction="out"
caller-allocates="0"
- transfer-ownership="none"
- doc="a #GObject">
+ transfer-ownership="none">
+ <doc xml:whitespace="preserve">a #GObject</doc>
<type name="GObject.Object" c:type="GObject**"/>
</parameter>
</parameters>
</method>
- <method name="get_strings"
- c:identifier="annotation_object_get_strings"
- doc="This is a test for returning a list of strings, where
-each string needs to be freed.">
- <return-value transfer-ownership="full" doc="list of strings">
+ <method name="get_strings" c:identifier="annotation_object_get_strings">
+ <doc xml:whitespace="preserve">This is a test for returning a list of strings, where
+each string needs to be freed.</doc>
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">list of strings</doc>
<type name="GLib.List" c:type="GList*">
<type name="utf8"/>
</type>
</return-value>
</method>
- <method name="get_hash"
- c:identifier="annotation_object_get_hash"
- doc="This is a test for returning a hash table mapping strings to
-objects.">
- <return-value transfer-ownership="full" doc="hash table">
+ <method name="get_hash" c:identifier="annotation_object_get_hash">
+ <doc xml:whitespace="preserve">This is a test for returning a hash table mapping strings to
+objects.</doc>
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">hash table</doc>
<type name="GLib.HashTable" c:type="GHashTable*">
<type name="utf8"/>
<type name="GObject.Object"/>
@@ -259,12 +259,12 @@ objects.">
</parameter>
</parameters>
</method>
- <method name="get_objects"
- c:identifier="annotation_object_get_objects"
- doc="This is a test for returning a list of objects.
+ <method name="get_objects" c:identifier="annotation_object_get_objects">
+ <doc xml:whitespace="preserve">This is a test for returning a list of objects.
The list itself should be freed, but not the internal objects,
-intentionally similar example to gtk_container_get_children">
- <return-value transfer-ownership="container" doc="list of objects">
+intentionally similar example to gtk_container_get_children</doc>
+ <return-value transfer-ownership="container">
+ <doc xml:whitespace="preserve">list of objects</doc>
<type name="GLib.SList" c:type="GSList*">
<type name="Object"/>
</type>
@@ -282,16 +282,14 @@ intentionally similar example to gtk_container_get_children">
</parameter>
</parameters>
</method>
- <method name="compute_sum"
- c:identifier="annotation_object_compute_sum"
- doc="Test taking a zero-terminated array">
+ <method name="compute_sum" c:identifier="annotation_object_compute_sum">
+ <doc xml:whitespace="preserve">Test taking a zero-terminated array</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="nums"
- transfer-ownership="none"
- doc="Sequence of numbers">
+ <parameter name="nums" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Sequence of numbers</doc>
<array c:type="int*">
<type name="int"/>
</array>
@@ -299,50 +297,45 @@ intentionally similar example to gtk_container_get_children">
</parameters>
</method>
<method name="compute_sum_n"
- c:identifier="annotation_object_compute_sum_n"
- doc="Test taking an array with length parameter">
+ c:identifier="annotation_object_compute_sum_n">
+ <doc xml:whitespace="preserve">Test taking an array with length parameter</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="nums"
- transfer-ownership="none"
- doc="Sequence of numbers that are zero-terminated">
+ <parameter name="nums" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Sequence of numbers that are zero-terminated</doc>
<array zero-terminated="0" length="2" c:type="int*">
<type name="int"/>
</array>
</parameter>
- <parameter name="n_nums"
- transfer-ownership="none"
- doc="Length of number array">
+ <parameter name="n_nums" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Length of number array</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
</method>
<method name="compute_sum_nz"
- c:identifier="annotation_object_compute_sum_nz"
- doc="Test taking a zero-terminated array with length parameter">
+ c:identifier="annotation_object_compute_sum_nz">
+ <doc xml:whitespace="preserve">Test taking a zero-terminated array with length parameter</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="nums"
- transfer-ownership="none"
- doc="Sequence of numbers that are zero-terminated">
+ <parameter name="nums" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Sequence of numbers that are zero-terminated</doc>
<array length="2" c:type="int*">
<type name="int"/>
</array>
</parameter>
- <parameter name="n_nums"
- transfer-ownership="none"
- doc="Length of number array">
+ <parameter name="n_nums" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Length of number array</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
</method>
- <method name="parse_args"
- c:identifier="annotation_object_parse_args"
- doc="Test taking a zero-terminated array with length parameter">
+ <method name="parse_args" c:identifier="annotation_object_parse_args">
+ <doc xml:whitespace="preserve">Test taking a zero-terminated array with length parameter</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -350,40 +343,39 @@ intentionally similar example to gtk_container_get_children">
<parameter name="argc"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="Length of the argument vector">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">Length of the argument vector</doc>
<type name="int" c:type="int*"/>
</parameter>
<parameter name="argv"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="Argument vector">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">Argument vector</doc>
<array length="1" c:type="char***">
<type name="utf8"/>
</array>
</parameter>
</parameters>
</method>
- <method name="string_out"
- c:identifier="annotation_object_string_out"
- doc="Test returning a string as an out parameter">
- <return-value transfer-ownership="none" doc="some boolean">
+ <method name="string_out" c:identifier="annotation_object_string_out">
+ <doc xml:whitespace="preserve">Test returning a string as an out parameter</doc>
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">some boolean</doc>
<type name="boolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="str_out"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="string return value">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">string return value</doc>
<type name="utf8" c:type="char**"/>
</parameter>
</parameters>
</method>
- <method name="foreach"
- c:identifier="annotation_object_foreach"
- doc="Test taking a call-scoped callback">
+ <method name="foreach" c:identifier="annotation_object_foreach">
+ <doc xml:whitespace="preserve">Test taking a call-scoped callback</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -391,71 +383,67 @@ intentionally similar example to gtk_container_get_children">
<parameter name="func"
transfer-ownership="none"
scope="call"
- closure="2"
- doc="Callback to invoke">
+ closure="2">
+ <doc xml:whitespace="preserve">Callback to invoke</doc>
<type name="ForeachFunc" c:type="AnnotationForeachFunc"/>
</parameter>
- <parameter name="user_data"
- transfer-ownership="none"
- doc="Callback user data">
+ <parameter name="user_data" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Callback user data</doc>
<type name="any" c:type="gpointer"/>
</parameter>
</parameters>
</method>
- <method name="set_data"
- c:identifier="annotation_object_set_data"
- doc="Test taking a guchar * with a length.">
+ <method name="set_data" c:identifier="annotation_object_set_data">
+ <doc xml:whitespace="preserve">Test taking a guchar * with a length.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="data" transfer-ownership="none" doc="The data">
+ <parameter name="data" transfer-ownership="none">
+ <doc xml:whitespace="preserve">The data</doc>
<array length="2" c:type="guchar*">
<type name="uint8"/>
</array>
</parameter>
- <parameter name="length"
- transfer-ownership="none"
- doc="Length of the data">
+ <parameter name="length" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Length of the data</doc>
<type name="size_t" c:type="gsize"/>
</parameter>
</parameters>
</method>
- <method name="set_data2"
- c:identifier="annotation_object_set_data2"
- doc="Test taking a gchar * with a length.">
+ <method name="set_data2" c:identifier="annotation_object_set_data2">
+ <doc xml:whitespace="preserve">Test taking a gchar * with a length.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="data" transfer-ownership="none" doc="The data">
+ <parameter name="data" transfer-ownership="none">
+ <doc xml:whitespace="preserve">The data</doc>
<array length="2" c:type="gchar*">
<type name="int8"/>
</array>
</parameter>
- <parameter name="length"
- transfer-ownership="none"
- doc="Length of the data">
+ <parameter name="length" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Length of the data</doc>
<type name="size_t" c:type="gsize"/>
</parameter>
</parameters>
</method>
- <method name="set_data3"
- c:identifier="annotation_object_set_data3"
- doc="Test taking a gchar * with a length, overriding the array element
-type.">
+ <method name="set_data3" c:identifier="annotation_object_set_data3">
+ <doc xml:whitespace="preserve">Test taking a gchar * with a length, overriding the array element
+type.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="data" transfer-ownership="none" doc="The data">
+ <parameter name="data" transfer-ownership="none">
+ <doc xml:whitespace="preserve">The data</doc>
<array length="2" c:type="gpointer">
<type name="uint8"/>
</array>
</parameter>
- <parameter name="length"
- transfer-ownership="none"
- doc="Length of the data">
+ <parameter name="length" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Length of the data</doc>
<type name="size_t" c:type="gsize"/>
</parameter>
</parameters>
@@ -468,9 +456,8 @@ type.">
<type name="GObject.Object" c:type="GObject*"/>
</return-value>
</method>
- <method name="watch"
- c:identifier="annotation_object_watch_full"
- doc="Test overriding via the &quot;Rename To&quot; annotation.">
+ <method name="watch" c:identifier="annotation_object_watch_full">
+ <doc xml:whitespace="preserve">Test overriding via the "Rename To" annotation.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -479,19 +466,16 @@ type.">
transfer-ownership="none"
scope="notified"
closure="2"
- destroy="3"
- doc="The callback">
+ destroy="3">
+ <doc xml:whitespace="preserve">The callback</doc>
<type name="ForeachFunc" c:type="AnnotationForeachFunc"/>
</parameter>
- <parameter name="user_data"
- transfer-ownership="none"
- doc="The callback data">
+ <parameter name="user_data" transfer-ownership="none">
+ <doc xml:whitespace="preserve">The callback data</doc>
<type name="any" c:type="gpointer"/>
</parameter>
- <parameter name="destroy"
- transfer-ownership="none"
- scope="call"
- doc="Destroy notification">
+ <parameter name="destroy" transfer-ownership="none" scope="call">
+ <doc xml:whitespace="preserve">Destroy notification</doc>
<type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
</parameter>
</parameters>
@@ -514,32 +498,35 @@ type.">
deprecated-version="1.2"
writable="1"
construct="1"
- transfer-ownership="none"
- doc="This is a property which is a string">
+ transfer-ownership="none">
+ <doc xml:whitespace="preserve">This is a property which is a string</doc>
<type name="utf8" c:type="gchararray"/>
</property>
<field name="parent_instance">
<type name="GObject.Object" c:type="GObject"/>
</field>
- <glib:signal name="attribute-signal"
- doc="This signal tests a signal with attributes.">
- <return-value transfer-ownership="full" doc="the return value">
+ <glib:signal name="attribute-signal">
+ <doc xml:whitespace="preserve">This signal tests a signal with attributes.</doc>
+ <return-value transfer-ownership="full">
<attribute name="some.annotation.foo3" value="val3"/>
+ <doc xml:whitespace="preserve">the return value</doc>
<type name="utf8" c:type="gchararray"/>
</return-value>
<parameters>
- <parameter name="arg1" transfer-ownership="none" doc="a value">
+ <parameter name="arg1" transfer-ownership="none">
<attribute name="some.annotation.foo1" value="val1"/>
+ <doc xml:whitespace="preserve">a value</doc>
<type name="utf8" c:type="gchararray"/>
</parameter>
- <parameter name="arg2" transfer-ownership="none" doc="another value">
+ <parameter name="arg2" transfer-ownership="none">
<attribute name="some.annotation.foo2" value="val2"/>
+ <doc xml:whitespace="preserve">another value</doc>
<type name="utf8" c:type="gchararray"/>
</parameter>
</parameters>
</glib:signal>
- <glib:signal name="doc-empty-arg-parsing"
- doc="This signal tests an empty document argument (@arg1)">
+ <glib:signal name="doc-empty-arg-parsing">
+ <doc xml:whitespace="preserve">This signal tests an empty document argument (@arg1)</doc>
<return-value transfer-ownership="full">
<type name="none" c:type="void"/>
</return-value>
@@ -549,16 +536,15 @@ type.">
</parameter>
</parameters>
</glib:signal>
- <glib:signal name="list-signal"
- doc="This is a signal which takes a list of strings, but it&apos;s not
-known by GObject as it&apos;s only marked as G_TYPE_POINTER">
+ <glib:signal name="list-signal">
+ <doc xml:whitespace="preserve">This is a signal which takes a list of strings, but it's not
+known by GObject as it's only marked as G_TYPE_POINTER</doc>
<return-value transfer-ownership="full">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="list"
- transfer-ownership="container"
- doc="a list of strings">
+ <parameter name="list" transfer-ownership="container">
+ <doc xml:whitespace="preserve">a list of strings</doc>
<type name="GLib.List" c:type="gpointer">
<type name="utf8"/>
</type>
@@ -566,16 +552,17 @@ known by GObject as it&apos;s only marked as G_TYPE_POINTER">
</parameters>
</glib:signal>
<glib:signal name="string-signal"
- doc="This is a signal which has a broken signal handler,
-it says it&apos;s pointer but it&apos;s actually a string."
version="1.0"
deprecated="Use other-signal instead"
deprecated-version="1.2">
+ <doc xml:whitespace="preserve">This is a signal which has a broken signal handler,
+it says it's pointer but it's actually a string.</doc>
<return-value transfer-ownership="full">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="string" transfer-ownership="none" doc="a string">
+ <parameter name="string" transfer-ownership="none">
+ <doc xml:whitespace="preserve">a string</doc>
<type name="utf8" c:type="gpointer"/>
</parameter>
</parameters>
@@ -588,9 +575,8 @@ it says it&apos;s pointer but it&apos;s actually a string."
<type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
</record>
- <record name="Struct"
- c:type="AnnotationStruct"
- doc="This is a test of an array of object in an field of a struct.">
+ <record name="Struct" c:type="AnnotationStruct">
+ <doc xml:whitespace="preserve">This is a test of an array of object in an field of a struct.</doc>
<field name="objects" writable="1">
<array zero-terminated="0" c:type="AnnotationObject*" fixed-size="10">
<type name="Object"/>
@@ -598,28 +584,28 @@ it says it&apos;s pointer but it&apos;s actually a string."
</field>
</record>
<function name="attribute_func" c:identifier="annotation_attribute_func">
- <return-value transfer-ownership="none" doc="The return value.">
+ <return-value transfer-ownership="none">
<attribute name="yet.another.annotation" value="another_value"/>
<attribute name="some.other.annotation" value="value2"/>
+ <doc xml:whitespace="preserve">The return value.</doc>
<type name="int" c:type="gint"/>
</return-value>
<parameters>
- <parameter name="object"
- transfer-ownership="none"
- doc="A #AnnotationObject.">
+ <parameter name="object" transfer-ownership="none">
+ <doc xml:whitespace="preserve">A #AnnotationObject.</doc>
<type name="Object" c:type="AnnotationObject*"/>
</parameter>
- <parameter name="data" transfer-ownership="none" doc="Some data.">
+ <parameter name="data" transfer-ownership="none">
<attribute name="another.annotation" value="blahvalue"/>
<attribute name="some.annotation" value="value"/>
+ <doc xml:whitespace="preserve">Some data.</doc>
<type name="utf8" c:type="gchar*"/>
</parameter>
</parameters>
</function>
- <function name="custom_destroy"
- c:identifier="annotation_custom_destroy"
- doc="Test messing up the heuristic of closure/destroy-notification
-detection, and fixing it via annotations.">
+ <function name="custom_destroy" c:identifier="annotation_custom_destroy">
+ <doc xml:whitespace="preserve">Test messing up the heuristic of closure/destroy-notification
+detection, and fixing it via annotations.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -628,8 +614,8 @@ detection, and fixing it via annotations.">
transfer-ownership="none"
scope="call"
closure="2"
- destroy="1"
- doc="Destroy notification">
+ destroy="1">
+ <doc xml:whitespace="preserve">Destroy notification</doc>
<type name="Callback" c:type="AnnotationCallback"/>
</parameter>
<parameter name="destroy" transfer-ownership="none" scope="call">
@@ -641,7 +627,8 @@ detection, and fixing it via annotations.">
</parameters>
</function>
<function name="get_source_file" c:identifier="annotation_get_source_file">
- <return-value transfer-ownership="full" doc="Source file">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">Source file</doc>
<type name="filename" c:type="char*"/>
</return-value>
</function>
@@ -653,15 +640,15 @@ detection, and fixing it via annotations.">
<parameter name="argc"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="The number of args.">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">The number of args.</doc>
<type name="int" c:type="int*"/>
</parameter>
<parameter name="argv"
direction="inout"
caller-allocates="0"
- transfer-ownership="full"
- doc="The arguments.">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">The arguments.</doc>
<array length="0" c:type="char***">
<type name="utf8"/>
</array>
@@ -674,9 +661,8 @@ detection, and fixing it via annotations.">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="foo"
- transfer-ownership="none"
- doc="some text (e.g. example) or else">
+ <parameter name="foo" transfer-ownership="none">
+ <doc xml:whitespace="preserve">some text (e.g. example) or else</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
@@ -686,7 +672,8 @@ detection, and fixing it via annotations.">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="array" transfer-ownership="none" doc="the array">
+ <parameter name="array" transfer-ownership="none">
+ <doc xml:whitespace="preserve">the array</doc>
<array name="GLib.PtrArray" c:type="GPtrArray*">
<type name="GLib.Value"/>
</array>
@@ -694,7 +681,8 @@ detection, and fixing it via annotations.">
</parameters>
</function>
<function name="return_array" c:identifier="annotation_return_array">
- <return-value transfer-ownership="full" doc="The return value">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">The return value</doc>
<array length="0" c:type="char**">
<type name="utf8"/>
</array>
@@ -703,8 +691,8 @@ detection, and fixing it via annotations.">
<parameter name="length"
direction="out"
caller-allocates="0"
- transfer-ownership="full"
- doc="Number of return values">
+ transfer-ownership="full">
+ <doc xml:whitespace="preserve">Number of return values</doc>
<type name="int" c:type="int*"/>
</parameter>
</parameters>
@@ -714,7 +702,8 @@ detection, and fixing it via annotations.">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="fname" transfer-ownership="none" doc="Source file">
+ <parameter name="fname" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Source file</doc>
<type name="filename" c:type="char*"/>
</parameter>
</parameters>
@@ -737,7 +726,8 @@ detection, and fixing it via annotations.">
</function>
<function name="string_zero_terminated"
c:identifier="annotation_string_zero_terminated">
- <return-value transfer-ownership="full" doc="The return value">
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">The return value</doc>
<array c:type="char**">
<type name="utf8"/>
</array>
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index f7ca794b..df14d235 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -311,11 +311,11 @@ and/or use gtk-doc annotations. -->
<type name="int" c:type="int"/>
</return-value>
</function>
- <function name="get_default"
- c:identifier="foo_object_get_default"
- doc="This function is intended to match clutter_stage_get_default which
-uses a C sugar return type.">
- <return-value transfer-ownership="full" doc="The global #FooSubobject">
+ <function name="get_default" c:identifier="foo_object_get_default">
+ <doc xml:whitespace="preserve">This function is intended to match clutter_stage_get_default which
+uses a C sugar return type.</doc>
+ <return-value transfer-ownership="full">
+ <doc xml:whitespace="preserve">The global #FooSubobject</doc>
<type name="Subobject" c:type="FooObject*"/>
</return-value>
</function>
@@ -329,15 +329,18 @@ uses a C sugar return type.">
</parameter>
</parameters>
</virtual-method>
- <virtual-method name="read_fn" invoker="read" doc="Read some stuff.">
+ <virtual-method name="read_fn" invoker="read">
+ <doc xml:whitespace="preserve">Read some stuff.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="offset" transfer-ownership="none" doc="offset">
+ <parameter name="offset" transfer-ownership="none">
+ <doc xml:whitespace="preserve">offset</doc>
<type name="int" c:type="int"/>
</parameter>
- <parameter name="length" transfer-ownership="none" doc="length">
+ <parameter name="length" transfer-ownership="none">
+ <doc xml:whitespace="preserve">length</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
@@ -436,25 +439,26 @@ uses a C sugar return type.">
</parameter>
</parameters>
</method>
- <method name="read"
- c:identifier="foo_object_read"
- doc="Read some stuff.">
+ <method name="read" c:identifier="foo_object_read">
+ <doc xml:whitespace="preserve">Read some stuff.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="offset" transfer-ownership="none" doc="offset">
+ <parameter name="offset" transfer-ownership="none">
+ <doc xml:whitespace="preserve">offset</doc>
<type name="int" c:type="int"/>
</parameter>
- <parameter name="length" transfer-ownership="none" doc="length">
+ <parameter name="length" transfer-ownership="none">
+ <doc xml:whitespace="preserve">length</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
</method>
<method name="skipped_method"
c:identifier="foo_object_skipped_method"
- doc="This is only useful from C."
introspectable="0">
+ <doc xml:whitespace="preserve">This is only useful from C.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
@@ -515,10 +519,12 @@ uses a C sugar return type.">
<parameter name="object" transfer-ownership="none">
<type name="Object" c:type="FooObject*"/>
</parameter>
- <parameter name="offset" transfer-ownership="none" doc="offset">
+ <parameter name="offset" transfer-ownership="none">
+ <doc xml:whitespace="preserve">offset</doc>
<type name="int" c:type="int"/>
</parameter>
- <parameter name="length" transfer-ownership="none" doc="length">
+ <parameter name="length" transfer-ownership="none">
+ <doc xml:whitespace="preserve">length</doc>
<type name="int" c:type="int"/>
</parameter>
</parameters>
@@ -570,9 +576,8 @@ uses a C sugar return type.">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="r2"
- transfer-ownership="none"
- doc="source rectangle">
+ <parameter name="r2" transfer-ownership="none">
+ <doc xml:whitespace="preserve">source rectangle</doc>
<type name="Rectangle" c:type="FooRectangle*"/>
</parameter>
</parameters>
@@ -581,11 +586,9 @@ uses a C sugar return type.">
<constant name="SUCCESS_INT" value="4408">
<type name="int"/>
</constant>
- <enumeration name="Skippable"
- doc="Some type that is only interesting from C and should not be
-exposed to language bindings."
- introspectable="0"
- c:type="FooSkippable">
+ <enumeration name="Skippable" introspectable="0" c:type="FooSkippable">
+ <doc xml:whitespace="preserve">Some type that is only interesting from C and should not be
+exposed to language bindings.</doc>
<member name="one" value="0" c:identifier="FOO_SKIPPABLE_ONE"/>
<member name="two" value="1" c:identifier="FOO_SKIPPABLE_TWO"/>
</enumeration>
@@ -819,16 +822,15 @@ exposed to language bindings."
</parameter>
</parameters>
</function>
- <function name="skip_me"
- c:identifier="foo_skip_me"
- doc="Does something that&apos;s only interesting from C and should not be
-exposed to language bindings."
- introspectable="0">
+ <function name="skip_me" c:identifier="foo_skip_me" introspectable="0">
+ <doc xml:whitespace="preserve">Does something that's only interesting from C and should not be
+exposed to language bindings.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="fs" transfer-ownership="none" doc="a #FooSkippable">
+ <parameter name="fs" transfer-ownership="none">
+ <doc xml:whitespace="preserve">a #FooSkippable</doc>
<type name="Skippable" c:type="FooSkippable"/>
</parameter>
</parameters>