summaryrefslogtreecommitdiff
path: root/giscanner
Commit message (Collapse)AuthorAgeFilesLines
* 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
* 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.message: Don't print node as the default contextMikhail Zabaluev2015-10-051-3/+1
| | | | | | | Node is always present in the output of .log_node(), so printing it another time as context just adds noise. https://bugzilla.gnome.org/show_bug.cgi?id=756088
* giscanner: Mark gpointer nodes as nullable by defaultPhilip Withnall2015-10-045-13/+62
| | | | | | | | | | | | | 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-042-5/+11
| | | | | | | | 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>
* giscanner.ast: Map size_t and ssize_t to gsize and gssize, respectivelyMikhail Zabaluev2015-10-041-2/+1
| | | | | | | The mapping to long int types seems bogus; the code above it did the right thing, but only for size_t. https://bugzilla.gnome.org/show_bug.cgi?id=756016
* giscanner.message: Fix module-level logging functionsMikhail Zabaluev2015-09-301-3/+7
| | | | | | | | MessageLogger.get() calls the class constructor without arguments. The __init__ signature, however, did not default the namespace parameter, so any usage of the logging functions caused a bogus exception. https://bugzilla.gnome.org/show_bug.cgi?id=755890
* giscanner: Add a Parameter.name propertyPhilip Withnall2015-09-291-0/+4
| | | | | | | This is an alias of Parameter.argname, which makes it easier to duck-type debugging of AST nodes by printing out their name property. https://bugzilla.gnome.org/show_bug.cgi?id=747979
* giscanner: Store direction in TypeContainer instancePhilip Withnall2015-09-291-5/+5
| | | | | | | | Instead of storing a direction property on both Parameter and Return separately, hoist it up to TypeContainer so it’s inherited. This neatens things up a bit, but doesn’t really change anything in practice. https://bugzilla.gnome.org/show_bug.cgi?id=747979
* giscanner: Store parent link in AST for TypeContainer instancesPhilip Withnall2015-09-292-0/+35
| | | | | | | | | | 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
* 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-294-5/+7
|
* 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 rich comparison methods for Python 3 compatibilitySimon Feltman2015-09-294-35/+173
| | | | | | | | | | 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
* docwriter: Update for Python 3 compatibilitySimon Feltman2015-09-291-12/+11
| | | | | | | | | Convert the results of various filter() calls to lists. This is needed because filter() returns a generator in Python 3 and len() checks are used on the results (which doesn't work on a generator). Explicitly open resulting files for output in binary mode. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* 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: Encode sha1 input for Python 3 compatibilitySimon Feltman2015-09-291-2/+5
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Encode data passed to subprocess.stdin.writeSimon Feltman2015-09-291-3/+2
| | | | | | | ASCII encode bytes sent to subprocess.stdin.write to ensure Python 2 and 3 compatibility. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Decode command output for Python 3 compatibilitySimon Feltman2015-09-293-1/+4
| | | | | | | Decode the output of various subprocess calls assuming ascii encoding. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use StringIO instead of cStringIO in Python 2Simon Feltman2015-09-293-12/+34
| | | | | | | | | | | | Replace usage of the Python 2 cStringIO module with StringIO and conditionally use io.StringIO for Python 3. This is needed to build up a unicode version of the XML since cStringIO does not support unicode. Add XMLWriter.get_encoded_xml() which returns a utf-8 encoded bytes object of the XML data. Open files for reading/writing in binary mode since we explicitly encode and decode as utf-8. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use pickle when cPickle is not availableSimon Feltman2015-09-291-6/+10
| | | | | | | | This adds compatibility with Python 3 which removed the cPickle module. Explicitly use binary files for reading and writing the cache. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Port scanner extension module to work with Python 3Simon Feltman2015-09-291-29/+75
| | | | | | | | | Define portable macros for use between Python 2 and 3. Replace usage of PyString related functions with PyBytes. Update pygi_source_scanner_parse_macros to support both PyBytes and PyUnicode. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-2926-35/+108
| | | | | | | | | | | | 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-298-45/+46
| | | | | | | | | | | 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-2924-21/+46
| | | | | | | 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-2924-0/+24
| | | | | | | | | | 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-2924-1/+41
| | | | | | 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-299-23/+23
| | | | | | | 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-293-6/+6
| | | | | | | | 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: Use binary files for comparison utilitySimon Feltman2015-09-291-1/+1
| | | | | | | Explicitly open files for comparison in utils.files_are_identical() in binary mode for reading (rb). https://bugzilla.gnome.org/show_bug.cgi?id=679438
* scanner: Explicitly error with constructors but no GObject includeColin Walters2015-09-292-1/+7
| | | | | 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-274-28/+87
| | | | This reverts commit 232f3c831260f596e36159112292897962a505b4.
* 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
* Revert "scanner: Warn and ignore on incorrect transfer annotations"Michael Catanzaro2015-09-274-87/+28
| | | | | | It broke at least atk and mutter. This reverts commit 5ae7bd58b6266997b61d897ad6562118eeb59210.
* scanner: Warn and ignore on incorrect transfer annotationsGarrett Regier2015-09-264-28/+87
| | | | | | | | 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>
* giscanner/ccompiler.py: Improve CFLAGS handlingChun-wei Fan2015-09-081-0/+16
| | | | | | | | Some packages such as GEGL set macro defines directly into CFLAGS, and distutils don't handle those with quotes well, so we need to deal with them seperately. https://bugzilla.gnome.org/show_bug.cgi?id=753428
* giscanner: Use Distutils to Build Dumper ProgramChun-wei Fan2015-09-012-119/+172
| | | | | | | | | | | | | | | | | | | Add compile() and link() functions in ccompiler.py to call distutils.ccompiler's compiler() and link() functions, so that we can in turn call them from dumper.py as needed. Note that for linking the dumper program when building with libtool, we are still using the original method of constructing the link command line and running that command line, as distutils and libtool do not get along well with each other. For non-libtool builds, such as MSVC builds, we would link the dumper program using distutils. For MSVC builds, we need to ignore mt.exe failing to find a .exe.manifest file as Visual Studio 2010+ do not generate such files during linking, and it is done by distutils as Python 2.7.x is built with Visual Studio 2008, which do generate such manifest files during the build. https://bugzilla.gnome.org/show_bug.cgi?id=753428
* g-ir-scanner: Support multiple arguments for compilerMarc-Antoine Perennou2015-08-241-1/+1
| | | | | | | | This should allow `CC='ccache gcc'` or the like to work. https://bugzilla.gnome.org/show_bug.cgi?id=753949 Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
* scanner: use open() as os.fdopen as context managersDieter Verfaillie2015-08-217-79/+68
| | | | | | Ensures files are correctly and immediately closed. https://bugzilla.gnome.org/show_bug.cgi?id=751926
* scanner: fix cachestore raceDieter Verfaillie2015-08-211-9/+8
| | | | | | | | Using tempfile.mkstemp should prevent the temp file from being cleaned while it might still be used by another process. https://bugzilla.gnome.org/show_bug.cgi?id=751926
* Revert "dumper.py: Use Distutils to Build Dumper Program"Chun-wei Fan2015-07-312-164/+157
| | | | | | | | | This reverts commit 7ce646db1cb0842db2089df671b17081f82f2b0a. Apparently this patch caused introspection build breakage for gnome-shell, as problems occurred during linking for libgnome-volume-control. Please see bug 728313 comment 105 for more details.
* dumper.py: Use Distutils to Build Dumper ProgramChun-wei Fan2015-07-302-157/+164
| | | | | | | | | | | | | | | | Add compiler() and link() functions in ccompiler.py to call distutil.ccompiler's compile() and link() functions, so that we can in turn call them from dumper.py to build the dumper program. As distutils don't get along well with libtool libraries (ie .la files), we can deduce the libraries to link from using the file name .la file and include $(builddir)/.libs in the linking stage. For MSVC builds, we need to ignore mt.exe failing to find a .exe.manifest file as Visual Studio 2010+ do not generate such files during linking, and it is done by distutils as Python 2.7.x is built with Visual Studio 2008, which do generate such manifest files during the build. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* sourcescanner.py: Use Distutils for PreprocessingChun-wei Fan2015-07-303-41/+170
| | | | | | | | | | | | | | | | | | Add a preprocess() function in ccompiler.py so that it will call the preprocess() method of the distutils.ccompiler class, and make use of it from sourcescanner.py. As we would need to set up the options (include paths, macros, undefs) to pass into the preprocessor (and later for the compiler), we have a new private function that translates what we have from the rest of giscanner so that it could be passed to distutils.ccompiler in a way that it understands. Also, as the MSVCCompiler classes in distutils do not provide a preprocess() implementation, we provide our own so that we can use it when preprocessing, via distutils, through subclassing MSVCCompiler. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* giscanner/ccompiler.py: Initiate Distutils Compiler InstanceChun-wei Fan2015-07-302-78/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | This updates the __init__ constructor method of CCompiler so that distutils can be used, with some environment or user-supplied options to create the compiler instance that is appropriate with the platform that the giscanner scripts are being run on, and sets some specific environment for the compilers as necessary. This also adds a check_is_msvc() method that will progressively replace calls in the other giscanner scripts that attempt to check for CC=cl (or so), where a part of which is done in this patch. This is done for dumper.py as well as it needs to be updated in this patch to use the updated ccompiler.py which uses distutils to initiate the compiler instance. Also, as we have been using the --library option on Windows to pass in the library (not DLL) to deduce the correct DLL to link to in the introspection files for some time, we no longer need to make a copy of the library (.lib) to introspect that matches the <namespace>-<namespace_version>.lib convention, but use the libraries that were passed in with --library directly, so that we can link the dumper program during the introspection build. Please note that this also partially reverts commit c9cfa2b as the distutils items are clearly needed for these to work. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* giscanner/sourcescanner.py: Use Tempfiles For ParsingChun-wei Fan2015-07-301-31/+47
| | | | | | | | | | | | | As we attempt to move giscanner to use distutils for preprocessing and building the introspection dumper program, we need to update _parse(), where the preprocessor is called, to not use stdin and stdout for the preprocessor input and output, as distutils do not accept such usage. The added bonus for this change is that MSVC builds can be done without using MinGW/GCC as a helper, as the '-' flag for preprocessing from stdin was the hindrance to that. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* scanner: Fix stray comment in previous commitColin Walters2015-07-271-1/+0
| | | | Forgot to amend.