summaryrefslogtreecommitdiff
path: root/giscanner/giscannermodule.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Set current_filename before lexing the file so error messages are reportedOwen Taylor2008-11-071-1/+1
| | | | | | | | | | 2008-11-07 Owen Taylor <otaylor@redhat.com> * giscanner/giscannermodule.c (pygi_source_scanner_lex_filename): Set current_filename before lexing the file so error messages are reported in the right file. svn path=/trunk/; revision=866
* Relicense the giscanner library under LGPLv2+. This has been approved byJohan Dahlin2008-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2008-11-04 Johan Dahlin <jdahlin@async.com.br> * giscanner/__init__.py: * giscanner/ast.py: * giscanner/cachestore.py: * giscanner/cgobject.py: * giscanner/girparser.py: * giscanner/girwriter.py: * giscanner/giscannermodule.c: * giscanner/glibast.py: * giscanner/glibtransformer.py: * giscanner/libtoolimporter.py: * giscanner/minixpath.py: * giscanner/odict.py: * giscanner/sourcescanner.c: * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/utils.py: * giscanner/xmlwriter.py: * COPYING: Relicense the giscanner library under LGPLv2+. This has been approved by all contributors. svn path=/trunk/; revision=862
* Write a C version of the xml namespace formatter. Saves 15% of the time itJohan Dahlin2008-10-301-0/+92
| | | | | | | | | | | | | 2008-10-30 Johan Dahlin <jdahlin@async.com.br> * giscanner/giscannermodule.c (calc_attrs_length), (pygi_collect_attributes): * giscanner/xmlwriter.py: Write a C version of the xml namespace formatter. Saves 15% of the time it takes to create a gtk gir. svn path=/trunk/; revision=846
* Add missing whitespace to make pep8 happyJohan Dahlin2008-10-211-0/+2
| | | | svn path=/trunk/; revision=774
* Bug 556543 – reduce compiler warningsTommi Komulainen2008-10-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2008-10-16 Tommi Komulainen <tommi.komulainen@iki.fi> Bug 556543 – reduce compiler warnings * girepository/ginfo.c: * girepository/girepository.c (register_internal, count_interfaces, find_interface, find_namespace_version, parse_version, g_irepository_require): * girepository/girmodule.c (g_ir_module_build_typelib): * girepository/girnode.c (init_stats, dump_stats, _g_irnode_init_stats, _g_irnode_dump_stats, g_ir_node_can_have_member): * girepository/girparser.c (firstpass_end_element_handler, locate_gir, parse_basic, parse_type_internal, resolve_aliases, start_alias, start_type, end_type_top, parse_include, cleanup, post_filter): * girepository/gtypelib.c (validate_function_blob, validate_enum_blob): * giscanner/giscannermodule.c (directive_get_options, type_get_child_list): * giscanner/scannerlexer.l (parse_gtkdoc): * giscanner/scannerparser.y (ctype_free): * giscanner/sourcescanner.c: * giscanner/sourcescanner.h (gi_source_scanner_parse_macros): * tests/types/gitesttypes.c: * tools/compiler.c (main): * tools/generate.c (write_repository): Remove unused variables and code, add missing includes, declarations and case statements. svn path=/trunk/; revision=730
* ignore non-UTF-8 string constantsJohan Bilien2008-10-111-0/+36
| | | | | | | | | | | | | | | | | | | | | | 2008-10-11 Johan Bilien <jobi@litl.com> * giscanner/scannerparser.y: ignore non-UTF-8 string constants 2008-10-11 Johan Bilien <jobi@litl.com> Bug 552347: Parse #defines constants * girepository/gtypelib.c: update the list of value_size with recently defined type tags * giscanner/scannerparser.y: brought back parsing of #defined, as present in older version * giscanner/giscannermodule.c: bind gi_source_scanner_append_filename * giscanner/girwriter.py: write out constant tags in the gir * giscanner/sourcescanner.py: add accessor for const_string * giscanner/transformer.py, giscanner/glibtransformer.py: handle constant svn path=/trunk/; revision=673
* Make g-ir-scanner work on Windows. Still problems with the typelib code.Tor Lillqvist2008-08-271-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2008-08-27 Tor Lillqvist <tml@novell.com> Make g-ir-scanner work on Windows. Still problems with the typelib code. Changes okayed by jdahlin. * configure.ac: Check for Windows, set Automake conditional OS_WIN32. Change backslashes to forward slashes in pyexecdir to avoid shell quoting issues * girepository/Makefile.am: Use -no-undefined so that libtool agrees to build a shared library on Windows. * girepository/girparser.c (backtrace_stderr): No backtrace() on Windows. Empty implementation on Windows so far. * girepository/gtypelib.c (g_typelib_check_sanity): Give more informative error message for the assertion failures. Tell also what the expected size of the struct is. Check all sizes first and fail afterwards if at least one size was different from expected. * tools/Makefile.am: Reorder libraries into proper logical dependency order. * tools/generate.c: Don't include <dlfcn.h>, not used. * giscanner/Makefile.am: On Windows, link with the Python library, and install the module DLL as _giscanner.pyd. Remove the unnecessary import library and libtool library that libtool has installed. * giscanner/scannerlexer.l: Recognize the gcc __attribute__ syntax and just skip it. Recognize also two "l" suffixes for long long constants. Recognize also __inline__. * giscanner/grealpath.h (g_realpath): Implement on Windows, using GetFullPathName(). As such, GetFullPathName() does more than the UNIX realpath(). It also changes relative paths into absolute paths. But for our purposes that shouldn't matter. * giscanner/giscannermodule.c (pygi_source_scanner_parse_file): On Windows the file descriptor passed to us is from Python. Python Python2.5 uses the msvcr71.dll C library, while mingw-built code uses msvcrt.dll. On Windows, file descriptors are specific to which C library is used. So we must find out what underlying OS handle corresponds to the file descriptor Python passes us, and then make that into a file descriptor valid for the C library this code uses. * giscanner/sourcescanner.py (_parse): Don't need to bypass __attribute__ as the lexer now handles it. The definition as empty was ineffective for mingw anyway, as mingw's _mingw.h undefines __attribute__. Close the temp file before unlinking it. * giscanner/cgobject.py: Use correct library name for the gobject DLL on Windows. * gir/Makefile.am: Must pass the full basename of the DLLs on Windows to g-ir-scanner. It's a bit ugly that we have to "know" that the names of the GLib DLLs are like libglib-2.0-0.dll, but in reality they won't change, until there is a GLib 3, and then also the Unix code here needs changing. Must pass CPPFLAGS to g-ir-scanner when building GLib.gir so that libintl.h is found. svn path=/trunk/; revision=503
* Prevent a crash when symbol->indent is NULL.Johan Dahlin2008-05-311-0/+7
| | | | | | | | | | 2008-05-31 Johan Dahlin <jdahlin@async.com.br> * giscanner/giscannermodule.c (symbol_get_ident): Prevent a crash when symbol->indent is NULL. svn path=/trunk/; revision=276
* Revert back to using temporary files to send in headers. Allow FunctionsJohan Dahlin2008-05-241-7/+19
| | | | | | | | | | | | | | | | | | | 2008-05-24 Johan Dahlin <jdahlin@async.com.br> * giscanner/ast.py: * giscanner/girwriter.py: * giscanner/giscannermodule.c (pygi_source_scanner_append_filename), (pygi_source_scanner_parse_file): * giscanner/glibtransformer.py: * giscanner/sourcescanner.py: Revert back to using temporary files to send in headers. Allow Functions to be passed in as callbacks, add a couple of try/excepts missing features. We can now scan pango svn path=/trunk/; revision=274
* Cast the getter, avoids a compilation warning.Johan Dahlin2008-04-271-1/+2
| | | | | | | | | | 2008-04-27 Johan Dahlin <johan@gnome.org> * giscanner/giscannermodule.c (]): Cast the getter, avoids a compilation warning. svn path=/trunk/; revision=231
* Add support for virtual methods. Pair struct FooClass with struct Foo.Johan Dahlin2008-04-251-27/+63
| | | | | | | | | | | | | | | | | | | | | | | | 2008-04-25 Johan Dahlin <jdahlin@async.com.br> * TODO: * giscanner/gidlwriter.py: * giscanner/giscannermodule.c (pygi_source_directive_new), (directive_get_options), (pygi_source_symbol_new), (symbol_get_base_type), (pygi_source_type_new), (type_get_base_type), (type_get_child_list), (pygi_source_scanner_get_symbols), (pygi_source_scanner_get_directives): * giscanner/gobjecttreebuilder.py: * giscanner/sourcescanner.py: * giscanner/treebuilder.py: * tests/parser/foo-object.h: Add support for virtual methods. Pair struct FooClass with struct Foo. Clean up the SourceScanner bindings a bit. Add a testcase for virtual methods. svn path=/trunk/; revision=226
* Add support for source/header annotations.Johan Dahlin2008-04-251-3/+133
| | | | | | | | | | | | | | | | | | | | | | 2008-04-24 Johan Dahlin <jdahlin@async.com.br> * giscanner/gidlwriter.py: * giscanner/girwriter.py: * giscanner/giscannermodule.c (directive_get_name), (directive_get_value), (directive_get_options), (symbol_get_directives), (symbol_set_directives), (pygi_source_scanner_parse_file), (pygi_source_scanner_lex_filename), (pygi_source_scanner_get_directives), (init_giscanner): * giscanner/sourcescanner.c (gi_source_scanner_get_directives): * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/treebuilder.py: * tools/g-ir-scanner: Add support for source/header annotations. svn path=/trunk/; revision=224
* Mark structures as const, wrap SourceType.const_string.Johan Dahlin2008-04-211-11/+25
| | | | | | | | | | 2008-04-21 Johan Dahlin <johan@gnome.org> * giscanner/giscannermodule.c: Mark structures as const, wrap SourceType.const_string. svn path=/trunk/; revision=195
* Start constructing a real node tree.Johan Dahlin2008-04-181-39/+75
| | | | | | | | | | | | | 2008-04-18 Johan Dahlin <johan@gnome.org> * tools/g-ir-scanner (Parameter.__init__): Start constructing a real node tree. * giscanner/giscannermodule.c: wrap GISourceType.child_list and fix the style svn path=/trunk/; revision=171
* Add simple pre-processor using subprocess and a PIPE. Change theJohan Dahlin2008-03-271-6/+5
| | | | | | | | | | | | | | | 2008-03-27 Johan Dahlin <johan@gnome.org> * giscanner/giscannermodule.c: * giscanner/scannerlexer.l: * giscanner/sourcescanner.c: * tools/g-ir-scanner: Add simple pre-processor using subprocess and a PIPE. Change the parse_file apis to accept a file descriptor. svn path=/trunk/; revision=169
* Add constants and wrap a few more SymbolType fieldsJohan Dahlin2008-03-251-0/+43
| | | | | | | | | | | | | 2008-03-25 Johan Dahlin <johan@gnome.org> * giscanner/__init__.py: * giscanner/giscannermodule.c: * giscanner/sourcescanner.c: * giscanner/sourcescanner.h: Add constants and wrap a few more SymbolType fields svn path=/trunk/; revision=166
* Add initial python bindings for the scanner and depend on python 2.5.Johan Dahlin2008-03-251-0/+257
2008-03-25 Johan Dahlin <johan@gnome.org> * configure.ac: * giscanner: * giscanner/__init__.py: * giscanner/giscannermodule.c: * giscanner/Makefile.am: Add initial python bindings for the scanner and depend on python 2.5. svn path=/trunk/; revision=165