summaryrefslogtreecommitdiff
path: root/giscanner/annotationparser.py
Commit message (Collapse)AuthorAgeFilesLines
* giscanner: Mark gpointer nodes as nullable by defaultPhilip Withnall2015-10-041-2/+34
| | | | | | | | | | | | | 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
* giscanner: Use rich comparison methods for Python 3 compatibilitySimon Feltman2015-09-291-2/+24
| | | | | | | | | | Add lt, le, gt, ge, eq, ne, and hash dunder methods to all classes that implement custom comparisons with __cmp__. This is needed to support Python 3 compatible sorting of instances of these classes. Avoid using @functools.total_ordering which does not work for some of these classes and also is not available in Python 2.6. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-291-2/+4
| | | | | | | | | | | | Add unicode_literals future import which turns any string literal into a unicode string. Return unicode strings from the Python C extension module. Force writing of annotations (g-ir-annotation-tool) to output utf8 encoded data to stdout. This is an initial pass at following the "unicode sandwich" model of programming (http://nedbatchelder.com/text/unipain.html) needed for supporting Python 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Replace repr format usage with string formatterSimon Feltman2015-09-291-4/+4
| | | | | | | | | | | Replace occurances of "%r" (repr) in format strings where the intended behaviour is to output a quoted string "'foo'" with explicit usage of "'%s'". This is needed to move the codebase to unicode literals in order to upgrade to Python 3. Python 2 unicode strings are expanded with repr formatting prefixed with a "u" as in "u'foo'" which causes failures for various text formatting scenarios. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use print as a function for Python 3 compatibilitySimon Feltman2015-09-291-0/+1
| | | | | | | Use future import "print_function" and update relevant uses of print as a function call. See: PEP 3105 https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Enable "true division" for all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | | | | | Import Python 3 compatible "true division" from the future (PEP 238). This changes the Python 2 classic division which uses floor division on integers to true division. Verfied we don't actually use the division operator anywhere in the code base so this a safety for supporting both Python 2 and 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* scanner: centralize caret error message handlingDieter Verfaillie2015-06-241-98/+67
| | | | | | | Not doing this manually all over the place makes the code slightly more readable. https://bugzilla.gnome.org/show_bug.cgi?id=689454
* tests: sync with GTK-Doc test suite @ ↵Dieter Verfaillie2015-06-241-5/+2
| | | | | | 02e545371e2132a97458888895cacf57b8c0f83a (2015-06-23) https://bugzilla.gnome.org/show_bug.cgi?id=725685
* scanner: allow multiline annotationsDieter Verfaillie2015-04-181-50/+49
| | | | | | | Allow `identifier`, `parameter` and `tag` part `annotations` fields to span multiple lines https://bugzilla.gnome.org/show_bug.cgi?id=676133
* scanner: fix a docstring typoDieter Verfaillie2015-04-181-1/+1
|
* scanner: allow (array zero-terminated) instead of (array zero-terminated=1)Dieter Verfaillie2015-03-031-1/+6
| | | | | | | | | | | | | | What we already had: - (array zero-terminated=1) > array which is NULL terminated - (array zero-terminated=0) > array which is not NULL terminated - (array) > array which is not NULL terminated - (array zero-terminated=X) > array which is not NULL terminated where X can be anything What this patch adds: - (array zero-terminated) > array which is NULL terminated https://bugzilla.gnome.org/show_bug.cgi?id=657754
* annotationparser: more nullable fixesRyan Lortie2014-05-081-0/+2
| | | | | Add ANN_NULLABLE and ANN_OPTIONAL in the one (and only) other place that ANN_ALLOW_NONE is mentioned...
* giscanner: allow (nullable) and (optional)Ryan Lortie2014-05-071-2/+2
| | | | | | | Add (nullable) and (optional) as recognised annotations in the same places that (allow-none) is allowed. This should have been done in the previous commits but the tests were passing because the only ill effect was that a warning was issued.
* Revert "giscanner: don't accept (allow-none) on Returns:"Ryan Lortie2014-05-061-1/+1
| | | | | | | This reverts commit 0839e696e9fbc1942ac5c61054de3b47e9578152. This was accidentally picked up by my 'git bz apply' against the bug as I was getting ready to push the last set of changes.
* giscanner: add (nullable) and (optional) annotationsRyan Lortie2014-05-061-0/+26
| | | | | | | | | | | Add two new annotations, (nullable) and (optional). (nullable) always means "the type of this value can also contain null". (optional) always means "this out parameter can be ignored by passing NULL to the C function". https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: don't accept (allow-none) on Returns:Dieter Verfaillie2014-05-061-1/+1
| | | | | | | | | The old annotationparser.py happily parsed this, but giscanner/girwriter.py never serialized an allow-none attribute to the .gir file and girepository/girparser.c never looked for an allow-none attribute either. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: fix c0e748e1cdf8cf0803266f94c3c5ad154df504a8Dieter Verfaillie2013-10-081-1/+2
| | | | | | | | | | | When encountering /**/ in the source, parse_gtk_doc_comment() would be executed (due to the /** part starting a GTK-Doc comment block) and would happily consume the / and everything up until the next comment block was closed or EOF, thus consuming a whole block of C code... Encoutered in the wild here: https://git.gnome.org/browse/clutter-gst/tree/clutter-gst/clutter-gst-player.c?id=03f0d8f48bd7f60e582e6185cb73a07038e8d55d#n1926
* giscanner: complain about text before the ' * 'Dieter Verfaillie2013-10-081-0/+9
| | | | | | Makes our GTK-Doc comment block rewriting tool halt on such issues, requireing user intervention instead of writing back even more bogus data.
* giscanner: return namedtuples where appropriateDieter Verfaillie2013-10-081-65/+77
| | | | | makes _parse_annotations() and _parse_fields() callers slightly more readable
* giscanner: Fix GtkDocBlock.position...Dieter Verfaillie2013-10-081-59/+119
| | | | | ... so it points to the start of the GTK-Doc comment block instead of the position of the identifier field.
* giscanner: refactor GTK-Doc comment block serializationDieter Verfaillie2013-10-081-103/+195
|
* giscanner: make some warnings errorsDieter Verfaillie2013-10-081-23/+23
| | | | | | | GTK-Doc comment block fixer tool will refuse to rewrite source files that generated errors (indicating a source->parse tree->source would result in information being lost), but will happily continue on warnings (which do not result in information being lost).
* giscanner: honor line and paragraph breaks in description fieldsDieter Verfaillie2013-10-081-14/+34
| | | | | | | | | GTK-Doc parameter description fields are allowed to span multiple lines, tag description fields are allowed to span multiple lines and paragraphs. A tool fixing/rewriting GTK-Doc comment blocks in source files would need to have description fields parsed and stored (almost) exactly as they appear in the source file.
* giscanner: improve state trackingDieter Verfaillie2013-10-081-19/+12
|
* giscanner: better lineno handlingDieter Verfaillie2013-10-081-12/+13
| | | | | | No need to enumerate the comment lines list as we already receive the lineno of the very first line as a parameter. Simply increment that one when looping over the comment lines list.
* giscanner: store indentation before the '*' of each lineDieter Verfaillie2013-10-081-14/+20
|
* giscanner: store code before and after comment blockDieter Verfaillie2013-10-081-32/+76
| | | | | | so we can later use them to re-write source files containing broken GTK-Doc comment blocks where /** is preceded by and/or */ is followed by code...
* giscanner: accept different forms of line breaksDieter Verfaillie2013-10-081-4/+4
|
* giscanner: merge _parse_comment_block() into parse_comment_block()Dieter Verfaillie2013-10-081-26/+0
|
* giscanner: refactor annotation validationDieter Verfaillie2013-10-081-260/+385
| | | | | | | | - annotations on the identifier (formerly g-i specific tags) have never been validated before, so fix this - removes duplicate validation code from GtkDocTag and GtkDocParameter - remove repeated validation code doing the same thing as annotationparser from maintransformer...
* giscanner: give parameters their own storage classDieter Verfaillie2013-10-081-40/+221
|
* giscanner: deprecate GObject-Introspection GTK-Doc tagsDieter Verfaillie2013-10-081-32/+53
| | | | | | | | | | | | | | | | | | | | | After discussing a different issue with the GTK-Doc maintainers, we learned that our g-i specific top level tags should never have existed in the first place. The prefered notation for annotations that apply to the identifier should be written on the identifier line, for example like what we already do with (skip). As a result, this patch deprecates g-i specific top level tags and implements them as annotations on the identifier instead but still keeps support for malformed comment blocks using g-i specific top level tags. This means that all annotated code "out there" will continue to work just fine with this version of g-i, but when a developer decides to fix deprecation warnings in his/her comment blocks, the dependency on g-i needs to be raised to a version that contains at least this patch. #676133 https://bugzilla.gnome.org/show_bug.cgi?id=676133
* giscanner: flesh out annotation parsing and storageDieter Verfaillie2013-10-081-367/+611
| | | | | | | | | | - 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
* giscanner: extract tag valuesDieter Verfaillie2013-10-081-9/+54
|
* giscanner: use Position and warn directlyDieter Verfaillie2013-10-081-75/+75
|
* giscanner: remove unused GtkDocCommentBlock.valueDieter Verfaillie2013-10-081-2/+1
|
* giscanner: remove unused backrefsDieter Verfaillie2013-10-081-10/+8
|
* giscanner: bring some order into our constantsDieter Verfaillie2013-10-081-47/+60
| | | | | Write them in alphabetical order and explain what they are used for a bit more clearly.
* giscanner: fix GTK-Doc section parsingDieter Verfaillie2013-10-081-6/+4
|
* giscanner: fix GTK-Doc identifier parsingDieter Verfaillie2013-10-081-51/+33
| | | | | | No need to track what type of identifier we've found as we don't use that information later on. Continue searching for an identifier if it's not found on the first line like gtkdoc-mkdb does.
* giscanner: rename DocAnnotations to GtkDocAnnotationsDieter Verfaillie2013-10-081-44/+44
| | | | and move it below DocOption for easier reading
* giscanner: rename DocTag to GtkDocTagDieter Verfaillie2013-10-081-85/+85
| | | | | and move it downwards after DocOption and DocAnnotations for easier reading
* giscanner: rename DocBlock to GtkDocCommentBlockDieter Verfaillie2013-10-081-64/+77
| | | | | and move it downwards after DocTag, DocOptions etc for easier reading
* giscanner: restore support for 'Return:' and 'Returns value:' tagsDieter Verfaillie2013-10-081-5/+13
| | | | | Accepted by old version of annotationparser.py and actually encountered in the wild. Internaly normalize to 'Returns:'.
* giscanner: only warn about missing delimiter when necessaryDieter Verfaillie2013-10-081-9/+9
| | | | | | | | Turns out gtkdoc-mkdb has always accepted identifier parts with and without a delimiter after the identifier_name field, so it is safe to only require it when annotations are present or in other words, when there are actually multiple fields to be seperated...
* giscanner: give pointer to original comment block...Dieter Verfaillie2013-10-081-8/+10
| | | | | ...when complaining about multiple comment blocks documenting the same identifier.
* giscanner: complete vararg parameter parsingDieter Verfaillie2013-10-081-3/+9
| | | | | | | | | | Normalize deprecated @Varargs [1] and named __VA_ARGS__ [2] notations in as single location, add tests. Remove special casing in maintransformer as it is no longer a special case (tests/warn/unknown-parameter.h passes). [1] https://git.gnome.org/browse/gtk-doc/commit/gtkdoc-mkdb.in?id=4c9d4db0e264d403b301dad9be1c290134846d03 [1] https://git.gnome.org/browse/gtk-doc/commit/gtkdoc-mkdb.in?id=55c78181d6ae1606bdf7885e9caed70a484127ec
* giscanner: define __slots__ on some classesDieter Verfaillie2013-10-081-0/+9
| | | | | | For example, when creating Gtk-3.0.gir, thousands of instances of these classes get created. This makes us waste less space for these instances by not having their __dict__ being created.
* giscanner: always use re.UNICODE modeDieter Verfaillie2013-10-081-16/+12
| | | | | should prevent us from running into locale specific issues wrt what's whitespace, alpha, numeric, etc.
* giscanner: use "\s" instead of "[^\S\n\r]"Dieter Verfaillie2013-10-081-48/+48
| | | | | The original idea was to only match non breaking space, but there's really no reason to do things differently than gtkdoc-mkdb.