summaryrefslogtreecommitdiff
path: root/giscanner/girparser.py
Commit message (Collapse)AuthorAgeFilesLines
* Add annotations for property setters and gettersEmmanuele Bassi2021-08-051-1/+3
| | | | | We need new annotations to allow library developers to associate a setter and a getter functions to a property definition.
* Add new annotations for property accessorsEmmanuele Bassi2021-08-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We introduce two new annotations: - (set-property PROPERTY_NAME) - (get-property PROPERTY_NAME) These annotations are valid inside function blocks for methods on objects and interfaces, and define whether a function is a property accessor, e.g.: /** * gtk_widget_set_name: (set-property name) * @self: ... * @name: ... * * ... */ /** * gtk_widget_get_name: (get-property name) * @self: ... * * ... * * Returns: ... */ The annotations are transformed into the GIR data as attributes: - glib:set-property="PROPERTY_NAME" - glib:get-property="PROPERTY_NAME" The underlying typelib data has had flags for setter and getter functions for a while, but they have never been plugged into the GIR data or the introspection scanner. Now they are; you can retrieve the GIPropertyInfo from a GIFunctionInfo that has the GI_FUNCTION_IS_SETTER or GI_FUNCTION_IS_GETTER flags set. Fixes: #13
* Add "final" class attributeEmmanuele Bassi2021-08-051-0/+3
| | | | | | | | A "final" class is a leaf node in a derivable type hierarchy, and cannot be derived any further. This matches the changes in libgobject that introduced G_TYPE_FLAG_FINAL to the type flags.
* Add glib:name to enum memberMarc-André Lureau2021-06-201-1/+2
| | | | | | | This member will contain the string from the GEnumValue/GFlagsValue 'value_name' introspection dump. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* Add the notion of standalone doc sections.Mathieu Duponchelle2020-07-121-0/+6
| | | | | | | | Up to now, section annotations had to match a class or interface name in order to be serialized in the gir. With this commit, they now get serialized as docsection nodes, for potential use by documentation tools.
* Revert "Add support for element-type to GListModel"Rico Tzschichholz2020-04-281-1/+1
| | | | | | Breaks vapigen and changes GListModel definition in Gio-2.0.gir This reverts commit a9f45431684e6be3623e272e54d481e4c5d9423d.
* Add support for element-type to GListModelEmmanuele Bassi2020-04-261-1/+1
| | | | | | | | GListModel is an interface for creating typed, list-like containers. The data stored is GObject instances, but it's useful to be able to annotate the actual type, for both documentation and code generation purposes. The annotation should be optional, to maintain backward compatibility.
* Revert "Add element-type support to GListModel"Emmanuele Bassi2020-04-261-1/+1
| | | | | | This reverts commit b4c058bba4d95ae10e1e4238f9417fe954f97795. See: #336
* Add element-type support to GListModelEmmanuele Bassi2020-04-241-1/+1
| | | | | | | | GListModel is an interface for creating typed, list-like containers. The data stored is GObject instances, but it's useful to be able to annotate the actual type, for both documentation and code generation purposes. Fixes: #328
* Replace calls to deprecated xml.etree.cElementTreeStephen Gallagher2020-03-261-1/+1
| | | | | | | | | cElementTree was removed in Python 3.9 in favor of ElementTree, which has used a fast, native implementation since Python 3.3. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1817649 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
* Drop deprecated xml.etree.ElementTree.Element.getchildren() callsMiro Hrončok2020-01-061-6/+6
| | | | | | | | | The XML elements are implicitly iterable in all Python versions including at least 2.7 and 3.2+. The .getchildren() method is deprecated since 2.7 and 3.2, removed in 3.9. Fixes https://gitlab.gnome.org/GNOME/gobject-introspection/issues/325
* scanner: parse and expose function macrosMathieu Duponchelle2019-07-191-0/+18
| | | | | This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library.
* giscanner: Allow fields which are callbacksPhilip Chimento2019-04-071-1/+1
| | | | This is apparently used in Gee-0.8 and Folks-0.6.
* Do not bail out when parsing GIR files without doc positionsEmmanuele Bassi2018-12-291-2/+2
| | | | | | | The position attributes on a <doc> element are not mandatory, so we should have some fallback value if they are missing. Fixes: #252
* Drop all Python 2 compat codeChristoph Reiter2018-12-081-5/+0
| | | | We only support 3.4+ now.
* writer: Include documentation and symbol position in source filesThibault Saunier2018-11-281-0/+18
| | | | | | | | | | | Some documentation tool (as hotdoc[0]) need to have information about symbol declaration and documentation positions in the source files to be able to do smart indexing (automatically build the documenation index). [0] https://hotdoc.github.io/ Fixes #175
* giscanner: Remove custom collections implementationNirbheek Chauhan2018-03-101-1/+1
| | | | | | | We already require python 2.7, and it has OrderedDict and Counter. Besides cleaning up unmaintained code, this change found and fixed a Python 3 bug where we were iterating over a dict while changing it.
* giscanner: Mark gpointer nodes as nullable by defaultPhilip Withnall2015-10-041-1/+1
| | | | | | | | | | | | | 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: Store parent link in AST for TypeContainer instancesPhilip Withnall2015-09-291-0/+3
| | | | | | | | | | It is useful for navigating the AST to have a link from each TypeContainer instance (e.g. each Parameter and Return) to the parent AST node, such as a Function. This will be used in the g-ir-diff tool. https://bugzilla.gnome.org/show_bug.cgi?id=747979
* 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: 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
* 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: Convert map() results to listSimon Feltman2015-09-291-3/+3
| | | | | | | | Convert the results map() calls to a list for Python 3 compatibility. In Python 3, map() returns an iterable "map object" which does not allow indexing or iteration more than once. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* scanner: fix broken assert messageDieter Verfaillie2015-06-291-1/+1
| | | | | | | | 288b339edf262f1dba4e87a9faef46cc79749bd5 changed the signature from def _parse_type_second_pass(self, parent, node, typeval): to def _parse_type_array_length(self, siblings, node, typeval) but failed to change the assert statement accordingly.
* giscanner: enable the --reparse-validate option for our test suiteDieter Verfaillie2015-03-041-1/+19
| | | | | | | | | | Doing so reveals GIRParser did not yet support: - the (skip) annotation on parameters and return values - the (attributes) annotation This patch fixes both issues an prevents further similar problems. https://bugzilla.gnome.org/show_bug.cgi?id=738171
* giscanner: support nullable return types tooRyan Lortie2014-05-061-1/+2
| | | | | | | | | | Promote the 'nullable' field to the TypeContainer base class (which is shared by Return and Parameter types). Add .gir support for nullability on return values, both in the writer and in the (scanner's) parser. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: write nullable and optional attributesRyan Lortie2014-05-061-0/+2
| | | | | | | | | | | | | | | | | | | Record our internal 'nullable' and 'optional' attributes into the written .gir file. It is now theoretically possible to express the concept of an out parameter with a nullable type (although presently there is no way to do this). Modify our own internal parser (in the scanner) to understand the newly-written attributes. Update the expected output of the 'Regress-1.0.gir' test to account for the new attributes. Nothing else understands 'nullable' yet, but the girparser in the typelib compiler already understands 'optional' and records a bit for it in the typelib. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* girparser: fix parsing of enum methodsGiovanni Campagna2014-02-261-0/+1
| | | | Make sure to set the parent of the function
* giscanner: Test fixups for field annotations and documentationStef Walter2013-10-281-7/+12
| | | | Related to: https://bugzilla.gnome.org/show_bug.cgi?id=710561
* giscanner: fix description field storage in .gir filesDieter Verfaillie2013-10-081-4/+16
| | | | | | | | | | | | | | | | | | 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: remove dead codeDieter Verfaillie2013-10-081-3/+0
| | | | | Last call sites where removed in 36aa515f1036978ced8d4ffb808260844f7229e0 about 3 years ago.
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-30/+24
| | | | | | | | | | | | | | | | | Version in our tree is a wee bit outdated. For example, later work will introduce an utf8 encoded python source file which our old pep8.py does not yet understand (yeah, it really was *that* ancient)... Updated from: https://raw.github.com/jcrocholl/pep8/1.4.5/pep8.py Takes 552c1f1525e37a30376790151c1ba437776682c5, f941537d1c0a40f0906490ed160db6c79af572d3, 5a4afe2a77d0ff7d9fea13dd93c3304a6ca993de and a17f157e19bd6792c00321c8020dca5e5a281f45 into account... https://bugzilla.gnome.org/show_bug.cgi?id=699535
* scanner: internals cleanup: Move pkgconfig list to NamespaceColin Walters2013-02-261-6/+1
| | | | Continuation of previous work.
* scanner: internals cleanup: Move c_includes to NamespaceColin Walters2013-02-261-3/+1
| | | | Continuation of previous work.
* scanner: internals cleanup: Move shared libraries to NamespaceColin Walters2013-02-261-7/+1
| | | | Continuing on with previous commit.
* scanner: internals cleanup: Key more things off NamespaceColin Walters2013-02-261-5/+2
| | | | | | | | | | | The .gir format has a weird legacy where stuff like the includes are outside of the <namespace>. But conceptually they're tied together, so let's start reflecting this in the code. This way we can just pass around and look at a Namespace object instead of a 4-tuple of (namespace, includes, c_includes, pkg_config). https://bugzilla.gnome.org/show_bug.cgi?id=694593
* ast: Rename Class.parent to parent_typeJasper St. Pierre2013-02-151-1/+1
| | | | | | | | | The eventual model I want to have is that .parent is the "container" of the node. In all the cases where we don't explicitly set the parent, this is the namespace, but having this under one field name would be a big cleanup for the docwriter. https://bugzilla.gnome.org/show_bug.cgi?id=693876
* girparser: Clean up codeJasper St. Pierre2013-02-151-4/+4
| | | | | | This makes it only use kwargs https://bugzilla.gnome.org/show_bug.cgi?id=693876
* girparser: Serialize and read back the instance_parameterJasper St. Pierre2013-02-011-10/+16
| | | | | | | | g-ir-doc-tool wants to use the instance parameter to read docs and the parameter name, so it needs to be shuttled through the GIR. https://bugzilla.gnome.org/show_bug.cgi?id=693040
* ast: Track enum/bitfield member parentsJasper St. Pierre2013-02-011-2/+4
| | | | | | | We need this for the doctool so that we can link to an enum definition when we reference one of the member values. https://bugzilla.gnome.org/show_bug.cgi?id=693040
* girparser: Remove unused methodJasper St. Pierre2013-02-011-3/+0
| | | | | | | pylint was complaining about the non-existent instance member, self._filename https://bugzilla.gnome.org/show_bug.cgi?id=693040
* Ast: Add parent to FieldsGiovanni Campagna2012-10-281-9/+12
| | | | | | | Properties have it, there is no reason for Field not to, and in this way mallard docs can treat a field almost like a property. https://bugzilla.gnome.org/show_bug.cgi?id=683046
* Namespace: fix appending of nodesGiovanni Campagna2012-10-281-3/+11
| | | | | | | | Traverse appended nodes for methods, so that namespace.symbols contains all known symbols and not just global functions. Also, ensure that all relevant nodes are appended when parsing GIRs. https://bugzilla.gnome.org/show_bug.cgi?id=683046
* girparser: Track methods/constructors by symbolJasper St. Pierre2012-08-291-0/+1
| | | | | | | In order to be able to linkify a constructor/method, we need to first track it by symbol. https://bugzilla.gnome.org/show_bug.cgi?id=682969
* g-ir-doc-tool: More Mallard work, using experimantal api extensionShaun McCance2012-02-171-14/+16
|
* Add constant value annotationJohan Dahlin2011-09-141-2/+3
| | | | | Add an annotation tag "Value:" which can be used on constants to override the value.
* Allow enums and bitfields to have static methodsTorsten Schönfeld2011-08-161-0/+3
| | | | | | | | | | | | | This uses the same backcompat machinery that was introduced for static methods for non-class types, so this change does not break users of the existing presentations. New libgirepository API: g_enum_info_get_n_methods g_enum_info_get_method https://bugzilla.gnome.org/show_bug.cgi?id=656499
* Teach scanner's girparser about fundamentalsPavel Holejsovsky2011-08-161-0/+8
| | | | | | | Make sure that fundamental attribute and associated functions (ref-func, unref-func, set-value-func and get-value-func) are parsed, otherwise we fail reparse-validating girs containing fundamentals.
* Make sure signal works when there isn't one specifiedJohan Dahlin2011-08-131-1/+1
|