summaryrefslogtreecommitdiff
path: root/giscanner/maintransformer.py
Commit message (Collapse)AuthorAgeFilesLines
* tests: Add more regression tests for (not nullable)Philip Withnall2015-11-061-0/+1
| | | | | | | | | | | | On bug #719966, the question arose of whether parameters annotated with (element-type) but not (not nullable) are regarded as nullable or non-nullable. Add some new unit tests to Regress-1.0.gir to check the behaviour is as expected: annotating a parameter with (element-type) implicitly makes it non-nullable (unless also annotated with (nullable)). https://bugzilla.gnome.org/show_bug.cgi?id=757678
* maintransformer: Fix regression in callback closure assignmentColin Walters2015-10-101-5/+6
| | | | | | | The nullable code needs to search via index lookup of closure_name, which drops the need to (incorrectly) assign closure_name again. https://bugzilla.gnome.org/show_bug.cgi?id=756352
* giscanner: Mark gpointer nodes as nullable by defaultPhilip Withnall2015-10-041-3/+17
| | | | | | | | | | | | | 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: Mark (closure) parameters as (nullable) by conventionPhilip Withnall2015-10-041-0/+7
| | | | | | | | All user_data pointers should be nullable, and they should all be annotated as closures too. I have not found any counter-examples where a closure is non-nullable. https://bugzilla.gnome.org/show_bug.cgi?id=729660
* scanner: Warn and ignore return annotations when there is no return valueGarrett Regier2015-10-041-1/+6
| | | | | | | | Otherwise the .gir can contain invalid data which would likely cause a crash at runtime. https://bugzilla.gnome.org/show_bug.cgi?id=752044 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* scanner: Warn and ignore on incorrect optional/nullable/allow-none annotationsGarrett Regier2015-10-041-3/+18
| | | | | | | These can easily be misunderstood, especially optional. https://bugzilla.gnome.org/show_bug.cgi?id=752065 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* scanner: Fix allow-none on return valuesGarrett Regier2015-09-291-1/+2
| | | | | | | | The optional annotation was being applied which is invalid for return values. https://bugzilla.gnome.org/show_bug.cgi?id=752029 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* scanner: Pacify PEP8Colin Walters2015-09-291-1/+1
|
* giscanner: Sort unknown parameters in error messageSimon Feltman2015-09-291-1/+2
| | | | | | | | | | Sort the parameters displayed for the "unknown parameters" error message. The parameter names are stored in a set which returns a different ordering between Python 2 and 3 (set/dict ordering should not be relied upon anyhow). This fixes test failures in warning tests. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | | | | | | | 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-22/+22
| | | | | | | | | | | 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-1/+2
| | | | | | | 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
* giscanner: Use absolute_import for all Python filesSimon Feltman2015-09-291-0/+2
| | | | | | Use absolute_import to ensure Python 3 compatibility of the code base. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use items() instead of iteritems()Simon Feltman2015-09-291-4/+4
| | | | | | | Replace usage of iteritems() and itervalues() with items() and values() respectively. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* scanner: Explicitly error with constructors but no GObject includeColin Walters2015-09-291-1/+5
| | | | | One of the Anaconda developers hit this; the fix was to include GObject, but without this commit we just traceback'd.
* scanner: GVariants are also valid to be floatingColin Walters2015-09-281-2/+3
| | | | More followup to https://bugzilla.gnome.org/show_bug.cgi?id=752047
* scanner: Tweak "invalid transfer" warning to show type tooColin Walters2015-09-271-6/+6
| | | | Should help debugging.
* scanner: Warn and ignore on incorrect transfer annotationsColin Walters2015-09-271-9/+59
| | | | This reverts commit 232f3c831260f596e36159112292897962a505b4.
* Revert "scanner: Warn and ignore on incorrect transfer annotations"Michael Catanzaro2015-09-271-59/+9
| | | | | | It broke at least atk and mutter. This reverts commit 5ae7bd58b6266997b61d897ad6562118eeb59210.
* scanner: Warn and ignore on incorrect transfer annotationsGarrett Regier2015-09-261-9/+59
| | | | | | | | This is an issue in various code bases and tends to confuse newcomers. https://bugzilla.gnome.org/show_bug.cgi?id=752047 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* tests: Update misc/pep8.py to 1.6.2Dieter Verfaillie2015-06-291-4/+4
| | | | | Updated from: https://raw.githubusercontent.com/jcrocholl/pep8/1.6.2/pep8.py
* scanner: allow (array zero-terminated) instead of (array zero-terminated=1)Dieter Verfaillie2015-03-031-3/+7
| | | | | | | | | | | | | | 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
* scanner: Honor nested types on array declarations as wellColin Walters2014-09-051-1/+4
| | | | | | | | | We have special code to look at (type GLib.List(utf8)), but (type GLib.PtrArray(utf8)) didn't work. This allows NetworkManager to annotate the ActiveConnections property. https://bugzilla.gnome.org/show_bug.cgi?id=733879
* giscanner: fix a comparisonRyan Lortie2014-05-061-1/+1
| | | | | | | | In the case that a parameter has not been explicitly annotated, the value of node.direction will be None, not 'in'. Instead of comparing as == 'in' we should therefore check for being != 'out'. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: add (nullable) and (optional) annotationsRyan Lortie2014-05-061-1/+7
| | | | | | | | | | | 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: change some internal field logicRyan Lortie2014-05-061-2/+5
| | | | | | | | | | | | | | | | | | Replace the 'allow_none' field on parameters with two separate fields: 'nullable' and 'optional'. Currently, we use 'nullable' to mean the same thing as 'allow-none' for normal (non-out) parameters. For out parameters, we use the 'optional' field instead. Note that the special case for GCancellable and GAsyncReadyCallback is already guarded by a check for being an in parameter, so we always use 'nullable' here. On the .gir writer side, we decide which variable to consult when writing the allow-none attribute depending on the parameter direction. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: tweak GCancellable null special caseRyan Lortie2014-05-061-2/+3
| | | | | | | | | | | | | | We treat GCancellable and GAsyncReadyCallback as if they were always tagged (allow-none) because these parameters universally allow %NULL to be given as a value when they appear as in parameters on functions. Unfortunately, the meaning of (allow-none) is different on out parameters. There it means that you can give %NULL to ignore the return value. Limit this special case to only in parameters. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* maintransformer: split up a complex conditionalRyan Lortie2014-05-061-3/+5
| | | | | | | | | | | | We assign node.allow_none in two separate cases: - if the (allow-none) annotation was given - for GCancellable and GAsyncReadyCallback, as special cases Split the two up. This will simplify future commits. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: Use range instead of xrange for Python 3 compatibilitySimon Feltman2014-05-011-1/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use modern exception handling for Python 3 compatibilitySimon Feltman2014-05-011-1/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=679438
* maintransformer: don't pair methods if the symbol prefix does not match with ↵Giovanni Campagna2014-02-261-7/+27
| | | | | | | | | | | a final underscore In cases like g_resources_register() and gdk_events_get_angle(), the c_symbol_prefix of the first parameter (resp. g_resource and gdk_event) is a prefix of the symbol, but the next character is not _, so that should not be considered a method. For backward compatibility reasons, we still generate one, but then it's not included in the documentation (because of moved_to)
* scanner: support virtual functions with a typedef-ed callbackGiovanni Campagna2014-02-201-3/+11
| | | | | | | | | | The field of a callback need not be anonymous, it could be a typedef, with a proper Type node. Fixes TelepathyGlib.BaseClient having no virtual functions (and probably others) https://bugzilla.gnome.org/show_bug.cgi?id=723439
* scanner: Don't barf on anonymous unionsColin Walters2013-10-301-0/+1
| | | | | | | | I'd like to be able to use this inside GTK+. See: https://bugzilla.gnome.org/show_bug.cgi?id=711153 https://bugzilla.gnome.org/show_bug.cgi?id=711157
* giscanner: Include field documentationStef Walter2013-10-281-1/+1
| | | | | | Structure field documentation was not being included in the gir file. https://bugzilla.gnome.org/show_bug.cgi?id=710562
* giscanner: Correctly consume field annotations on structsStef Walter2013-10-281-8/+26
| | | | | | | | A hidden exception was being thrown (which we now log), due to fields being treated as function parameters. Fixed to make field array annotations be transformed and written out to the gir correctly. https://bugzilla.gnome.org/show_bug.cgi?id=710561
* giscanner: write virtual method instance parameter docs to .gir fileDieter Verfaillie2013-10-081-0/+6
|
* giscanner: make Annotated.attributes an OrderedDictDieter Verfaillie2013-10-081-2/+2
| | | | | | annotationparser.py already stores attributes in a mapping so it makes little sense using a list of tuples (suggesting multiple duplicate keys would be allowed) on the ast side.
* giscanner: use proper terminologyDieter Verfaillie2013-10-081-49/+50
|
* giscanner: honor line and paragraph breaks in description fieldsDieter Verfaillie2013-10-081-5/+6
| | | | | | | | | 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: fix description field storage in .gir filesDieter Verfaillie2013-10-081-2/+6
| | | | | | | | | | | | | | | | | | GTK-Doc description fields for tags can contain multiple lines and even multiple paragraphs. Whitespace cannot be preserved in XML attributes, so we move the "deprecated" description text into a "<doc-deprecated />" element right next to where we already have the "<doc />" element. Keep the "deprecated" attribute around for backwards compatibility though, but set its value to "1" (analogous to the "writable", "contruct", etc attributes) if the annotated symbol is marked as deprecated. While at it, add <doc-version /> and <doc-stability /> which was not yet available in the .gir files... This takes care of the "Since:", "Stability:" and "Deprecated:" GTK-Doc tags. Nothing needs to be done for the "Returns:" tag as as we already write a "<doc />" child element on "<return-value />".
* giscanner: refactor annotation validationDieter Verfaillie2013-10-081-10/+7
| | | | | | | | - 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: deprecate GObject-Introspection GTK-Doc tagsDieter Verfaillie2013-10-081-37/+32
| | | | | | | | | | | | | | | | | | | | | 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-59/+58
| | | | | | | | | | - 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-18/+8
|
* giscanner: complete vararg parameter parsingDieter Verfaillie2013-10-081-3/+0
| | | | | | | | | | 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: rename "comment" to "description"Dieter Verfaillie2013-10-081-5/+5
| | | | Simply because they are called description fields on GTK-Doc parts...
* giscanner: rename "colon" to "delimiter"Dieter Verfaillie2013-10-081-3/+3
| | | | | | | It serves as a GTK-Doc "field" separator, so delimiter seems like a better name. This also makes the distinction between the colon used in property/signal names (which is not a "field" separator) and the GTK-Doc "field" separator a bit more clear.
* giscanner: rename "options" to "annotations"Dieter Verfaillie2013-10-081-56/+54
| | | | | | | Makes it easier to understand the difference between an annotation and an option, which are written as "(annotation option1=value1 option2=value2 ...)" in GTK-Doc comment blocks.
* giscanner: fix parameter name checkDieter Verfaillie2013-10-081-1/+1
| | | | | | It's been impossible to have a TAG_RETURNS in GTK-Doc comment block parameters for a long while now as we transform those into valid tags in parse_comment_block()...