summaryrefslogtreecommitdiff
path: root/giscanner/transformer.py
Commit message (Collapse)AuthorAgeFilesLines
* Add glib:name to enum memberMarc-André Lureau2021-06-201-3/+1
| | | | | | | This member will contain the string from the GEnumValue/GFlagsValue 'value_name' introspection dump. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* Revert "Add support for element-type to GListModel"Rico Tzschichholz2020-04-281-3/+0
| | | | | | 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-0/+3
| | | | | | | | 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-3/+0
| | | | | | This reverts commit b4c058bba4d95ae10e1e4238f9417fe954f97795. See: #336
* Add element-type support to GListModelEmmanuele Bassi2020-04-241-0/+3
| | | | | | | | 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
* Make meson.override_find_program working on more complex use casesThibault Saunier2019-08-151-2/+1
| | | | | | | Add some missing `meson.override_find_program` And make sure that the `.gir` we build are found when used uninstalled as a concequence of `meson.override_find_program`.
* transformer: only include function macros from headers. See #159Christoph Reiter2019-07-221-0/+4
| | | | | We already do the same thing for constants (see _create_const()). Otherwise macros in .c files which aren't namespaced will trigger a warning.
* scanner: parse and expose function macrosMathieu Duponchelle2019-07-191-3/+21
| | | | | This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library.
* Revert "Restore original meaning of disguised attribute."Christoph Reiter2019-01-161-1/+11
| | | | | | This reverts commit f606183a010fbec4382acb728882cc0eddbaf7f7. See https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/9#note_409979
* Restore original meaning of disguised attribute.Tomasz Miąsko2019-01-101-11/+1
| | | | | | | | | | | | | | | | > Certain types like GIConv and GdkAtom are pointers internally but don't > look like pointers when referenced. They have the form. > > typedef struct _X *X; > > Parse these as structures/records but mark them in the gir with a 'disguised' > attribute so that we know that they need special handling. Additionally, stop relaying on disguised attribute when deciding whether to render a page. Check number of fields instead, so as to avoid introducing large regression in the docs. Fixes #101.
* scanner: Flatten multi-dimensional arrays fieldsTomasz Miąsko2019-01-071-10/+17
| | | | | | | | | | | | | Provide partial support for multi-dimensional arrays by representing them as flattened one dimensional array with size that is equal to product of sizes in each dimension. Previously only the first dimension would be actually used. This should be sufficient to ensure that those fields have layout compatible with C, without using nested array types that are currently unsupported by vapigen Issue #255.
* scanner: Remove incorrect c:type generated for array of synthesized unionsTomasz Miąsko2019-01-061-4/+2
| | | | | | | | This also reverts workaround introduced to support this use case in f77cfc4275b1fba4f9fedea6e40b00e0ebbe142c, since it is no longer necessary. Fixes issue #141.
* scanner: Remove incorrect c:type from fields with array typeTomasz Miąsko2019-01-061-12/+1
| | | | | | | | | | Neither `_create_source_type` nor `_create_complete_source_type` actually support fixed size arrays, so previously generated C types were incorrect. Remove C types from array fields instead of producing incorrect ones. Fixes issue #145.
* scanner: make using bool without stdbool include work again. Fixes #247Christoph Reiter2018-12-211-1/+1
| | | | | | | | | With !45 special casing of bool in the lexer was removed which previously allowed the usage of bool without including stdbool.h. This breaks scanning of graphene headers which guarded the stdbool include with __GI_SCANNER__ (I haven't figured out why). Add back the special handling for bool in the lexer and also map it to gboolean like _Bool as if stdbool.h was included.
* 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-1/+2
| | | | | | | | | | | 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
* g-ir-tools: respect gir_dir_prefixKai Kang2018-10-081-0/+1
| | | | | | | | | Configure option gir_dir_prefix is used to configure install dir for .gir files, so add its value to include file search paths. Fix for flake8 and meson-test at same time. Signed-off-by: Kai Kang <kai.kang@windriver.com>
* tests: depend on flake8 instead of including pep8/pyflakesChristoph Reiter2018-08-151-1/+0
| | | | | | | | | | | | | | | | g-i includes an old version of pep8 and pyflakes and uses that during "make check". It (1) doesn't catch all cases newer versions of pycodestyle/pyflakes catch and (2) doesn't test all Python files (3) doesn't work with meson. Instead of updating just remove them and depend on flake8 instead. To run the checks simply run flake8 in the root dir. This also makes it possible to run those checks when using meson and not autotools. To not get test suite failures on flake8 updates move the checks from "make check" to an extra "make check.quality" target.
* transformer: Strip whitespace from filter commandsPhilip Chimento2018-08-061-0/+1
| | | | | | | | On OS X, the output of sed as reported back to Python has a newline at the end. It seems like a good idea to strip whitespace from the symbol and identifier filter commands anyhow, so strip() the result. https://bugzilla.gnome.org/show_bug.cgi?id=752468
* transformer: don't shell out for filter commands and make the tests work on ↵Christoph Reiter2018-07-251-7/+5
| | | | | | | | | | | | | Windows Instead of passing the filter commands to the shell, split them with the shlex module. This gives us more control and a more similar behaviour on unix/win32 systems. I could only find two users in Debian which just call python with some script, so this seems safe to me. Adjust the tests accordingly and use the running python executable to test the functionality as we can be sure that's available on all platforms. Also add a new test for the symbol filter commadn which wasn't tested before.
* Convert _Bool to gboolean for backward compatibility.Tomasz Miąsko2018-06-231-0/+9
| | | | See !24 for the discussion
* Merge branch 'array-to-pointer-adjustment' into 'master'Christoph Reiter2018-06-181-12/+19
|\ | | | | | | | | | | | | Perform array to pointer adjustment in function parameters. Closes #189 See merge request GNOME/gobject-introspection!8
| * Perform array to pointer adjustment in function parameters.Tomasz Miąsko2018-04-281-12/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A declaration of a parameter as "array of type" shall be adjusted to "qualified pointer to type". This change performs this adjustment. For example, this makes parameters of following functions equivalent: ``` void f1(const char s[]); void f2(const char s[10]); void f3(const char *s); ``` Fixes issue #189.
* | Use uint8 as default element type when constructing ByteArray.Tomasz Miąsko2018-04-151-3/+6
|/ | | | Fixes issue #184.
* transformer: Strip whitespace from filter commandsPhilip Chimento2018-03-271-1/+2
| | | | | | | | On OS X, the output of sed as reported back to Python has a newline at the end. It seems like a good idea to strip whitespace from the symbol and identifier filter commands anyhow, so strip() the result. See #139.
* typedefs: fix type information.Mathieu Duponchelle2017-03-141-6/+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: fix tests with python3.5Marc-Antoine Perennou2016-01-181-1/+2
| | | | | | https://bugzilla.gnome.org/show_bug.cgi?id=760682 Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
* giscanner/transformer.py: Fix --identifier-filter on Python 3.xChun-wei Fan2015-10-281-1/+2
| | | | | | | We need to encode the identifier-filter command to bytes, and decode its outputs to ascii in order for it to work on Python 3.x. https://bugzilla.gnome.org/show_bug.cgi?id=757126
* Add support for function typedefs without pointerBen Iofel2015-10-191-2/+10
| | | | | | | | | | g-ir-scanner now supports something like this: typedef void my_callback(int); Notice how my_callback is not a pointer. https://bugzilla.gnome.org/show_bug.cgi?id=755645
* transformer: Strip out GLib _autoptr typedefsColin Walters2015-10-101-0/+3
| | | | | | | They're just internal bits for users of C, shouldn't be part of the API. https://bugzilla.gnome.org/show_bug.cgi?id=755882
* giscanner: Update namespace sort for Python 3 compatibilitySimon Feltman2015-09-291-7/+10
| | | | | | | | Use key function instead of cmp for list.sort which is compatible with both Python 2 and 3. Make sure a list is returned from split function. Don't use identity comparison "is" on strings. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-291-1/+2
| | | | | | | | | | | | 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-6/+7
| | | | | | | | | | | 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-3/+3
| | | | | | | Replace usage of iteritems() and itervalues() with items() and values() respectively. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Convert map() results to listSimon Feltman2015-09-291-1/+1
| | | | | | | | 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
* giscanner: fix alias resolutionGiovanni Campagna2015-09-271-1/+1
| | | | | | | | | | | | | | | Atk has a "typedef GSList AtkAttributeSet", which causes an ast.Alias() targeting a ast.List(). The latter has a target_fundamental of '<list>', which cannot be looked up in ast.type_names (because it's not a real fundamental type), and that breaks the build. It turns out that we don't need to find the fundamental type and then the fundamental type node - the target field of the ast.Alias already points to the desired type node. https://bugzilla.gnome.org/show_bug.cgi?id=755681
* tests: Update misc/pep8.py to 1.6.2Dieter Verfaillie2015-06-291-2/+2
| | | | | Updated from: https://raw.githubusercontent.com/jcrocholl/pep8/1.6.2/pep8.py
* scanner: remove unused param_namesDieter Verfaillie2015-06-291-2/+0
| | | | | | we haven't been emitting the warning for about six years (see 7dbbda9abea9882d2c98726f382a905fa8738706) so remove the leftovers...
* scanner: add "XDG Base Directory" functionsDieter Verfaillie2015-06-201-8/+10
| | | | | | | | | | | | Extract cache and data dir lookup code into documented get_user_cache_dir() and get_system_data_dirs() functions. Note that previously, the data dirs code did not fall back to '/usr/local/share:/usr/share' when the XDG_DATA_DIRS environment variable was either not set or empty, as required by the XDG Base Directory Specification. https://bugzilla.gnome.org/show_bug.cgi?id=747770
* scanner: Add --symbol-filter-cmdGarrett Regier2015-04-201-1/+15
| | | | | | | | | | Add the command line flag --symbol-filter-cmd to g-ir-scanner which allows running symbol names through a filtering shell command. The symbol is sent as stdin to the filter command and expects a filtered result written to stdout. https://bugzilla.gnome.org/show_bug.cgi?id=744534 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* scanner: Don't fail when GI_SCANNER_DISABLE_CACHE is setGarrett Regier2015-04-191-2/+2
| | | | | | | | | It was assumed that cache store was always working, this also removes a round trip to the cache store. So performance should also get a small boost. https://bugzilla.gnome.org/show_bug.cgi?id=746231 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* scanner: Add --identifier-filter-cmdSimon Feltman2014-06-031-1/+14
| | | | | | | | | Add the command line flag --identifier-filter-cmd to g-ir-scanner which allows running identifier names through a filtering shell command. The identifier is sent as stdin to the filter command and expects a filtered result written to stdout. https://bugzilla.gnome.org/show_bug.cgi?706898
* scanner: Replace GInitiallyUnowned field sharing with generic solutionSimon Feltman2014-01-041-6/+7
| | | | | | | | | | | | Remove GInitiallyUnowned special case in gdumpparser where fields are copied from GObject. Add generic solution where anytime we have multiple typedef structs, the fields become shared: typedef struct _Foo Foo; typedef struct _Foo Bar; struct _Foo {...}; https://bugzilla.gnome.org/show_bug.cgi?id=581525
* scanner: Cleanup exception handling in the transformerSimon Feltman2014-01-041-42/+15
| | | | | | | | | Move exception handling of various symbol/identifier stripping into the outer level parse function. This removes a lot of embedded try excepts peppered throughout the code by letting exceptions flow to the top level where they can be handled just as gracefully. https://bugzilla.gnome.org/show_bug.cgi?id=581525
* scanner: Remove typedef namespace cacheSimon Feltman2014-01-041-20/+0
| | | | | | | | | Remove the caching of typedefs in Transformer._typedef_ns. This is no longer used due to the added _tag_ns cache which store tags rather than typedefs. Remove adding of callback typdefs to the typedef_ns since these were not being used anyhow. https://bugzilla.gnome.org/show_bug.cgi?id=581525
* scanner: Use tag namespace for parsing unionsSimon Feltman2014-01-041-74/+30
| | | | | | | Generalize _create_tag_ns_struct for both structs and unions. Remove _create_compound newer struct parsing code has completely replaced it. https://bugzilla.gnome.org/show_bug.cgi?id=581525
* scanner: Add simplified parsing for nested structsSimon Feltman2014-01-041-4/+7
| | | | | | | | Add _create_member_struct for the parsing of nested structs. This is precursory work to remove the member/anonymous flag from other struct/union creation code and allow simplification of those code paths. https://bugzilla.gnome.org/show_bug.cgi?id=581525