summaryrefslogtreecommitdiff
path: root/giscanner
Commit message (Collapse)AuthorAgeFilesLines
* ast: Avoid a crash with anonymous structsScott D Phillips2016-05-081-1/+2
| | | | | | | We enabled anonymous unions earlier, this is a bugfix to enable anonymous structs. https://bugzilla.gnome.org/show_bug.cgi?id=766011
* ccompiler.py: MSVC builds: Fix running on Python 3.xChun-wei Fan2016-03-171-1/+1
| | | | | When resolving libraries, open the temp file generated by dumpbin with 'r' mode rather than 'rb', since this is a text file.
* ccompiler.py: Win32: Use tempfile for resolving libsChun-wei Fan2016-03-161-21/+36
| | | | | | | | | | | | When using the NMake Makefile within the Visual Studio projects, as we are using dumpbin to resolve the .lib file that we link to, the outputs of dumpbin is captured by the Visual Studio output panel, which causes it not to be processed by proc.communicate(). This is due to dumpbin being an integrated component of Visual Studio. In order to remedy this, we need to use a temp file, and use the /out:<tempfile> flag, and look for the DLL that is linked to by the .lib that we pass in. https://bugzilla.gnome.org/show_bug.cgi?id=763739
* Do not segfault on comments with invalid UTF-8Pascal Terjan2016-03-071-0/+6
|
* giscanner/msvccompiler.py: Fix exception handlingChun-wei Fan2016-02-191-1/+1
| | | | | | | | | | Fix the syntax where we handle the exception during preprocessing, so that we won't trigger a NameError when preprocessing fails, and so the error would become clearer to people. Reported by Cosimo Lupo. https://bugzilla.gnome.org/show_bug.cgi?id=757126
* scanner: Assume gcc use the same path separator as pythonNicola Fontana2016-02-161-1/+1
| | | | | | | resolve_windows_libs() uses `gcc -print-search-dirs`. When we are cross compiling with MinGW on linux, gcc uses ':' as path separator, not ';'. https://bugzilla.gnome.org/show_bug.cgi?id=761981
* Allow overriding of dlltool nameNicola Fontana2016-02-161-2/+1
| | | | | | | | Allow to override it with the DLLTOOL environment variable, leaving "dlltool" as a fallback when not defined so backward compatibility is ensured. https://bugzilla.gnome.org/show_bug.cgi?id=761984
* scanner: Remove leading $SHELL in libtool callNicola Fontana2016-02-161-1/+2
| | | | | | | | | | | | Avoid crashes due to double shell in subprocess.Popen() on linux, e.g.: ``` >>> import subprocess >>> subprocess.Popen(['/bin/sh', '/bin/sh']) /bin/sh: /bin/sh: cannot execute binary file ``` https://bugzilla.gnome.org/show_bug.cgi?id=761982
* Use a launcher for executing g-ir-scannerNicola Fontana2016-02-161-0/+6
| | | | | | | | In cross-compilation the build system is unable to execute the compiled binary. Give the possibility to use a launcher, e.g. wine for MinGW or qemu for different CPU type. https://bugzilla.gnome.org/show_bug.cgi?id=696773
* Revert "giscanner: Disable warnings arising from -D_FORTIFY_SOURCE -O0"Philip Withnall2016-02-061-6/+0
| | | | | | | | | This reverts commit 0ff7ca94a608663649defc72021062de098853a8. As reported by Ting-Wei Lan, this breaks builds with Clang, which doesn’t support -Wno-cpp. https://bugzilla.gnome.org/show_bug.cgi?id=757934#c5
* giscanner: Disable warnings arising from -D_FORTIFY_SOURCE -O0Philip Withnall2016-01-301-0/+6
| | | | | | | | | | | | | | | Using distutils.ccompiler means that we are forced to use the CFLAGS from the system’s Python installation, which may contain -D_FORTIFY_SOURCE. The user’s environment-provided CFLAGS may contain -O0 (because they are a developer). These two flags cause a warning when used together. Silence that warning by passing -Wno-cpp to disable warnings from #warning preprocessor statements in the generated C code. It doesn’t seem to be possible to selectively undefine _FORTIFY_SOURCE or to stop using the compiler flags from distutils.sysconfig, unfortunately. https://bugzilla.gnome.org/show_bug.cgi?id=757934
* 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>
* MingGW Builds: Don't load msvcrt for MinGW64Alexey Pavlov2016-01-131-1/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=733535
* Win32: Fix giscannermodule.c for Python 3.5+Chun-wei Fan2016-01-081-7/+14
| | | | | | | | | | | | Python 3.5+ is now built with Visual Studio 2015, which now has a refactored set of CRT DLLs where CRT functions are placed in, so we need to acquire the _get_osfhandle() from the correct CRT DLL so that we can pass around file descriptors correctly between different CRT versions. This patch will enable Windows builds of introspection files using Python 3.5+ to work correctly. https://bugzilla.gnome.org/show_bug.cgi?id=759531
* scanner: fix line number countingDieter Verfaillie2015-12-271-13/+13
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=752047
* tests: Add more regression tests for (not nullable)Philip Withnall2015-11-061-0/+1
| | | | | | | | | | | | On bug #719966, the question arose of whether parameters annotated with (element-type) but not (not nullable) are regarded as nullable or non-nullable. Add some new unit tests to Regress-1.0.gir to check the behaviour is as expected: annotating a parameter with (element-type) implicitly makes it non-nullable (unless also annotated with (nullable)). https://bugzilla.gnome.org/show_bug.cgi?id=757678
* g-ir-scanner: Set sensible permissions on the output fileMikhail Zabaluev2015-11-011-0/+8
| | | | | | | | If the file is new, set the permissions to 0644. If the file with the name specified as --output exists, copy its metadata onto the temporary output file. https://bugzilla.gnome.org/show_bug.cgi?id=757442
* Don't lose output silently when overwrite of the output file is deniedMikhail Zabaluev2015-11-011-1/+0
| | | | | | | If the move resulted in EPERM, discard the temporary output file, but raise the error so that the tool exits with a nonzero status. https://bugzilla.gnome.org/show_bug.cgi?id=757442
* 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
* giscanner/dumper.py: Fix for Python 3.x for MSVC 2010+Chun-wei Fan2015-10-281-1/+2
| | | | | | | | sys.exc_clear(), which was called when we need to ignore the error when we can't embed manifests to the dumper program on MSVC 2010 and later, is only available/needed for Python 2.7.x, so only use it there. https://bugzilla.gnome.org/show_bug.cgi?id=757126
* giscanner/ccompiler.py: Make Windows builds work with Python 3.xChun-wei Fan2015-10-281-2/+2
| | | | | | | | | | Windows builds check the library that was passed into the introspection scanner to deduce the correct DLL that is to be used by the .gir/.typelib file, but this was not updated for Python 2.x/3.x compatibility, as the outputs of a subprocess must be decoded. Fix this for both MSVC and MinGW-based builds. https://bugzilla.gnome.org/show_bug.cgi?id=757126
* giscanner/msvccompiler.py: Make it compatible with Python 3.xChun-wei Fan2015-10-281-2/+2
| | | | | | This is checked for Python 2.7.x compatibility as well. https://bugzilla.gnome.org/show_bug.cgi?id=757126
* scanner: Fix non-libtool linker flags on DarwinPhilip Chimento2015-10-201-3/+4
| | | | | | | | | Darwin's linker doesn't like "-rpath=path"; instead pass "-rpath path", which works on more linkers than the version with the = sign does. Additionally, Darwin's linker has no equivalent for "--no-as-needed" (it seems to do the right thing by default?) https://bugzilla.gnome.org/show_bug.cgi?id=625195
* 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
* giscanner: Fix python2/3 compatibilityDamien Grassart2015-10-193-8/+8
| | | | | | | This allows building in both Python 2 and 3 by fixing a few text/binary ambiguities and using "as" in an except clause. https://bugzilla.gnome.org/show_bug.cgi?id=756763
* 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