diff options
author | Colin Walters <walters@verbum.org> | 2011-08-14 05:42:53 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2011-08-14 06:01:52 -0400 |
commit | ff290d2982c6f7a3ee31a8275e9d78bf49ad9dbe (patch) | |
tree | 0c282f61947f1169a1d2f718bb949a9d8fd7d57e | |
parent | 736924a8ed80b6d8ef14f342abf3440a8e9c9541 (diff) | |
download | gobject-introspection-ff290d2982c6f7a3ee31a8275e9d78bf49ad9dbe.tar.gz |
annotationparser: Don't eat lines that look like parameters outside param list
If we're done parsing parameters, previously we would simply eat lines that looked like
@foo: blah blah
Example is in gtkcssprovider.c.
https://bugzilla.gnome.org/show_bug.cgi?id=656504
-rw-r--r-- | giscanner/annotationparser.py | 14 | ||||
-rw-r--r-- | tests/scanner/regress.c | 38 | ||||
-rw-r--r-- | tests/scanner/regress.h | 1 |
3 files changed, 49 insertions, 4 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 67ba72bb..c99cf630 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -509,7 +509,8 @@ class AnnotationParser(object): if not line.startswith('*'): lineno += 1 continue - is_whitespace = self.WHITESPACE_RE.match(line[1:]) is not None + nostar_line = line[1:] + is_whitespace = self.WHITESPACE_RE.match(nostar_line) is not None if parsing_parameters and is_whitespace: # As soon as we find a line that's just whitespace, # we're done parsing the parameters. @@ -521,12 +522,17 @@ class AnnotationParser(object): lineno += 1 continue - line = line[1:].lstrip() + # Explicitly only accept parameters of the form "* @foo" with one space. + is_parameter = nostar_line.startswith(' @') + + # Strip the rest of the leading whitespace for the rest of + # the code; may not actually be necessary, but still doing + # it to avoid regressions. + line = nostar_line.lstrip() # Look for a parameter or return value. Both of these can # have parenthesized options. first_colonspace_index = line.find(': ') - is_parameter = line.startswith('@') is_return_value = self.RETURNS_RE.search(line) parse_options = True if ((is_parameter or is_return_value) @@ -594,7 +600,7 @@ class AnnotationParser(object): block.tags[tag_name] = tag else: comment_lines.append(line) - elif (not is_parameter): + elif not parsing_parameters: comment_lines.append(line) lineno += 1 block.comment = '\n'.join(comment_lines).strip() diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 938bcf11..276a7d10 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3210,6 +3210,44 @@ regress_test_multiline_doc_comments (void) } /** + * regress_test_nested_parameter: + * @a: An integer + * + * <informaltable> + * <tgroup cols="3"> + * <thead> + * <row> + * <entry>Syntax</entry> + * <entry>Explanation</entry> + * <entry>Examples</entry> + * </row> + * </thead> + * <tbody> + * <row> + * <entry>rgb(@r, @g, @b)</entry> + * <entry>An opaque color; @r, @g, @b can be either integers between + * 0 and 255 or percentages</entry> + * <entry><literallayout>rgb(128, 10, 54) + * rgb(20%, 30%, 0%)</literallayout></entry> + * </row> + * <row> + * <entry>rgba(@r, @g, @b, @a)</entry> + * <entry>A translucent color; @r, @g, @b are as in the previous row, + * @a is a floating point number between 0 and 1</entry> + * <entry><literallayout>rgba(255, 255, 0, 0.5)</literallayout></entry> + * </row> + * </tbody> + * </tgroup> + * </informaltable> + * + * What we're testing here is that the scanner ignores the @a nested inside XML. + */ +void +regress_test_nested_parameter (int a) +{ +} + +/** * regress_introspectable_via_alias: * */ diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 4c74e098..25d43586 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -611,6 +611,7 @@ GValue *regress_test_strv_in_gvalue (void); GObject * _regress_this_is_a_private_symbol (void); void regress_test_multiline_doc_comments (void); +void regress_test_nested_parameter (int a); /** * RegressSkippedStructure: (skip) |