summaryrefslogtreecommitdiff
path: root/giscanner/giscannermodule.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'define-PY_SSIZE_T_CLEAN' into 'master'Christoph Reiter2020-11-081-0/+1
|\ | | | | | | | | giscanner: always define PY_SSIZE_T_CLEAN See merge request GNOME/gobject-introspection!244
| * giscanner: always define PY_SSIZE_T_CLEANChristoph Reiter2020-10-061-0/+1
| | | | | | | | This is required for Python 3.10 and always a good idea anyway.
* | Don't assume Py_TYPE being a macroChristoph Reiter2020-10-061-5/+5
|/ | | | | | | It got changed to a function in Python 3.10. Use the Py_SET_TYPE macro suggested at https://docs.python.org/3.10/whatsnew/3.10.html instead. Fixes #358
* Replace linked lists with arrays in source scannerTomasz Miąsko2018-12-091-23/+18
| | | | Reduce total number of memory allocations and increase data locality.
* sourcescanner: collect error messages and expose themChristoph Reiter2018-12-081-1/+22
| | | | | | | | | | | It just printed errors to stderr and always returns success even if parsing fails. This prevents us to write any tests for it. As a first step collect all lexing/parsing error messages and print them to stderr after the scanner is done. This allows us to add some regression tests for !78. In the future we probably want to raise an exception with those errors if parsing fails.
* gi_source_scanner_parse_file: use a filename instead of a FILE structChristoph Reiter2018-12-061-103/+3
| | | | | | This allows us to get rid of the msvc hacks which are needed in case Python is built with a different msvc than g-i. By passing a filename the FILE struct never passes over library boundaries.
* Revert "scanner: remove hacks to make mingw g-i work with msvc Python"Chun-wei Fan2018-08-211-0/+84
| | | | | | | | Unfortunately, this is still needed for Visual Studio versions that do not have an official CPython release that uses the CRT which the compiler targets to, such as Visual Studio 2012 and 2013 This reverts commit a6a479af1bbe7c0d17766f1408c9fcb720df78dc.
* Revert "scanner: remove some unnecessary Windows includes"Chun-wei Fan2018-08-211-1/+9
| | | | | | | | | | | We need those includes and defines as we need to revert the commit that revert the hacks on Windows, as they are still necessary in the cases where we are using a Python installation that is not linked to the CRT that the currently used compiler targets to, such as on Visual Studio 2012 and 2013, where no official Python release is linked to their respective CRTs. This reverts commit e36350e3fdcb18a21089256b63298d6e3a49212b.
* build: enable -Wcast-function-typeChristoph Reiter2018-07-291-2/+2
| | | | | | | | Where it's easy add dummy args to match the cast; where the target is a subset just prevent the warning with a cast to void*. Provide a real copy function for the boxed type code in regress_foo. This code is never executed afaics, but why not.
* scanner: remove some unnecessary Windows includesChristoph Reiter2018-07-271-9/+1
|
* scanner: remove use of USE_WINDOWSChristoph Reiter2018-07-271-4/+0
| | | | It was never defined because G_OS_WIN32 was used before the glib include.
* scanner: remove hacks to make mingw g-i work with msvc PythonChristoph Reiter2018-07-271-84/+0
| | | | | | | | | From what I understand this was to support a g-i built with mingw using a different msvcrt to work with the official CPython built with msvc. Now that we can build with meson there is no need for this anymore as far as I can see. Just remove the code. Please file a bug if this affects you.
* xmlwriter: move collect_attributes() back to a Python implementationChristoph Reiter2018-07-271-158/+2
| | | | | | | | | This reverts f345916405d94829696985 and related. The commit states that both versions are about the same in performance, but the C version is more code and harder to maintain. It also states that the behaviour re invalid control characters is better with the C version which produces entities. But those make any Python xml parser fail, which given that most of our tooling is Python, doesn't seem better to me, see #135.
* Annotate possibly unused variableEmmanuele Bassi2018-03-101-1/+1
| | | | | | | | | | When using the NEW_CLASS macro, we're also declaring a static constant that we might end up using later. GCC will complain if we're not using the declared variable, so we should annotate it with G_GNUC_UNUSED. If we end up using the variable, the compiler will ignore the annotation; if we don't, we won't be getting a compiler warning when we don't use it.
* meson: Use symbol visibility for giscanner moduleEmmanuele Bassi2018-03-101-1/+1
| | | | | | | | Remove the existing TODO and avoid playing games with the linker. We already have a mechanism in place for controlling he visibility of our symbols. Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com>
* Do not segfault on comments with invalid UTF-8Pascal Terjan2016-03-071-0/+6
|
* 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
* 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-291-7/+32
| | | | | | | | | | | | 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
* scanner: Fix get_symbols/comments to maintain the scanner listsSimon Feltman2014-01-021-0/+2
| | | | | | | | | | | | Use g_slist_copy prior to returning the lists run through g_slist_reverse. This preserves the source scanners internally held lists where previously they would only point to a single element after a call, leaking memory and breaking subsequent calls. Note the functions as (transfer container) and use g_slist_free after calls in the Python bindings. Add new unittest file: test_sourcescanner.py for isolated unittesting of the SourceScanner. https://bugzilla.gnome.org/show_bug.cgi?id=581525
* scanner: Support boolean constantsFlorian Müllner2013-11-291-0/+15
| | | | | | | | 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: remove g_realpathDieter Verfaillie2013-10-171-3/+2
| | | | | | | | | | | giscannermodule expects file names to be canonicalized and symlinks to be resolved (most likely to support users of symlinked /usr/local). Instead of computing absolute and real paths all over the place, we can do this once on entry in SourceScanner().parse_files() and SourceScanner().parse_macros() and clean the rest a bit... https://bugzilla.gnome.org/show_bug.cgi?id=710320
* giscanner: speed up SourceScanner().parse_files()Dieter Verfaillie2013-10-171-5/+7
| | | | | | | | | | | | | | | | | | | Was looking around a bit and noticed about 2/3 of g-ir-scanner time is spent in SourceScanner().parse_files(). Some profiling quickly shows most of that 2/3 is used by gi_source_scanner_add_symbol() where it creates a whole bunch of GFile instances just to compare paths and throw them away again. With this a scanner instance now maintains a hash table of GFile instances instead of a list of file names, so comparing those paths can be reduced to a fast g_hash_table_contains() call. This makes "g-ir-scanner <whole_bunch_of_options> --output Gtk-3.0.gir" complete in about 10 seconds on my box instead of about 30 seconds (both best of 3 runs). https://bugzilla.gnome.org/show_bug.cgi?id=710320
* scanner: Consistently use realpath() on input filenamesColin Walters2013-07-281-1/+1
| | | | | | | | | | | | | | | | The scanner has some logic to compare the filenames specified on the command line against files it will parse. For the latter, it uses g_realpath(). With this patch, we also use g_realpath() on the command line arguments. This fixes g-i when used inside jhbuild in a gnome-ostree VM, which has a symbolic link /home -> /sysroot/home. This caused a realpath mismatch, and then we'd ignore the input source files. It'd be best to get out of the realpath business entirely...but a patch to do that seems more likely to break. https://bugzilla.gnome.org/show_bug.cgi?id=704864
* scannermodule: Fix a bad checkJasper St. Pierre2013-04-071-1/+1
| | | | Spotted by Coverity
* scanner: Correctly handle large 64 bit integer constantsColin Walters2012-10-301-1/+4
| | | | | | | | | | | | | | | | In C, positive integer constants are by default unsigned. This means an expression like 0x8000000000000000 will be "unsigned long long". In the actual scanner code, we were parsing them as "gint64", and storing them as gint64. This was incorrect; we need to parse them as guint64, and store the bits we get from that. This gives us an equivalent result to what the C compiler does. However, when we actually return the value as a Python "long" (arbitrary length integer), we need to treat the value as unsigned if the result indicated it was. https://bugzilla.gnome.org/show_bug.cgi?id=685022
* giscannermodule.c: Updates for WindowsChun-wei Fan2012-10-271-31/+67
| | | | | | | | | | | | | -Incorporate and extend Dieter's patch regarding possible different CRTs used in Windows Python (msvcrt71.dll for Python 2.5, msvcrt90.dll for Python 2.6- 3.2, and msvcrt100.dll for Python 3.3+) vs. the CRT used to build g-i (msvcrt.dll for MinGW/WinDDK, msvcrt90.dll for stock MSVC 2008 and msvcrt100.dll for stock MSVC 2010) -Avoid C99ism for NEW_CLASS as we are having an array without a pre-determined length. There might be better ways to get around this though. https://bugzilla.gnome.org/show_bug.cgi?id=681820
* Drop calls to g_type_init()Colin Walters2012-10-161-2/+0
| | | | And bump our GLib requirement.
* Compare filenames using g_file_equal()Johan Dahlin2012-04-091-0/+4
| | | | | | Makes it work on case-sensitive file systems such as HFS+. https://bugzilla.gnome.org/show_bug.cgi?id=667405
* giscanner: fix use after decrefAndreas Schwab2011-12-151-4/+6
| | | | | Decrement reference to temporary string object only after last use of its value.
* Fix compilation with mingwAndoni Morales Alastruey2011-09-031-0/+4
| | | | | | grealpath.h defines GetFullPathNameA() as windows.h is not imported, but for gitscanner.c, windows.h is imported and the compiler throws an error.
* scanner: Switch to only Python 2.5 C API usageColin Walters2010-12-031-10/+14
| | | | | | | | PyUnicode_FromString is 2.6 only, we can use PyUnicode_DecodeUTF8 easily enough though. Also, fix memory leaks in this function; we leaked the buffer on success, and also in most failure paths.
* Add proper unicode support to the source scannerJohan Dahlin2010-12-021-6/+36
| | | | | | The assumption is that the only allowed source encoding is utf-8. Always strings as unicode and fix up the transformer and xml writer to properly output utf-8.
* Switch to nonrecursive make for core (i.e. not tests/)Colin Walters2010-11-091-2/+8
| | | | | This is cleaner and faster, and prepares us better for an incoming import of CMPH.
* Handle enumerations with the full range of signed and unsigned valuesOwen W. Taylor2010-11-011-1/+2
| | | | | | | | | | | | | The C compiler will pick an enumeration type that accomodates the specified values for the enumeration, so ignoring 64-bit enumerations, we can have enumeration values from MININT32 to MAXUINT32. To handle this properly: - Use gint64 for holding eumeration values when scanning - Add a 'unsigned_value' bit to ValueBlob so we can distinguish the int32 vs. uint32 cases in the typelib - Change the return value of g_value_info_get_value() to gint64. https://bugzilla.gnome.org/show_bug.cgi?id=629704
* Remove trailing whitespaceJohan Dahlin2010-09-261-27/+27
|
* [sourcescanner] Plug a couple of python leaksJohan Dahlin2010-09-261-4/+1
| | | | | There's no need to increase the reference count to items passed into PyList_SetItem, it already steals a reference.
* [scanner] Support private/public directivesJohan Dahlin2010-09-201-0/+8
| | | | Fixes https://bugzilla.gnome.org/show_bug.cgi?id=594125
* Save the line number of a source commentJohan Dahlin2010-09-191-4/+7
|
* [sourcescanner] Support for line numbers on SymbolAlan Knowles2010-05-251-0/+8
| | | | | Add line numbers to symbols, which can be useful in later stages of the scanner.
* Include Python.h earlierJohan Dahlin2009-12-311-1/+1
| | | | This avoids pyconfig.h:1028:1: warning: "_POSIX_C_SOURCE" redefined
* Consistently resolve symbolic linksAdam Sampson2009-09-281-1/+2
| | | | | | | | When building the list of valid filenames for the scanner, resolve symlinks in the filenames; the lexer does this when including files, so otherwise we'll get filename mismatches if the path to the files being scanned includes a symlink. Signed-off-by: Colin Walters <walters@verbum.org>
* Bug 555964 - Parse floating-point #definesColin Walters2009-02-251-1/+20
| | | | | | Previously we just supported int and string, add double to this. Technically we should probably differentiate between float and double, but it's not likely to be very useful in practice to do so.
* Bug 572790 - Don't register #defines from .c files as constantsColin Walters2009-02-241-1/+15
| | | | | We keep track of the source filename for every symbol. This enables us to later filter symbols based on that name.
* giscanner: Set Python exceptions on type errors instead of g_assertColin Walters2009-02-191-7/+17
| | | | This gives us nice stack traces.
* Improve type checkingJohan Dahlin2009-02-191-0/+3
|
* Add a hall of shame commentJohan Dahlin2009-02-191-0/+3
|
* Bug 563591 – Flags not recognized when there is no introspection dataJohan Dahlin2009-01-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | 2009-01-12 Johan Dahlin <jdahlin@async.com.br> Bug 563591 – Flags not recognized when there is no introspection data * giscanner/ast.py: * giscanner/girwriter.py: * giscanner/giscannermodule.c (type_get_is_bitfield): * giscanner/glibast.py: * giscanner/glibtransformer.py: * giscanner/scannerparser.y: * giscanner/sourcescanner.c (gi_source_type_copy): * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/transformer.py: * tests/scanner/foo-1.0-expected.gir: * tests/scanner/foo-1.0-expected.tgir: * tests/scanner/foo.h: Large parts of this patch was done by Jürg Billeter. svn path=/trunk/; revision=1025
* Bug 563794 - Redo annotation parsing & applyingJohan Dahlin2009-01-121-111/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2009-01-12 Johan Dahlin <jdahlin@async.com.br> Bug 563794 - Redo annotation parsing & applying Thanks to Colin for helping out considerably in landing this. * giscanner/Makefile.am: * giscanner/ast.py: * giscanner/dumper.py: * giscanner/girparser.py: * giscanner/giscannermodule.c (pygi_source_scanner_get_comments), (calc_attrs_length), (pygi_collect_attributes), (init_giscanner): * giscanner/glibtransformer.py: * giscanner/scannerlexer.l: * giscanner/sourcescanner.c (gi_source_symbol_unref), (gi_source_scanner_new), (gi_source_scanner_free), (gi_source_scanner_get_comments): * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/xmlwriter.py: * tests/scanner/annotation-1.0-expected.gir: * tests/scanner/annotation-1.0-expected.tgir: * tests/scanner/annotation.c: * tests/scanner/annotation.h: * tests/scanner/foo-1.0-expected.gir: * tests/scanner/foo-1.0-expected.tgir: * tests/scanner/foo.h: * tools/g-ir-scanner: This commit merges the annotation parser rewrite branch. It'll change the annotation parsing to be done completely in python code which will make it easier to do further annotation parsing easier. svn path=/trunk/; revision=1017