diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-20 13:52:14 +0100 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-10-04 17:46:09 -0400 |
commit | 10cb665fee2cc378dd2f13bad16e6384836a8b16 (patch) | |
tree | 3d699aa40290c4902774233290ec89d277ff9dec /tests/scanner | |
parent | 0a134a608f5b471c3a12739785e149ceaf90df27 (diff) | |
download | gobject-introspection-10cb665fee2cc378dd2f13bad16e6384836a8b16.tar.gz |
giscanner: Mark gpointer nodes as nullable by default
gpointer parameters and return types should be marked as nullable by
default, unless:
• also annotated with (type) and not with (nullable); or
• explicitly annotated with (not nullable).
This introduces the (not nullable) annotation as a direct opposite to
(nullable). In future, (not) could be extended to invert other
annotations.
https://bugzilla.gnome.org/show_bug.cgi?id=729660
Diffstat (limited to 'tests/scanner')
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 31 | ||||
-rw-r--r-- | tests/scanner/WarnLib-1.0-expected.gir | 30 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/annotation_not_nullable.xml | 76 | ||||
-rw-r--r-- | tests/scanner/regress.c | 1 |
4 files changed, 122 insertions, 16 deletions
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index b856867f..dfbbd8d5 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -790,7 +790,10 @@ regress_annotation_object_watch_full().</doc> <instance-parameter name="object" transfer-ownership="none"> <type name="AnnotationObject" c:type="RegressAnnotationObject*"/> </instance-parameter> - <parameter name="data" transfer-ownership="none"> + <parameter name="data" + transfer-ownership="none" + nullable="1" + allow-none="1"> <doc xml:space="preserve">Opaque pointer handle</doc> <type name="gpointer" c:type="void*"/> </parameter> @@ -851,7 +854,10 @@ of tabs and strings to test the tab handling capabilities of the scanner.</doc> <type name="none" c:type="void"/> </return-value> <parameters> - <parameter name="arg1" transfer-ownership="none"> + <parameter name="arg1" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -1071,7 +1077,10 @@ it says it's pointer but it's actually a string.</doc> <parameter name="b" transfer-ownership="none"> <type name="gboolean" c:type="gboolean"/> </parameter> - <parameter name="data" transfer-ownership="none"> + <parameter name="data" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -1553,7 +1562,10 @@ uses a C sugar return type.</doc> <instance-parameter name="object" transfer-ownership="none"> <type name="FooObject" c:type="RegressFooObject*"/> </instance-parameter> - <parameter name="data" transfer-ownership="none"> + <parameter name="data" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="void*"/> </parameter> <parameter name="some_type" transfer-ownership="none"> @@ -1602,7 +1614,10 @@ uses a C sugar return type.</doc> <parameter name="object" transfer-ownership="none"> <type name="GObject.Object"/> </parameter> - <parameter name="p0" transfer-ownership="none"> + <parameter name="p0" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -5486,11 +5501,7 @@ call and can be released on return.</doc> <type name="TestCallbackUserData" c:type="RegressTestCallbackUserData"/> </parameter> - <parameter name="user_data" - transfer-ownership="none" - nullable="1" - allow-none="1" - closure="1"> + <parameter name="user_data" transfer-ownership="none" closure="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> diff --git a/tests/scanner/WarnLib-1.0-expected.gir b/tests/scanner/WarnLib-1.0-expected.gir index 47e3666c..007ec864 100644 --- a/tests/scanner/WarnLib-1.0-expected.gir +++ b/tests/scanner/WarnLib-1.0-expected.gir @@ -33,7 +33,10 @@ and/or use gtk-doc annotations. --> <doc xml:space="preserve">x parameter</doc> <type name="gint" c:type="int"/> </parameter> - <parameter name="y" transfer-ownership="none"> + <parameter name="y" + transfer-ownership="none" + nullable="1" + allow-none="1"> <doc xml:space="preserve">y parameter</doc> <type name="gpointer" c:type="gpointer"/> </parameter> @@ -50,7 +53,10 @@ and/or use gtk-doc annotations. --> <parameter name="arg1" transfer-ownership="none"> <type name="gint" c:type="int"/> </parameter> - <parameter name="arg2" transfer-ownership="none"> + <parameter name="arg2" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -68,7 +74,10 @@ and/or use gtk-doc annotations. --> <parameter name="arg1" transfer-ownership="none"> <type name="gint" c:type="int"/> </parameter> - <parameter name="arg2" transfer-ownership="none"> + <parameter name="arg2" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -84,7 +93,10 @@ and/or use gtk-doc annotations. --> <parameter name="arg1" transfer-ownership="none"> <type name="gint" c:type="int"/> </parameter> - <parameter name="arg2" transfer-ownership="none"> + <parameter name="arg2" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -108,7 +120,10 @@ and/or use gtk-doc annotations. --> <parameter name="arg1" transfer-ownership="none"> <type name="gint" c:type="int"/> </parameter> - <parameter name="arg2" transfer-ownership="none"> + <parameter name="arg2" + transfer-ownership="none" + nullable="1" + allow-none="1"> <type name="gpointer" c:type="gpointer"/> </parameter> </parameters> @@ -128,7 +143,10 @@ and/or use gtk-doc annotations. --> <doc xml:space="preserve">x parameter</doc> <type name="gint" c:type="int"/> </parameter> - <parameter name="y" transfer-ownership="none"> + <parameter name="y" + transfer-ownership="none" + nullable="1" + allow-none="1"> <doc xml:space="preserve">y parameter</doc> <type name="gpointer" c:type="gpointer"/> </parameter> diff --git a/tests/scanner/annotationparser/gi/annotation_not_nullable.xml b/tests/scanner/annotationparser/gi/annotation_not_nullable.xml new file mode 100644 index 00000000..d63ec94e --- /dev/null +++ b/tests/scanner/annotationparser/gi/annotation_not_nullable.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<tests xmlns="http://schemas.gnome.org/gobject-introspection/2013/test"> + +<test> + <input>/** + * annotation_object_not_nullable: + * @object: a #GObject + * @closurearg: (closure) (not nullable): This is an argument test + * + * This is a test for not-nullable arguments which would otherwise be nullable + * by convention. + * + * Return value: (not nullable): a pointer + */</input> + <parser> + <docblock> + <identifier> + <name>annotation_object_not_nullable</name> + </identifier> + <parameters> + <parameter> + <name>object</name> + <description>a #GObject</description> + </parameter> + <parameter> + <name>closurearg</name> + <annotations> + <annotation> + <name>closure</name> + </annotation> + <annotation> + <name>not</name> + <options> + <option> + <name>nullable</name> + </option> + </options> + </annotation> + </annotations> + <description>This is an argument test</description> + </parameter> + </parameters> + <description>This is a test for not-nullable arguments which would otherwise be nullable +by convention.</description> + <tags> + <tag> + <name>returns</name> + <annotations> + <annotation> + <name>not</name> + <options> + <option> + <name>nullable</name> + </option> + </options> + </annotation> + </annotations> + <description>a pointer</description> + </tag> + </tags> + </docblock> + </parser> + <output>/** + * annotation_object_not_nullable: + * @object: a #GObject + * @closurearg: (closure) (not nullable): This is an argument test + * + * This is a test for not-nullable arguments which would otherwise be nullable + * by convention. + * + * Returns: (not nullable): a pointer + */</output> +</test> + +</tests> diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 537d7d66..3644f4ca 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3478,6 +3478,7 @@ regress_test_simple_callback (RegressTestSimpleCallback callback) /** * regress_test_callback_user_data: * @callback: (scope call): + * @user_data: (not nullable): * * Call - callback parameter persists for the duration of the method * call and can be released on return. |