summaryrefslogtreecommitdiff
path: root/giscanner/transformer.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
* scanner: Fix parsing for various typedef struct orderingsSimon Feltman2014-01-041-5/+95
| | | | | | | | | Add structs parsed from C's "tag namespace" into their own cache for lookup by typdef parsing. This fixes issues where a typedef declared after a struct would not have a correct name. This also cleans up the need for special casing struct tags prefixed with an underscore. https://bugzilla.gnome.org/show_bug.cgi?id=581525
* scanner: Support boolean constantsFlorian Müllner2013-11-291-0/+3
| | | | | | | | Aliasing TRUE or FALSE is not very common, but done occasionally for extra clarity. Namely G_SOURCE_REMOVE / G_SOURCE_CONTINUE are self-explanatory, unlike the "raw" booleans. https://bugzilla.gnome.org/show_bug.cgi?id=719566
* giscanner: don't generate synthetic names for '...' parameterDieter Verfaillie2013-10-081-8/+8
| | | | tests/warn/unkown-parameter.h:41 still passes with this...
* giscanner: remove dead codeDieter Verfaillie2013-10-081-37/+0
| | | | | Last call sites where removed in 36aa515f1036978ced8d4ffb808260844f7229e0 about 3 years ago.
* tests: Update misc/pep8.py to 1.4.6Dieter Verfaillie2013-10-081-2/+1
| | | | | Updated from: https://raw.github.com/jcrocholl/pep8/1.4.6/pep8.py
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-25/+20
| | | | | | | | | | | | | | | | | 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
* transformer: Remove annotationsJasper St. Pierre2013-05-071-4/+0
| | | | | | | The transformer doesn't need the annotations, so why are we giving it to it? https://bugzilla.gnome.org/show_bug.cgi?id=699854
* giscanner: prefer "except X as e" over "except X, e"Dieter Verfaillie2013-04-091-12/+12
| | | | | | It's more readable and as an added bonus Python 3 compatible. https://bugzilla.gnome.org/show_bug.cgi?id=697616