diff options
author | Dieter Verfaillie <dieterv@optionexplicit.be> | 2013-08-12 16:54:11 +0200 |
---|---|---|
committer | Dieter Verfaillie <dieterv@optionexplicit.be> | 2013-10-08 20:55:46 +0200 |
commit | a2b22ce75937d2d996ef90e0ab683d36031365d0 (patch) | |
tree | 42a1e8e7ba992a89efd98fa41b2d5e013f7165b2 /tests | |
parent | 839e4f10a6b291a261c200484ff05ec44a31d93e (diff) | |
download | gobject-introspection-a2b22ce75937d2d996ef90e0ab683d36031365d0.tar.gz |
giscanner: flesh out annotation parsing and storage
- remove annotations regex, restore proper parens parsing
- drop weird DocOption() storage class and use lists/dicts
as appropriate
- make GtkDocAnnotations a simple OrderedDict subclass instead
of a weird hybrid dict/list storage class
- Deprecate Attribute: tag, replace with (attributes) annotation
on the identifier
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scanner/Makefile.am | 1 | ||||
-rw-r--r-- | tests/scanner/annotation.c | 14 | ||||
-rw-r--r-- | tests/scanner/annotation.h | 4 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/annotation_attributes.xml | 395 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/annotation_element_type.xml | 2 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/annotation_in_out.xml | 7 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/identifier_symbol.xml | 6 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/tag_deprecated.xml | 2 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/tag_since.xml | 2 | ||||
-rw-r--r-- | tests/scanner/annotationparser/gi/tag_stability.xml | 2 | ||||
-rw-r--r-- | tests/scanner/annotationparser/test_parser.py | 92 | ||||
-rw-r--r-- | tests/scanner/annotationparser/test_patterns.py | 221 | ||||
-rw-r--r-- | tests/warn/invalid-element-type.h | 10 |
13 files changed, 569 insertions, 189 deletions
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am index 0957a5f7..aa5b55af 100644 --- a/tests/scanner/Makefile.am +++ b/tests/scanner/Makefile.am @@ -202,6 +202,7 @@ EXTRA_DIST += \ annotationparser/tests.xsd \ annotationparser/gi/annotation_allow_none.xml \ annotationparser/gi/annotation_array.xml \ + annotationparser/gi/annotation_attributes.xml \ annotationparser/gi/annotation_closure.xml \ annotationparser/gi/annotation_constructor.xml \ annotationparser/gi/annotation_destroy.xml \ diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index 0a92d3a1..32187d38 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -128,12 +128,12 @@ regress_annotation_object_class_init (RegressAnnotationObjectClass *klass) /** * RegressAnnotationObject::attribute-signal: * @regress_annotation: the regress_annotation object - * @arg1: (attribute some.annotation.foo1 val1): a value - * @arg2: (attribute some.annotation.foo2 val2): another value + * @arg1: (attributes some.annotation.foo1=val1): a value + * @arg2: (attributes some.annotation.foo2=val2): another value * * This signal tests a signal with attributes. * - * Returns: (attribute some.annotation.foo3 val3): the return value + * Returns: (attributes some.annotation.foo3=val3): the return value */ regress_annotation_object_signals[ATTRIBUTE_SIGNAL] = g_signal_new ("attribute-signal", @@ -707,9 +707,7 @@ regress_annotation_string_array_length (guint n_properties, const gchar * const } /** - * regress_annotation_object_extra_annos: - * - * Attributes: (org.foobar testvalue) + * regress_annotation_object_extra_annos: (attributes org.foobar=testvalue) */ void regress_annotation_object_extra_annos (RegressAnnotationObject *object) @@ -763,9 +761,9 @@ regress_annotation_ptr_array (GPtrArray *array) /** * regress_annotation_attribute_func: * @object: A #RegressAnnotationObject. - * @data: (attribute some.annotation value) (attribute another.annotation blahvalue): Some data. + * @data: (attributes some.annotation=value another.annotation=blahvalue): Some data. * - * Returns: (attribute some.other.annotation value2) (attribute yet.another.annotation another_value): The return value. + * Returns: (attributes some.other.annotation=value2 yet.another.annotation=another_value): The return value. */ gint regress_annotation_attribute_func (RegressAnnotationObject *object, diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h index 66470cbb..b982a5b7 100644 --- a/tests/scanner/annotation.h +++ b/tests/scanner/annotation.h @@ -37,11 +37,9 @@ typedef GList* (*RegressAnnotationListCallback) (GList *in); typedef void (*RegressAnnotationNotifyFunc) (gpointer data); /** - * RegressAnnotationObject: + * RegressAnnotationObject: (attributes org.example.Test=cows) * * This is an object used to test annotations. - * - * Attributes: (org.example.Test cows) */ typedef struct _RegressAnnotationObject RegressAnnotationObject; typedef struct _RegressAnnotationObjectClass RegressAnnotationObjectClass; diff --git a/tests/scanner/annotationparser/gi/annotation_attributes.xml b/tests/scanner/annotationparser/gi/annotation_attributes.xml new file mode 100644 index 00000000..e7c46894 --- /dev/null +++ b/tests/scanner/annotationparser/gi/annotation_attributes.xml @@ -0,0 +1,395 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<tests xmlns="http://schemas.gnome.org/gobject-introspection/2013/test"> + +<test> + <input>/** + * AnnotationObject: (attributes org.example.test1=horses org.example.test2 org.example.test3=cows) + * + * This is an object used to test annotations. + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>org.example.test1</name> + <value>horses</value> + </option> + <option> + <name>org.example.test2</name> + </option> + <option> + <name>org.example.test3</name> + <value>cows</value> + </option> + </options> + </annotation> + </annotations> + </identifier> + <description>This is an object used to test annotations.</description> + </docblock> + </parser> +</test> + +<test> + <!-- + Deprecated "Attributes:" tag + --> + <input>/** + * AnnotationObject: + * + * This is an object used to test annotations. + * + * Attributes: (org.example.test1 horses) (org.example.test2) (org.example.test3 cows) + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>org.example.test1</name> + <value>horses</value> + </option> + <option> + <name>org.example.test2</name> + </option> + <option> + <name>org.example.test3</name> + <value>cows</value> + </option> + </options> + </annotation> + </annotations> + </identifier> + <description>This is an object used to test annotations.</description> + </docblock> + <messages> + <message>6: Warning: Test: GObject-Introspection specific GTK-Doc tag "Attributes" has been deprecated, please use annotations on the identifier instead: + * Attributes: (org.example.test1 horses) (org.example.test2) (org.example.test3 cows) + ^</message> + </messages> + </parser> +</test> + +<test> + <!-- + (attributes) annotation on the identifier together with a + deprecated "Attributes:" tag. + --> + <input>/** + * AnnotationObject: (attributes org.example.test1=horses) + * + * This is an object used to test annotations. + * + * Attributes: (org.example.test1 horses) (org.example.test2 cows) + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>org.example.test1</name> + <value>horses</value> + </option> + </options> + </annotation> + </annotations> + </identifier> + <description>This is an object used to test annotations.</description> + </docblock> + <messages> + <message>6: Warning: Test: GObject-Introspection specific GTK-Doc tag "Attributes" has been deprecated, please use annotations on the identifier instead: + * Attributes: (org.example.test1 horses) (org.example.test2 cows) + ^</message> + <message>6: Error: Test: Duplicate "Attributes:" annotation will be ignored: + * Attributes: (org.example.test1 horses) (org.example.test2 cows) + ^</message> + </messages> + </parser> +</test> + +<test> + <!-- + Deprecated "Attributes:" tag in the wrong location + --> + <input>/** + * AnnotationObject: + * + * Attributes: (org.example.Test horses) (org.example.test2 cows) + * + * This is an object used to test annotations. + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>org.example.Test</name> + <value>horses</value> + </option> + <option> + <name>org.example.test2</name> + <value>cows</value> + </option> + </options> + </annotation> + </annotations> + </identifier> + <description>This is an object used to test annotations.</description> + </docblock> + <messages> + <message>4: Warning: Test: GObject-Introspection specific GTK-Doc tag "Attributes" has been deprecated, please use annotations on the identifier instead: + * Attributes: (org.example.Test horses) (org.example.test2 cows) + ^</message> + </messages> + </parser> +</test> + +<test> + <input>/** + * AnnotationObject: + * + * Attributes: (org.example.Test horses cows) + * + * This is an object used to test annotations. + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject</name> + </identifier> + <description>This is an object used to test annotations.</description> + </docblock> + <messages> + <message>4: Warning: Test: GObject-Introspection specific GTK-Doc tag "Attributes" has been deprecated, please use annotations on the identifier instead: + * Attributes: (org.example.Test horses cows) + ^</message> + <message>4: Error: Test: malformed "Attributes:" tag will be ignored: + * Attributes: (org.example.Test horses cows) + ^</message> + </messages> + </parser> +</test> + +<test> + <input>/** + * AnnotationObject::attribute-signal: + * @annotation: the annotation object + * @arg1: (attributes some.annotation.foo1=val1): a value + * @arg2: (attributes some.annotation.foo2=val2): another value + * @arg3: (array fixed-size=2): a third value + * + * This signal tests a signal with attributes. + * + * Returns: (attributes some.annotation.foo3=val3): the return value + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject::attribute-signal</name> + </identifier> + <parameters> + <parameter> + <name>annotation</name> + <description>the annotation object</description> + </parameter> + <parameter> + <name>arg1</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>some.annotation.foo1</name> + <value>val1</value> + </option> + </options> + </annotation> + </annotations> + <description>a value</description> + </parameter> + <parameter> + <name>arg2</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>some.annotation.foo2</name> + <value>val2</value> + </option> + </options> + </annotation> + </annotations> + <description>another value</description> + </parameter> + <parameter> + <name>arg3</name> + <annotations> + <annotation> + <name>array</name> + <options> + <option> + <name>fixed-size</name> + <value>2</value> + </option> + </options> + </annotation> + </annotations> + <description>a third value</description> + </parameter> + </parameters> + <description>This signal tests a signal with attributes.</description> + <tags> + <tag> + <name>returns</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>some.annotation.foo3</name> + <value>val3</value> + </option> + </options> + </annotation> + </annotations> + <description>the return value</description> + </tag> + </tags> + </docblock> + </parser> +</test> + +<test> + <!-- + Deprecated (attribute) annotation. + --> + <input>/** + * AnnotationObject::attribute-signal: + * @annotation: the annotation object + * @arg1: (attribute some.annotation.foo1): a value + * @arg2: (attribute some.annotation.foo2 val2): another value + * @arg3: (attribute x y z): something special + * @arg4: (array fixed-size=2): a third value + * + * This signal tests a signal with attributes. + * + * Returns: (attribute some.annotation.foo3 val3): the return value + */</input> + <parser> + <docblock> + <identifier> + <name>AnnotationObject::attribute-signal</name> + </identifier> + <parameters> + <parameter> + <name>annotation</name> + <description>the annotation object</description> + </parameter> + <parameter> + <name>arg1</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>some.annotation.foo1</name> + </option> + </options> + </annotation> + </annotations> + <description>a value</description> + </parameter> + <parameter> + <name>arg2</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>some.annotation.foo2</name> + <value>val2</value> + </option> + </options> + </annotation> + </annotations> + <description>another value</description> + </parameter> + <parameter> + <name>arg3</name> + <description>something special</description> + </parameter> + <parameter> + <name>arg4</name> + <annotations> + <annotation> + <name>array</name> + <options> + <option> + <name>fixed-size</name> + <value>2</value> + </option> + </options> + </annotation> + </annotations> + <description>a third value</description> + </parameter> + </parameters> + <description>This signal tests a signal with attributes.</description> + <tags> + <tag> + <name>returns</name> + <annotations> + <annotation> + <name>attributes</name> + <options> + <option> + <name>some.annotation.foo3</name> + <value>val3</value> + </option> + </options> + </annotation> + </annotations> + <description>the return value</description> + </tag> + </tags> + </docblock> + <messages> + <message>4: Warning: Test: "attribute" annotation has been deprecated, please use "attributes" instead: + * @arg1: (attribute some.annotation.foo1): a value + ^</message> + <message>5: Warning: Test: "attribute" annotation has been deprecated, please use "attributes" instead: + * @arg2: (attribute some.annotation.foo2 val2): another value + ^</message> + <message>6: Warning: Test: "attribute" annotation has been deprecated, please use "attributes" instead: + * @arg3: (attribute x y z): something special + ^</message> + <message>6: Error: Test: malformed "(attribute)" annotation will be ignored: + * @arg3: (attribute x y z): something special + ^</message> + <message>11: Warning: Test: "attribute" annotation has been deprecated, please use "attributes" instead: + * Returns: (attribute some.annotation.foo3 val3): the return value + ^</message> + </messages> + </parser> +</test> + +</tests> diff --git a/tests/scanner/annotationparser/gi/annotation_element_type.xml b/tests/scanner/annotationparser/gi/annotation_element_type.xml index 30fffafc..84337b7e 100644 --- a/tests/scanner/annotationparser/gi/annotation_element_type.xml +++ b/tests/scanner/annotationparser/gi/annotation_element_type.xml @@ -110,7 +110,7 @@ element-type annotation.</description> <name>utf8</name> </option> <option> - <name><![CDATA[GLib.HashTable<utf8,utf8>]]></name> + <name>GLib.HashTable(utf8,utf8)</name> </option> </options> </annotation> diff --git a/tests/scanner/annotationparser/gi/annotation_in_out.xml b/tests/scanner/annotationparser/gi/annotation_in_out.xml index cb489577..5530a6ab 100644 --- a/tests/scanner/annotationparser/gi/annotation_in_out.xml +++ b/tests/scanner/annotationparser/gi/annotation_in_out.xml @@ -36,7 +36,7 @@ <name>inoutarg2</name> <annotations> <annotation> - <name>in-out</name> + <name>inout</name> </annotation> </annotations> <description>This is an argument test</description> @@ -50,6 +50,11 @@ </tag> </tags> </docblock> + <messages> + <message>5: Warning: Test: "in-out" annotation has been deprecated, please use "inout" instead: + * @inoutarg2: (in-out): This is an argument test + ^</message> + </messages> </parser> </test> diff --git a/tests/scanner/annotationparser/gi/identifier_symbol.xml b/tests/scanner/annotationparser/gi/identifier_symbol.xml index 7e317769..4a97936d 100644 --- a/tests/scanner/annotationparser/gi/identifier_symbol.xml +++ b/tests/scanner/annotationparser/gi/identifier_symbol.xml @@ -74,7 +74,7 @@ <description>Missing colon will result in a warning.</description> </docblock> <messages> - <message>2: Warning: Test: missing ':' at column 30: + <message>2: Warning: Test: missing ":" at column 30: * test_symbol_missing_colon (skip) ^</message> </messages> @@ -153,7 +153,7 @@ <description>Missing colon will result in a warning.</description> </docblock> <messages> - <message>2: Warning: Test: missing ':' at column 42: + <message>2: Warning: Test: missing ":" at column 42: * GtkWidget:test_property_missing_colon (skip) ^</message> </messages> @@ -232,7 +232,7 @@ <description>Missing colon will result in a warning.</description> </docblock> <messages> - <message>2: Warning: Test: missing ':' at column 41: + <message>2: Warning: Test: missing ":" at column 41: * GtkWidget::test_signal_missing_colon (skip) ^</message> </messages> diff --git a/tests/scanner/annotationparser/gi/tag_deprecated.xml b/tests/scanner/annotationparser/gi/tag_deprecated.xml index b33509c4..fbd342b6 100644 --- a/tests/scanner/annotationparser/gi/tag_deprecated.xml +++ b/tests/scanner/annotationparser/gi/tag_deprecated.xml @@ -67,7 +67,7 @@ </tags> </docblock> <messages> - <message>6: Warning: Test: annotations not supported for tag 'Deprecated:'.</message> + <message>6: Error: Test: annotations not supported for tag "Deprecated:".</message> </messages> </parser> </test> diff --git a/tests/scanner/annotationparser/gi/tag_since.xml b/tests/scanner/annotationparser/gi/tag_since.xml index e736aba2..502d8b6e 100644 --- a/tests/scanner/annotationparser/gi/tag_since.xml +++ b/tests/scanner/annotationparser/gi/tag_since.xml @@ -66,7 +66,7 @@ </tags> </docblock> <messages> - <message>6: Warning: Test: annotations not supported for tag 'Since:'.</message> + <message>6: Error: Test: annotations not supported for tag "Since:".</message> </messages> </parser> </test> diff --git a/tests/scanner/annotationparser/gi/tag_stability.xml b/tests/scanner/annotationparser/gi/tag_stability.xml index 27976fd8..ec87b027 100644 --- a/tests/scanner/annotationparser/gi/tag_stability.xml +++ b/tests/scanner/annotationparser/gi/tag_stability.xml @@ -108,7 +108,7 @@ </tags> </docblock> <messages> - <message>6: Warning: Test: annotations not supported for tag 'Stability:'.</message> + <message>6: Error: Test: annotations not supported for tag "Stability:".</message> </messages> </parser> </test> diff --git a/tests/scanner/annotationparser/test_parser.py b/tests/scanner/annotationparser/test_parser.py index 98ae787e..c7ff5321 100644 --- a/tests/scanner/annotationparser/test_parser.py +++ b/tests/scanner/annotationparser/test_parser.py @@ -130,20 +130,25 @@ class TestCommentBlock(unittest.TestCase): parsed += ' <identifier>\n' parsed += ' <name>%s</name>\n' % (docblock.name, ) - if docblock.annotations.values: + if docblock.annotations: parsed += ' <annotations>\n' - for key, value in docblock.annotations.values: + for ann_name, ann_options in docblock.annotations.items(): parsed += ' <annotation>\n' - parsed += ' <name>%s</name>\n' % (key, ) - if value is not None: - options = value.all() + parsed += ' <name>%s</name>\n' % (ann_name, ) + if ann_options: parsed += ' <options>\n' - for option in options: - parsed += ' <option>\n' - parsed += ' <name>%s</name>\n' % (option, ) - if options[option] is not None: - parsed += ' <value>%s</value>\n' % (options[option], ) - parsed += ' </option>\n' + if isinstance(ann_options, list): + for option in ann_options: + parsed += ' <option>\n' + parsed += ' <name>%s</name>\n' % (option, ) + parsed += ' </option>\n' + else: + for (option, value) in ann_options.items(): + parsed += ' <option>\n' + parsed += ' <name>%s</name>\n' % (option, ) + if value: + parsed += ' <value>%s</value>\n' % (value, ) + parsed += ' </option>\n' parsed += ' </options>\n' parsed += ' </annotation>\n' parsed += ' </annotations>\n' @@ -155,20 +160,25 @@ class TestCommentBlock(unittest.TestCase): param = docblock.params.get(param_name) parsed += ' <parameter>\n' parsed += ' <name>%s</name>\n' % (param_name, ) - if param.annotations.values: + if param.annotations: parsed += ' <annotations>\n' - for key, value in param.annotations.values: + for ann_name, ann_options in param.annotations.items(): parsed += ' <annotation>\n' - parsed += ' <name>%s</name>\n' % (key, ) - if value is not None: - options = value.all() + parsed += ' <name>%s</name>\n' % (ann_name, ) + if ann_options: parsed += ' <options>\n' - for option in options: - parsed += ' <option>\n' - parsed += ' <name>%s</name>\n' % (option, ) - if options[option] is not None: - parsed += ' <value>%s</value>\n' % (options[option], ) - parsed += ' </option>\n' + if isinstance(ann_options, list): + for option in ann_options: + parsed += ' <option>\n' + parsed += ' <name>%s</name>\n' % (option, ) + parsed += ' </option>\n' + else: + for (option, value) in ann_options.items(): + parsed += ' <option>\n' + parsed += ' <name>%s</name>\n' % (option, ) + if value: + parsed += ' <value>%s</value>\n' % (value, ) + parsed += ' </option>\n' parsed += ' </options>\n' parsed += ' </annotation>\n' parsed += ' </annotations>\n' @@ -186,20 +196,25 @@ class TestCommentBlock(unittest.TestCase): tag = docblock.tags.get(tag_name) parsed += ' <tag>\n' parsed += ' <name>%s</name>\n' % (tag_name, ) - if tag.annotations.values: + if tag.annotations: parsed += ' <annotations>\n' - for key, value in tag.annotations.values: + for ann_name, ann_options in tag.annotations.items(): parsed += ' <annotation>\n' - parsed += ' <name>%s</name>\n' % (key, ) - if value is not None: - options = value.all() + parsed += ' <name>%s</name>\n' % (ann_name, ) + if ann_options: parsed += ' <options>\n' - for option in options: - parsed += ' <option>\n' - parsed += ' <name>%s</name>\n' % (option, ) - if options[option] is not None: - parsed += ' <value>%s</value>\n' % (options[option], ) - parsed += ' </option>\n' + if isinstance(ann_options, list): + for option in ann_options: + parsed += ' <option>\n' + parsed += ' <name>%s</name>\n' % (option, ) + parsed += ' </option>\n' + else: + for (option, value) in ann_options.items(): + parsed += ' <option>\n' + parsed += ' <name>%s</name>\n' % (option, ) + if value: + parsed += ' <value>%s</value>\n' % (value, ) + parsed += ' </option>\n' parsed += ' </options>\n' parsed += ' </annotation>\n' parsed += ' </annotations>\n' @@ -235,8 +250,9 @@ class TestCommentBlock(unittest.TestCase): expected += ' <options>\n' for option in annotation.findall(ns('{}options/{}option')): expected += ' <option>\n' - expected += ' <name>%s</name>\n' % (option.find(ns('{}name')).text, ) - if option.find('value') is not None: + if option.find(ns('{}name')) is not None: + expected += ' <name>%s</name>\n' % (option.find(ns('{}name')).text, ) + if option.find(ns('{}value')) is not None: expected += ' <value>%s</value>\n' % (option.find(ns('{}value')).text, ) expected += ' </option>\n' expected += ' </options>\n' @@ -260,7 +276,8 @@ class TestCommentBlock(unittest.TestCase): expected += ' <options>\n' for option in annotation.findall(ns('{}options/{}option')): expected += ' <option>\n' - expected += ' <name>%s</name>\n' % (option.find(ns('{}name')).text, ) + if option.find(ns('{}name')) is not None: + expected += ' <name>%s</name>\n' % (option.find(ns('{}name')).text, ) if option.find(ns('{}value')) is not None: expected += ' <value>%s</value>\n' % (option.find(ns('{}value')).text, ) expected += ' </option>\n' @@ -292,7 +309,8 @@ class TestCommentBlock(unittest.TestCase): expected += ' <options>\n' for option in annotation.findall(ns('{}options/{}option')): expected += ' <option>\n' - expected += ' <name>%s</name>\n' % (option.find(ns('{}name')).text, ) + if option.find(ns('{}name')) is not None: + expected += ' <name>%s</name>\n' % (option.find(ns('{}name')).text, ) if option.find(ns('{}value')) is not None: expected += ' <value>%s</value>\n' % (option.find(ns('{}value')).text, ) expected += ' </option>\n' diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py index d121ae60..023f61f6 100644 --- a/tests/scanner/annotationparser/test_patterns.py +++ b/tests/scanner/annotationparser/test_patterns.py @@ -85,182 +85,182 @@ identifier_symbol_tests = [ (SYMBOL_RE, 'GBaseFinalizeFunc:', {'delimiter': ':', 'symbol_name': 'GBaseFinalizeFunc', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, 'gtk_widget_show ', {'delimiter': '', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, ' gtk_widget_show', {'delimiter': '', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, ' gtk_widget_show ', {'delimiter': '', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, 'gtk_widget_show:', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, 'gtk_widget_show :', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, 'gtk_widget_show: ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, 'gtk_widget_show : ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, ' gtk_widget_show:', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, ' gtk_widget_show :', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, ' gtk_widget_show: ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, ' gtk_widget_show : ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': ''}), + 'fields': ''}), (SYMBOL_RE, 'gtk_widget_show (skip)', {'delimiter': '', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, 'gtk_widget_show: (skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, 'gtk_widget_show : (skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, 'gtk_widget_show: (skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, 'gtk_widget_show : (skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, ' gtk_widget_show:(skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, ' gtk_widget_show :(skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, ' gtk_widget_show: (skip)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SYMBOL_RE, ' gtk_widget_show : (skip) \t ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) \t '}), + 'fields': '(skip)'}), (SYMBOL_RE, ' gtk_widget_show : (skip) \t ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) \t '}), + 'fields': '(skip)'}), (SYMBOL_RE, 'gtk_widget_show:(skip)(test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)(test1)'}), + 'fields': '(skip)(test1)'}), (SYMBOL_RE, 'gtk_widget_show (skip)(test1)', {'delimiter': '', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip)(test1)'}), + 'fields': '(skip)(test1)'}), (SYMBOL_RE, 'gtk_widget_show: (skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, 'gtk_widget_show : (skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, 'gtk_widget_show: (skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, 'gtk_widget_show : (skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, ' gtk_widget_show:(skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, ' gtk_widget_show :(skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, ' gtk_widget_show: (skip) (test1)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1)'}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, ' gtk_widget_show : (skip) (test1) ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) '}), + 'fields': '(skip) (test1)'}), (SYMBOL_RE, 'gtk_widget_show: (skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, 'gtk_widget_show : (skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, 'gtk_widget_show: (skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, 'gtk_widget_show : (skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, ' gtk_widget_show:(skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, ' gtk_widget_show :(skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, ' gtk_widget_show: (skip) (test1) (test-2)', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2)'}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, ' gtk_widget_show : (skip) (test1) (test-2) ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2) '}), + 'fields': '(skip) (test1) (test-2)'}), (SYMBOL_RE, ' gtk_widget_show : (skip) (test1) (test-2) ', {'delimiter': ':', 'symbol_name': 'gtk_widget_show', - 'annotations': '(skip) (test1) (test-2) '}), + 'fields': '(skip) (test1) (test-2)'}), # constants (SYMBOL_RE, 'MY_CONSTANT:', {'delimiter': ':', 'symbol_name': 'MY_CONSTANT', - 'annotations': ''}), + 'fields': ''}), # structs (SYMBOL_RE, 'FooWidget:', {'delimiter': ':', 'symbol_name': 'FooWidget', - 'annotations': ''}), + 'fields': ''}), # enums (SYMBOL_RE, 'Something:', {'delimiter': ':', 'symbol_name': 'Something', - 'annotations': ''})] + 'fields': ''})] identifier_property_tests = [ # simple property name @@ -268,57 +268,57 @@ identifier_property_tests = [ {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': '', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (PROPERTY_RE, 'GtkWidget:name', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' GtkWidget :name', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'GtkWidget: name ', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' GtkWidget : name ', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'GtkWidget:name:', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'GtkWidget:name: ', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' GtkWidget:name:', {'class_name': 'GtkWidget', 'property_name': 'name', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'Something:name:', {'class_name': 'Something', 'property_name': 'name', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'Something:name: ', {'class_name': 'Something', 'property_name': 'name', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' Something:name:', {'class_name': 'Something', 'property_name': 'name', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'Weird-thing:name:', None), (PROPERTY_RE, 'really-weird_thing:name:', @@ -327,63 +327,63 @@ identifier_property_tests = [ {'class_name': 'GWin32InputStream', 'property_name': 'handle', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), # property name that contains a dash (PROPERTY_RE, 'GtkWidget:double-buffered (skip)', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': '', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (PROPERTY_RE, 'GtkWidget:double-buffered', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' GtkWidget :double-buffered', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'GtkWidget: double-buffered ', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' GtkWidget : double-buffered ', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': '', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'GtkWidget:double-buffered:', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'GtkWidget:double-buffered: ', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' GtkWidget:double-buffered:', {'class_name': 'GtkWidget', 'property_name': 'double-buffered', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'Something:double-buffered:', {'class_name': 'Something', 'property_name': 'double-buffered', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'Something:double-buffered: ', {'class_name': 'Something', 'property_name': 'double-buffered', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, ' Something:double-buffered:', {'class_name': 'Something', 'property_name': 'double-buffered', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (PROPERTY_RE, 'Weird-thing:double-buffered:', None), (PROPERTY_RE, 'really-weird_thing:double-buffered:', @@ -392,7 +392,7 @@ identifier_property_tests = [ {'class_name': 'GMemoryOutputStream', 'property_name': 'realloc-function', 'delimiter': ':', - 'annotations': '(skip)'})] + 'fields': '(skip)'})] identifier_signal_tests = [ # simple property name @@ -400,17 +400,17 @@ identifier_signal_tests = [ {'class_name': 'GtkWidget', 'signal_name': 'changed', 'delimiter': ':', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SIGNAL_RE, 'GtkWidget::changed:', {'class_name': 'GtkWidget', 'signal_name': 'changed', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (SIGNAL_RE, 'Something::changed:', {'class_name': 'Something', 'signal_name': 'changed', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (SIGNAL_RE, 'Weird-thing::changed:', None), (SIGNAL_RE, 'really-weird_thing::changed:', @@ -420,17 +420,17 @@ identifier_signal_tests = [ {'class_name': 'GtkWidget', 'signal_name': 'hierarchy-changed', 'delimiter': ':', - 'annotations': '(skip)'}), + 'fields': '(skip)'}), (SIGNAL_RE, 'GtkWidget::hierarchy-changed:', {'class_name': 'GtkWidget', 'signal_name': 'hierarchy-changed', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (SIGNAL_RE, 'Something::hierarchy-changed:', {'class_name': 'Something', 'signal_name': 'hierarchy-changed', 'delimiter': ':', - 'annotations': ''}), + 'fields': ''}), (SIGNAL_RE, 'Weird-thing::hierarchy-changed:', None), (SIGNAL_RE, 'really-weird_thing::hierarchy-changed:', @@ -439,106 +439,71 @@ identifier_signal_tests = [ parameter_tests = [ (PARAMETER_RE, '@Short_description: Base class for all widgets ', {'parameter_name': 'Short_description', - 'annotations': '', - 'delimiter': '', - 'description': 'Base class for all widgets'}), + 'fields': 'Base class for all widgets'}), (PARAMETER_RE, '@...: the value of the first property, followed optionally by more', {'parameter_name': '...', - 'annotations': '', - 'delimiter': '', - 'description': 'the value of the first property, followed optionally by more'}), + 'fields': 'the value of the first property, followed optionally by more'}), (PARAMETER_RE, '@widget: a #GtkWidget', {'parameter_name': 'widget', - 'annotations': '', - 'delimiter': '', - 'description': 'a #GtkWidget'}), + 'fields': 'a #GtkWidget'}), (PARAMETER_RE, '@widget_pointer: (inout) (transfer none): ' 'address of a variable that contains @widget', {'parameter_name': 'widget_pointer', - 'annotations': '(inout) (transfer none)', - 'delimiter': ':', - 'description': 'address of a variable that contains @widget'}), + 'fields': '(inout) (transfer none): address of a variable that contains @widget'}), (PARAMETER_RE, '@weird_thing: (inout) (transfer none) (allow-none) (attribute) (destroy) ' '(foreign) (inout) (out) (transfer) (skip) (method): some weird @thing', {'parameter_name': 'weird_thing', - 'annotations': '(inout) (transfer none) (allow-none) (attribute) (destroy) ' - '(foreign) (inout) (out) (transfer) (skip) (method)', - 'delimiter': ':', - 'description': 'some weird @thing'}), + 'fields': '(inout) (transfer none) (allow-none) (attribute) (destroy) ' + '(foreign) (inout) (out) (transfer) (skip) (method): ' + 'some weird @thing'}), (PARAMETER_RE, '@data: a pointer to the element data. The data may be moved as elements ' 'are added to the #GByteArray.', {'parameter_name': 'data', - 'annotations': '', - 'delimiter': '', - 'description': 'a pointer to the element data. The data may be moved as elements ' + 'fields': 'a pointer to the element data. The data may be moved as elements ' 'are added to the #GByteArray.'}), (PARAMETER_RE, '@a: a #GSequenceIter', {'parameter_name': 'a', - 'annotations': '', - 'delimiter': '', - 'description': 'a #GSequenceIter'}), + 'fields': 'a #GSequenceIter'}), (PARAMETER_RE, '@keys: (array length=n_keys) (element-type GQuark) (allow-none):', {'parameter_name': 'keys', - 'annotations': '(array length=n_keys) (element-type GQuark) (allow-none)', - 'delimiter': ':', - 'description': ''})] + 'fields': '(array length=n_keys) (element-type GQuark) (allow-none):'})] tag_tests = [ (TAG_RE, 'Since 3.0', None), (TAG_RE, 'Since: 3.0', {'tag_name': 'Since', - 'annotations': '', - 'delimiter': '', - 'description': '3.0'}), + 'fields': '3.0'}), (TAG_RE, 'Attributes: (inout) (transfer none): some note about attributes', {'tag_name': 'Attributes', - 'annotations': '(inout) (transfer none)', - 'delimiter': ':', - 'description': 'some note about attributes'}), + 'fields': '(inout) (transfer none): some note about attributes'}), (TAG_RE, 'Rename to: something_else', {'tag_name': 'Rename to', - 'annotations': '', - 'delimiter': '', - 'description': 'something_else'}), + 'fields': 'something_else'}), (TAG_RE, '@Deprecated: Since 2.8, reference counting is done atomically', None), (TAG_RE, 'Returns %TRUE and does weird things', None), (TAG_RE, 'Returns: a #GtkWidget', {'tag_name': 'Returns', - 'annotations': '', - 'delimiter': '', - 'description': 'a #GtkWidget'}), + 'fields': 'a #GtkWidget'}), (TAG_RE, 'Return value: (transfer none): The binary data that @text responds. ' 'This pointer', {'tag_name': 'Return value', - 'annotations': '(transfer none)', - 'delimiter': ':', - 'description': 'The binary data that @text responds. This pointer'}), + 'fields': '(transfer none): The binary data that @text responds. This pointer'}), (TAG_RE, 'Return value: (transfer full) (array length=out_len) (element-type guint8):', {'tag_name': 'Return value', - 'annotations': '(transfer full) (array length=out_len) (element-type guint8)', - 'delimiter': ':', - 'description': ''}), + 'fields': '(transfer full) (array length=out_len) (element-type guint8):'}), (TAG_RE, 'Returns: A boolean value, but let me tell you a bit about this boolean. It', {'tag_name': 'Returns', - 'annotations': '', - 'delimiter': '', - 'description': 'A boolean value, but let me tell you a bit about this boolean. ' - 'It'}), + 'fields': 'A boolean value, but let me tell you a bit about this boolean. It'}), (TAG_RE, 'Returns: (transfer container) (element-type GObject.ParamSpec): a', {'tag_name': 'Returns', - 'annotations': '(transfer container) (element-type GObject.ParamSpec)', - 'delimiter': ':', - 'description': 'a'}), + 'fields': '(transfer container) (element-type GObject.ParamSpec): a'}), (TAG_RE, 'Return value: (type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) ' '(transfer full):', {'tag_name': 'Return value', - 'annotations': '(type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) ' - '(transfer full)', - 'delimiter': ':', - 'description': ''})] + 'fields': '(type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) (transfer full):'})] tag_value_version_tests = [ (TAG_VALUE_VERSION_RE, ' abc', diff --git a/tests/warn/invalid-element-type.h b/tests/warn/invalid-element-type.h index bcd9123b..97b8281d 100644 --- a/tests/warn/invalid-element-type.h +++ b/tests/warn/invalid-element-type.h @@ -74,16 +74,16 @@ GList* test_unresolved_element_type(void); GPtrArray* test_unresolved_value_element_type(void); -// EXPECT:5: Warning: Test: element-type annotation takes at least one option, none given +// EXPECT:5: Warning: Test: element-type annotation for a list must have exactly one option, not 0 options // EXPECT:6: Warning: Test: element-type annotation for a list must have exactly one option, not 2 options -// EXPECT:16: Warning: Test: element-type annotation takes at least one option, none given // EXPECT:20: Warning: Test: Unknown container Type(target_fundamental=utf8, ctype=char*) for element-type annotation -// EXPECT:27: Warning: Test: element-type annotation takes at least one option, none given +// EXPECT:20: Warning: Test: Unknown container Type(target_fundamental=utf8, ctype=char*) for element-type annotation +// EXPECT:27: Warning: Test: element-type annotation for a hash table must have exactly two options, not 0 option(s) // EXPECT:28: Warning: Test: element-type annotation for a hash table must have exactly two options, not 1 option(s) // EXPECT:29: Warning: Test: element-type annotation for a hash table must have exactly two options, not 3 option(s) -// EXPECT:40: Warning: Test: element-type annotation takes at least one option, none given +// EXPECT:40: Warning: Test: element-type annotation for an array must have exactly one option, not 0 options // EXPECT:41: Warning: Test: invalid (element-type) for a GByteArray, must be one of guint8, gint8 or gchar -// EXPECT:51: Warning: Test: element-type annotation takes at least one option, none given +// EXPECT:51: Warning: Test: element-type annotation for an array must have exactly one option, not 0 options // EXPECT:52: Warning: Test: invalid (element-type) for a GPtrArray, must be a pointer // EXPECT:63: Warning: Test: test_unresolved_element_type: Unknown type: 'Unresolved' // EXPECT:71: Warning: Test: test_unresolved_value_element_type: Unknown type: 'GLib.Value' |