summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
Commit message (Collapse)AuthorAgeFilesLines
* Split disguised attribute into twoEmmanuele Bassi2023-01-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The disguised attribute started off as a way to indicate a typedef to a structure pointer, e.g. typedef struct Foo* FooPtr; Over the years, though, it started to include opaque structure types, e.g. typedef struct _FooObject FooObject; typedef struct _FooObjectClass FooObjectClass; This has led to issues in language bindings, code generators, and documentation generators, which now have issues when dealing with both pointer aliases and opaque types. An initial attempt at fixing this mess in commit f606183a ended up breaking Vala, and had to be reverted. To avoid breaking existing users we can follow a similar approach to the allow-none/nullable/optional solution: 1. introduce a new pair of attributes: "pointer" and "opaque" 2. deprecate the "disguised" attribute The "pointer" attribute covers the case of pointer types. The "opaque" attribute covers the case of opaque structured types. See also: https://gitlab.gnome.org/GNOME/vala/-/issues/735 Fixes: #101
* Add copy and free function annotations for POD typesEmmanuele Bassi2023-01-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Plain Old Data (POD) types with or without a representation in the GType type system can still have a copy and/or a free function. We should allow annotating these types with their corresponding functions for copying their data into a new instance, and freeing their data. From a language bindings perspective, POD types should have a boxed GType wrapper around them, so they can use the generic GBoxed API to copy and free instances; from a documentation perspective, though, it'd be good to have a way to match a structured type, like a struct or a union, with its copy and free functions. In order to do that, we add two new header block annotations: - (copy-func function_name) - (free-func function_name) These annotations work exactly like ref-func and unref-func for typed instances: /** * GdkRGBA: (copy-func gdk_rgba_copy) * (free-func gdk_rgba_free) * @red: ... * @green: ... * @blue: ... * @alpha: ... * * ... */ The function is stored in the GIR data as two new attributes for the `<record>` and `<union>` elements: <record name="RGBA" c:type="GdkRGBA" copy-function="gdk_rgba_copy" free-function="gdk_rgba_free" glib:type-name="GdkRGBA" glib:get-type="gdk_rgba_get_type" c:symbol-prefix="gdk_rgba"> The annotations are not mandatory. See: #14
* Add an optional attribute for the property default valueEmmanuele Bassi2023-01-081-0/+2
| | | | | | | | | The default-value attribute for a property element is fundamentally meant for documentation generators. We only care about the GIR data, as the conversion from the default value to a string is lossy by definition, and may very well not roundtrip.
* scanner: Add (emitter) annotation for signalsEmmanuele Bassi2022-02-121-0/+2
| | | | | | Signals that have an emitter function should have an annotation to allow consumers of the introspection XML to effectively pair signals to their corresponding emitter functions that share the same prototype.
* Add annotations for property setters and gettersEmmanuele Bassi2021-08-051-0/+4
| | | | | 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/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+2
| | | | | | | | 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-0/+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>
* Merge branch 'standalone-doc-sections' into 'master'Mathieu Duponchelle2020-07-221-0/+7
|\ | | | | | | | | Add the notion of standalone doc sections. See merge request GNOME/gobject-introspection!226
| * Add the notion of standalone doc sections.Mathieu Duponchelle2020-07-121-0/+7
| | | | | | | | | | | | | | | | 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.
* | giscanner: parse block comments for members and fieldsMathieu Duponchelle2020-07-121-0/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | There was previously no mechanism for tagging enum members and struct fields with Since tags (or other, eg deprecation tags). While the customary place to add Since tags for these symbols is inline in the parent symbol's documentation eg: /** * Foo: * * @FOO_BAR: some bar. Since X.Y */ And variations on that theme, implementing parsing for that scheme would result in a pretty ambiguous grammar, especially if we also want support for multiple tags. Instead, the solution implemented here is to allow providing documentation for individual members and fields through their own separate block, as is done for virtual functions already. Inline comments are still used, with a lower precedence. Fixes #348
* scanner: parse and expose function macrosMathieu Duponchelle2019-07-191-0/+25
| | | | | This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library.
* Drop all Python 2 compat codeChristoph Reiter2018-12-081-6/+0
| | | | We only support 3.4+ now.
* giscanner/girwriter.py: Fix running on WindowsChun-wei Fan2018-12-061-1/+8
| | | | | | | ... When we are building in a drive that is different from the drive that we are acquiring the depedencies from. For example, os.path.relpath() does not like it when we we are building G-I on D:\foo while the GLib headers are found are C:\glib.
* writer: Include documentation and symbol position in source filesThibault Saunier2018-11-281-3/+28
| | | | | | | | | | | 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
* typedefs: fix type information.Mathieu Duponchelle2017-03-141-1/+1
| | | | | | | | | | | We now reuse _create_type_from_base instead of reimplementing it in a semi-broken way in transformer, and use complete_ctype when writing it out if available. This incidentally allows us to remove a test where the comment acknowledged the non-optimal behaviour. https://bugzilla.gnome.org/show_bug.cgi?id=779959
* giscanner: Mark gpointer nodes as nullable by defaultPhilip Withnall2015-10-041-2/+2
| | | | | | | | | | | | | 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-10/+5
| | | | | | | | | | 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-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-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/+1
| | | | | | 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-1/+1
| | | | | | | Replace usage of iteritems() and itervalues() with items() and values() respectively. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: support nullable return types tooRyan Lortie2014-05-061-0/+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
* giscanner: change some internal field logicRyan Lortie2014-05-061-2/+6
| | | | | | | | | | | | | | | | | | 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: Correctly consume field annotations on structsStef Walter2013-10-281-10/+14
| | | | | | | | 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: remove unneeded isinstance checkDieter Verfaillie2013-10-091-3/+2
| | | | | | _write_class() is only ever called with ast.Class and ast.Interface nodes so the check served no purpose other than contribute to global warming...
* giscanner: write '<varargs/>' instead of '<varargs></varargs>'Dieter Verfaillie2013-10-081-2/+1
|
* giscanner: make Annotated.attributes an OrderedDictDieter Verfaillie2013-10-081-1/+1
| | | | | | 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: fix description field storage in .gir filesDieter Verfaillie2013-10-081-4/+23
| | | | | | | | | | | | | | | | | | 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 />".
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-11/+10
| | | | | | | | | | | | | | | | | 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
* giscanner: fix broken xml:whitespace attributes in .gir filesDieter Verfaillie2013-04-091-1/+1
| | | | | | | The XML specification clearly states it's xml:space http://www.w3.org/TR/xml/#sec-white-space https://bugzilla.gnome.org/show_bug.cgi?id=628739
* scanner: internals cleanup: Move pkgconfig list to NamespaceColin Walters2013-02-261-6/+4
| | | | Continuation of previous work.
* scanner: internals cleanup: Move c_includes to NamespaceColin Walters2013-02-261-8/+4
| | | | Continuation of previous work.
* scanner: internals cleanup: Move shared libraries to NamespaceColin Walters2013-02-261-6/+6
| | | | Continuing on with previous commit.
* scanner: internals cleanup: Key more things off NamespaceColin Walters2013-02-261-6/+4
| | | | | | | | | | | 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-2/+2
| | | | | | | | | 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
* scanner: remove backcompat copies more safelyTorsten Schönfeld2013-02-101-0/+2
| | | | | | | | Instead of modifying the namespace while we are iterating over it, which leads to nodes not being tested, set an 'internal_skipped' property on the function and read it in the GIR writer. https://bugzilla.gnome.org/show_bug.cgi?id=660698
* girparser: Serialize and read back the instance_parameterJasper St. Pierre2013-02-011-8/+10
| | | | | | | | 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
* giscanner: Apply standard annotations to constant valuesJasper St. Pierre2013-02-011-0/+3
| | | | | | | | | | While there's no particular reason I need to do this, there really isn't any reason to not do this, and it helps with doctool or whatever in the future if we want to document when a constant showed up. g-ir-compiler also keeps track of constant deprecations, so this fixes constants not ever being deprecated. https://bugzilla.gnome.org/show_bug.cgi?id=693040
* Add documentation for enumeration membersGiovanni Campagna2012-10-281-1/+2
| | | | | | | | Enum members were Annotated in the AST, and most code already assumed they could have docs. What was missing was reading the docs from the comment blocks and writing them in the XML. https://bugzilla.gnome.org/show_bug.cgi?id=683046
* mallardwriter: Fix formatting the function nameJasper St. Pierre2012-08-291-2/+2
| | | | This is not what format_type is for.
* scanner: support stability tagEvan Nemerson2012-07-101-0/+2
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=679160
* giscanner: Write detailed information in "type" tag's "c:type" attribute.Krzesimir Nowak2012-07-071-1/+3
| | | | | | | | That is - write also type qualifiers (const and volatile here). Update existing tests and add a new struct to regress.h having members with type qualifiers. https://bugzilla.gnome.org/show_bug.cgi?id=656445
* Add constant value annotationJohan Dahlin2011-09-141-1/+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/+4
| | | | | | | | | | | | | 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
* Make sure signal works when there isn't one specifiedJohan Dahlin2011-08-131-2/+3
|
* Add signal flagsJohan Dahlin2011-08-131-1/+11
| | | | | | This adds all GSignalFlags into the gir. https://bugzilla.gnome.org/show_bug.cgi?id=656457
* scanner: add a moved_to property to backcompat functionsTorsten Schönfeld2011-08-131-0/+2
| | | | | | | Use it to remove backcompat copies of functions that non introspectable anyway. https://bugzilla.gnome.org/show_bug.cgi?id=572408